Merge tag 'iio-fixes-for-3.14b' of git://git.kernel.org/pub/scm/linux/kernel/git...
authorGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Sat, 8 Feb 2014 21:29:18 +0000 (13:29 -0800)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Sat, 8 Feb 2014 21:29:18 +0000 (13:29 -0800)
Jonathan writes:

Second round of IIO fixes for the 3.14 cycle.

Another mixed bag, including some that were not in round 1 because
they applied to elements that went in during the merge window whereas
round 1 predated that.  I have been effectively out of action for 3 weeks
so will take a little while to catch up with my backlog.

* mag3110 - report busy in read_raw / write_raw when buffered capture
  is underway to avoid either changing the characteristics of the capture or
  causing capture issues by reading data destined for the buffer.
* mag3110 - fix a failure to specify leading zeros when formatting a decimal
  number.
* lradc - fix a buffer overflow and incorrect reporting of scale for voltage
  channel 15
* lradc - drop some scale_available attributes for elements that don't actually
  exist.  These could otherwise cause some interesting issues for userspace.
* ad799x - a typo in the events information mask resulted in some nasty crashes
  on failed probes.
* ak8975 - fix scale attribute output to avoid incorrect intepretation of
  readings in userspace.
* adis16400 - make sure the timestamp is the last element in all channel_spec
  arrays as this assumption is made by the buffer filling code, but was not
  true previously.
* bma180 - correctly use modifiers to distinguish the channels rather than
  indexes.  This brings the abi inline with the standard option for 3 axis
  accelerometers.
* max1363 - use devm_regulator_get_optional instead of the non optional case
  to allow the device to successfully probe when a regulator is not specified.

drivers/iio/accel/bma180.c
drivers/iio/adc/max1363.c
drivers/iio/imu/adis16400.h
drivers/iio/imu/adis16400_core.c
drivers/iio/magnetometer/ak8975.c
drivers/iio/magnetometer/mag3110.c
drivers/staging/iio/adc/ad799x_core.c
drivers/staging/iio/adc/mxs-lradc.c

index 3bec922..bfec313 100644 (file)
@@ -447,14 +447,14 @@ static const struct iio_chan_spec_ext_info bma180_ext_info[] = {
        { },
 };
 
-#define BMA180_CHANNEL(_index) {                                       \
+#define BMA180_CHANNEL(_axis) {                                        \
        .type = IIO_ACCEL,                                              \
-       .indexed = 1,                                                   \
-       .channel = (_index),                                            \
+       .modified = 1,                                                  \
+       .channel2 = IIO_MOD_##_axis,                                    \
        .info_mask_separate = BIT(IIO_CHAN_INFO_RAW) |                  \
                BIT(IIO_CHAN_INFO_LOW_PASS_FILTER_3DB_FREQUENCY),       \
        .info_mask_shared_by_type = BIT(IIO_CHAN_INFO_SCALE),           \
-       .scan_index = (_index),                                         \
+       .scan_index = AXIS_##_axis,                                     \
        .scan_type = {                                                  \
                .sign = 's',                                            \
                .realbits = 14,                                         \
@@ -465,10 +465,10 @@ static const struct iio_chan_spec_ext_info bma180_ext_info[] = {
 }
 
 static const struct iio_chan_spec bma180_channels[] = {
-       BMA180_CHANNEL(AXIS_X),
-       BMA180_CHANNEL(AXIS_Y),
-       BMA180_CHANNEL(AXIS_Z),
-       IIO_CHAN_SOFT_TIMESTAMP(4),
+       BMA180_CHANNEL(X),
+       BMA180_CHANNEL(Y),
+       BMA180_CHANNEL(Z),
+       IIO_CHAN_SOFT_TIMESTAMP(3),
 };
 
 static irqreturn_t bma180_trigger_handler(int irq, void *p)
index e283f2f..3602592 100644 (file)
@@ -1560,7 +1560,7 @@ static int max1363_probe(struct i2c_client *client,
        st->client = client;
 
        st->vref_uv = st->chip_info->int_vref_mv * 1000;
-       vref = devm_regulator_get(&client->dev, "vref");
+       vref = devm_regulator_get_optional(&client->dev, "vref");
        if (!IS_ERR(vref)) {
                int vref_uv;
 
index 2f8f9d6..0916bf6 100644 (file)
@@ -189,6 +189,7 @@ enum {
        ADIS16300_SCAN_INCLI_X,
        ADIS16300_SCAN_INCLI_Y,
        ADIS16400_SCAN_ADC,
+       ADIS16400_SCAN_TIMESTAMP,
 };
 
 #ifdef CONFIG_IIO_BUFFER
index 368660d..7c582f7 100644 (file)
@@ -632,7 +632,7 @@ static const struct iio_chan_spec adis16400_channels[] = {
        ADIS16400_MAGN_CHAN(Z, ADIS16400_ZMAGN_OUT, 14),
        ADIS16400_TEMP_CHAN(ADIS16400_TEMP_OUT, 12),
        ADIS16400_AUX_ADC_CHAN(ADIS16400_AUX_ADC, 12),
-       IIO_CHAN_SOFT_TIMESTAMP(12)
+       IIO_CHAN_SOFT_TIMESTAMP(ADIS16400_SCAN_TIMESTAMP),
 };
 
 static const struct iio_chan_spec adis16448_channels[] = {
@@ -659,7 +659,7 @@ static const struct iio_chan_spec adis16448_channels[] = {
                },
        },
        ADIS16400_TEMP_CHAN(ADIS16448_TEMP_OUT, 12),
-       IIO_CHAN_SOFT_TIMESTAMP(11)
+       IIO_CHAN_SOFT_TIMESTAMP(ADIS16400_SCAN_TIMESTAMP),
 };
 
 static const struct iio_chan_spec adis16350_channels[] = {
@@ -677,7 +677,7 @@ static const struct iio_chan_spec adis16350_channels[] = {
        ADIS16400_MOD_TEMP_CHAN(X, ADIS16350_XTEMP_OUT, 12),
        ADIS16400_MOD_TEMP_CHAN(Y, ADIS16350_YTEMP_OUT, 12),
        ADIS16400_MOD_TEMP_CHAN(Z, ADIS16350_ZTEMP_OUT, 12),
-       IIO_CHAN_SOFT_TIMESTAMP(11)
+       IIO_CHAN_SOFT_TIMESTAMP(ADIS16400_SCAN_TIMESTAMP),
 };
 
 static const struct iio_chan_spec adis16300_channels[] = {
@@ -690,7 +690,7 @@ static const struct iio_chan_spec adis16300_channels[] = {
        ADIS16400_AUX_ADC_CHAN(ADIS16300_AUX_ADC, 12),
        ADIS16400_INCLI_CHAN(X, ADIS16300_PITCH_OUT, 13),
        ADIS16400_INCLI_CHAN(Y, ADIS16300_ROLL_OUT, 13),
-       IIO_CHAN_SOFT_TIMESTAMP(14)
+       IIO_CHAN_SOFT_TIMESTAMP(ADIS16400_SCAN_TIMESTAMP),
 };
 
 static const struct iio_chan_spec adis16334_channels[] = {
@@ -701,7 +701,7 @@ static const struct iio_chan_spec adis16334_channels[] = {
        ADIS16400_ACCEL_CHAN(Y, ADIS16400_YACCL_OUT, 14),
        ADIS16400_ACCEL_CHAN(Z, ADIS16400_ZACCL_OUT, 14),
        ADIS16400_TEMP_CHAN(ADIS16350_XTEMP_OUT, 12),
-       IIO_CHAN_SOFT_TIMESTAMP(8)
+       IIO_CHAN_SOFT_TIMESTAMP(ADIS16400_SCAN_TIMESTAMP),
 };
 
 static struct attribute *adis16400_attributes[] = {
index ff284e5..0542354 100644 (file)
@@ -85,6 +85,7 @@
 #define AK8975_MAX_CONVERSION_TIMEOUT  500
 #define AK8975_CONVERSION_DONE_POLL_TIME 10
 #define AK8975_DATA_READY_TIMEOUT      ((100*HZ)/1000)
+#define RAW_TO_GAUSS(asa) ((((asa) + 128) * 3000) / 256)
 
 /*
  * Per-instance context data for the device.
@@ -265,15 +266,15 @@ static int ak8975_setup(struct i2c_client *client)
  *
  * Since 1uT = 0.01 gauss, our final scale factor becomes:
  *
- * Hadj = H * ((ASA + 128) / 256) * 3/10 * 100
- * Hadj = H * ((ASA + 128) * 30 / 256
+ * Hadj = H * ((ASA + 128) / 256) * 3/10 * 1/100
+ * Hadj = H * ((ASA + 128) * 0.003) / 256
  *
  * Since ASA doesn't change, we cache the resultant scale factor into the
  * device context in ak8975_setup().
  */
-       data->raw_to_gauss[0] = ((data->asa[0] + 128) * 30) >> 8;
-       data->raw_to_gauss[1] = ((data->asa[1] + 128) * 30) >> 8;
-       data->raw_to_gauss[2] = ((data->asa[2] + 128) * 30) >> 8;
+       data->raw_to_gauss[0] = RAW_TO_GAUSS(data->asa[0]);
+       data->raw_to_gauss[1] = RAW_TO_GAUSS(data->asa[1]);
+       data->raw_to_gauss[2] = RAW_TO_GAUSS(data->asa[2]);
 
        return 0;
 }
@@ -428,8 +429,9 @@ static int ak8975_read_raw(struct iio_dev *indio_dev,
        case IIO_CHAN_INFO_RAW:
                return ak8975_read_axis(indio_dev, chan->address, val);
        case IIO_CHAN_INFO_SCALE:
-               *val = data->raw_to_gauss[chan->address];
-               return IIO_VAL_INT;
+               *val = 0;
+               *val2 = data->raw_to_gauss[chan->address];
+               return IIO_VAL_INT_PLUS_MICRO;
        }
        return -EINVAL;
 }
index 4b65b6d..f66955f 100644 (file)
@@ -106,7 +106,7 @@ static ssize_t mag3110_show_int_plus_micros(char *buf,
 
        while (n-- > 0)
                len += scnprintf(buf + len, PAGE_SIZE - len,
-                       "%d.%d ", vals[n][0], vals[n][1]);
+                       "%d.%06d ", vals[n][0], vals[n][1]);
 
        /* replace trailing space by newline */
        buf[len - 1] = '\n';
@@ -154,6 +154,9 @@ static int mag3110_read_raw(struct iio_dev *indio_dev,
 
        switch (mask) {
        case IIO_CHAN_INFO_RAW:
+               if (iio_buffer_enabled(indio_dev))
+                       return -EBUSY;
+
                switch (chan->type) {
                case IIO_MAGN: /* in 0.1 uT / LSB */
                        ret = mag3110_read(data, buffer);
@@ -199,6 +202,9 @@ static int mag3110_write_raw(struct iio_dev *indio_dev,
        struct mag3110_data *data = iio_priv(indio_dev);
        int rate;
 
+       if (iio_buffer_enabled(indio_dev))
+               return -EBUSY;
+
        switch (mask) {
        case IIO_CHAN_INFO_SAMP_FREQ:
                rate = mag3110_get_samp_freq_index(data, val, val2);
index 31a2be6..5708ffc 100644 (file)
@@ -393,7 +393,7 @@ static const struct iio_event_spec ad799x_events[] = {
        }, {
                .type = IIO_EV_TYPE_THRESH,
                .dir = IIO_EV_DIR_FALLING,
-               .mask_separate = BIT(IIO_EV_INFO_VALUE),
+               .mask_separate = BIT(IIO_EV_INFO_VALUE) |
                        BIT(IIO_EV_INFO_ENABLE),
        }, {
                .type = IIO_EV_TYPE_THRESH,
index df71669..7fc66a6 100644 (file)
@@ -1035,8 +1035,6 @@ SHOW_SCALE_AVAILABLE_ATTR(4);
 SHOW_SCALE_AVAILABLE_ATTR(5);
 SHOW_SCALE_AVAILABLE_ATTR(6);
 SHOW_SCALE_AVAILABLE_ATTR(7);
-SHOW_SCALE_AVAILABLE_ATTR(8);
-SHOW_SCALE_AVAILABLE_ATTR(9);
 SHOW_SCALE_AVAILABLE_ATTR(10);
 SHOW_SCALE_AVAILABLE_ATTR(11);
 SHOW_SCALE_AVAILABLE_ATTR(12);
@@ -1053,8 +1051,6 @@ static struct attribute *mxs_lradc_attributes[] = {
        &iio_dev_attr_in_voltage5_scale_available.dev_attr.attr,
        &iio_dev_attr_in_voltage6_scale_available.dev_attr.attr,
        &iio_dev_attr_in_voltage7_scale_available.dev_attr.attr,
-       &iio_dev_attr_in_voltage8_scale_available.dev_attr.attr,
-       &iio_dev_attr_in_voltage9_scale_available.dev_attr.attr,
        &iio_dev_attr_in_voltage10_scale_available.dev_attr.attr,
        &iio_dev_attr_in_voltage11_scale_available.dev_attr.attr,
        &iio_dev_attr_in_voltage12_scale_available.dev_attr.attr,
@@ -1613,7 +1609,7 @@ static int mxs_lradc_probe(struct platform_device *pdev)
                         * of the array.
                         */
                        scale_uv = ((u64)lradc->vref_mv[i] * 100000000) >>
-                                  (iio->channels[i].scan_type.realbits - s);
+                                  (LRADC_RESOLUTION - s);
                        lradc->scale_avail[i][s].nano =
                                        do_div(scale_uv, 100000000) * 10;
                        lradc->scale_avail[i][s].integer = scale_uv;