* [PATCH 2/6] staging:iio:accel:sca3000: Fix format of comments
@ 2014-01-13 21:28 Peter Meerwald
2014-01-13 21:28 ` [PATCH 3/6] staging:iio:accel:sca3000: Event_attribute_group seems to be missing for _info_with_temp Peter Meerwald
` (4 more replies)
0 siblings, 5 replies; 9+ messages in thread
From: Peter Meerwald @ 2014-01-13 21:28 UTC (permalink / raw)
To: linux-iio; +Cc: Peter Meerwald
Signed-off-by: Peter Meerwald <pmeerw@pmeerw.net>
---
drivers/staging/iio/accel/sca3000_core.c | 52 ++++++++++++++++++--------------
1 file changed, 29 insertions(+), 23 deletions(-)
diff --git a/drivers/staging/iio/accel/sca3000_core.c b/drivers/staging/iio/accel/sca3000_core.c
index 908d5cd..b627d8f 100644
--- a/drivers/staging/iio/accel/sca3000_core.c
+++ b/drivers/staging/iio/accel/sca3000_core.c
@@ -32,7 +32,8 @@ enum sca3000_variant {
e05,
};
-/* Note where option modes are not defined, the chip simply does not
+/*
+ * Note where option modes are not defined, the chip simply does not
* support any.
* Other chips in the sca3000 series use i2c and are not included here.
*
@@ -191,7 +192,6 @@ error_ret:
return ret;
}
-/* Crucial that lock is called before calling this */
/**
* sca3000_read_ctrl_reg() read from lock protected control register.
*
@@ -402,7 +402,8 @@ error_ret:
}
-/* Not even vaguely standard attributes so defined here rather than
+/*
+ * Not even vaguely standard attributes so defined here rather than
* in the relevant IIO core headers
*/
static IIO_DEVICE_ATTR(measurement_mode_available, S_IRUGO,
@@ -662,7 +663,8 @@ error_free_lock:
return ret ? ret : len;
}
-/* Should only really be registered if ring buffer support is compiled in.
+/*
+ * Should only really be registered if ring buffer support is compiled in.
* Does no harm however and doing it right would add a fair bit of complexity
*/
static IIO_DEV_ATTR_SAMP_FREQ_AVAIL(sca3000_read_av_freq);
@@ -675,10 +677,10 @@ static IIO_DEV_ATTR_SAMP_FREQ(S_IWUSR | S_IRUGO,
/**
* sca3000_read_temp() sysfs interface to get the temperature when available
*
-* The alignment of data in here is downright odd. See data sheet.
-* Converting this into a meaningful value is left to inline functions in
-* userspace part of header.
-**/
+ * The alignment of data in here is downright odd. See data sheet.
+ * Converting this into a meaningful value is left to inline functions in
+ * userspace part of header.
+ **/
static ssize_t sca3000_read_temp(struct device *dev,
struct device_attribute *attr,
char *buf)
@@ -802,12 +804,12 @@ static const struct attribute_group sca3000_attribute_group_with_temp = {
.attrs = sca3000_attributes_with_temp,
};
-/* RING RELATED interrupt handler */
-/* depending on event, push to the ring buffer event chrdev or the event one */
-
/**
* sca3000_event_handler() - handling ring and non ring events
*
+ * Ring related interrupt handler. Depending on event, push to
+ * the ring buffer event chrdev or the event one.
+ *
* This function is complicated by the fact that the devices can signify ring
* and non ring events via the same interrupt line and they can only
* be distinguished via a read of the relevant status register.
@@ -819,7 +821,8 @@ static irqreturn_t sca3000_event_handler(int irq, void *private)
int ret, val;
s64 last_timestamp = iio_get_time_ns();
- /* Could lead if badly timed to an extra read of status reg,
+ /*
+ * Could lead if badly timed to an extra read of status reg,
* but ensures no interrupt is missed.
*/
mutex_lock(&st->lock);
@@ -934,7 +937,6 @@ static ssize_t sca3000_query_free_fall_mode(struct device *dev,
* the device falls more than 25cm. This has not been tested due
* to fragile wiring.
**/
-
static ssize_t sca3000_set_free_fall_mode(struct device *dev,
struct device_attribute *attr,
const char *buf,
@@ -956,7 +958,7 @@ static ssize_t sca3000_set_free_fall_mode(struct device *dev,
if (ret)
goto error_ret;
- /*if off and should be on*/
+ /* if off and should be on */
if (val && !(st->rx[0] & protect_mask))
ret = sca3000_write_reg(st, SCA3000_REG_ADDR_MODE,
(st->rx[0] | SCA3000_FREE_FALL_DETECT));
@@ -991,13 +993,15 @@ static int sca3000_write_event_config(struct iio_dev *indio_dev,
int num = chan->channel2;
mutex_lock(&st->lock);
- /* First read the motion detector config to find out if
- * this axis is on*/
+ /*
+ * First read the motion detector config to find out if
+ * this axis is on
+ */
ret = sca3000_read_ctrl_reg(st, SCA3000_REG_CTRL_SEL_MD_CTRL);
if (ret < 0)
goto exit_point;
ctrlval = ret;
- /* Off and should be on */
+ /* if off and should be on */
if (state && !(ctrlval & sca3000_addresses[num][2])) {
ret = sca3000_write_ctrl_reg(st,
SCA3000_REG_CTRL_SEL_MD_CTRL,
@@ -1020,7 +1024,7 @@ static int sca3000_write_event_config(struct iio_dev *indio_dev,
ret = sca3000_read_data_short(st, SCA3000_REG_ADDR_MODE, 1);
if (ret)
goto exit_point;
- /*if off and should be on*/
+ /* if off and should be on */
if ((st->mo_det_use_count)
&& ((st->rx[0] & protect_mask) != SCA3000_MEAS_MODE_MOT_DET))
ret = sca3000_write_reg(st, SCA3000_REG_ADDR_MODE,
@@ -1066,7 +1070,7 @@ static struct attribute_group sca3000_event_attribute_group = {
* Devices use flash memory to store many of the register values
* and hence can come up in somewhat unpredictable states.
* Hence reset everything on driver load.
- **/
+ **/
static int sca3000_clean_setup(struct sca3000_state *st)
{
int ret;
@@ -1106,9 +1110,11 @@ static int sca3000_clean_setup(struct sca3000_state *st)
| SCA3000_INT_MASK_ACTIVE_LOW);
if (ret)
goto error_ret;
- /* Select normal measurement mode, free fall off, ring off */
- /* Ring in 12 bit mode - it is fine to overwrite reserved bits 3,5
- * as that occurs in one of the example on the datasheet */
+ /*
+ * Select normal measurement mode, free fall off, ring off
+ * Ring in 12 bit mode - it is fine to overwrite reserved bits 3,5
+ * as that occurs in one of the example on the datasheet
+ */
ret = sca3000_read_data_short(st, SCA3000_REG_ADDR_MODE, 1);
if (ret)
goto error_ret;
@@ -1235,7 +1241,7 @@ static int sca3000_remove(struct spi_device *spi)
struct iio_dev *indio_dev = spi_get_drvdata(spi);
struct sca3000_state *st = iio_priv(indio_dev);
- /* Must ensure no interrupts can be generated after this!*/
+ /* Must ensure no interrupts can be generated after this! */
sca3000_stop_all_interrupts(st);
if (spi->irq)
free_irq(spi->irq, indio_dev);
--
1.8.3.2
^ permalink raw reply related [flat|nested] 9+ messages in thread
* [PATCH 3/6] staging:iio:accel:sca3000: Event_attribute_group seems to be missing for _info_with_temp
2014-01-13 21:28 [PATCH 2/6] staging:iio:accel:sca3000: Fix format of comments Peter Meerwald
@ 2014-01-13 21:28 ` Peter Meerwald
2014-01-18 11:08 ` Jonathan Cameron
2014-01-13 21:28 ` [PATCH 4/6] staging:iio:accel:sca3000: Channels missing in temp_output case Peter Meerwald
` (3 subsequent siblings)
4 siblings, 1 reply; 9+ messages in thread
From: Peter Meerwald @ 2014-01-13 21:28 UTC (permalink / raw)
To: linux-iio; +Cc: Peter Meerwald
issue introduced here 6fe8135f:
staging:iio: implement an iio_info structure to take some of the constant elements out of iio_dev
Signed-off-by: Peter Meerwald <pmeerw@pmeerw.net>
---
drivers/staging/iio/accel/sca3000_core.c | 1 +
1 file changed, 1 insertion(+)
diff --git a/drivers/staging/iio/accel/sca3000_core.c b/drivers/staging/iio/accel/sca3000_core.c
index b627d8f..159272e 100644
--- a/drivers/staging/iio/accel/sca3000_core.c
+++ b/drivers/staging/iio/accel/sca3000_core.c
@@ -1141,6 +1141,7 @@ static const struct iio_info sca3000_info = {
static const struct iio_info sca3000_info_with_temp = {
.attrs = &sca3000_attribute_group_with_temp,
.read_raw = &sca3000_read_raw,
+ .event_attrs = &sca3000_event_attribute_group,
.read_event_value = &sca3000_read_thresh,
.write_event_value = &sca3000_write_thresh,
.read_event_config = &sca3000_read_event_config,
--
1.8.3.2
^ permalink raw reply related [flat|nested] 9+ messages in thread
* [PATCH 4/6] staging:iio:accel:sca3000: Channels missing in temp_output case
2014-01-13 21:28 [PATCH 2/6] staging:iio:accel:sca3000: Fix format of comments Peter Meerwald
2014-01-13 21:28 ` [PATCH 3/6] staging:iio:accel:sca3000: Event_attribute_group seems to be missing for _info_with_temp Peter Meerwald
@ 2014-01-13 21:28 ` Peter Meerwald
2014-01-18 11:09 ` Jonathan Cameron
2014-01-13 21:28 ` [PATCH 5/6] staging:iio:accel:sca3000: Move temperature attribute to channels Peter Meerwald
` (2 subsequent siblings)
4 siblings, 1 reply; 9+ messages in thread
From: Peter Meerwald @ 2014-01-13 21:28 UTC (permalink / raw)
To: linux-iio; +Cc: Peter Meerwald
issues introduced here 25888dc5,
staging:iio:sca3000 extract old event handling and move to poll for events
Signed-off-by: Peter Meerwald <pmeerw@pmeerw.net>
---
drivers/staging/iio/accel/sca3000_core.c | 7 +++----
1 file changed, 3 insertions(+), 4 deletions(-)
diff --git a/drivers/staging/iio/accel/sca3000_core.c b/drivers/staging/iio/accel/sca3000_core.c
index 159272e..0123bc0 100644
--- a/drivers/staging/iio/accel/sca3000_core.c
+++ b/drivers/staging/iio/accel/sca3000_core.c
@@ -1170,11 +1170,10 @@ static int sca3000_probe(struct spi_device *spi)
indio_dev->name = spi_get_device_id(spi)->name;
if (st->info->temp_output)
indio_dev->info = &sca3000_info_with_temp;
- else {
+ else
indio_dev->info = &sca3000_info;
- indio_dev->channels = sca3000_channels;
- indio_dev->num_channels = ARRAY_SIZE(sca3000_channels);
- }
+ indio_dev->channels = sca3000_channels;
+ indio_dev->num_channels = ARRAY_SIZE(sca3000_channels);
indio_dev->modes = INDIO_DIRECT_MODE;
sca3000_configure_ring(indio_dev);
--
1.8.3.2
^ permalink raw reply related [flat|nested] 9+ messages in thread
* [PATCH 5/6] staging:iio:accel:sca3000: Move temperature attribute to channels
2014-01-13 21:28 [PATCH 2/6] staging:iio:accel:sca3000: Fix format of comments Peter Meerwald
2014-01-13 21:28 ` [PATCH 3/6] staging:iio:accel:sca3000: Event_attribute_group seems to be missing for _info_with_temp Peter Meerwald
2014-01-13 21:28 ` [PATCH 4/6] staging:iio:accel:sca3000: Channels missing in temp_output case Peter Meerwald
@ 2014-01-13 21:28 ` Peter Meerwald
2014-01-13 21:28 ` [PATCH 6/6] staging:iio:accel:sca3000: Cleanup sca3000.h Peter Meerwald
2014-01-18 11:07 ` [PATCH 2/6] staging:iio:accel:sca3000: Fix format of comments Jonathan Cameron
4 siblings, 0 replies; 9+ messages in thread
From: Peter Meerwald @ 2014-01-13 21:28 UTC (permalink / raw)
To: linux-iio; +Cc: Peter Meerwald
differantiate between channels with_temp and without
Signed-off-by: Peter Meerwald <pmeerw@pmeerw.net>
---
drivers/staging/iio/accel/sca3000_core.c | 125 ++++++++++++-------------------
1 file changed, 48 insertions(+), 77 deletions(-)
diff --git a/drivers/staging/iio/accel/sca3000_core.c b/drivers/staging/iio/accel/sca3000_core.c
index 0123bc0..ed30e32 100644
--- a/drivers/staging/iio/accel/sca3000_core.c
+++ b/drivers/staging/iio/accel/sca3000_core.c
@@ -450,6 +450,18 @@ static const struct iio_chan_spec sca3000_channels[] = {
SCA3000_CHAN(2, IIO_MOD_Z),
};
+static const struct iio_chan_spec sca3000_channels_with_temp[] = {
+ SCA3000_CHAN(0, IIO_MOD_X),
+ SCA3000_CHAN(1, IIO_MOD_Y),
+ SCA3000_CHAN(2, IIO_MOD_Z),
+ {
+ .type = IIO_TEMP,
+ .info_mask_separate = BIT(IIO_CHAN_INFO_RAW),
+ .info_mask_shared_by_type = BIT(IIO_CHAN_INFO_SCALE) |
+ BIT(IIO_CHAN_INFO_OFFSET),
+ },
+};
+
static u8 sca3000_addresses[3][3] = {
[0] = {SCA3000_REG_ADDR_X_MSB, SCA3000_REG_CTRL_SEL_MD_X_TH,
SCA3000_MD_CTRL_OR_X},
@@ -472,19 +484,30 @@ static int sca3000_read_raw(struct iio_dev *indio_dev,
switch (mask) {
case IIO_CHAN_INFO_RAW:
mutex_lock(&st->lock);
- if (st->mo_det_use_count) {
- mutex_unlock(&st->lock);
- return -EBUSY;
- }
- address = sca3000_addresses[chan->address][0];
- ret = sca3000_read_data_short(st, address, 2);
- if (ret < 0) {
- mutex_unlock(&st->lock);
- return ret;
+ if (chan->type == IIO_ACCEL) {
+ if (st->mo_det_use_count) {
+ mutex_unlock(&st->lock);
+ return -EBUSY;
+ }
+ address = sca3000_addresses[chan->address][0];
+ ret = sca3000_read_data_short(st, address, 2);
+ if (ret < 0) {
+ mutex_unlock(&st->lock);
+ return ret;
+ }
+ *val = (be16_to_cpup((__be16 *)st->rx) >> 3) & 0x1FFF;
+ *val = ((*val) << (sizeof(*val)*8 - 13)) >>
+ (sizeof(*val)*8 - 13);
+ } else {
+ /* get the temperature when available */
+ ret = sca3000_read_data_short(st,
+ SCA3000_REG_ADDR_TEMP_MSB, 2);
+ if (ret < 0) {
+ mutex_unlock(&st->lock);
+ return ret;
+ }
+ *val = ((st->rx[0] & 0x3F) << 3) | ((st->rx[1] & 0xE0) >> 5);
}
- *val = (be16_to_cpup((__be16 *)st->rx) >> 3) & 0x1FFF;
- *val = ((*val) << (sizeof(*val)*8 - 13)) >>
- (sizeof(*val)*8 - 13);
mutex_unlock(&st->lock);
return IIO_VAL_INT;
case IIO_CHAN_INFO_SCALE:
@@ -494,6 +517,10 @@ static int sca3000_read_raw(struct iio_dev *indio_dev,
else /* temperature */
*val2 = 555556;
return IIO_VAL_INT_PLUS_MICRO;
+ case IIO_CHAN_INFO_OFFSET:
+ *val = -214;
+ *val2 = 600000;
+ return IIO_VAL_INT_PLUS_MICRO;
default:
return -EINVAL;
}
@@ -673,37 +700,6 @@ static IIO_DEV_ATTR_SAMP_FREQ(S_IWUSR | S_IRUGO,
sca3000_read_frequency,
sca3000_set_frequency);
-
-/**
- * sca3000_read_temp() sysfs interface to get the temperature when available
- *
- * The alignment of data in here is downright odd. See data sheet.
- * Converting this into a meaningful value is left to inline functions in
- * userspace part of header.
- **/
-static ssize_t sca3000_read_temp(struct device *dev,
- struct device_attribute *attr,
- char *buf)
-{
- struct iio_dev *indio_dev = dev_to_iio_dev(dev);
- struct sca3000_state *st = iio_priv(indio_dev);
- int ret;
- int val;
- ret = sca3000_read_data_short(st, SCA3000_REG_ADDR_TEMP_MSB, 2);
- if (ret < 0)
- goto error_ret;
- val = ((st->rx[0] & 0x3F) << 3) | ((st->rx[1] & 0xE0) >> 5);
-
- return sprintf(buf, "%d\n", val);
-
-error_ret:
- return ret;
-}
-static IIO_DEV_ATTR_TEMP_RAW(sca3000_read_temp);
-
-static IIO_CONST_ATTR_TEMP_SCALE("0.555556");
-static IIO_CONST_ATTR_TEMP_OFFSET("-214.6");
-
/**
* sca3000_read_thresh() - query of a threshold
**/
@@ -783,27 +779,10 @@ static struct attribute *sca3000_attributes[] = {
NULL,
};
-static struct attribute *sca3000_attributes_with_temp[] = {
- &iio_dev_attr_revision.dev_attr.attr,
- &iio_dev_attr_measurement_mode_available.dev_attr.attr,
- &iio_dev_attr_measurement_mode.dev_attr.attr,
- &iio_dev_attr_sampling_frequency_available.dev_attr.attr,
- &iio_dev_attr_sampling_frequency.dev_attr.attr,
- /* Only present if temp sensor is */
- &iio_dev_attr_in_temp_raw.dev_attr.attr,
- &iio_const_attr_in_temp_offset.dev_attr.attr,
- &iio_const_attr_in_temp_scale.dev_attr.attr,
- NULL,
-};
-
static const struct attribute_group sca3000_attribute_group = {
.attrs = sca3000_attributes,
};
-static const struct attribute_group sca3000_attribute_group_with_temp = {
- .attrs = sca3000_attributes_with_temp,
-};
-
/**
* sca3000_event_handler() - handling ring and non ring events
*
@@ -1138,17 +1117,6 @@ static const struct iio_info sca3000_info = {
.driver_module = THIS_MODULE,
};
-static const struct iio_info sca3000_info_with_temp = {
- .attrs = &sca3000_attribute_group_with_temp,
- .read_raw = &sca3000_read_raw,
- .event_attrs = &sca3000_event_attribute_group,
- .read_event_value = &sca3000_read_thresh,
- .write_event_value = &sca3000_write_thresh,
- .read_event_config = &sca3000_read_event_config,
- .write_event_config = &sca3000_write_event_config,
- .driver_module = THIS_MODULE,
-};
-
static int sca3000_probe(struct spi_device *spi)
{
int ret;
@@ -1168,12 +1136,15 @@ static int sca3000_probe(struct spi_device *spi)
indio_dev->dev.parent = &spi->dev;
indio_dev->name = spi_get_device_id(spi)->name;
- if (st->info->temp_output)
- indio_dev->info = &sca3000_info_with_temp;
- else
- indio_dev->info = &sca3000_info;
- indio_dev->channels = sca3000_channels;
- indio_dev->num_channels = ARRAY_SIZE(sca3000_channels);
+ indio_dev->info = &sca3000_info;
+ if (st->info->temp_output) {
+ indio_dev->channels = sca3000_channels_with_temp;
+ indio_dev->num_channels =
+ ARRAY_SIZE(sca3000_channels_with_temp);
+ } else {
+ indio_dev->channels = sca3000_channels;
+ indio_dev->num_channels = ARRAY_SIZE(sca3000_channels);
+ }
indio_dev->modes = INDIO_DIRECT_MODE;
sca3000_configure_ring(indio_dev);
--
1.8.3.2
^ permalink raw reply related [flat|nested] 9+ messages in thread
* [PATCH 6/6] staging:iio:accel:sca3000: Cleanup sca3000.h
2014-01-13 21:28 [PATCH 2/6] staging:iio:accel:sca3000: Fix format of comments Peter Meerwald
` (2 preceding siblings ...)
2014-01-13 21:28 ` [PATCH 5/6] staging:iio:accel:sca3000: Move temperature attribute to channels Peter Meerwald
@ 2014-01-13 21:28 ` Peter Meerwald
2014-01-18 11:12 ` Jonathan Cameron
2014-01-18 11:07 ` [PATCH 2/6] staging:iio:accel:sca3000: Fix format of comments Jonathan Cameron
4 siblings, 1 reply; 9+ messages in thread
From: Peter Meerwald @ 2014-01-13 21:28 UTC (permalink / raw)
To: linux-iio; +Cc: Peter Meerwald
kerneldoc and comment formating, typos
Signed-off-by: Peter Meerwald <pmeerw@pmeerw.net>
---
drivers/staging/iio/accel/sca3000.h | 26 ++++++++++++++++----------
1 file changed, 16 insertions(+), 10 deletions(-)
diff --git a/drivers/staging/iio/accel/sca3000.h b/drivers/staging/iio/accel/sca3000.h
index c1016c5..b284e5a 100644
--- a/drivers/staging/iio/accel/sca3000.h
+++ b/drivers/staging/iio/accel/sca3000.h
@@ -65,7 +65,8 @@
#define SCA3000_RING_BUF_ENABLE 0x80
#define SCA3000_RING_BUF_8BIT 0x40
-/* Free fall detection triggers an interrupt if the acceleration
+/*
+ * Free fall detection triggers an interrupt if the acceleration
* is below a threshold for equivalent of 25cm drop
*/
#define SCA3000_FREE_FALL_DETECT 0x10
@@ -73,8 +74,9 @@
#define SCA3000_MEAS_MODE_OP_1 0x01
#define SCA3000_MEAS_MODE_OP_2 0x02
-/* In motion detection mode the accelerations are band pass filtered
- * (aprox 1 - 25Hz) and then a programmable threshold used to trigger
+/*
+ * In motion detection mode the accelerations are band pass filtered
+ * (approx 1 - 25Hz) and then a programmable threshold used to trigger
* and interrupt.
*/
#define SCA3000_MEAS_MODE_MOT_DET 0x03
@@ -99,8 +101,10 @@
#define SCA3000_REG_CTRL_SEL_MD_Y_TH 0x03
#define SCA3000_REG_CTRL_SEL_MD_X_TH 0x04
#define SCA3000_REG_CTRL_SEL_MD_Z_TH 0x05
-/* BE VERY CAREFUL WITH THIS, IF 3 BITS ARE NOT SET the device
- will not function */
+/*
+ * BE VERY CAREFUL WITH THIS, IF 3 BITS ARE NOT SET the device
+ * will not function
+ */
#define SCA3000_REG_CTRL_SEL_OUT_CTRL 0x0B
#define SCA3000_OUT_CTRL_PROT_MASK 0xE0
#define SCA3000_OUT_CTRL_BUF_X_EN 0x10
@@ -109,8 +113,9 @@
#define SCA3000_OUT_CTRL_BUF_DIV_4 0x02
#define SCA3000_OUT_CTRL_BUF_DIV_2 0x01
-/* Control which motion detector interrupts are on.
- * For now only OR combinations are supported.x
+/*
+ * Control which motion detector interrupts are on.
+ * For now only OR combinations are supported.
*/
#define SCA3000_MD_CTRL_PROT_MASK 0xC0
#define SCA3000_MD_CTRL_OR_Y 0x01
@@ -121,7 +126,8 @@
#define SCA3000_MD_CTRL_AND_X 0x10
#define SAC3000_MD_CTRL_AND_Z 0x20
-/* Some control registers of complex access methods requiring this register to
+/*
+ * Some control registers of complex access methods requiring this register to
* be used to remove a lock.
*/
#define SCA3000_REG_ADDR_UNLOCK 0x1e
@@ -139,7 +145,8 @@
/* Values of multiplexed registers (write to ctrl_data after select) */
#define SCA3000_REG_ADDR_CTRL_DATA 0x22
-/* Measurement modes available on some sca3000 series chips. Code assumes others
+/*
+ * Measurement modes available on some sca3000 series chips. Code assumes others
* may become available in the future.
*
* Bypass - Bypass the low-pass filter in the signal channel so as to increase
@@ -160,7 +167,6 @@
* struct sca3000_state - device instance state information
* @us: the associated spi device
* @info: chip variant information
- * @indio_dev: device information used by the IIO core
* @interrupt_handler_ws: event interrupt handler for all events
* @last_timestamp: the timestamp of the last event
* @mo_det_use_count: reference counter for the motion detection unit
--
1.8.3.2
^ permalink raw reply related [flat|nested] 9+ messages in thread
* Re: [PATCH 2/6] staging:iio:accel:sca3000: Fix format of comments
2014-01-13 21:28 [PATCH 2/6] staging:iio:accel:sca3000: Fix format of comments Peter Meerwald
` (3 preceding siblings ...)
2014-01-13 21:28 ` [PATCH 6/6] staging:iio:accel:sca3000: Cleanup sca3000.h Peter Meerwald
@ 2014-01-18 11:07 ` Jonathan Cameron
4 siblings, 0 replies; 9+ messages in thread
From: Jonathan Cameron @ 2014-01-18 11:07 UTC (permalink / raw)
To: Peter Meerwald, linux-iio
On 13/01/14 21:28, Peter Meerwald wrote:
> Signed-off-by: Peter Meerwald <pmeerw@pmeerw.net>
Applied to the togreg branch of iio.git
Thanks,
> ---
> drivers/staging/iio/accel/sca3000_core.c | 52 ++++++++++++++++++--------------
> 1 file changed, 29 insertions(+), 23 deletions(-)
>
> diff --git a/drivers/staging/iio/accel/sca3000_core.c b/drivers/staging/iio/accel/sca3000_core.c
> index 908d5cd..b627d8f 100644
> --- a/drivers/staging/iio/accel/sca3000_core.c
> +++ b/drivers/staging/iio/accel/sca3000_core.c
> @@ -32,7 +32,8 @@ enum sca3000_variant {
> e05,
> };
>
> -/* Note where option modes are not defined, the chip simply does not
> +/*
> + * Note where option modes are not defined, the chip simply does not
> * support any.
> * Other chips in the sca3000 series use i2c and are not included here.
> *
> @@ -191,7 +192,6 @@ error_ret:
> return ret;
> }
>
> -/* Crucial that lock is called before calling this */
> /**
> * sca3000_read_ctrl_reg() read from lock protected control register.
> *
> @@ -402,7 +402,8 @@ error_ret:
> }
>
>
> -/* Not even vaguely standard attributes so defined here rather than
> +/*
> + * Not even vaguely standard attributes so defined here rather than
> * in the relevant IIO core headers
> */
> static IIO_DEVICE_ATTR(measurement_mode_available, S_IRUGO,
> @@ -662,7 +663,8 @@ error_free_lock:
> return ret ? ret : len;
> }
>
> -/* Should only really be registered if ring buffer support is compiled in.
> +/*
> + * Should only really be registered if ring buffer support is compiled in.
> * Does no harm however and doing it right would add a fair bit of complexity
> */
> static IIO_DEV_ATTR_SAMP_FREQ_AVAIL(sca3000_read_av_freq);
> @@ -675,10 +677,10 @@ static IIO_DEV_ATTR_SAMP_FREQ(S_IWUSR | S_IRUGO,
> /**
> * sca3000_read_temp() sysfs interface to get the temperature when available
> *
> -* The alignment of data in here is downright odd. See data sheet.
> -* Converting this into a meaningful value is left to inline functions in
> -* userspace part of header.
> -**/
> + * The alignment of data in here is downright odd. See data sheet.
> + * Converting this into a meaningful value is left to inline functions in
> + * userspace part of header.
> + **/
> static ssize_t sca3000_read_temp(struct device *dev,
> struct device_attribute *attr,
> char *buf)
> @@ -802,12 +804,12 @@ static const struct attribute_group sca3000_attribute_group_with_temp = {
> .attrs = sca3000_attributes_with_temp,
> };
>
> -/* RING RELATED interrupt handler */
> -/* depending on event, push to the ring buffer event chrdev or the event one */
> -
> /**
> * sca3000_event_handler() - handling ring and non ring events
> *
> + * Ring related interrupt handler. Depending on event, push to
> + * the ring buffer event chrdev or the event one.
> + *
> * This function is complicated by the fact that the devices can signify ring
> * and non ring events via the same interrupt line and they can only
> * be distinguished via a read of the relevant status register.
> @@ -819,7 +821,8 @@ static irqreturn_t sca3000_event_handler(int irq, void *private)
> int ret, val;
> s64 last_timestamp = iio_get_time_ns();
>
> - /* Could lead if badly timed to an extra read of status reg,
> + /*
> + * Could lead if badly timed to an extra read of status reg,
> * but ensures no interrupt is missed.
> */
> mutex_lock(&st->lock);
> @@ -934,7 +937,6 @@ static ssize_t sca3000_query_free_fall_mode(struct device *dev,
> * the device falls more than 25cm. This has not been tested due
> * to fragile wiring.
> **/
> -
> static ssize_t sca3000_set_free_fall_mode(struct device *dev,
> struct device_attribute *attr,
> const char *buf,
> @@ -956,7 +958,7 @@ static ssize_t sca3000_set_free_fall_mode(struct device *dev,
> if (ret)
> goto error_ret;
>
> - /*if off and should be on*/
> + /* if off and should be on */
> if (val && !(st->rx[0] & protect_mask))
> ret = sca3000_write_reg(st, SCA3000_REG_ADDR_MODE,
> (st->rx[0] | SCA3000_FREE_FALL_DETECT));
> @@ -991,13 +993,15 @@ static int sca3000_write_event_config(struct iio_dev *indio_dev,
> int num = chan->channel2;
>
> mutex_lock(&st->lock);
> - /* First read the motion detector config to find out if
> - * this axis is on*/
> + /*
> + * First read the motion detector config to find out if
> + * this axis is on
> + */
> ret = sca3000_read_ctrl_reg(st, SCA3000_REG_CTRL_SEL_MD_CTRL);
> if (ret < 0)
> goto exit_point;
> ctrlval = ret;
> - /* Off and should be on */
> + /* if off and should be on */
> if (state && !(ctrlval & sca3000_addresses[num][2])) {
> ret = sca3000_write_ctrl_reg(st,
> SCA3000_REG_CTRL_SEL_MD_CTRL,
> @@ -1020,7 +1024,7 @@ static int sca3000_write_event_config(struct iio_dev *indio_dev,
> ret = sca3000_read_data_short(st, SCA3000_REG_ADDR_MODE, 1);
> if (ret)
> goto exit_point;
> - /*if off and should be on*/
> + /* if off and should be on */
> if ((st->mo_det_use_count)
> && ((st->rx[0] & protect_mask) != SCA3000_MEAS_MODE_MOT_DET))
> ret = sca3000_write_reg(st, SCA3000_REG_ADDR_MODE,
> @@ -1066,7 +1070,7 @@ static struct attribute_group sca3000_event_attribute_group = {
> * Devices use flash memory to store many of the register values
> * and hence can come up in somewhat unpredictable states.
> * Hence reset everything on driver load.
> - **/
> + **/
> static int sca3000_clean_setup(struct sca3000_state *st)
> {
> int ret;
> @@ -1106,9 +1110,11 @@ static int sca3000_clean_setup(struct sca3000_state *st)
> | SCA3000_INT_MASK_ACTIVE_LOW);
> if (ret)
> goto error_ret;
> - /* Select normal measurement mode, free fall off, ring off */
> - /* Ring in 12 bit mode - it is fine to overwrite reserved bits 3,5
> - * as that occurs in one of the example on the datasheet */
> + /*
> + * Select normal measurement mode, free fall off, ring off
> + * Ring in 12 bit mode - it is fine to overwrite reserved bits 3,5
> + * as that occurs in one of the example on the datasheet
> + */
> ret = sca3000_read_data_short(st, SCA3000_REG_ADDR_MODE, 1);
> if (ret)
> goto error_ret;
> @@ -1235,7 +1241,7 @@ static int sca3000_remove(struct spi_device *spi)
> struct iio_dev *indio_dev = spi_get_drvdata(spi);
> struct sca3000_state *st = iio_priv(indio_dev);
>
> - /* Must ensure no interrupts can be generated after this!*/
> + /* Must ensure no interrupts can be generated after this! */
> sca3000_stop_all_interrupts(st);
> if (spi->irq)
> free_irq(spi->irq, indio_dev);
>
^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: [PATCH 3/6] staging:iio:accel:sca3000: Event_attribute_group seems to be missing for _info_with_temp
2014-01-13 21:28 ` [PATCH 3/6] staging:iio:accel:sca3000: Event_attribute_group seems to be missing for _info_with_temp Peter Meerwald
@ 2014-01-18 11:08 ` Jonathan Cameron
0 siblings, 0 replies; 9+ messages in thread
From: Jonathan Cameron @ 2014-01-18 11:08 UTC (permalink / raw)
To: Peter Meerwald, linux-iio
On 13/01/14 21:28, Peter Meerwald wrote:
> issue introduced here 6fe8135f:
> staging:iio: implement an iio_info structure to take some of the constant elements out of iio_dev
>
> Signed-off-by: Peter Meerwald <pmeerw@pmeerw.net>
Applied to the togreg branch of iio.git.
Clearly we could have pushed this out as a fix, but given no one has commented on it and
the amount of other stuff you are cleaning up in the driver, I don't think it is terribly
urgent. Hence can go through the slow route...
Jonathan
> ---
> drivers/staging/iio/accel/sca3000_core.c | 1 +
> 1 file changed, 1 insertion(+)
>
> diff --git a/drivers/staging/iio/accel/sca3000_core.c b/drivers/staging/iio/accel/sca3000_core.c
> index b627d8f..159272e 100644
> --- a/drivers/staging/iio/accel/sca3000_core.c
> +++ b/drivers/staging/iio/accel/sca3000_core.c
> @@ -1141,6 +1141,7 @@ static const struct iio_info sca3000_info = {
> static const struct iio_info sca3000_info_with_temp = {
> .attrs = &sca3000_attribute_group_with_temp,
> .read_raw = &sca3000_read_raw,
> + .event_attrs = &sca3000_event_attribute_group,
> .read_event_value = &sca3000_read_thresh,
> .write_event_value = &sca3000_write_thresh,
> .read_event_config = &sca3000_read_event_config,
>
^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: [PATCH 4/6] staging:iio:accel:sca3000: Channels missing in temp_output case
2014-01-13 21:28 ` [PATCH 4/6] staging:iio:accel:sca3000: Channels missing in temp_output case Peter Meerwald
@ 2014-01-18 11:09 ` Jonathan Cameron
0 siblings, 0 replies; 9+ messages in thread
From: Jonathan Cameron @ 2014-01-18 11:09 UTC (permalink / raw)
To: Peter Meerwald, linux-iio
On 13/01/14 21:28, Peter Meerwald wrote:
> issues introduced here 25888dc5,
> staging:iio:sca3000 extract old event handling and move to poll for events
>
Ouch
> Signed-off-by: Peter Meerwald <pmeerw@pmeerw.net>
Applied to the togreg branch of iio.git
> ---
> drivers/staging/iio/accel/sca3000_core.c | 7 +++----
> 1 file changed, 3 insertions(+), 4 deletions(-)
>
> diff --git a/drivers/staging/iio/accel/sca3000_core.c b/drivers/staging/iio/accel/sca3000_core.c
> index 159272e..0123bc0 100644
> --- a/drivers/staging/iio/accel/sca3000_core.c
> +++ b/drivers/staging/iio/accel/sca3000_core.c
> @@ -1170,11 +1170,10 @@ static int sca3000_probe(struct spi_device *spi)
> indio_dev->name = spi_get_device_id(spi)->name;
> if (st->info->temp_output)
> indio_dev->info = &sca3000_info_with_temp;
> - else {
> + else
> indio_dev->info = &sca3000_info;
> - indio_dev->channels = sca3000_channels;
> - indio_dev->num_channels = ARRAY_SIZE(sca3000_channels);
> - }
> + indio_dev->channels = sca3000_channels;
> + indio_dev->num_channels = ARRAY_SIZE(sca3000_channels);
> indio_dev->modes = INDIO_DIRECT_MODE;
>
> sca3000_configure_ring(indio_dev);
>
^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: [PATCH 6/6] staging:iio:accel:sca3000: Cleanup sca3000.h
2014-01-13 21:28 ` [PATCH 6/6] staging:iio:accel:sca3000: Cleanup sca3000.h Peter Meerwald
@ 2014-01-18 11:12 ` Jonathan Cameron
0 siblings, 0 replies; 9+ messages in thread
From: Jonathan Cameron @ 2014-01-18 11:12 UTC (permalink / raw)
To: Peter Meerwald, linux-iio
On 13/01/14 21:28, Peter Meerwald wrote:
> kerneldoc and comment formating, typos
>
> Signed-off-by: Peter Meerwald <pmeerw@pmeerw.net>
Applied to the togreg branch of iio.git.
Thanks for cleaning this up. I've been feeling a bit guilty about the state
of this driver for some time but never quite gotten round to fixing it!
Jonathan
> ---
> drivers/staging/iio/accel/sca3000.h | 26 ++++++++++++++++----------
> 1 file changed, 16 insertions(+), 10 deletions(-)
>
> diff --git a/drivers/staging/iio/accel/sca3000.h b/drivers/staging/iio/accel/sca3000.h
> index c1016c5..b284e5a 100644
> --- a/drivers/staging/iio/accel/sca3000.h
> +++ b/drivers/staging/iio/accel/sca3000.h
> @@ -65,7 +65,8 @@
>
> #define SCA3000_RING_BUF_ENABLE 0x80
> #define SCA3000_RING_BUF_8BIT 0x40
> -/* Free fall detection triggers an interrupt if the acceleration
> +/*
> + * Free fall detection triggers an interrupt if the acceleration
> * is below a threshold for equivalent of 25cm drop
> */
> #define SCA3000_FREE_FALL_DETECT 0x10
> @@ -73,8 +74,9 @@
> #define SCA3000_MEAS_MODE_OP_1 0x01
> #define SCA3000_MEAS_MODE_OP_2 0x02
>
> -/* In motion detection mode the accelerations are band pass filtered
> - * (aprox 1 - 25Hz) and then a programmable threshold used to trigger
> +/*
> + * In motion detection mode the accelerations are band pass filtered
> + * (approx 1 - 25Hz) and then a programmable threshold used to trigger
> * and interrupt.
> */
> #define SCA3000_MEAS_MODE_MOT_DET 0x03
> @@ -99,8 +101,10 @@
> #define SCA3000_REG_CTRL_SEL_MD_Y_TH 0x03
> #define SCA3000_REG_CTRL_SEL_MD_X_TH 0x04
> #define SCA3000_REG_CTRL_SEL_MD_Z_TH 0x05
> -/* BE VERY CAREFUL WITH THIS, IF 3 BITS ARE NOT SET the device
> - will not function */
> +/*
> + * BE VERY CAREFUL WITH THIS, IF 3 BITS ARE NOT SET the device
> + * will not function
> + */
> #define SCA3000_REG_CTRL_SEL_OUT_CTRL 0x0B
> #define SCA3000_OUT_CTRL_PROT_MASK 0xE0
> #define SCA3000_OUT_CTRL_BUF_X_EN 0x10
> @@ -109,8 +113,9 @@
> #define SCA3000_OUT_CTRL_BUF_DIV_4 0x02
> #define SCA3000_OUT_CTRL_BUF_DIV_2 0x01
>
> -/* Control which motion detector interrupts are on.
> - * For now only OR combinations are supported.x
> +/*
> + * Control which motion detector interrupts are on.
> + * For now only OR combinations are supported.
> */
> #define SCA3000_MD_CTRL_PROT_MASK 0xC0
> #define SCA3000_MD_CTRL_OR_Y 0x01
> @@ -121,7 +126,8 @@
> #define SCA3000_MD_CTRL_AND_X 0x10
> #define SAC3000_MD_CTRL_AND_Z 0x20
>
> -/* Some control registers of complex access methods requiring this register to
> +/*
> + * Some control registers of complex access methods requiring this register to
> * be used to remove a lock.
> */
> #define SCA3000_REG_ADDR_UNLOCK 0x1e
> @@ -139,7 +145,8 @@
> /* Values of multiplexed registers (write to ctrl_data after select) */
> #define SCA3000_REG_ADDR_CTRL_DATA 0x22
>
> -/* Measurement modes available on some sca3000 series chips. Code assumes others
> +/*
> + * Measurement modes available on some sca3000 series chips. Code assumes others
> * may become available in the future.
> *
> * Bypass - Bypass the low-pass filter in the signal channel so as to increase
> @@ -160,7 +167,6 @@
> * struct sca3000_state - device instance state information
> * @us: the associated spi device
> * @info: chip variant information
> - * @indio_dev: device information used by the IIO core
> * @interrupt_handler_ws: event interrupt handler for all events
> * @last_timestamp: the timestamp of the last event
> * @mo_det_use_count: reference counter for the motion detection unit
>
^ permalink raw reply [flat|nested] 9+ messages in thread
end of thread, other threads:[~2014-01-18 11:12 UTC | newest]
Thread overview: 9+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2014-01-13 21:28 [PATCH 2/6] staging:iio:accel:sca3000: Fix format of comments Peter Meerwald
2014-01-13 21:28 ` [PATCH 3/6] staging:iio:accel:sca3000: Event_attribute_group seems to be missing for _info_with_temp Peter Meerwald
2014-01-18 11:08 ` Jonathan Cameron
2014-01-13 21:28 ` [PATCH 4/6] staging:iio:accel:sca3000: Channels missing in temp_output case Peter Meerwald
2014-01-18 11:09 ` Jonathan Cameron
2014-01-13 21:28 ` [PATCH 5/6] staging:iio:accel:sca3000: Move temperature attribute to channels Peter Meerwald
2014-01-13 21:28 ` [PATCH 6/6] staging:iio:accel:sca3000: Cleanup sca3000.h Peter Meerwald
2014-01-18 11:12 ` Jonathan Cameron
2014-01-18 11:07 ` [PATCH 2/6] staging:iio:accel:sca3000: Fix format of comments Jonathan Cameron
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).