[PATCH v4 23/36] iio: position: hid-sensor-custom-intel-hinge: use local struct device

From: Sanjay Chitroda

Date: Sun May 24 2026 - 15:31:26 EST


From: Sanjay Chitroda <sanjayembeddedse@xxxxxxxxx>

Introduce a local struct device pointer derived from &pdev->dev.
This avoids repeated &pdev->dev usage and improves readability.

Signed-off-by: Sanjay Chitroda <sanjayembeddedse@xxxxxxxxx>
---
.../position/hid-sensor-custom-intel-hinge.c | 17 +++++++++--------
1 file changed, 9 insertions(+), 8 deletions(-)

diff --git a/drivers/iio/position/hid-sensor-custom-intel-hinge.c b/drivers/iio/position/hid-sensor-custom-intel-hinge.c
index 0ba9d2d43913..34c7cf734018 100644
--- a/drivers/iio/position/hid-sensor-custom-intel-hinge.c
+++ b/drivers/iio/position/hid-sensor-custom-intel-hinge.c
@@ -263,13 +263,14 @@ static int hinge_parse_report(struct platform_device *pdev,
/* Function to initialize the processing for usage id */
static int hid_hinge_probe(struct platform_device *pdev)
{
- struct hid_sensor_hub_device *hsdev = dev_get_platdata(&pdev->dev);
+ struct device *dev = &pdev->dev;
+ struct hid_sensor_hub_device *hsdev = dev_get_platdata(dev);
struct hinge_state *st;
struct iio_dev *indio_dev;
int ret;
int i;

- indio_dev = devm_iio_device_alloc(&pdev->dev, sizeof(*st));
+ indio_dev = devm_iio_device_alloc(dev, sizeof(*st));
if (!indio_dev)
return -ENOMEM;

@@ -287,12 +288,12 @@ static int hid_hinge_probe(struct platform_device *pdev)
hinge_sensitivity_addresses,
ARRAY_SIZE(hinge_sensitivity_addresses));
if (ret) {
- dev_err(&pdev->dev, "failed to setup common attributes\n");
+ dev_err(dev, "failed to setup common attributes\n");
return ret;
}

indio_dev->num_channels = ARRAY_SIZE(hinge_channels);
- indio_dev->channels = devm_kmemdup(&pdev->dev, hinge_channels,
+ indio_dev->channels = devm_kmemdup(dev, hinge_channels,
sizeof(hinge_channels), GFP_KERNEL);
if (!indio_dev->channels)
return -ENOMEM;
@@ -301,7 +302,7 @@ static int hid_hinge_probe(struct platform_device *pdev)
(struct iio_chan_spec *)indio_dev->channels,
hsdev->usage, st);
if (ret) {
- dev_err(&pdev->dev, "failed to setup attributes\n");
+ dev_err(dev, "failed to setup attributes\n");
return ret;
}

@@ -313,7 +314,7 @@ static int hid_hinge_probe(struct platform_device *pdev)
ret = hid_sensor_setup_trigger(indio_dev, indio_dev->name,
&st->common_attributes);
if (ret < 0) {
- dev_err(&pdev->dev, "trigger setup failed\n");
+ dev_err(dev, "trigger setup failed\n");
return ret;
}

@@ -322,13 +323,13 @@ static int hid_hinge_probe(struct platform_device *pdev)
st->callbacks.pdev = pdev;
ret = sensor_hub_register_callback(hsdev, hsdev->usage, &st->callbacks);
if (ret < 0) {
- dev_err(&pdev->dev, "callback reg failed\n");
+ dev_err(dev, "callback reg failed\n");
goto error_remove_trigger;
}

ret = iio_device_register(indio_dev);
if (ret) {
- dev_err(&pdev->dev, "device register failed\n");
+ dev_err(dev, "device register failed\n");
goto error_remove_callback;
}

--
2.34.1