Re: [PATCH 02/10] iio: gyro: hid-sensor-gyro-3d: use local struct device
From: Sanjay Chitroda
Date: Mon Jul 20 2026 - 12:55:45 EST
On 20 July 2026 5:24:33 pm IST, Andy Shevchenko <andriy.shevchenko@xxxxxxxxx> wrote:
>On Mon, Jul 20, 2026 at 03:10:14PM +0530, Sanjay Chitroda via B4 Relay wrote:
>
>> Introduce a local struct device pointer derived from &pdev->dev.
>> This avoids repeated &pdev->dev usage and improves readability.
>
>...
>
>> if (ret) {
>> - dev_err(&pdev->dev, "failed to setup common attributes\n");
>> + dev_err(dev, "failed to setup common attributes\n");
>> return ret;
>
>Nope, First one (to eliminate a lot of churn) should be to convert this and
>similar to use
>
> return dev_err_probe(...);
>
Hi Andy,
Thank you for your input.
I'm planning to have a incremental series: first introduce a local "dev" pointer, then convert the resource management to "devm_*", and finally replace the remaining error reporting with "dev_err_probe()".
This keeps each series focused and avoids introducing intermediate patterns such as:
ret = dev_err_probe(dev, ret, ...);
goto error;
Once the cleanup paths are removed, those sites naturally become:
return dev_err_probe(dev, ret, ...);
Does this approach sound reasonable?
>> }
>>
>> - indio_dev->channels = devm_kmemdup(&pdev->dev, gyro_3d_channels,
>> + indio_dev->channels = devm_kmemdup(dev, gyro_3d_channels,
>> sizeof(gyro_3d_channels), GFP_KERNEL);
>> if (!indio_dev->channels) {
>> - dev_err(&pdev->dev, "failed to duplicate channels\n");
>> + dev_err(dev, "failed to duplicate channels\n");
>
>And this kind of messages are dead code and must be just removed completely.
>
>> return -ENOMEM;
>> }
>
>...
>
>Please, revisit the whole series.
Yep, understood.
I'll revisit series, drop dead code and send v2.
Thanks, Sanjay
>