]> Pileus Git - ~andy/linux/commitdiff
Merge tag 'iio-for-3.14a' of git://git.kernel.org/pub/scm/linux/kernel/git/jic23...
authorGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Tue, 26 Nov 2013 02:42:40 +0000 (18:42 -0800)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Tue, 26 Nov 2013 02:42:40 +0000 (18:42 -0800)
Jonathan writes:

First set of new features, drivers and cleanups for IIO in the 3.14 cycle.
This mostly consists of patches that didn't quite make the last cycle. Lots
of interesting things under review currently.

Core:
- Add devm_iio_device_register/unregister.  I took some convincing on whether
  there would be many devices that really were simple enough to need no
  explicit actions on removal.  Turns out there are some.
- Move some stray docs to above the relevant implemenation.
- Drop a redundant repeated check on the fact the trigger has actually changed
  when there is a userspace attempt change it.

Drivers:
New drivers
- Freescale MPL3115A2 Pressure / temperature sensor

New functionality
- hid_sensors: add sensitivity support.

DT bindings
- tsl2563
- hmc5843

Cleanups
- Drop unused scan_type from viperboard adc driver.
- devm_iio_device_register used in viperboard, ad5421, ad5755, adis16130,
  adxrs450, vcnl4000, adis16220, ad7816, lpc32xx, adt7316, adis16060, isl29018
  and ad2s1200.  Note that this was proposed in a number of other drivers
  and this revealed a number of missorderings in remove functions.  Also for
  now I have blocked this on any device that any hardware suspend suport on
  the basis that we probably want to power down devices if they have no driver
  support loaded.

35 files changed:
Documentation/devicetree/bindings/iio/light/tsl2563.txt [new file with mode: 0644]
Documentation/devicetree/bindings/iio/magnetometer/hmc5843.txt [new file with mode: 0644]
Documentation/devicetree/bindings/vendor-prefixes.txt
Documentation/driver-model/devres.txt
drivers/iio/accel/hid-sensor-accel-3d.c
drivers/iio/adc/mcp3422.c
drivers/iio/adc/viperboard_adc.c
drivers/iio/dac/ad5421.c
drivers/iio/dac/ad5755.c
drivers/iio/gyro/adis16130.c
drivers/iio/gyro/adxrs450.c
drivers/iio/gyro/hid-sensor-gyro-3d.c
drivers/iio/industrialio-core.c
drivers/iio/industrialio-event.c
drivers/iio/industrialio-trigger.c
drivers/iio/light/hid-sensor-als.c
drivers/iio/light/tsl2563.c
drivers/iio/light/vcnl4000.c
drivers/iio/magnetometer/hid-sensor-magn-3d.c
drivers/iio/pressure/Kconfig
drivers/iio/pressure/Makefile
drivers/iio/pressure/mpl3115.c [new file with mode: 0644]
drivers/staging/iio/accel/adis16220_core.c
drivers/staging/iio/adc/ad7816.c
drivers/staging/iio/adc/lpc32xx_adc.c
drivers/staging/iio/addac/adt7316-i2c.c
drivers/staging/iio/addac/adt7316-spi.c
drivers/staging/iio/addac/adt7316.c
drivers/staging/iio/addac/adt7316.h
drivers/staging/iio/gyro/adis16060_core.c
drivers/staging/iio/light/isl29018.c
drivers/staging/iio/magnetometer/hmc5843.c
drivers/staging/iio/resolver/ad2s1200.c
include/linux/hid-sensor-ids.h
include/linux/iio/iio.h

diff --git a/Documentation/devicetree/bindings/iio/light/tsl2563.txt b/Documentation/devicetree/bindings/iio/light/tsl2563.txt
new file mode 100644 (file)
index 0000000..f91e809
--- /dev/null
@@ -0,0 +1,19 @@
+* AMS TAOS TSL2563 ambient light sensor
+
+Required properties:
+
+  - compatible : should be "amstaos,tsl2563"
+  - reg : the I2C address of the sensor
+
+Optional properties:
+
+  - amstaos,cover-comp-gain : integer used as multiplier for gain
+                              compensation (default = 1)
+
+Example:
+
+tsl2563@29 {
+       compatible = "amstaos,tsl2563";
+       reg = <0x29>;
+       amstaos,cover-comp-gain = <16>;
+};
diff --git a/Documentation/devicetree/bindings/iio/magnetometer/hmc5843.txt b/Documentation/devicetree/bindings/iio/magnetometer/hmc5843.txt
new file mode 100644 (file)
index 0000000..90d5f34
--- /dev/null
@@ -0,0 +1,17 @@
+* Honeywell HMC5843 magnetometer sensor
+
+Required properties:
+
+  - compatible : should be "honeywell,hmc5843"
+  - reg : the I2C address of the magnetometer - typically 0x1e
+
+Optional properties:
+
+  - gpios : should be device tree identifier of the magnetometer DRDY pin
+
+Example:
+
+hmc5843@1e {
+        compatible = "honeywell,hmc5843"
+        reg = <0x1e>;
+};
index ce95ed1c6d3e26578eaca876aa0f7caf26fa101d..8c75d8506c42788514655fb3589e8d6bc367f506 100644 (file)
@@ -9,6 +9,7 @@ aeroflexgaisler Aeroflex Gaisler AB
 ak     Asahi Kasei Corp.
 altr   Altera Corp.
 amcc   Applied Micro Circuits Corporation (APM, formally AMCC)
+amstaos        AMS-Taos Inc.
 apm    Applied Micro Circuits Corporation (APM)
 arm    ARM Ltd.
 atmel  Atmel Corporation
index 5bdc8cb5fc2855047004cf673d735fa23c561fb8..4f7897e99cba8a8fc7b5a33343825cfb94ce2d68 100644 (file)
@@ -242,6 +242,8 @@ IIO
   devm_iio_device_free()
   devm_iio_trigger_alloc()
   devm_iio_trigger_free()
+  devm_iio_device_register()
+  devm_iio_device_unregister()
 
 IO region
   devm_request_region()
index dcda17395c4e68f31f3382cd0c393a5845b025c5..6b8735ce8345b21f6f68526519587315148890d4 100644 (file)
@@ -262,6 +262,18 @@ static int accel_3d_parse_report(struct platform_device *pdev,
                        st->accel[1].index, st->accel[1].report_id,
                        st->accel[2].index, st->accel[2].report_id);
 
+       /* Set Sensitivity field ids, when there is no individual modifier */
+       if (st->common_attributes.sensitivity.index < 0) {
+               sensor_hub_input_get_attribute_info(hsdev,
+                       HID_FEATURE_REPORT, usage_id,
+                       HID_USAGE_SENSOR_DATA_MOD_CHANGE_SENSITIVITY_ABS |
+                       HID_USAGE_SENSOR_DATA_ACCELERATION,
+                       &st->common_attributes.sensitivity);
+               dev_dbg(&pdev->dev, "Sensitivity index:report %d:%d\n",
+                       st->common_attributes.sensitivity.index,
+                       st->common_attributes.sensitivity.report_id);
+       }
+
        return ret;
 }
 
index 12948325431c98a1a01effc90d1bec0f6a564b50..dbdbd77f69eaa0d94d7d71e61c5ac46d26a2ae95 100644 (file)
@@ -362,7 +362,7 @@ static int mcp3422_probe(struct i2c_client *client,
                | MCP3422_SAMPLE_RATE_VALUE(MCP3422_SRATE_240));
        mcp3422_update_config(adc, config);
 
-       err = iio_device_register(indio_dev);
+       err = devm_iio_device_register(&client->dev, indio_dev);
        if (err < 0)
                return err;
 
@@ -371,12 +371,6 @@ static int mcp3422_probe(struct i2c_client *client,
        return 0;
 }
 
-static int mcp3422_remove(struct i2c_client *client)
-{
-       iio_device_unregister(i2c_get_clientdata(client));
-       return 0;
-}
-
 static const struct i2c_device_id mcp3422_id[] = {
        { "mcp3422", 2 },
        { "mcp3423", 3 },
@@ -400,7 +394,6 @@ static struct i2c_driver mcp3422_driver = {
                .of_match_table = of_match_ptr(mcp3422_of_match),
        },
        .probe = mcp3422_probe,
-       .remove = mcp3422_remove,
        .id_table = mcp3422_id,
 };
 module_i2c_driver(mcp3422_driver);
index 09727a71e9fa1578744c4334ad83679274ff24d2..d0add8f9416ba8edf9b0263c8ba0b50831eef58a 100644 (file)
@@ -42,12 +42,6 @@ struct vprbrd_adc {
        .indexed = 1,                                   \
        .channel = _index,                              \
        .info_mask_separate = BIT(IIO_CHAN_INFO_RAW),   \
-       .scan_index = _index,                           \
-       .scan_type = {                                  \
-               .sign = 'u',                            \
-               .realbits = 8,                          \
-               .storagebits = 8,                       \
-       },                                              \
 }
 
 static struct iio_chan_spec const vprbrd_adc_iio_channels[] = {
@@ -73,7 +67,7 @@ static int vprbrd_iio_read_raw(struct iio_dev *iio_dev,
                mutex_lock(&vb->lock);
 
                admsg->cmd = VPRBRD_ADC_CMD_GET;
-               admsg->chan = chan->scan_index;
+               admsg->chan = chan->channel;
                admsg->val = 0x00;
 
                ret = usb_control_msg(vb->usb_dev,
@@ -139,7 +133,7 @@ static int vprbrd_adc_probe(struct platform_device *pdev)
        indio_dev->channels = vprbrd_adc_iio_channels;
        indio_dev->num_channels = ARRAY_SIZE(vprbrd_adc_iio_channels);
 
-       ret = iio_device_register(indio_dev);
+       ret = devm_iio_device_register(&pdev->dev, indio_dev);
        if (ret) {
                dev_err(&pdev->dev, "could not register iio (adc)");
                return ret;
@@ -150,22 +144,12 @@ static int vprbrd_adc_probe(struct platform_device *pdev)
        return 0;
 }
 
-static int vprbrd_adc_remove(struct platform_device *pdev)
-{
-       struct iio_dev *indio_dev = platform_get_drvdata(pdev);
-
-       iio_device_unregister(indio_dev);
-
-       return 0;
-}
-
 static struct platform_driver vprbrd_adc_driver = {
        .driver = {
                .name   = "viperboard-adc",
                .owner  = THIS_MODULE,
        },
        .probe          = vprbrd_adc_probe,
-       .remove         = vprbrd_adc_remove,
 };
 
 module_platform_driver(vprbrd_adc_driver);
index 3eeaa82075f7bca0649b5e15afb0c02f21a32458..7d1e90811c718e2b494df7fbc00910cdea8eaf08 100644 (file)
@@ -514,16 +514,7 @@ static int ad5421_probe(struct spi_device *spi)
                        return ret;
        }
 
-       return iio_device_register(indio_dev);
-}
-
-static int ad5421_remove(struct spi_device *spi)
-{
-       struct iio_dev *indio_dev = spi_get_drvdata(spi);
-
-       iio_device_unregister(indio_dev);
-
-       return 0;
+       return devm_iio_device_register(&spi->dev, indio_dev);
 }
 
 static struct spi_driver ad5421_driver = {
@@ -532,7 +523,6 @@ static struct spi_driver ad5421_driver = {
                   .owner = THIS_MODULE,
        },
        .probe = ad5421_probe,
-       .remove = ad5421_remove,
 };
 module_spi_driver(ad5421_driver);
 
index 9a78d5abb2f6646579fe6ffea21acd51dce91ca7..ee1e95a3a0c31b65c91104340fed80ca97bb5b55 100644 (file)
@@ -589,16 +589,7 @@ static int ad5755_probe(struct spi_device *spi)
        if (ret)
                return ret;
 
-       return iio_device_register(indio_dev);
-}
-
-static int ad5755_remove(struct spi_device *spi)
-{
-       struct iio_dev *indio_dev = spi_get_drvdata(spi);
-
-       iio_device_unregister(indio_dev);
-
-       return 0;
+       return devm_iio_device_register(&spi->dev, indio_dev);
 }
 
 static const struct spi_device_id ad5755_id[] = {
@@ -617,7 +608,6 @@ static struct spi_driver ad5755_driver = {
                .owner = THIS_MODULE,
        },
        .probe = ad5755_probe,
-       .remove = ad5755_remove,
        .id_table = ad5755_id,
 };
 module_spi_driver(ad5755_driver);
index 445c2aecfadde205921049a1e0b42d64342318d5..8d08c7ed1ea64d554f9414eb15c8ad41303c3381 100644 (file)
@@ -161,13 +161,7 @@ static int adis16130_probe(struct spi_device *spi)
        indio_dev->info = &adis16130_info;
        indio_dev->modes = INDIO_DIRECT_MODE;
 
-       return iio_device_register(indio_dev);
-}
-
-static int adis16130_remove(struct spi_device *spi)
-{
-       iio_device_unregister(spi_get_drvdata(spi));
-       return 0;
+       return devm_iio_device_register(&spi->dev, indio_dev);
 }
 
 static struct spi_driver adis16130_driver = {
@@ -176,7 +170,6 @@ static struct spi_driver adis16130_driver = {
                .owner = THIS_MODULE,
        },
        .probe = adis16130_probe,
-       .remove = adis16130_remove,
 };
 module_spi_driver(adis16130_driver);
 
index 1e546ba7ba45e1c92acf9ae926b9c29c386785ef..eb0e08ec9e20d43fce5233e44d8144006fd433a3 100644 (file)
@@ -434,23 +434,14 @@ static int adxrs450_probe(struct spi_device *spi)
        indio_dev->num_channels = ARRAY_SIZE(adxrs450_channels);
        indio_dev->name = spi->dev.driver->name;
 
-       ret = iio_device_register(indio_dev);
+       ret = devm_iio_device_register(&spi->dev, indio_dev);
        if (ret)
                return ret;
 
        /* Get the device into a sane initial state */
        ret = adxrs450_initial_setup(indio_dev);
        if (ret)
-               goto error_initial;
-       return 0;
-error_initial:
-       iio_device_unregister(indio_dev);
-       return ret;
-}
-
-static int adxrs450_remove(struct spi_device *spi)
-{
-       iio_device_unregister(spi_get_drvdata(spi));
+               return ret;
 
        return 0;
 }
@@ -468,7 +459,6 @@ static struct spi_driver adxrs450_driver = {
                .owner = THIS_MODULE,
        },
        .probe = adxrs450_probe,
-       .remove = adxrs450_remove,
        .id_table       = adxrs450_id,
 };
 module_spi_driver(adxrs450_driver);
index ea01c6bcfb56825979efc7bfc588eeb9e429e059..97797dbaad342b4bc264f3a82b48cef34d05949b 100644 (file)
@@ -262,6 +262,17 @@ static int gyro_3d_parse_report(struct platform_device *pdev,
                        st->gyro[1].index, st->gyro[1].report_id,
                        st->gyro[2].index, st->gyro[2].report_id);
 
+       /* Set Sensitivity field ids, when there is no individual modifier */
+       if (st->common_attributes.sensitivity.index < 0) {
+               sensor_hub_input_get_attribute_info(hsdev,
+                       HID_FEATURE_REPORT, usage_id,
+                       HID_USAGE_SENSOR_DATA_MOD_CHANGE_SENSITIVITY_ABS |
+                       HID_USAGE_SENSOR_DATA_ANGL_VELOCITY,
+                       &st->common_attributes.sensitivity);
+               dev_dbg(&pdev->dev, "Sensitivity index:report %d:%d\n",
+                       st->common_attributes.sensitivity.index,
+                       st->common_attributes.sensitivity.report_id);
+       }
        return ret;
 }
 
index 18f72e3d0ed6e6c8e9bb73ec8616124a2422aed4..2fe88c189f74cd346c01dd45f81060f92a077c59 100644 (file)
@@ -107,6 +107,11 @@ static const char * const iio_chan_info_postfix[] = {
        [IIO_CHAN_INFO_INT_TIME] = "integration_time",
 };
 
+/**
+ * iio_find_channel_from_si() - get channel from its scan index
+ * @indio_dev:         device
+ * @si:                        scan index to match
+ */
 const struct iio_chan_spec
 *iio_find_channel_from_si(struct iio_dev *indio_dev, int si)
 {
@@ -922,6 +927,10 @@ struct device_type iio_device_type = {
        .release = iio_dev_release,
 };
 
+/**
+ * iio_device_alloc() - allocate an iio_dev from a driver
+ * @sizeof_priv:       Space to allocate for private structure.
+ **/
 struct iio_dev *iio_device_alloc(int sizeof_priv)
 {
        struct iio_dev *dev;
@@ -962,6 +971,10 @@ struct iio_dev *iio_device_alloc(int sizeof_priv)
 }
 EXPORT_SYMBOL(iio_device_alloc);
 
+/**
+ * iio_device_free() - free an iio_dev from a driver
+ * @dev:               the iio_dev associated with the device
+ **/
 void iio_device_free(struct iio_dev *dev)
 {
        if (dev)
@@ -984,6 +997,20 @@ static int devm_iio_device_match(struct device *dev, void *res, void *data)
        return *r == data;
 }
 
+/**
+ * devm_iio_device_alloc - Resource-managed iio_device_alloc()
+ * @dev:               Device to allocate iio_dev for
+ * @sizeof_priv:       Space to allocate for private structure.
+ *
+ * Managed iio_device_alloc. iio_dev allocated with this function is
+ * automatically freed on driver detach.
+ *
+ * If an iio_dev allocated with this function needs to be freed separately,
+ * devm_iio_device_free() must be used.
+ *
+ * RETURNS:
+ * Pointer to allocated iio_dev on success, NULL on failure.
+ */
 struct iio_dev *devm_iio_device_alloc(struct device *dev, int sizeof_priv)
 {
        struct iio_dev **ptr, *iio_dev;
@@ -1006,6 +1033,13 @@ struct iio_dev *devm_iio_device_alloc(struct device *dev, int sizeof_priv)
 }
 EXPORT_SYMBOL_GPL(devm_iio_device_alloc);
 
+/**
+ * devm_iio_device_free - Resource-managed iio_device_free()
+ * @dev:               Device this iio_dev belongs to
+ * @iio_dev:           the iio_dev associated with the device
+ *
+ * Free iio_dev allocated with devm_iio_device_alloc().
+ */
 void devm_iio_device_free(struct device *dev, struct iio_dev *iio_dev)
 {
        int rc;
@@ -1080,6 +1114,10 @@ static const struct file_operations iio_buffer_fileops = {
 
 static const struct iio_buffer_setup_ops noop_ring_setup_ops;
 
+/**
+ * iio_device_register() - register a device with the IIO subsystem
+ * @indio_dev:         Device structure filled by the device driver
+ **/
 int iio_device_register(struct iio_dev *indio_dev)
 {
        int ret;
@@ -1141,6 +1179,10 @@ error_ret:
 }
 EXPORT_SYMBOL(iio_device_register);
 
+/**
+ * iio_device_unregister() - unregister a device from the IIO subsystem
+ * @indio_dev:         Device structure representing the device.
+ **/
 void iio_device_unregister(struct iio_dev *indio_dev)
 {
        mutex_lock(&indio_dev->info_exist_lock);
@@ -1161,6 +1203,65 @@ void iio_device_unregister(struct iio_dev *indio_dev)
        mutex_unlock(&indio_dev->info_exist_lock);
 }
 EXPORT_SYMBOL(iio_device_unregister);
+
+static void devm_iio_device_unreg(struct device *dev, void *res)
+{
+       iio_device_unregister(*(struct iio_dev **)res);
+}
+
+/**
+ * devm_iio_device_register - Resource-managed iio_device_register()
+ * @dev:       Device to allocate iio_dev for
+ * @indio_dev: Device structure filled by the device driver
+ *
+ * Managed iio_device_register.  The IIO device registered with this
+ * function is automatically unregistered on driver detach. This function
+ * calls iio_device_register() internally. Refer to that function for more
+ * information.
+ *
+ * If an iio_dev registered with this function needs to be unregistered
+ * separately, devm_iio_device_unregister() must be used.
+ *
+ * RETURNS:
+ * 0 on success, negative error number on failure.
+ */
+int devm_iio_device_register(struct device *dev, struct iio_dev *indio_dev)
+{
+       struct iio_dev **ptr;
+       int ret;
+
+       ptr = devres_alloc(devm_iio_device_unreg, sizeof(*ptr), GFP_KERNEL);
+       if (!ptr)
+               return -ENOMEM;
+
+       *ptr = indio_dev;
+       ret = iio_device_register(indio_dev);
+       if (!ret)
+               devres_add(dev, ptr);
+       else
+               devres_free(ptr);
+
+       return ret;
+}
+EXPORT_SYMBOL_GPL(devm_iio_device_register);
+
+/**
+ * devm_iio_device_unregister - Resource-managed iio_device_unregister()
+ * @dev:       Device this iio_dev belongs to
+ * @indio_dev: the iio_dev associated with the device
+ *
+ * Unregister iio_dev registered with devm_iio_device_register().
+ */
+void devm_iio_device_unregister(struct device *dev, struct iio_dev *indio_dev)
+{
+       int rc;
+
+       rc = devres_release(dev, devm_iio_device_unreg,
+                           devm_iio_device_match, indio_dev);
+       WARN_ON(rc);
+}
+EXPORT_SYMBOL_GPL(devm_iio_device_unregister);
+
 subsys_initcall(iio_init);
 module_exit(iio_exit);
 
index c10eab64bc0524eca6caa476d224c370fcd49262..bc043fab4cd12cbcd86f182e67d69b4da78f8a07 100644 (file)
@@ -42,6 +42,12 @@ struct iio_event_interface {
        struct attribute_group  group;
 };
 
+/**
+ * iio_push_event() - try to add event to the list for userspace reading
+ * @indio_dev:         IIO device structure
+ * @ev_code:           What event
+ * @timestamp:         When the event occurred
+ **/
 int iio_push_event(struct iio_dev *indio_dev, u64 ev_code, s64 timestamp)
 {
        struct iio_event_interface *ev_int = indio_dev->event_interface;
index bf5e70a32d3fb6011be6324c20ad45d4ba704064..7ba2f002ffcad423527d096703c099b5007d116c 100644 (file)
@@ -318,7 +318,7 @@ static ssize_t iio_trigger_read_current(struct device *dev,
  * iio_trigger_write_current() - trigger consumer sysfs set current trigger
  *
  * For trigger consumers the current_trigger interface allows the trigger
- * used for this device to be specified at run time based on the triggers
+ * used for this device to be specified at run time based on the trigger's
  * name.
  **/
 static ssize_t iio_trigger_write_current(struct device *dev,
@@ -356,7 +356,7 @@ static ssize_t iio_trigger_write_current(struct device *dev,
 
        indio_dev->trig = trig;
 
-       if (oldtrig && indio_dev->trig != oldtrig)
+       if (oldtrig)
                iio_trigger_put(oldtrig);
        if (indio_dev->trig)
                iio_trigger_get(indio_dev->trig);
@@ -506,6 +506,23 @@ static int devm_iio_trigger_match(struct device *dev, void *res, void *data)
        return *r == data;
 }
 
+/**
+ * devm_iio_trigger_alloc - Resource-managed iio_trigger_alloc()
+ * @dev:               Device to allocate iio_trigger for
+ * @fmt:               trigger name format. If it includes format
+ *                     specifiers, the additional arguments following
+ *                     format are formatted and inserted in the resulting
+ *                     string replacing their respective specifiers.
+ *
+ * Managed iio_trigger_alloc.  iio_trigger allocated with this function is
+ * automatically freed on driver detach.
+ *
+ * If an iio_trigger allocated with this function needs to be freed separately,
+ * devm_iio_trigger_free() must be used.
+ *
+ * RETURNS:
+ * Pointer to allocated iio_trigger on success, NULL on failure.
+ */
 struct iio_trigger *devm_iio_trigger_alloc(struct device *dev,
                                                const char *fmt, ...)
 {
@@ -532,6 +549,13 @@ struct iio_trigger *devm_iio_trigger_alloc(struct device *dev,
 }
 EXPORT_SYMBOL_GPL(devm_iio_trigger_alloc);
 
+/**
+ * devm_iio_trigger_free - Resource-managed iio_trigger_free()
+ * @dev:               Device this iio_dev belongs to
+ * @iio_trig:          the iio_trigger associated with the device
+ *
+ * Free iio_trigger allocated with devm_iio_trigger_alloc().
+ */
 void devm_iio_trigger_free(struct device *dev, struct iio_trigger *iio_trig)
 {
        int rc;
index fa6ae8cf89eaa9edfdfffe379939bc7cc8a491f0..0c7f115ee3b3c35f1b35e804686cb16d76f05aad 100644 (file)
@@ -229,6 +229,17 @@ static int als_parse_report(struct platform_device *pdev,
        dev_dbg(&pdev->dev, "als %x:%x\n", st->als_illum.index,
                        st->als_illum.report_id);
 
+       /* Set Sensitivity field ids, when there is no individual modifier */
+       if (st->common_attributes.sensitivity.index < 0) {
+               sensor_hub_input_get_attribute_info(hsdev,
+                       HID_FEATURE_REPORT, usage_id,
+                       HID_USAGE_SENSOR_DATA_MOD_CHANGE_SENSITIVITY_ABS |
+                       HID_USAGE_SENSOR_DATA_LIGHT,
+                       &st->common_attributes.sensitivity);
+               dev_dbg(&pdev->dev, "Sensitivity index:report %d:%d\n",
+                       st->common_attributes.sensitivity.index,
+                       st->common_attributes.sensitivity.report_id);
+       }
        return ret;
 }
 
index 5e5d9dea22c598016c225848333c1e31595c811f..0c6e459c86b1de6450e8de0fa05b3a3f8df57a3b 100644 (file)
@@ -714,6 +714,7 @@ static int tsl2563_probe(struct i2c_client *client,
        struct iio_dev *indio_dev;
        struct tsl2563_chip *chip;
        struct tsl2563_platform_data *pdata = client->dev.platform_data;
+       struct device_node *np = client->dev.of_node;
        int err = 0;
        u8 id = 0;
 
@@ -750,6 +751,9 @@ static int tsl2563_probe(struct i2c_client *client,
 
        if (pdata)
                chip->cover_comp_gain = pdata->cover_comp_gain;
+       else if (np)
+               of_property_read_u32(np, "amstaos,cover-comp-gain",
+                                    &chip->cover_comp_gain);
        else
                chip->cover_comp_gain = 1;
 
index ecb3341ef9c07a8e56ddaf1de8d76d31456e6d2a..384ac23f576f3dddcfa276f8070b8b8009b099c6 100644 (file)
@@ -179,13 +179,7 @@ static int vcnl4000_probe(struct i2c_client *client,
        indio_dev->name = VCNL4000_DRV_NAME;
        indio_dev->modes = INDIO_DIRECT_MODE;
 
-       return iio_device_register(indio_dev);
-}
-
-static int vcnl4000_remove(struct i2c_client *client)
-{
-       iio_device_unregister(i2c_get_clientdata(client));
-       return 0;
+       return devm_iio_device_register(&client->dev, indio_dev);
 }
 
 static struct i2c_driver vcnl4000_driver = {
@@ -194,7 +188,6 @@ static struct i2c_driver vcnl4000_driver = {
                .owner  = THIS_MODULE,
        },
        .probe  = vcnl4000_probe,
-       .remove = vcnl4000_remove,
        .id_table = vcnl4000_id,
 };
 
index 2634920562fb7263bad4ac9d8c6c75fe7a434b49..67fce1916d2173466277da389708a895f462c2ce 100644 (file)
@@ -263,6 +263,18 @@ static int magn_3d_parse_report(struct platform_device *pdev,
                        st->magn[1].index, st->magn[1].report_id,
                        st->magn[2].index, st->magn[2].report_id);
 
+       /* Set Sensitivity field ids, when there is no individual modifier */
+       if (st->common_attributes.sensitivity.index < 0) {
+               sensor_hub_input_get_attribute_info(hsdev,
+                       HID_FEATURE_REPORT, usage_id,
+                       HID_USAGE_SENSOR_DATA_MOD_CHANGE_SENSITIVITY_ABS |
+                       HID_USAGE_SENSOR_DATA_ORIENTATION,
+                       &st->common_attributes.sensitivity);
+               dev_dbg(&pdev->dev, "Sensitivity index:report %d:%d\n",
+                       st->common_attributes.sensitivity.index,
+                       st->common_attributes.sensitivity.report_id);
+       }
+
        return ret;
 }
 
index 4f2e0f9bad8c100d89a43265daa0af8bb3b7450b..a8b9cae5c17355ba8268308d5428fd38c6cc6b55 100644 (file)
@@ -5,6 +5,18 @@
 
 menu "Pressure sensors"
 
+config MPL3115
+       tristate "Freescale MPL3115A2 pressure sensor driver"
+       depends on I2C
+       select IIO_BUFFER
+       select IIO_TRIGGERED_BUFFER
+       help
+         Say yes here to build support for the Freescale MPL3115A2
+         pressure sensor / altimeter.
+
+          To compile this driver as a module, choose M here: the module
+          will be called mpl3115.
+
 config IIO_ST_PRESS
        tristate "STMicroelectronics pressure sensor Driver"
        depends on (I2C || SPI_MASTER) && SYSFS
index be71464c27525be86adcf577be3d04dea0978f6e..42bb9fcf54362d7abbbc4e21cd757443608c38fa 100644 (file)
@@ -3,6 +3,7 @@
 #
 
 # When adding new entries keep the list in alphabetical order
+obj-$(CONFIG_MPL3115) += mpl3115.o
 obj-$(CONFIG_IIO_ST_PRESS) += st_pressure.o
 st_pressure-y := st_pressure_core.o
 st_pressure-$(CONFIG_IIO_BUFFER) += st_pressure_buffer.o
diff --git a/drivers/iio/pressure/mpl3115.c b/drivers/iio/pressure/mpl3115.c
new file mode 100644 (file)
index 0000000..ac8c8ab
--- /dev/null
@@ -0,0 +1,329 @@
+/*
+ * mpl3115.c - Support for Freescale MPL3115A2 pressure/temperature sensor
+ *
+ * Copyright (c) 2013 Peter Meerwald <pmeerw@pmeerw.net>
+ *
+ * This file is subject to the terms and conditions of version 2 of
+ * the GNU General Public License.  See the file COPYING in the main
+ * directory of this archive for more details.
+ *
+ * (7-bit I2C slave address 0x60)
+ *
+ * TODO: FIFO buffer, altimeter mode, oversampling, continuous mode,
+ * interrupts, user offset correction, raw mode
+ */
+
+#include <linux/module.h>
+#include <linux/i2c.h>
+#include <linux/iio/iio.h>
+#include <linux/iio/sysfs.h>
+#include <linux/iio/trigger_consumer.h>
+#include <linux/iio/buffer.h>
+#include <linux/iio/triggered_buffer.h>
+#include <linux/delay.h>
+
+#define MPL3115_STATUS 0x00
+#define MPL3115_OUT_PRESS 0x01 /* MSB first, 20 bit */
+#define MPL3115_OUT_TEMP 0x04 /* MSB first, 12 bit */
+#define MPL3115_WHO_AM_I 0x0c
+#define MPL3115_CTRL_REG1 0x26
+
+#define MPL3115_DEVICE_ID 0xc4
+
+#define MPL3115_STATUS_PRESS_RDY BIT(2)
+#define MPL3115_STATUS_TEMP_RDY BIT(1)
+
+#define MPL3115_CTRL_RESET BIT(2) /* software reset */
+#define MPL3115_CTRL_OST BIT(1) /* initiate measurement */
+#define MPL3115_CTRL_ACTIVE BIT(0) /* continuous measurement */
+#define MPL3115_CTRL_OS_258MS (BIT(5) | BIT(4)) /* 64x oversampling */
+
+struct mpl3115_data {
+       struct i2c_client *client;
+       struct mutex lock;
+       u8 ctrl_reg1;
+};
+
+static int mpl3115_request(struct mpl3115_data *data)
+{
+       int ret, tries = 15;
+
+       /* trigger measurement */
+       ret = i2c_smbus_write_byte_data(data->client, MPL3115_CTRL_REG1,
+               data->ctrl_reg1 | MPL3115_CTRL_OST);
+       if (ret < 0)
+               return ret;
+
+       while (tries-- > 0) {
+               ret = i2c_smbus_read_byte_data(data->client, MPL3115_CTRL_REG1);
+               if (ret < 0)
+                       return ret;
+               /* wait for data ready, i.e. OST cleared */
+               if (!(ret & MPL3115_CTRL_OST))
+                       break;
+               msleep(20);
+       }
+
+       if (tries < 0) {
+               dev_err(&data->client->dev, "data not ready\n");
+               return -EIO;
+       }
+
+       return 0;
+}
+
+static int mpl3115_read_raw(struct iio_dev *indio_dev,
+                           struct iio_chan_spec const *chan,
+                           int *val, int *val2, long mask)
+{
+       struct mpl3115_data *data = iio_priv(indio_dev);
+       s32 tmp = 0;
+       int ret;
+
+       switch (mask) {
+       case IIO_CHAN_INFO_RAW:
+               if (iio_buffer_enabled(indio_dev))
+                       return -EBUSY;
+
+               switch (chan->type) {
+               case IIO_PRESSURE: /* in 0.25 pascal / LSB */
+                       mutex_lock(&data->lock);
+                       ret = mpl3115_request(data);
+                       if (ret < 0) {
+                               mutex_unlock(&data->lock);
+                               return ret;
+                       }
+                       ret = i2c_smbus_read_i2c_block_data(data->client,
+                               MPL3115_OUT_PRESS, 3, (u8 *) &tmp);
+                       mutex_unlock(&data->lock);
+                       if (ret < 0)
+                               return ret;
+                       *val = sign_extend32(be32_to_cpu(tmp) >> 12, 23);
+                       return IIO_VAL_INT;
+               case IIO_TEMP: /* in 0.0625 celsius / LSB */
+                       mutex_lock(&data->lock);
+                       ret = mpl3115_request(data);
+                       if (ret < 0) {
+                               mutex_unlock(&data->lock);
+                               return ret;
+                       }
+                       ret = i2c_smbus_read_i2c_block_data(data->client,
+                               MPL3115_OUT_TEMP, 2, (u8 *) &tmp);
+                       mutex_unlock(&data->lock);
+                       if (ret < 0)
+                               return ret;
+                       *val = sign_extend32(be32_to_cpu(tmp) >> 20, 15);
+                       return IIO_VAL_INT;
+               default:
+                       return -EINVAL;
+               }
+       case IIO_CHAN_INFO_SCALE:
+               switch (chan->type) {
+               case IIO_PRESSURE:
+                       *val = 0;
+                       *val2 = 250; /* want kilopascal */
+                       return IIO_VAL_INT_PLUS_MICRO;
+               case IIO_TEMP:
+                       *val = 0;
+                       *val2 = 62500;
+                       return IIO_VAL_INT_PLUS_MICRO;
+               default:
+                       return -EINVAL;
+               }
+       }
+       return -EINVAL;
+}
+
+static irqreturn_t mpl3115_trigger_handler(int irq, void *p)
+{
+       struct iio_poll_func *pf = p;
+       struct iio_dev *indio_dev = pf->indio_dev;
+       struct mpl3115_data *data = iio_priv(indio_dev);
+       u8 buffer[16]; /* 32-bit channel + 16-bit channel + padding + ts */
+       int ret, pos = 0;
+
+       mutex_lock(&data->lock);
+       ret = mpl3115_request(data);
+       if (ret < 0) {
+               mutex_unlock(&data->lock);
+               goto done;
+       }
+
+       memset(buffer, 0, sizeof(buffer));
+       if (test_bit(0, indio_dev->active_scan_mask)) {
+               ret = i2c_smbus_read_i2c_block_data(data->client,
+                       MPL3115_OUT_PRESS, 3, &buffer[pos]);
+               if (ret < 0) {
+                       mutex_unlock(&data->lock);
+                       goto done;
+               }
+               pos += 4;
+       }
+
+       if (test_bit(1, indio_dev->active_scan_mask)) {
+               ret = i2c_smbus_read_i2c_block_data(data->client,
+                       MPL3115_OUT_TEMP, 2, &buffer[pos]);
+               if (ret < 0) {
+                       mutex_unlock(&data->lock);
+                       goto done;
+               }
+       }
+       mutex_unlock(&data->lock);
+
+       iio_push_to_buffers_with_timestamp(indio_dev, buffer,
+               iio_get_time_ns());
+
+done:
+       iio_trigger_notify_done(indio_dev->trig);
+       return IRQ_HANDLED;
+}
+
+static const struct iio_chan_spec mpl3115_channels[] = {
+       {
+               .type = IIO_PRESSURE,
+               .info_mask_separate = BIT(IIO_CHAN_INFO_RAW),
+                       BIT(IIO_CHAN_INFO_SCALE),
+               .scan_index = 0,
+               .scan_type = {
+                       .sign = 's',
+                       .realbits = 20,
+                       .storagebits = 32,
+                       .shift = 12,
+                       .endianness = IIO_BE,
+               }
+       },
+       {
+               .type = IIO_TEMP,
+               .info_mask_separate = BIT(IIO_CHAN_INFO_RAW),
+                       BIT(IIO_CHAN_INFO_SCALE),
+               .scan_index = 1,
+               .scan_type = {
+                       .sign = 's',
+                       .realbits = 12,
+                       .storagebits = 16,
+                       .shift = 4,
+                       .endianness = IIO_BE,
+               }
+       },
+       IIO_CHAN_SOFT_TIMESTAMP(2),
+};
+
+static const struct iio_info mpl3115_info = {
+       .read_raw = &mpl3115_read_raw,
+       .driver_module = THIS_MODULE,
+};
+
+static int mpl3115_probe(struct i2c_client *client,
+                        const struct i2c_device_id *id)
+{
+       struct mpl3115_data *data;
+       struct iio_dev *indio_dev;
+       int ret;
+
+       ret = i2c_smbus_read_byte_data(client, MPL3115_WHO_AM_I);
+       if (ret < 0)
+               return ret;
+       if (ret != MPL3115_DEVICE_ID)
+               return -ENODEV;
+
+       indio_dev = devm_iio_device_alloc(&client->dev, sizeof(*data));
+       if (!indio_dev)
+               return -ENOMEM;
+
+       data = iio_priv(indio_dev);
+       data->client = client;
+       mutex_init(&data->lock);
+
+       i2c_set_clientdata(client, indio_dev);
+       indio_dev->info = &mpl3115_info;
+       indio_dev->name = id->name;
+       indio_dev->dev.parent = &client->dev;
+       indio_dev->modes = INDIO_DIRECT_MODE;
+       indio_dev->channels = mpl3115_channels;
+       indio_dev->num_channels = ARRAY_SIZE(mpl3115_channels);
+
+       /* software reset, I2C transfer is aborted (fails) */
+       i2c_smbus_write_byte_data(client, MPL3115_CTRL_REG1,
+               MPL3115_CTRL_RESET);
+       msleep(50);
+
+       data->ctrl_reg1 = MPL3115_CTRL_OS_258MS;
+       ret = i2c_smbus_write_byte_data(client, MPL3115_CTRL_REG1,
+               data->ctrl_reg1);
+       if (ret < 0)
+               return ret;
+
+       ret = iio_triggered_buffer_setup(indio_dev, NULL,
+               mpl3115_trigger_handler, NULL);
+       if (ret < 0)
+               return ret;
+
+       ret = iio_device_register(indio_dev);
+       if (ret < 0)
+               goto buffer_cleanup;
+       return 0;
+
+buffer_cleanup:
+       iio_triggered_buffer_cleanup(indio_dev);
+       return ret;
+}
+
+static int mpl3115_standby(struct mpl3115_data *data)
+{
+       return i2c_smbus_write_byte_data(data->client, MPL3115_CTRL_REG1,
+               data->ctrl_reg1 & ~MPL3115_CTRL_ACTIVE);
+}
+
+static int mpl3115_remove(struct i2c_client *client)
+{
+       struct iio_dev *indio_dev = i2c_get_clientdata(client);
+
+       iio_device_unregister(indio_dev);
+       iio_triggered_buffer_cleanup(indio_dev);
+       mpl3115_standby(iio_priv(indio_dev));
+
+       return 0;
+}
+
+#ifdef CONFIG_PM_SLEEP
+static int mpl3115_suspend(struct device *dev)
+{
+       return mpl3115_standby(iio_priv(i2c_get_clientdata(
+               to_i2c_client(dev))));
+}
+
+static int mpl3115_resume(struct device *dev)
+{
+       struct mpl3115_data *data = iio_priv(i2c_get_clientdata(
+               to_i2c_client(dev)));
+
+       return i2c_smbus_write_byte_data(data->client, MPL3115_CTRL_REG1,
+               data->ctrl_reg1);
+}
+
+static SIMPLE_DEV_PM_OPS(mpl3115_pm_ops, mpl3115_suspend, mpl3115_resume);
+#define MPL3115_PM_OPS (&mpl3115_pm_ops)
+#else
+#define MPL3115_PM_OPS NULL
+#endif
+
+static const struct i2c_device_id mpl3115_id[] = {
+       { "mpl3115", 0 },
+       { }
+};
+MODULE_DEVICE_TABLE(i2c, mpl3115_id);
+
+static struct i2c_driver mpl3115_driver = {
+       .driver = {
+               .name   = "mpl3115",
+               .pm     = MPL3115_PM_OPS,
+       },
+       .probe = mpl3115_probe,
+       .remove = mpl3115_remove,
+       .id_table = mpl3115_id,
+};
+module_i2c_driver(mpl3115_driver);
+
+MODULE_AUTHOR("Peter Meerwald <pmeerw@pmeerw.net>");
+MODULE_DESCRIPTION("Freescale MPL3115 pressure/temperature driver");
+MODULE_LICENSE("GPL");
index 4c9364b63c77d61a1088298993ad46435c0cca6e..6f38ca95f9bb39eb1379e75d7b9175be1a07aa8f 100644 (file)
@@ -439,13 +439,13 @@ static int adis16220_probe(struct spi_device *spi)
        indio_dev->channels = adis16220_channels;
        indio_dev->num_channels = ARRAY_SIZE(adis16220_channels);
 
-       ret = iio_device_register(indio_dev);
+       ret = devm_iio_device_register(&spi->dev, indio_dev);
        if (ret)
                return ret;
 
        ret = sysfs_create_bin_file(&indio_dev->dev.kobj, &accel_bin);
        if (ret)
-               goto error_unregister_dev;
+               return ret;
 
        ret = sysfs_create_bin_file(&indio_dev->dev.kobj, &adc1_bin);
        if (ret)
@@ -470,8 +470,6 @@ error_rm_adc1_bin:
        sysfs_remove_bin_file(&indio_dev->dev.kobj, &adc1_bin);
 error_rm_accel_bin:
        sysfs_remove_bin_file(&indio_dev->dev.kobj, &accel_bin);
-error_unregister_dev:
-       iio_device_unregister(indio_dev);
        return ret;
 }
 
@@ -482,7 +480,6 @@ static int adis16220_remove(struct spi_device *spi)
        sysfs_remove_bin_file(&indio_dev->dev.kobj, &adc2_bin);
        sysfs_remove_bin_file(&indio_dev->dev.kobj, &adc1_bin);
        sysfs_remove_bin_file(&indio_dev->dev.kobj, &accel_bin);
-       iio_device_unregister(indio_dev);
 
        return 0;
 }
index 9f48e5c74eed85c8f164208d4ddbaf4ed108dfb8..2369cf28412ed682046e99c715b21a0b778faee5 100644 (file)
@@ -412,7 +412,7 @@ static int ad7816_probe(struct spi_device *spi_dev)
                        return ret;
        }
 
-       ret = iio_device_register(indio_dev);
+       ret = devm_iio_device_register(&spi_dev->dev, indio_dev);
        if (ret)
                return ret;
 
@@ -422,15 +422,6 @@ static int ad7816_probe(struct spi_device *spi_dev)
        return 0;
 }
 
-static int ad7816_remove(struct spi_device *spi_dev)
-{
-       struct iio_dev *indio_dev = dev_get_drvdata(&spi_dev->dev);
-
-       iio_device_unregister(indio_dev);
-
-       return 0;
-}
-
 static const struct spi_device_id ad7816_id[] = {
        { "ad7816", 0 },
        { "ad7817", 0 },
@@ -446,7 +437,6 @@ static struct spi_driver ad7816_driver = {
                .owner = THIS_MODULE,
        },
        .probe = ad7816_probe,
-       .remove = ad7816_remove,
        .id_table = ad7816_id,
 };
 module_spi_driver(ad7816_driver);
index ef0a21d8ce15ce76ea4ae39bb72d0523f3bfc230..a876ce7553517523b14428b101e4fc77b25fe234 100644 (file)
@@ -183,7 +183,7 @@ static int lpc32xx_adc_probe(struct platform_device *pdev)
        iodev->channels = lpc32xx_adc_iio_channels;
        iodev->num_channels = ARRAY_SIZE(lpc32xx_adc_iio_channels);
 
-       retval = iio_device_register(iodev);
+       retval = devm_iio_device_register(&pdev->dev, iodev);
        if (retval)
                return retval;
 
@@ -192,15 +192,6 @@ static int lpc32xx_adc_probe(struct platform_device *pdev)
        return 0;
 }
 
-static int lpc32xx_adc_remove(struct platform_device *pdev)
-{
-       struct iio_dev *iodev = platform_get_drvdata(pdev);
-
-       iio_device_unregister(iodev);
-
-       return 0;
-}
-
 #ifdef CONFIG_OF
 static const struct of_device_id lpc32xx_adc_match[] = {
        { .compatible = "nxp,lpc3220-adc" },
@@ -211,7 +202,6 @@ MODULE_DEVICE_TABLE(of, lpc32xx_adc_match);
 
 static struct platform_driver lpc32xx_adc_driver = {
        .probe          = lpc32xx_adc_probe,
-       .remove         = lpc32xx_adc_remove,
        .driver         = {
                .name   = MOD_NAME,
                .owner  = THIS_MODULE,
index 0feea5541d02d5f98f24023ffcd4623480a0cc6b..75ddd4f801a3daf9346c186e3a7dc9510b36817a 100644 (file)
@@ -108,11 +108,6 @@ static int adt7316_i2c_probe(struct i2c_client *client,
        return adt7316_probe(&client->dev, &bus, id->name);
 }
 
-static int adt7316_i2c_remove(struct i2c_client *client)
-{
-       return adt7316_remove(&client->dev);
-}
-
 static const struct i2c_device_id adt7316_i2c_id[] = {
        { "adt7316", 0 },
        { "adt7317", 0 },
@@ -132,7 +127,6 @@ static struct i2c_driver adt7316_driver = {
                .owner  = THIS_MODULE,
        },
        .probe = adt7316_i2c_probe,
-       .remove = adt7316_i2c_remove,
        .id_table = adt7316_i2c_id,
 };
 module_i2c_driver(adt7316_driver);
index 7f4f0a8245b480090387c0f03aab24dbbb8ee178..e480abb72e4a495e772a02fd7ce7896b5f69cc43 100644 (file)
@@ -116,11 +116,6 @@ static int adt7316_spi_probe(struct spi_device *spi_dev)
        return adt7316_probe(&spi_dev->dev, &bus, spi_dev->modalias);
 }
 
-static int adt7316_spi_remove(struct spi_device *spi_dev)
-{
-       return adt7316_remove(&spi_dev->dev);
-}
-
 static const struct spi_device_id adt7316_spi_id[] = {
        { "adt7316", 0 },
        { "adt7317", 0 },
@@ -140,7 +135,6 @@ static struct spi_driver adt7316_driver = {
                .owner = THIS_MODULE,
        },
        .probe = adt7316_spi_probe,
-       .remove = adt7316_spi_remove,
        .id_table = adt7316_spi_id,
 };
 module_spi_driver(adt7316_driver);
index 80266e801d5673919533c9208241b3a0e3868d7f..16a8201228ffc18f912eb1ea69794a706096a048 100644 (file)
@@ -2166,7 +2166,7 @@ int adt7316_probe(struct device *dev, struct adt7316_bus *bus,
        if (ret)
                return -EIO;
 
-       ret = iio_device_register(indio_dev);
+       ret = devm_iio_device_register(dev, indio_dev);
        if (ret)
                return ret;
 
@@ -2177,16 +2177,6 @@ int adt7316_probe(struct device *dev, struct adt7316_bus *bus,
 }
 EXPORT_SYMBOL(adt7316_probe);
 
-int adt7316_remove(struct device *dev)
-{
-       struct iio_dev *indio_dev = dev_get_drvdata(dev);
-
-       iio_device_unregister(indio_dev);
-
-       return 0;
-}
-EXPORT_SYMBOL(adt7316_remove);
-
 MODULE_AUTHOR("Sonic Zhang <sonic.zhang@analog.com>");
 MODULE_DESCRIPTION("Analog Devices ADT7316/7/8 and ADT7516/7/9 digital"
                        " temperature sensor, ADC and DAC driver");
index 4d3efff46ae7144b8c218434dc8e8fa22ef21ae4..2dbfb499528d2be1afc954b06a67c99a574de7d9 100644 (file)
@@ -31,6 +31,5 @@ extern const struct dev_pm_ops adt7316_pm_ops;
 #define ADT7316_PM_OPS NULL
 #endif
 int adt7316_probe(struct device *dev, struct adt7316_bus *bus, const char *name);
-int adt7316_remove(struct device *dev);
 
 #endif
index 6d3d771154f3c3b45eaa9c7f667b34749f1e8301..d5d395c2e3e4088ee69dfc3484483b875f80328f 100644 (file)
@@ -167,7 +167,7 @@ static int adis16060_r_probe(struct spi_device *spi)
        indio_dev->channels = adis16060_channels;
        indio_dev->num_channels = ARRAY_SIZE(adis16060_channels);
 
-       ret = iio_device_register(indio_dev);
+       ret = devm_iio_device_register(&spi->dev, indio_dev);
        if (ret)
                return ret;
 
@@ -175,13 +175,6 @@ static int adis16060_r_probe(struct spi_device *spi)
        return 0;
 }
 
-/* fixme, confirm ordering in this function */
-static int adis16060_r_remove(struct spi_device *spi)
-{
-       iio_device_unregister(spi_get_drvdata(spi));
-       return 0;
-}
-
 static int adis16060_w_probe(struct spi_device *spi)
 {
        int ret;
@@ -211,7 +204,6 @@ static struct spi_driver adis16060_r_driver = {
                .owner = THIS_MODULE,
        },
        .probe = adis16060_r_probe,
-       .remove = adis16060_r_remove,
 };
 
 static struct spi_driver adis16060_w_driver = {
index 488e690388c948dc3cda08afdc334cebc15966ef..3660a43b5f08058ee4d2af1d313169188c1bf47b 100644 (file)
@@ -585,7 +585,7 @@ static int isl29018_probe(struct i2c_client *client,
        indio_dev->name = id->name;
        indio_dev->dev.parent = &client->dev;
        indio_dev->modes = INDIO_DIRECT_MODE;
-       err = iio_device_register(indio_dev);
+       err = devm_iio_device_register(&client->dev, indio_dev);
        if (err) {
                dev_err(&client->dev, "iio registration fails\n");
                return err;
@@ -594,16 +594,6 @@ static int isl29018_probe(struct i2c_client *client,
        return 0;
 }
 
-static int isl29018_remove(struct i2c_client *client)
-{
-       struct iio_dev *indio_dev = i2c_get_clientdata(client);
-
-       dev_dbg(&client->dev, "%s()\n", __func__);
-       iio_device_unregister(indio_dev);
-
-       return 0;
-}
-
 #ifdef CONFIG_PM_SLEEP
 static int isl29018_suspend(struct device *dev)
 {
@@ -664,7 +654,6 @@ static struct i2c_driver isl29018_driver = {
                        .of_match_table = isl29018_of_match,
                    },
        .probe   = isl29018_probe,
-       .remove  = isl29018_remove,
        .id_table = isl29018_id,
 };
 module_i2c_driver(isl29018_driver);
index 99421f90d1895f6a0691d4443c457f5aac2335db..bdb01887829635c5489f45afbd391a07de086288 100644 (file)
@@ -624,10 +624,17 @@ static const struct i2c_device_id hmc5843_id[] = {
 };
 MODULE_DEVICE_TABLE(i2c, hmc5843_id);
 
+static const struct of_device_id hmc5843_of_match[] = {
+       { .compatible = "honeywell,hmc5843" },
+       {}
+};
+MODULE_DEVICE_TABLE(of, hmc5843_of_match);
+
 static struct i2c_driver hmc5843_driver = {
        .driver = {
                .name   = "hmc5843",
                .pm     = HMC5843_PM_OPS,
+               .of_match_table = of_match_ptr(hmc5843_of_match),
        },
        .id_table       = hmc5843_id,
        .probe          = hmc5843_probe,
index 62d30179301fa52e0d6b9322d553371641b952e2..36eedd8a0ea9815c168889d3ed614597a93847a6 100644 (file)
@@ -131,7 +131,7 @@ static int ad2s1200_probe(struct spi_device *spi)
        indio_dev->num_channels = ARRAY_SIZE(ad2s1200_channels);
        indio_dev->name = spi_get_device_id(spi)->name;
 
-       ret = iio_device_register(indio_dev);
+       ret = devm_iio_device_register(&spi->dev, indio_dev);
        if (ret)
                return ret;
 
@@ -142,13 +142,6 @@ static int ad2s1200_probe(struct spi_device *spi)
        return 0;
 }
 
-static int ad2s1200_remove(struct spi_device *spi)
-{
-       iio_device_unregister(spi_get_drvdata(spi));
-
-       return 0;
-}
-
 static const struct spi_device_id ad2s1200_id[] = {
        { "ad2s1200" },
        { "ad2s1205" },
@@ -162,7 +155,6 @@ static struct spi_driver ad2s1200_driver = {
                .owner = THIS_MODULE,
        },
        .probe = ad2s1200_probe,
-       .remove = ad2s1200_remove,
        .id_table = ad2s1200_id,
 };
 module_spi_driver(ad2s1200_driver);
index 4f945d3ed49fc7a511affdc307ea84aff60565cb..4cc165887b091685d5ada87624156c2dc0b98626 100644 (file)
 
 /* Accel 3D (200073) */
 #define HID_USAGE_SENSOR_ACCEL_3D                              0x200073
+#define HID_USAGE_SENSOR_DATA_ACCELERATION                     0x200452
 #define HID_USAGE_SENSOR_ACCEL_X_AXIS                          0x200453
 #define HID_USAGE_SENSOR_ACCEL_Y_AXIS                          0x200454
 #define HID_USAGE_SENSOR_ACCEL_Z_AXIS                          0x200455
 
 /* ALS (200041) */
 #define HID_USAGE_SENSOR_ALS                                   0x200041
+#define HID_USAGE_SENSOR_DATA_LIGHT                            0x2004d0
 #define HID_USAGE_SENSOR_LIGHT_ILLUM                           0x2004d1
 
 /* Gyro 3D: (200076) */
 #define HID_USAGE_SENSOR_GYRO_3D                               0x200076
+#define HID_USAGE_SENSOR_DATA_ANGL_VELOCITY                    0x200456
 #define HID_USAGE_SENSOR_ANGL_VELOCITY_X_AXIS                  0x200457
 #define HID_USAGE_SENSOR_ANGL_VELOCITY_Y_AXIS                  0x200458
 #define HID_USAGE_SENSOR_ANGL_VELOCITY_Z_AXIS                  0x200459
 
 /* ORIENTATION: Compass 3D: (200083) */
 #define HID_USAGE_SENSOR_COMPASS_3D                            0x200083
+#define HID_USAGE_SENSOR_DATA_ORIENTATION                      0x200470
 #define HID_USAGE_SENSOR_ORIENT_MAGN_HEADING                   0x200471
 #define HID_USAGE_SENSOR_ORIENT_MAGN_HEADING_X                 0x200472
 #define HID_USAGE_SENSOR_ORIENT_MAGN_HEADING_Y                 0x200473
 #define HID_USAGE_SENSOR_PROP_REPORT_STATE                     0x200316
 #define HID_USAGE_SENSOR_PROY_POWER_STATE                      0x200319
 
+/* Per data field properties */
+#define HID_USAGE_SENSOR_DATA_MOD_NONE                                 0x00
+#define HID_USAGE_SENSOR_DATA_MOD_CHANGE_SENSITIVITY_ABS               0x1000
+
 #endif
index 256a90a1bea681fde6473e2d5d74bc93ea868a87..5b125fd554e42dcf70fb27defd8dbfa752ab82b5 100644 (file)
@@ -490,32 +490,12 @@ struct iio_dev {
 #endif
 };
 
-/**
- * iio_find_channel_from_si() - get channel from its scan index
- * @indio_dev:         device
- * @si:                        scan index to match
- */
 const struct iio_chan_spec
 *iio_find_channel_from_si(struct iio_dev *indio_dev, int si);
-
-/**
- * iio_device_register() - register a device with the IIO subsystem
- * @indio_dev:         Device structure filled by the device driver
- **/
 int iio_device_register(struct iio_dev *indio_dev);
-
-/**
- * iio_device_unregister() - unregister a device from the IIO subsystem
- * @indio_dev:         Device structure representing the device.
- **/
 void iio_device_unregister(struct iio_dev *indio_dev);
-
-/**
- * iio_push_event() - try to add event to the list for userspace reading
- * @indio_dev:         IIO device structure
- * @ev_code:           What event
- * @timestamp:         When the event occurred
- **/
+int devm_iio_device_register(struct device *dev, struct iio_dev *indio_dev);
+void devm_iio_device_unregister(struct device *dev, struct iio_dev *indio_dev);
 int iio_push_event(struct iio_dev *indio_dev, u64 ev_code, s64 timestamp);
 
 extern struct bus_type iio_bus_type;
@@ -579,10 +559,6 @@ static inline void *iio_device_get_drvdata(struct iio_dev *indio_dev)
 
 /* Can we make this smaller? */
 #define IIO_ALIGN L1_CACHE_BYTES
-/**
- * iio_device_alloc() - allocate an iio_dev from a driver
- * @sizeof_priv:       Space to allocate for private structure.
- **/
 struct iio_dev *iio_device_alloc(int sizeof_priv);
 
 static inline void *iio_priv(const struct iio_dev *indio_dev)
@@ -596,64 +572,11 @@ static inline struct iio_dev *iio_priv_to_dev(void *priv)
                                  ALIGN(sizeof(struct iio_dev), IIO_ALIGN));
 }
 
-/**
- * iio_device_free() - free an iio_dev from a driver
- * @indio_dev:                 the iio_dev associated with the device
- **/
 void iio_device_free(struct iio_dev *indio_dev);
-
-/**
- * devm_iio_device_alloc - Resource-managed iio_device_alloc()
- * @dev:               Device to allocate iio_dev for
- * @sizeof_priv:       Space to allocate for private structure.
- *
- * Managed iio_device_alloc.  iio_dev allocated with this function is
- * automatically freed on driver detach.
- *
- * If an iio_dev allocated with this function needs to be freed separately,
- * devm_iio_device_free() must be used.
- *
- * RETURNS:
- * Pointer to allocated iio_dev on success, NULL on failure.
- */
 struct iio_dev *devm_iio_device_alloc(struct device *dev, int sizeof_priv);
-
-/**
- * devm_iio_device_free - Resource-managed iio_device_free()
- * @dev:               Device this iio_dev belongs to
- * @indio_dev:                 the iio_dev associated with the device
- *
- * Free iio_dev allocated with devm_iio_device_alloc().
- */
 void devm_iio_device_free(struct device *dev, struct iio_dev *indio_dev);
-
-/**
- * devm_iio_trigger_alloc - Resource-managed iio_trigger_alloc()
- * @dev:               Device to allocate iio_trigger for
- * @fmt:               trigger name format. If it includes format
- *                     specifiers, the additional arguments following
- *                     format are formatted and inserted in the resulting
- *                     string replacing their respective specifiers.
- *
- * Managed iio_trigger_alloc.  iio_trigger allocated with this function is
- * automatically freed on driver detach.
- *
- * If an iio_trigger allocated with this function needs to be freed separately,
- * devm_iio_trigger_free() must be used.
- *
- * RETURNS:
- * Pointer to allocated iio_trigger on success, NULL on failure.
- */
 struct iio_trigger *devm_iio_trigger_alloc(struct device *dev,
                                                const char *fmt, ...);
-
-/**
- * devm_iio_trigger_free - Resource-managed iio_trigger_free()
- * @dev:               Device this iio_dev belongs to
- * @iio_trig:          the iio_trigger associated with the device
- *
- * Free iio_trigger allocated with devm_iio_trigger_alloc().
- */
 void devm_iio_trigger_free(struct device *dev, struct iio_trigger *iio_trig);
 
 /**