Re: [PATCH v3 5/5] iio: common: ssp_sensors: Add sensorhub gyroscope sensor

From: Hartmut Knaack
Date: Wed Dec 17 2014 - 17:20:48 EST


Karol Wrona schrieb am 05.12.2014 um 20:54:
> This patch adds gyroscope iio driver which uses sensorhub as data
> provider.
>
This one has got a more serious issue.
> Change-Id: Ia16bc92159d062a29957de8e62ea3fefdcd7985a
> Signed-off-by: Karol Wrona <k.wrona@xxxxxxxxxxx>
> Acked-by: Kyungmin Park <kyungmin.park@xxxxxxxxxxx>
> ---
> drivers/iio/gyro/Makefile | 2 +
> drivers/iio/gyro/ssp_gyro_sensor.c | 202 ++++++++++++++++++++++++++++++++++++
> 2 files changed, 204 insertions(+)
> create mode 100644 drivers/iio/gyro/ssp_gyro_sensor.c
>

> +static int ssp_gyro_probe(struct platform_device *pdev)
> +{
> + int ret;
> + struct iio_dev *indio_dev;
> + struct ssp_sensor_data *spd;
> +
> + indio_dev = iio_device_alloc(sizeof(*spd));
Need to use devm_iio_device_alloc(), since iio_device_free() has been dropped.
> + if (!indio_dev)
> + return -ENOMEM;
> +
> + spd = iio_priv(indio_dev);
> +
> + spd->process_data = ssp_process_gyro_data;
> + spd->type = SSP_GYROSCOPE_SENSOR;
> +
> + indio_dev->name = ssp_gyro_name;
> + indio_dev->dev.parent = &pdev->dev;
> + indio_dev->info = &ssp_gyro_iio_info;
> + indio_dev->modes = INDIO_BUFFER_HARDWARE;
> + indio_dev->channels = ssp_gyro_channels;
> + indio_dev->num_channels = ARRAY_SIZE(ssp_gyro_channels);
> +
> + ret = ssp_common_setup_buffer(indio_dev, &ssp_gyro_buffer_ops);
> + if (ret < 0) {
> + dev_err(&pdev->dev, "Buffer setup fail\n");
> + return ret;
> + }
> +
> + platform_set_drvdata(pdev, indio_dev);
> +
> + ret = iio_device_register(indio_dev);
> + if (ret < 0) {
> + iio_buffer_unregister(indio_dev);
> + iio_kfifo_free(indio_dev->buffer);
> + return ret;
> + };
> +
> + /* similar to accel */
> + ssp_register_consumer(indio_dev, SSP_GYROSCOPE_SENSOR);
> +
> + return 0;
> +}
> +
> +static int ssp_gyro_remove(struct platform_device *pdev)
> +{
> + struct iio_dev *indio_dev = platform_get_drvdata(pdev);
> +
> + iio_device_unregister(indio_dev);
> + iio_buffer_unregister(indio_dev);
> + iio_kfifo_free(indio_dev->buffer);
> +
> + return 0;
> +}
> +
> +static const struct of_device_id ssp_gyro_id_table[] = {
> + {
> + .compatible = "samsung,mpu6500-gyro",
> + },
> + {},
> +};
> +
> +static struct platform_driver ssp_gyro_driver = {
> + .driver = {
> + .owner = THIS_MODULE,
> + .name = SSP_GYROSCOPE_NAME,
> + .of_match_table = ssp_gyro_id_table,
> + },
> + .probe = ssp_gyro_probe,
> + .remove = ssp_gyro_remove,
> +};
> +
> +module_platform_driver(ssp_gyro_driver);
> +
> +MODULE_AUTHOR("Karol Wrona <k.wrona@xxxxxxxxxxx>");
> +MODULE_DESCRIPTION("Samsung sensorhub gyroscopes driver");
> +MODULE_LICENSE("GPL");
>

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/