aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/iio/orientation/hid-sensor-rotation.c
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/iio/orientation/hid-sensor-rotation.c')
-rw-r--r--drivers/iio/orientation/hid-sensor-rotation.c17
1 files changed, 9 insertions, 8 deletions
diff --git a/drivers/iio/orientation/hid-sensor-rotation.c b/drivers/iio/orientation/hid-sensor-rotation.c
index 4afb6c79ccbc..b98b9d94d184 100644
--- a/drivers/iio/orientation/hid-sensor-rotation.c
+++ b/drivers/iio/orientation/hid-sensor-rotation.c
@@ -222,7 +222,6 @@ static int hid_dev_rot_probe(struct platform_device *pdev)
222 struct iio_dev *indio_dev; 222 struct iio_dev *indio_dev;
223 struct dev_rot_state *rot_state; 223 struct dev_rot_state *rot_state;
224 struct hid_sensor_hub_device *hsdev = pdev->dev.platform_data; 224 struct hid_sensor_hub_device *hsdev = pdev->dev.platform_data;
225 struct iio_chan_spec *channels;
226 225
227 indio_dev = devm_iio_device_alloc(&pdev->dev, 226 indio_dev = devm_iio_device_alloc(&pdev->dev,
228 sizeof(struct dev_rot_state)); 227 sizeof(struct dev_rot_state));
@@ -243,21 +242,23 @@ static int hid_dev_rot_probe(struct platform_device *pdev)
243 return ret; 242 return ret;
244 } 243 }
245 244
246 channels = devm_kmemdup(&pdev->dev, dev_rot_channels, 245 indio_dev->channels = devm_kmemdup(&pdev->dev, dev_rot_channels,
247 sizeof(dev_rot_channels), GFP_KERNEL); 246 sizeof(dev_rot_channels),
248 if (!channels) { 247 GFP_KERNEL);
248 if (!indio_dev->channels) {
249 dev_err(&pdev->dev, "failed to duplicate channels\n"); 249 dev_err(&pdev->dev, "failed to duplicate channels\n");
250 return -ENOMEM; 250 return -ENOMEM;
251 } 251 }
252 252
253 ret = dev_rot_parse_report(pdev, hsdev, channels, 253 ret = dev_rot_parse_report(pdev, hsdev,
254 HID_USAGE_SENSOR_DEVICE_ORIENTATION, rot_state); 254 (struct iio_chan_spec *)indio_dev->channels,
255 HID_USAGE_SENSOR_DEVICE_ORIENTATION,
256 rot_state);
255 if (ret) { 257 if (ret) {
256 dev_err(&pdev->dev, "failed to setup attributes\n"); 258 dev_err(&pdev->dev, "failed to setup attributes\n");
257 return ret; 259 return ret;
258 } 260 }
259 261
260 indio_dev->channels = channels;
261 indio_dev->num_channels = ARRAY_SIZE(dev_rot_channels); 262 indio_dev->num_channels = ARRAY_SIZE(dev_rot_channels);
262 indio_dev->dev.parent = &pdev->dev; 263 indio_dev->dev.parent = &pdev->dev;
263 indio_dev->info = &dev_rot_info; 264 indio_dev->info = &dev_rot_info;
@@ -321,7 +322,7 @@ static int hid_dev_rot_remove(struct platform_device *pdev)
321 return 0; 322 return 0;
322} 323}
323 324
324static struct platform_device_id hid_dev_rot_ids[] = { 325static const struct platform_device_id hid_dev_rot_ids[] = {
325 { 326 {
326 /* Format: HID-SENSOR-usage_id_in_hex_lowercase */ 327 /* Format: HID-SENSOR-usage_id_in_hex_lowercase */
327 .name = "HID-SENSOR-20008a", 328 .name = "HID-SENSOR-20008a",