iio: Update iio_channel_get API to use consumer device pointer as argument
authorGuenter Roeck <linux@roeck-us.net>
Mon, 4 Feb 2013 20:26:00 +0000 (20:26 +0000)
committerJonathan Cameron <jic23@kernel.org>
Wed, 6 Feb 2013 19:23:52 +0000 (19:23 +0000)
For iio_channel_get to work with OF based configurations, it needs the
consumer device pointer instead of the consumer device name as argument.

Signed-off-by: Guenter Roeck <linux@roeck-us.net>
Acked-by: Anton Vorontsov <anton@enomsg.org>
Acked-by: Chanwoo Choi <cw00.choi@samsung.com>
Signed-off-by: Jonathan Cameron <jic23@kernel.org>
drivers/extcon/extcon-adc-jack.c
drivers/iio/inkern.c
drivers/power/generic-adc-battery.c
drivers/power/lp8788-charger.c
include/linux/iio/consumer.h

index eda2a1aa4adb1919a3563d5be2e5d3e773136658..d0233cd18ffa71b37bb7b0dbc2434cebac964d90 100644 (file)
@@ -135,8 +135,7 @@ static int adc_jack_probe(struct platform_device *pdev)
                ;
        data->num_conditions = i;
 
-       data->chan = iio_channel_get(dev_name(&pdev->dev),
-                       pdata->consumer_channel);
+       data->chan = iio_channel_get(&pdev->dev, pdata->consumer_channel);
        if (IS_ERR(data->chan)) {
                err = PTR_ERR(data->chan);
                goto out;
index c42aba6817e8ba09df9e455fa8fb7ea8bc5ccfa9..b289915b8469774664ccd181cc0fa9883dda35d8 100644 (file)
@@ -93,7 +93,8 @@ static const struct iio_chan_spec
 }
 
 
-struct iio_channel *iio_channel_get(const char *name, const char *channel_name)
+static struct iio_channel *iio_channel_get_sys(const char *name,
+                                              const char *channel_name)
 {
        struct iio_map_internal *c_i = NULL, *c = NULL;
        struct iio_channel *channel;
@@ -144,6 +145,14 @@ error_no_mem:
        iio_device_put(c->indio_dev);
        return ERR_PTR(err);
 }
+
+struct iio_channel *iio_channel_get(struct device *dev,
+                                   const char *channel_name)
+{
+       const char *name = dev ? dev_name(dev) : NULL;
+
+       return iio_channel_get_sys(name, channel_name);
+}
 EXPORT_SYMBOL_GPL(iio_channel_get);
 
 void iio_channel_release(struct iio_channel *channel)
index 32ce17e235c08ef3644c81573a22ad37417e50b2..42733c4dcb0eb1ea0fbc3e6c861c232fbaa722df 100644 (file)
@@ -287,8 +287,8 @@ static int gab_probe(struct platform_device *pdev)
         * based on the channel supported by consumer device.
         */
        for (chan = 0; chan < ARRAY_SIZE(gab_chan_name); chan++) {
-               adc_bat->channel[chan] = iio_channel_get(dev_name(&pdev->dev),
-                                               gab_chan_name[chan]);
+               adc_bat->channel[chan] = iio_channel_get(&pdev->dev,
+                                                        gab_chan_name[chan]);
                if (IS_ERR(adc_bat->channel[chan])) {
                        ret = PTR_ERR(adc_bat->channel[chan]);
                } else {
index 22b6407c9ca9949d65b0c719e895549e8bb3e902..27889088e78e31894895008d984bf1e66bdf8f63 100644 (file)
@@ -580,7 +580,7 @@ static void lp8788_irq_unregister(struct platform_device *pdev,
        }
 }
 
-static void lp8788_setup_adc_channel(const char *consumer_name,
+static void lp8788_setup_adc_channel(struct device *dev,
                                struct lp8788_charger *pchg)
 {
        struct lp8788_charger_platform_data *pdata = pchg->pdata;
@@ -590,11 +590,11 @@ static void lp8788_setup_adc_channel(const char *consumer_name,
                return;
 
        /* ADC channel for battery voltage */
-       chan = iio_channel_get(consumer_name, pdata->adc_vbatt);
+       chan = iio_channel_get(dev, pdata->adc_vbatt);
        pchg->chan[LP8788_VBATT] = IS_ERR(chan) ? NULL : chan;
 
        /* ADC channel for battery temperature */
-       chan = iio_channel_get(consumer_name, pdata->adc_batt_temp);
+       chan = iio_channel_get(dev, pdata->adc_batt_temp);
        pchg->chan[LP8788_BATT_TEMP] = IS_ERR(chan) ? NULL : chan;
 }
 
@@ -704,7 +704,7 @@ static int lp8788_charger_probe(struct platform_device *pdev)
        if (ret)
                return ret;
 
-       lp8788_setup_adc_channel(pdev->name, pchg);
+       lp8788_setup_adc_channel(&pdev->dev, pchg);
 
        ret = lp8788_psy_register(pdev, pchg);
        if (ret)
index a85787ac66abd1cbcdfa874aa26dd4f7eb279d7f..833926c91aa84dff36403b814a046267dd968557 100644 (file)
@@ -31,14 +31,15 @@ struct iio_channel {
 
 /**
  * iio_channel_get() - get description of all that is needed to access channel.
- * @name:              Unique name of the device as provided in the iio_map
+ * @dev:               Pointer to consumer device. Device name must match
+ *                     the name of the device as provided in the iio_map
  *                     with which the desired provider to consumer mapping
  *                     was registered.
  * @consumer_channel:  Unique name to identify the channel on the consumer
  *                     side. This typically describes the channels use within
  *                     the consumer. E.g. 'battery_voltage'
  */
-struct iio_channel *iio_channel_get(const char *name,
+struct iio_channel *iio_channel_get(struct device *dev,
                                    const char *consumer_channel);
 
 /**