spidev: Use dev_dbg() instead of pr_debug()
diff mbox series

Message ID 20190604025129.20387-1-festevam@gmail.com
State New, archived
Headers show
Series
  • spidev: Use dev_dbg() instead of pr_debug()
Related show

Commit Message

Fabio Estevam June 4, 2019, 2:51 a.m. UTC
dev_dbg() is more appropriate for printing debug messages inside
drivers, so switch to dev_dbg().

Signed-off-by: Fabio Estevam <festevam@gmail.com>
---
 drivers/spi/spidev.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

Comments

Geert Uytterhoeven June 4, 2019, 7:22 a.m. UTC | #1
Hi Fabio,

On Tue, Jun 4, 2019 at 4:53 AM Fabio Estevam <festevam@gmail.com> wrote:
> dev_dbg() is more appropriate for printing debug messages inside
> drivers, so switch to dev_dbg().
>
> Signed-off-by: Fabio Estevam <festevam@gmail.com>

Thanks for your patch!

> --- a/drivers/spi/spidev.c
> +++ b/drivers/spi/spidev.c
> @@ -560,7 +560,8 @@ static int spidev_open(struct inode *inode, struct file *filp)
>         }
>
>         if (status) {
> -               pr_debug("spidev: nothing for minor %d\n", iminor(inode));
> +               dev_dbg(&spidev->spi->dev, "spidev: nothing for minor %d\n",
> +                       iminor(inode));

This doesn't look correct to me, as a non-zero status indicates that the
corresponding spidev was not found, and thus spidev is not a valid
object pointer to dereference.

>                 goto err_find_dev;
>         }
>

Gr{oetje,eeting}s,

                        Geert
Mark Brown June 4, 2019, 3:35 p.m. UTC | #2
On Tue, Jun 04, 2019 at 09:22:30AM +0200, Geert Uytterhoeven wrote:
> On Tue, Jun 4, 2019 at 4:53 AM Fabio Estevam <festevam@gmail.com> wrote:

> >         if (status) {
> > -               pr_debug("spidev: nothing for minor %d\n", iminor(inode));
> > +               dev_dbg(&spidev->spi->dev, "spidev: nothing for minor %d\n",
> > +                       iminor(inode));

> This doesn't look correct to me, as a non-zero status indicates that the
> corresponding spidev was not found, and thus spidev is not a valid
> object pointer to dereference.

Right, the issue is that we don't have the device.

Patch
diff mbox series

diff --git a/drivers/spi/spidev.c b/drivers/spi/spidev.c
index 255786f2e844..0ea67ef3e65c 100644
--- a/drivers/spi/spidev.c
+++ b/drivers/spi/spidev.c
@@ -560,7 +560,8 @@  static int spidev_open(struct inode *inode, struct file *filp)
 	}
 
 	if (status) {
-		pr_debug("spidev: nothing for minor %d\n", iminor(inode));
+		dev_dbg(&spidev->spi->dev, "spidev: nothing for minor %d\n",
+			iminor(inode));
 		goto err_find_dev;
 	}