diff options
Diffstat (limited to 'drivers/iio/accel/hid-sensor-accel-3d.c')
-rw-r--r-- | drivers/iio/accel/hid-sensor-accel-3d.c | 43 |
1 files changed, 18 insertions, 25 deletions
diff --git a/drivers/iio/accel/hid-sensor-accel-3d.c b/drivers/iio/accel/hid-sensor-accel-3d.c index bbcbd7101f33..46d22f3fb1a9 100644 --- a/drivers/iio/accel/hid-sensor-accel-3d.c +++ b/drivers/iio/accel/hid-sensor-accel-3d.c | |||
@@ -30,10 +30,6 @@ | |||
30 | #include <linux/iio/triggered_buffer.h> | 30 | #include <linux/iio/triggered_buffer.h> |
31 | #include "../common/hid-sensors/hid-sensor-trigger.h" | 31 | #include "../common/hid-sensors/hid-sensor-trigger.h" |
32 | 32 | ||
33 | /*Format: HID-SENSOR-usage_id_in_hex*/ | ||
34 | /*Usage ID from spec for Accelerometer-3D: 0x200073*/ | ||
35 | #define DRIVER_NAME "HID-SENSOR-200073" | ||
36 | |||
37 | enum accel_3d_channel { | 33 | enum accel_3d_channel { |
38 | CHANNEL_SCAN_INDEX_X, | 34 | CHANNEL_SCAN_INDEX_X, |
39 | CHANNEL_SCAN_INDEX_Y, | 35 | CHANNEL_SCAN_INDEX_Y, |
@@ -179,18 +175,10 @@ static int accel_3d_write_raw(struct iio_dev *indio_dev, | |||
179 | return ret; | 175 | return ret; |
180 | } | 176 | } |
181 | 177 | ||
182 | static int accel_3d_write_raw_get_fmt(struct iio_dev *indio_dev, | ||
183 | struct iio_chan_spec const *chan, | ||
184 | long mask) | ||
185 | { | ||
186 | return IIO_VAL_INT_PLUS_MICRO; | ||
187 | } | ||
188 | |||
189 | static const struct iio_info accel_3d_info = { | 178 | static const struct iio_info accel_3d_info = { |
190 | .driver_module = THIS_MODULE, | 179 | .driver_module = THIS_MODULE, |
191 | .read_raw = &accel_3d_read_raw, | 180 | .read_raw = &accel_3d_read_raw, |
192 | .write_raw = &accel_3d_write_raw, | 181 | .write_raw = &accel_3d_write_raw, |
193 | .write_raw_get_fmt = &accel_3d_write_raw_get_fmt, | ||
194 | }; | 182 | }; |
195 | 183 | ||
196 | /* Function to push data to buffer */ | 184 | /* Function to push data to buffer */ |
@@ -286,11 +274,11 @@ static int hid_accel_3d_probe(struct platform_device *pdev) | |||
286 | struct hid_sensor_hub_device *hsdev = pdev->dev.platform_data; | 274 | struct hid_sensor_hub_device *hsdev = pdev->dev.platform_data; |
287 | struct iio_chan_spec *channels; | 275 | struct iio_chan_spec *channels; |
288 | 276 | ||
289 | indio_dev = iio_device_alloc(sizeof(struct accel_3d_state)); | 277 | indio_dev = devm_iio_device_alloc(&pdev->dev, |
290 | if (indio_dev == NULL) { | 278 | sizeof(struct accel_3d_state)); |
291 | ret = -ENOMEM; | 279 | if (indio_dev == NULL) |
292 | goto error_ret; | 280 | return -ENOMEM; |
293 | } | 281 | |
294 | platform_set_drvdata(pdev, indio_dev); | 282 | platform_set_drvdata(pdev, indio_dev); |
295 | 283 | ||
296 | accel_state = iio_priv(indio_dev); | 284 | accel_state = iio_priv(indio_dev); |
@@ -302,15 +290,14 @@ static int hid_accel_3d_probe(struct platform_device *pdev) | |||
302 | &accel_state->common_attributes); | 290 | &accel_state->common_attributes); |
303 | if (ret) { | 291 | if (ret) { |
304 | dev_err(&pdev->dev, "failed to setup common attributes\n"); | 292 | dev_err(&pdev->dev, "failed to setup common attributes\n"); |
305 | goto error_free_dev; | 293 | return ret; |
306 | } | 294 | } |
307 | 295 | ||
308 | channels = kmemdup(accel_3d_channels, sizeof(accel_3d_channels), | 296 | channels = kmemdup(accel_3d_channels, sizeof(accel_3d_channels), |
309 | GFP_KERNEL); | 297 | GFP_KERNEL); |
310 | if (!channels) { | 298 | if (!channels) { |
311 | ret = -ENOMEM; | ||
312 | dev_err(&pdev->dev, "failed to duplicate channels\n"); | 299 | dev_err(&pdev->dev, "failed to duplicate channels\n"); |
313 | goto error_free_dev; | 300 | return -ENOMEM; |
314 | } | 301 | } |
315 | 302 | ||
316 | ret = accel_3d_parse_report(pdev, hsdev, channels, | 303 | ret = accel_3d_parse_report(pdev, hsdev, channels, |
@@ -367,9 +354,6 @@ error_unreg_buffer_funcs: | |||
367 | iio_triggered_buffer_cleanup(indio_dev); | 354 | iio_triggered_buffer_cleanup(indio_dev); |
368 | error_free_dev_mem: | 355 | error_free_dev_mem: |
369 | kfree(indio_dev->channels); | 356 | kfree(indio_dev->channels); |
370 | error_free_dev: | ||
371 | iio_device_free(indio_dev); | ||
372 | error_ret: | ||
373 | return ret; | 357 | return ret; |
374 | } | 358 | } |
375 | 359 | ||
@@ -384,14 +368,23 @@ static int hid_accel_3d_remove(struct platform_device *pdev) | |||
384 | hid_sensor_remove_trigger(indio_dev); | 368 | hid_sensor_remove_trigger(indio_dev); |
385 | iio_triggered_buffer_cleanup(indio_dev); | 369 | iio_triggered_buffer_cleanup(indio_dev); |
386 | kfree(indio_dev->channels); | 370 | kfree(indio_dev->channels); |
387 | iio_device_free(indio_dev); | ||
388 | 371 | ||
389 | return 0; | 372 | return 0; |
390 | } | 373 | } |
391 | 374 | ||
375 | static struct platform_device_id hid_accel_3d_ids[] = { | ||
376 | { | ||
377 | /* Format: HID-SENSOR-usage_id_in_hex_lowercase */ | ||
378 | .name = "HID-SENSOR-200073", | ||
379 | }, | ||
380 | { /* sentinel */ } | ||
381 | }; | ||
382 | MODULE_DEVICE_TABLE(platform, hid_accel_3d_ids); | ||
383 | |||
392 | static struct platform_driver hid_accel_3d_platform_driver = { | 384 | static struct platform_driver hid_accel_3d_platform_driver = { |
385 | .id_table = hid_accel_3d_ids, | ||
393 | .driver = { | 386 | .driver = { |
394 | .name = DRIVER_NAME, | 387 | .name = KBUILD_MODNAME, |
395 | .owner = THIS_MODULE, | 388 | .owner = THIS_MODULE, |
396 | }, | 389 | }, |
397 | .probe = hid_accel_3d_probe, | 390 | .probe = hid_accel_3d_probe, |