[PATCH 10/32] media: i2c: imx335: Use %pe format specifier
Ricardo Ribalda
ribalda at chromium.org
Mon Oct 13 08:55:51 PDT 2025
Hi Kieran
On Mon, 13 Oct 2025 at 17:03, Kieran Bingham
<kieran.bingham at ideasonboard.com> wrote:
>
> Quoting Ricardo Ribalda (2025-10-13 15:14:50)
> > The %pe format specifier is designed to print error pointers. It prints
> > a symbolic error name (eg. -EINVAL) and it makes the code simpler by
> > omitting PTR_ERR().
> >
> > This patch fixes this cocci report:
> > ./i2c/imx335.c:1013:3-10: WARNING: Consider using %pe to print PTR_ERR()
>
> Ohhh nice. Is this new ? First I've come across it.
It is actually from 2019:
https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/commit/?id=57f5677e535ba24b8926a7125be2ef8d7f09323c
I just learned about it because there is a new check in coccinelle :).
It is pretty cool, but you need to be careful to check IS_ERR(ptr)
before doing the printk, otherwise %pe will print the pointer value.
Regards!
>
>
>
> > Signed-off-by: Ricardo Ribalda <ribalda at chromium.org>
> > ---
> > drivers/media/i2c/imx335.c | 4 ++--
> > 1 file changed, 2 insertions(+), 2 deletions(-)
> >
> > diff --git a/drivers/media/i2c/imx335.c b/drivers/media/i2c/imx335.c
> > index c043df2f15fb25b3a56422092f99a1fd9a508fa9..71ed9a0d84a252ee362621c4d38001508fb86d28 100644
> > --- a/drivers/media/i2c/imx335.c
> > +++ b/drivers/media/i2c/imx335.c
> > @@ -1009,8 +1009,8 @@ static int imx335_parse_hw_config(struct imx335 *imx335)
> > imx335->reset_gpio = devm_gpiod_get_optional(imx335->dev, "reset",
> > GPIOD_OUT_HIGH);
> > if (IS_ERR(imx335->reset_gpio)) {
> > - dev_err(imx335->dev, "failed to get reset gpio %ld\n",
> > - PTR_ERR(imx335->reset_gpio));
> > + dev_err(imx335->dev, "failed to get reset gpio %pe\n",
> > + imx335->reset_gpio);
>
> Reviewed-by: Kieran Bingham <kieran.bingham at ideasonboard.com>
>
> > return PTR_ERR(imx335->reset_gpio);
> > }
> >
> >
> > --
> > 2.51.0.760.g7b8bcc2412-goog
> >
--
Ricardo Ribalda
More information about the Linux-mediatek
mailing list