Skip to content

Commit 77f9f77

Browse files
Wolfram SangJiri Kosina
authored andcommitted
HID: hid-sensor-custom: simplify getting .driver_data
We should get 'driver_data' from 'struct device' directly. Going via platform_device is an unneeded step back and forth. Signed-off-by: Wolfram Sang <[email protected]> Acked-by: Srinivas Pandruvada <[email protected]> Reviewed-by: Simon Horman <[email protected]> Signed-off-by: Jiri Kosina <[email protected]>
1 parent c6400e5 commit 77f9f77

File tree

1 file changed

+4
-8
lines changed

1 file changed

+4
-8
lines changed

drivers/hid/hid-sensor-custom.c

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -157,8 +157,7 @@ static int usage_id_cmp(const void *p1, const void *p2)
157157
static ssize_t enable_sensor_show(struct device *dev,
158158
struct device_attribute *attr, char *buf)
159159
{
160-
struct platform_device *pdev = to_platform_device(dev);
161-
struct hid_sensor_custom *sensor_inst = platform_get_drvdata(pdev);
160+
struct hid_sensor_custom *sensor_inst = dev_get_drvdata(dev);
162161

163162
return sprintf(buf, "%d\n", sensor_inst->enable);
164163
}
@@ -237,8 +236,7 @@ static ssize_t enable_sensor_store(struct device *dev,
237236
struct device_attribute *attr,
238237
const char *buf, size_t count)
239238
{
240-
struct platform_device *pdev = to_platform_device(dev);
241-
struct hid_sensor_custom *sensor_inst = platform_get_drvdata(pdev);
239+
struct hid_sensor_custom *sensor_inst = dev_get_drvdata(dev);
242240
int value;
243241
int ret = -EINVAL;
244242

@@ -283,8 +281,7 @@ static const struct attribute_group enable_sensor_attr_group = {
283281
static ssize_t show_value(struct device *dev, struct device_attribute *attr,
284282
char *buf)
285283
{
286-
struct platform_device *pdev = to_platform_device(dev);
287-
struct hid_sensor_custom *sensor_inst = platform_get_drvdata(pdev);
284+
struct hid_sensor_custom *sensor_inst = dev_get_drvdata(dev);
288285
struct hid_sensor_hub_attribute_info *attribute;
289286
int index, usage, field_index;
290287
char name[HID_CUSTOM_NAME_LENGTH];
@@ -392,8 +389,7 @@ static ssize_t show_value(struct device *dev, struct device_attribute *attr,
392389
static ssize_t store_value(struct device *dev, struct device_attribute *attr,
393390
const char *buf, size_t count)
394391
{
395-
struct platform_device *pdev = to_platform_device(dev);
396-
struct hid_sensor_custom *sensor_inst = platform_get_drvdata(pdev);
392+
struct hid_sensor_custom *sensor_inst = dev_get_drvdata(dev);
397393
int index, field_index, usage;
398394
char name[HID_CUSTOM_NAME_LENGTH];
399395
int value;

0 commit comments

Comments
 (0)