diff mbox series

[v2,4/6] drivers: usb: serial: mos7840: using '__func__' to replace function name in dbg message

Message ID 20241025061711.198933-5-tony467913@gmail.com
State New
Headers show
Series [v2,1/6] driver: usb: serial: mos7840: fix style warnings | expand

Commit Message

Tony Chung Oct. 25, 2024, 6:17 a.m. UTC
fix warning of Prefer '"%s...",__func__' to using 'function name'.

Signed-off-by: Tony Chung <tony467913@gmail.com>
---
 drivers/usb/serial/mos7840.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

Comments

Johan Hovold Feb. 11, 2025, 9:29 a.m. UTC | #1
On Fri, Oct 25, 2024 at 02:17:14PM +0800, Tony Chung wrote:
> fix warning of Prefer '"%s...",__func__' to using 'function name'.
> 
> Signed-off-by: Tony Chung <tony467913@gmail.com>
> ---
>  drivers/usb/serial/mos7840.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/drivers/usb/serial/mos7840.c b/drivers/usb/serial/mos7840.c
> index b48a26468..31ec2cf1b 100644
> --- a/drivers/usb/serial/mos7840.c
> +++ b/drivers/usb/serial/mos7840.c
> @@ -230,7 +230,7 @@ static int mos7840_set_reg_sync(struct usb_serial_port *port, __u16 reg,
>  	struct usb_device *dev = port->serial->dev;
>  
>  	val = val & 0x00ff;
> -	dev_dbg(&port->dev, "mos7840_set_reg_sync offset is %x, value %x\n", reg, val);
> +	dev_dbg(&port->dev, "%s offset is %x, value %x\n", __func__, reg, val);

I suggest you just leave this as is.

Johan
Greg KH Feb. 11, 2025, 9:32 a.m. UTC | #2
On Tue, Feb 11, 2025 at 10:29:22AM +0100, Johan Hovold wrote:
> On Fri, Oct 25, 2024 at 02:17:14PM +0800, Tony Chung wrote:
> > fix warning of Prefer '"%s...",__func__' to using 'function name'.
> > 
> > Signed-off-by: Tony Chung <tony467913@gmail.com>
> > ---
> >  drivers/usb/serial/mos7840.c | 2 +-
> >  1 file changed, 1 insertion(+), 1 deletion(-)
> > 
> > diff --git a/drivers/usb/serial/mos7840.c b/drivers/usb/serial/mos7840.c
> > index b48a26468..31ec2cf1b 100644
> > --- a/drivers/usb/serial/mos7840.c
> > +++ b/drivers/usb/serial/mos7840.c
> > @@ -230,7 +230,7 @@ static int mos7840_set_reg_sync(struct usb_serial_port *port, __u16 reg,
> >  	struct usb_device *dev = port->serial->dev;
> >  
> >  	val = val & 0x00ff;
> > -	dev_dbg(&port->dev, "mos7840_set_reg_sync offset is %x, value %x\n", reg, val);
> > +	dev_dbg(&port->dev, "%s offset is %x, value %x\n", __func__, reg, val);
> 
> I suggest you just leave this as is.

__func__ should NEVER be added to dev_dbg() lines as it is already
available if the user want it.  Adding it explicitly to the string is
just redundant.

thanks,

greg k-h
Johan Hovold Feb. 11, 2025, 9:38 a.m. UTC | #3
On Tue, Feb 11, 2025 at 10:32:14AM +0100, Greg Kroah-Hartman wrote:
> On Tue, Feb 11, 2025 at 10:29:22AM +0100, Johan Hovold wrote:
> > On Fri, Oct 25, 2024 at 02:17:14PM +0800, Tony Chung wrote:
> > > fix warning of Prefer '"%s...",__func__' to using 'function name'.
> > > 
> > > Signed-off-by: Tony Chung <tony467913@gmail.com>
> > > ---
> > >  drivers/usb/serial/mos7840.c | 2 +-
> > >  1 file changed, 1 insertion(+), 1 deletion(-)
> > > 
> > > diff --git a/drivers/usb/serial/mos7840.c b/drivers/usb/serial/mos7840.c
> > > index b48a26468..31ec2cf1b 100644
> > > --- a/drivers/usb/serial/mos7840.c
> > > +++ b/drivers/usb/serial/mos7840.c
> > > @@ -230,7 +230,7 @@ static int mos7840_set_reg_sync(struct usb_serial_port *port, __u16 reg,
> > >  	struct usb_device *dev = port->serial->dev;
> > >  
> > >  	val = val & 0x00ff;
> > > -	dev_dbg(&port->dev, "mos7840_set_reg_sync offset is %x, value %x\n", reg, val);
> > > +	dev_dbg(&port->dev, "%s offset is %x, value %x\n", __func__, reg, val);
> > 
> > I suggest you just leave this as is.
> 
> __func__ should NEVER be added to dev_dbg() lines as it is already
> available if the user want it.  Adding it explicitly to the string is
> just redundant.

It can sometimes be useful to allow for compact but self-contained debug
messages that makes sense also when the generic function prefix is not
printed (I tend not to enable those myself).

But in general, try to follow the style of the driver you're changing.

Johan
diff mbox series

Patch

diff --git a/drivers/usb/serial/mos7840.c b/drivers/usb/serial/mos7840.c
index b48a26468..31ec2cf1b 100644
--- a/drivers/usb/serial/mos7840.c
+++ b/drivers/usb/serial/mos7840.c
@@ -230,7 +230,7 @@  static int mos7840_set_reg_sync(struct usb_serial_port *port, __u16 reg,
 	struct usb_device *dev = port->serial->dev;
 
 	val = val & 0x00ff;
-	dev_dbg(&port->dev, "mos7840_set_reg_sync offset is %x, value %x\n", reg, val);
+	dev_dbg(&port->dev, "%s offset is %x, value %x\n", __func__, reg, val);
 
 	return usb_control_msg(dev, usb_sndctrlpipe(dev, 0), MCS_WRREQ,
 			       MCS_WR_RTYPE, val, reg, NULL, 0,