19 #include <linux/device.h>
21 #include <linux/module.h>
24 #include <linux/slab.h>
31 #include "../common/hid-sensors/hid-sensor-attributes.h"
32 #include "../common/hid-sensors/hid-sensor-trigger.h"
36 #define DRIVER_NAME "HID-SENSOR-200073"
102 static int accel_3d_read_raw(
struct iio_dev *indio_dev,
118 address = accel_3d_addresses[chan->
scan_index];
135 *val = hid_sensor_convert_exponent(
158 static int accel_3d_write_raw(
struct iio_dev *indio_dev,
183 static int accel_3d_write_raw_get_fmt(
struct iio_dev *indio_dev,
190 static const struct iio_info accel_3d_info = {
192 .read_raw = &accel_3d_read_raw,
193 .write_raw = &accel_3d_write_raw,
194 .write_raw_get_fmt = &accel_3d_write_raw_get_fmt,
198 static void hid_sensor_push_data(
struct iio_dev *indio_dev,
u8 *
data,
int len)
203 dev_dbg(&indio_dev->
dev,
"hid_sensor_push_data\n");
208 datum_sz = buffer->access->get_bytes_per_datum(buffer);
209 if (len > datum_sz) {
210 dev_err(&indio_dev->
dev,
"Datum size mismatch %d:%d\n", len,
222 struct iio_dev *indio_dev = platform_get_drvdata(priv);
225 dev_dbg(&indio_dev->
dev,
"accel_3d_proc_event [%d]\n",
228 hid_sensor_push_data(indio_dev,
238 size_t raw_len,
char *raw_data,
241 struct iio_dev *indio_dev = platform_get_drvdata(priv);
280 accel_3d_adjust_channel_bit_mask(channels,
284 dev_dbg(&pdev->
dev,
"accel_3d %x:%x, %x:%x, %x:%x\n",
286 st->
accel[0].report_id,
297 static const char *
name =
"accel_3d";
304 if (indio_dev ==
NULL) {
308 platform_set_drvdata(pdev, indio_dev);
310 accel_state = iio_priv(indio_dev);
318 dev_err(&pdev->
dev,
"failed to setup common attributes\n");
322 channels =
kmemdup(accel_3d_channels,
323 sizeof(accel_3d_channels),
326 dev_err(&pdev->
dev,
"failed to duplicate channels\n");
330 ret = accel_3d_parse_report(pdev, hsdev, channels,
333 dev_err(&pdev->
dev,
"failed to setup attributes\n");
334 goto error_free_dev_mem;
339 indio_dev->
dev.parent = &pdev->
dev;
340 indio_dev->
info = &accel_3d_info;
347 dev_err(&pdev->
dev,
"failed to initialize trigger buffer\n");
348 goto error_free_dev_mem;
354 dev_err(&pdev->
dev,
"trigger setup failed\n");
355 goto error_unreg_buffer_funcs;
360 dev_err(&pdev->
dev,
"device register failed\n");
361 goto error_remove_trigger;
364 accel_state->
callbacks.send_event = accel_3d_proc_event;
365 accel_state->
callbacks.capture_sample = accel_3d_capture_sample;
371 goto error_iio_unreg;
378 error_remove_trigger:
380 error_unreg_buffer_funcs:
394 struct iio_dev *indio_dev = platform_get_drvdata(pdev);
411 .probe = hid_accel_3d_probe,
412 .remove = hid_accel_3d_remove,