From: Hartmut Knaack <knaack.h@gmx.de>
To: Karol Wrona <k.wrona@samsung.com>,
Jonathan Cameron <jic23@kernel.org>,
linux-iio@vger.kernel.org, Arnd Bergmann <arnd@arndb.de>,
linux-kernel@vger.kernel.org
Cc: Bartlomiej Zolnierkiewicz <b.zolnierkie@samsung.com>,
Kyungmin Park <kyungmin.park@samsung.com>
Subject: Re: [PATCH v2 3/5] iio: sensorhub: Add sensorhub iio commons
Date: Thu, 04 Dec 2014 00:19:55 +0100 [thread overview]
Message-ID: <547F9A9B.1090202@gmx.de> (raw)
In-Reply-To: <1416593957-19788-4-git-send-email-k.wrona@samsung.com>
Karol Wrona schrieb am 21.11.2014 um 19:19:
> This patch adds common library for sensorhub iio drivers.
>
Some comments inline.
> Signed-off-by: Karol Wrona <k.wrona@samsung.com>
> Acked-by: Kyungmin Park <kyungmin.park@samsung.com>
> ---
> drivers/iio/common/Kconfig | 1 +
> drivers/iio/common/Makefile | 1 +
> drivers/iio/common/ssp_sensors/Kconfig | 13 ++++
> drivers/iio/common/ssp_sensors/Makefile | 5 ++
> drivers/iio/common/ssp_sensors/ssp_iio.c | 81 +++++++++++++++++++++++
> drivers/iio/common/ssp_sensors/ssp_iio_sensor.h | 59 +++++++++++++++++
> 6 files changed, 160 insertions(+)
> create mode 100644 drivers/iio/common/ssp_sensors/Kconfig
> create mode 100644 drivers/iio/common/ssp_sensors/Makefile
> create mode 100644 drivers/iio/common/ssp_sensors/ssp_iio.c
> create mode 100644 drivers/iio/common/ssp_sensors/ssp_iio_sensor.h
>
> diff --git a/drivers/iio/common/Kconfig b/drivers/iio/common/Kconfig
> index 0b6e97d..630f9d8 100644
> --- a/drivers/iio/common/Kconfig
> +++ b/drivers/iio/common/Kconfig
> @@ -4,3 +4,4 @@
>
> source "drivers/iio/common/hid-sensors/Kconfig"
> source "drivers/iio/common/st_sensors/Kconfig"
> +source "drivers/iio/common/ssp_sensors/Kconfig"
Maintain alphabetic order.
> diff --git a/drivers/iio/common/Makefile b/drivers/iio/common/Makefile
> index 3112df0..5119642 100644
> --- a/drivers/iio/common/Makefile
> +++ b/drivers/iio/common/Makefile
> @@ -9,3 +9,4 @@
> # When adding new entries keep the list in alphabetical order
> obj-y += hid-sensors/
> obj-y += st_sensors/
> +obj-y += ssp_sensors/
Maintain alphabetic order.
> diff --git a/drivers/iio/common/ssp_sensors/Kconfig b/drivers/iio/common/ssp_sensors/Kconfig
> new file mode 100644
> index 0000000..3c10f6f
> --- /dev/null
> +++ b/drivers/iio/common/ssp_sensors/Kconfig
> @@ -0,0 +1,13 @@
> +#
> +# SSP Sensor common modules
> +#
> +menu "SSP Sensor IIO Common"
Do we need to mention IIO here, again?
> +
> +config SSP_SENSOR_IIO
Better call it IIO_SSP_SENSOR.
> + tristate "Commons for all SSP Sensor IIO drivers"
> + depends on SENSORS_SAMSUNG_SSP
> + select IIO_BUFFER
> + help
> + Say yes here to build commons for SSP sensors.
Or build as a module named ssp_iio.
> +
> +endmenu
> diff --git a/drivers/iio/common/ssp_sensors/Makefile b/drivers/iio/common/ssp_sensors/Makefile
> new file mode 100644
> index 0000000..f39f109
> --- /dev/null
> +++ b/drivers/iio/common/ssp_sensors/Makefile
> @@ -0,0 +1,5 @@
> +#
> +# Makefile for the SSP sensor common modules.
> +#
> +
> +obj-$(CONFIG_SSP_SENSOR_IIO) += ssp_iio.o
> diff --git a/drivers/iio/common/ssp_sensors/ssp_iio.c b/drivers/iio/common/ssp_sensors/ssp_iio.c
> new file mode 100644
> index 0000000..bbe9e5e
> --- /dev/null
> +++ b/drivers/iio/common/ssp_sensors/ssp_iio.c
> @@ -0,0 +1,81 @@
> +/*
> + * Copyright (C) 2014, Samsung Electronics Co. Ltd. All Rights Reserved.
> + *
> + * This program is free software; you can redistribute it and/or modify
> + * it under the terms of the GNU General Public License as published by
> + * the Free Software Foundation; either version 2 of the License, or
> + * (at your option) any later version.
> + *
> + * This program is distributed in the hope that it will be useful,
> + * but WITHOUT ANY WARRANTY; without even the implied warranty of
> + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
> + * GNU General Public License for more details.
> + *
> + */
> +
> +#include <linux/iio/common/ssp_sensors.h>
> +#include <linux/iio/kfifo_buf.h>
> +#include "ssp_iio_sensor.h"
> +
> +/**
> + * ssp_common_buffer_postenable() - generic postenable callback for ssp buffer
> + *
> + * @indio_dev: iio device
> + *
> + * Returns 0 or negative value in case of error
> + */
> +int ssp_common_buffer_postenable(struct iio_dev *indio_dev)
> +{
> + struct ssp_sensor_data *c = iio_priv(indio_dev);
> + struct ssp_data *data = dev_get_drvdata(indio_dev->dev.parent->parent);
> +
> + return ssp_enable_sensor(data, c->type,
> + ssp_get_sensor_delay(data, c->type));
Improve indentation.
> +}
> +EXPORT_SYMBOL(ssp_common_buffer_postenable);
> +
> +/**
> + * ssp_common_buffer_predisable() - generic predisable callback for ssp buffer
> + *
> + * @indio_dev: iio device
> + *
> + * Returns 0 or negative value in case of error
> + */
> +int ssp_common_buffer_predisable(struct iio_dev *indio_dev)
> +{
> + struct ssp_sensor_data *c = iio_priv(indio_dev);
> + struct ssp_data *data = dev_get_drvdata(indio_dev->dev.parent->parent);
> +
> + return ssp_disable_sensor(data, c->type);
> +}
> +EXPORT_SYMBOL(ssp_common_buffer_predisable);
> +
> +/**
> + * ssp_common_setup_buffer() - creates iio kfifo and registers the buffer for device
Wrap comment.
> + *
> + * @indio_dev: iio device
> + *
> + * Returns 0 or negative value in case of error
> + */
> +int ssp_common_setup_buffer(struct iio_dev *indio_dev,
> + const struct iio_buffer_setup_ops *ops)
> +{
> + int ret;
> + struct iio_buffer *buffer;
> +
> + buffer = iio_kfifo_allocate(indio_dev);
> + if (!buffer)
> + return -ENOMEM;
> +
> + iio_device_attach_buffer(indio_dev, buffer);
> +
> + indio_dev->setup_ops = ops;
> +
> + ret = iio_buffer_register(indio_dev, indio_dev->channels,
> + indio_dev->num_channels);
> + if (ret)
> + iio_kfifo_free(buffer);
> +
> + return ret;
> +}
> +EXPORT_SYMBOL(ssp_common_setup_buffer);
> diff --git a/drivers/iio/common/ssp_sensors/ssp_iio_sensor.h b/drivers/iio/common/ssp_sensors/ssp_iio_sensor.h
> new file mode 100644
> index 0000000..bf4a6ad
> --- /dev/null
> +++ b/drivers/iio/common/ssp_sensors/ssp_iio_sensor.h
> @@ -0,0 +1,59 @@
> +#ifndef __SSP_IIO_SENSOR_H__
> +#define __SSP_IIO_SENSOR_H__
> +
> +#define SSP_CHANNEL_AG(_type, _mod, _index) \
> +{ \
> + .type = _type,\
> + .modified = 1,\
> + .channel2 = _mod,\
> + .info_mask_shared_by_type = BIT(IIO_CHAN_INFO_SAMP_FREQ),\
> + .scan_index = _index,\
> + .scan_type = {\
> + .sign = 's',\
> + .realbits = 16,\
> + .storagebits = 16,\
> + .shift = 0,\
> + .endianness = IIO_LE,\
> + },\
> +}
> +
> +#define SSP_DIVISOR 1000000ULL
> +#define SSP_MS_PER_S 1000
> +#define SSP_DIVIDEND (SSP_DIVISOR * SSP_MS_PER_S)
> +
> +int ssp_common_buffer_postenable(struct iio_dev *indio_dev);
> +
> +int ssp_common_buffer_predisable(struct iio_dev *indio_dev);
> +
> +int ssp_common_setup_buffer(struct iio_dev *indio_dev,
> + const struct iio_buffer_setup_ops *ops);
> +
> +/* Converts time in ms to frequency */
> +static inline void ssp_convert_to_freq(u32 time, int *integer_part,
> + int *fractional)
> +{
> + unsigned int value;
> +
> + if (time == 0) {
> + *fractional = 0;
> + *integer_part = 0;
> + return;
> + }
> +
> + value = SSP_DIVIDEND / time;
> + *fractional = value % SSP_DIVISOR;
> + *integer_part = value / SSP_DIVISOR;
do_div() does the same, but could make value obsolete.
> +}
> +
> +/* Converts frequency to time in ms*/
Missing whitespace at end of comment.
> +static inline int ssp_convert_to_time(int integer_part, int fractional)
> +{
> + u64 value;
> +
> + value = integer_part * SSP_DIVISOR + fractional;
> + if (value == 0)
> + return 0;
> +
> + return div_u64(SSP_DIVIDEND, value);
Double whitespace.
> +}
> +#endif /* __SSP_IIO_SENSOR_H__ */
>
next prev parent reply other threads:[~2014-12-03 23:20 UTC|newest]
Thread overview: 15+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-11-21 18:19 [PATCH v2 0/5] misc: sensorhub: Add sensorhub driver Karol Wrona
2014-11-21 18:19 ` [PATCH v2 1/5] " Karol Wrona
2014-11-21 19:38 ` Arnd Bergmann
2014-11-22 12:17 ` Jonathan Cameron
2014-11-24 11:39 ` Karol Wrona
2014-11-24 12:35 ` Arnd Bergmann
2014-11-24 13:04 ` Karol Wrona
2014-12-03 23:12 ` Hartmut Knaack
2014-11-21 18:19 ` [PATCH v2 2/5] sensorhub: Add sensorhub bindings Karol Wrona
2014-12-03 23:14 ` Hartmut Knaack
2014-11-21 18:19 ` [PATCH v2 3/5] iio: sensorhub: Add sensorhub iio commons Karol Wrona
2014-12-03 23:19 ` Hartmut Knaack [this message]
2014-11-21 18:19 ` [PATCH v2 4/5] iio: sensorhub: Add sensorhub accelerometer sensor Karol Wrona
2014-12-03 23:29 ` Hartmut Knaack
2014-11-21 18:19 ` [PATCH v2 5/5] iio: sensorhub: Add sensorhub gyroscope sensor Karol Wrona
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=547F9A9B.1090202@gmx.de \
--to=knaack.h@gmx.de \
--cc=arnd@arndb.de \
--cc=b.zolnierkie@samsung.com \
--cc=jic23@kernel.org \
--cc=k.wrona@samsung.com \
--cc=kyungmin.park@samsung.com \
--cc=linux-iio@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.