Re: [PATCH v2 5/6] iio: position: hid-sensor-custom-intel-hinge: use common device for devres

From: Jonathan Cameron

Date: Thu Jul 02 2026 - 13:32:37 EST


On Thu, 02 Jul 2026 21:48:02 +0530
Sanjay Chitroda via B4 Relay <devnull+sanjayembeddedse.gmail.com@xxxxxxxxxx> wrote:

> From: Sanjay Chitroda <sanjayembeddedse@xxxxxxxxx>
>
> kmemdup() is used for memory that is logically tied to the HID
> platform device, even though the driver binds into the IIO framework.
>
> Using &indio_dev->dev for devres allocations works functionally, but it
> results in two separate devres ownership trees—one for the HID
> platform device (pdev) and another for the IIO device (indio_dev).
>
> The devres framework is intended to have a single, well-defined parent
> device. Since the memory originates from HID sensor probing and is not
> IIO-specific, &pdev->dev is the correct and logical owner.
>
> Switch to using the platform device for devm_kmemdup() so that all
> resources are released deterministically and consistently.
>
> Signed-off-by: Sanjay Chitroda <sanjayembeddedse@xxxxxxxxx>
Applied this one.

> ---
> drivers/iio/position/hid-sensor-custom-intel-hinge.c | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/drivers/iio/position/hid-sensor-custom-intel-hinge.c b/drivers/iio/position/hid-sensor-custom-intel-hinge.c
> index 1f4a40716c3f..eb6c59f81c3f 100644
> --- a/drivers/iio/position/hid-sensor-custom-intel-hinge.c
> +++ b/drivers/iio/position/hid-sensor-custom-intel-hinge.c
> @@ -293,7 +293,7 @@ static int hid_hinge_probe(struct platform_device *pdev)
> }
>
> indio_dev->num_channels = ARRAY_SIZE(hinge_channels);
> - indio_dev->channels = devm_kmemdup(&indio_dev->dev, hinge_channels,
> + indio_dev->channels = devm_kmemdup(&pdev->dev, hinge_channels,
> sizeof(hinge_channels), GFP_KERNEL);
> if (!indio_dev->channels)
> return -ENOMEM;
>