diff options
author | Guenter Roeck <linux@roeck-us.net> | 2013-02-04 15:26:00 -0500 |
---|---|---|
committer | Jonathan Cameron <jic23@kernel.org> | 2013-02-06 14:23:52 -0500 |
commit | 5aa57f0a655276f62683c0cc714cd6328d98e08a (patch) | |
tree | df06afdc9f598c3da0671a296d2319191e46be2b | |
parent | 860c9c54272deaab43b40dbe416becb34abd344f (diff) |
iio: Update iio_channel_get API to use consumer device pointer as argument
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>
-rw-r--r-- | drivers/extcon/extcon-adc-jack.c | 3 | ||||
-rw-r--r-- | drivers/iio/inkern.c | 11 | ||||
-rw-r--r-- | drivers/power/generic-adc-battery.c | 4 | ||||
-rw-r--r-- | drivers/power/lp8788-charger.c | 8 | ||||
-rw-r--r-- | include/linux/iio/consumer.h | 5 |
5 files changed, 20 insertions, 11 deletions
diff --git a/drivers/extcon/extcon-adc-jack.c b/drivers/extcon/extcon-adc-jack.c index eda2a1aa4adb..d0233cd18ffa 100644 --- a/drivers/extcon/extcon-adc-jack.c +++ b/drivers/extcon/extcon-adc-jack.c | |||
@@ -135,8 +135,7 @@ static int adc_jack_probe(struct platform_device *pdev) | |||
135 | ; | 135 | ; |
136 | data->num_conditions = i; | 136 | data->num_conditions = i; |
137 | 137 | ||
138 | data->chan = iio_channel_get(dev_name(&pdev->dev), | 138 | data->chan = iio_channel_get(&pdev->dev, pdata->consumer_channel); |
139 | pdata->consumer_channel); | ||
140 | if (IS_ERR(data->chan)) { | 139 | if (IS_ERR(data->chan)) { |
141 | err = PTR_ERR(data->chan); | 140 | err = PTR_ERR(data->chan); |
142 | goto out; | 141 | goto out; |
diff --git a/drivers/iio/inkern.c b/drivers/iio/inkern.c index c42aba6817e8..b289915b8469 100644 --- a/drivers/iio/inkern.c +++ b/drivers/iio/inkern.c | |||
@@ -93,7 +93,8 @@ static const struct iio_chan_spec | |||
93 | } | 93 | } |
94 | 94 | ||
95 | 95 | ||
96 | struct iio_channel *iio_channel_get(const char *name, const char *channel_name) | 96 | static struct iio_channel *iio_channel_get_sys(const char *name, |
97 | const char *channel_name) | ||
97 | { | 98 | { |
98 | struct iio_map_internal *c_i = NULL, *c = NULL; | 99 | struct iio_map_internal *c_i = NULL, *c = NULL; |
99 | struct iio_channel *channel; | 100 | struct iio_channel *channel; |
@@ -144,6 +145,14 @@ error_no_mem: | |||
144 | iio_device_put(c->indio_dev); | 145 | iio_device_put(c->indio_dev); |
145 | return ERR_PTR(err); | 146 | return ERR_PTR(err); |
146 | } | 147 | } |
148 | |||
149 | struct iio_channel *iio_channel_get(struct device *dev, | ||
150 | const char *channel_name) | ||
151 | { | ||
152 | const char *name = dev ? dev_name(dev) : NULL; | ||
153 | |||
154 | return iio_channel_get_sys(name, channel_name); | ||
155 | } | ||
147 | EXPORT_SYMBOL_GPL(iio_channel_get); | 156 | EXPORT_SYMBOL_GPL(iio_channel_get); |
148 | 157 | ||
149 | void iio_channel_release(struct iio_channel *channel) | 158 | void iio_channel_release(struct iio_channel *channel) |
diff --git a/drivers/power/generic-adc-battery.c b/drivers/power/generic-adc-battery.c index 32ce17e235c0..42733c4dcb0e 100644 --- a/drivers/power/generic-adc-battery.c +++ b/drivers/power/generic-adc-battery.c | |||
@@ -287,8 +287,8 @@ static int gab_probe(struct platform_device *pdev) | |||
287 | * based on the channel supported by consumer device. | 287 | * based on the channel supported by consumer device. |
288 | */ | 288 | */ |
289 | for (chan = 0; chan < ARRAY_SIZE(gab_chan_name); chan++) { | 289 | for (chan = 0; chan < ARRAY_SIZE(gab_chan_name); chan++) { |
290 | adc_bat->channel[chan] = iio_channel_get(dev_name(&pdev->dev), | 290 | adc_bat->channel[chan] = iio_channel_get(&pdev->dev, |
291 | gab_chan_name[chan]); | 291 | gab_chan_name[chan]); |
292 | if (IS_ERR(adc_bat->channel[chan])) { | 292 | if (IS_ERR(adc_bat->channel[chan])) { |
293 | ret = PTR_ERR(adc_bat->channel[chan]); | 293 | ret = PTR_ERR(adc_bat->channel[chan]); |
294 | } else { | 294 | } else { |
diff --git a/drivers/power/lp8788-charger.c b/drivers/power/lp8788-charger.c index 22b6407c9ca9..27889088e78e 100644 --- a/drivers/power/lp8788-charger.c +++ b/drivers/power/lp8788-charger.c | |||
@@ -580,7 +580,7 @@ static void lp8788_irq_unregister(struct platform_device *pdev, | |||
580 | } | 580 | } |
581 | } | 581 | } |
582 | 582 | ||
583 | static void lp8788_setup_adc_channel(const char *consumer_name, | 583 | static void lp8788_setup_adc_channel(struct device *dev, |
584 | struct lp8788_charger *pchg) | 584 | struct lp8788_charger *pchg) |
585 | { | 585 | { |
586 | struct lp8788_charger_platform_data *pdata = pchg->pdata; | 586 | struct lp8788_charger_platform_data *pdata = pchg->pdata; |
@@ -590,11 +590,11 @@ static void lp8788_setup_adc_channel(const char *consumer_name, | |||
590 | return; | 590 | return; |
591 | 591 | ||
592 | /* ADC channel for battery voltage */ | 592 | /* ADC channel for battery voltage */ |
593 | chan = iio_channel_get(consumer_name, pdata->adc_vbatt); | 593 | chan = iio_channel_get(dev, pdata->adc_vbatt); |
594 | pchg->chan[LP8788_VBATT] = IS_ERR(chan) ? NULL : chan; | 594 | pchg->chan[LP8788_VBATT] = IS_ERR(chan) ? NULL : chan; |
595 | 595 | ||
596 | /* ADC channel for battery temperature */ | 596 | /* ADC channel for battery temperature */ |
597 | chan = iio_channel_get(consumer_name, pdata->adc_batt_temp); | 597 | chan = iio_channel_get(dev, pdata->adc_batt_temp); |
598 | pchg->chan[LP8788_BATT_TEMP] = IS_ERR(chan) ? NULL : chan; | 598 | pchg->chan[LP8788_BATT_TEMP] = IS_ERR(chan) ? NULL : chan; |
599 | } | 599 | } |
600 | 600 | ||
@@ -704,7 +704,7 @@ static int lp8788_charger_probe(struct platform_device *pdev) | |||
704 | if (ret) | 704 | if (ret) |
705 | return ret; | 705 | return ret; |
706 | 706 | ||
707 | lp8788_setup_adc_channel(pdev->name, pchg); | 707 | lp8788_setup_adc_channel(&pdev->dev, pchg); |
708 | 708 | ||
709 | ret = lp8788_psy_register(pdev, pchg); | 709 | ret = lp8788_psy_register(pdev, pchg); |
710 | if (ret) | 710 | if (ret) |
diff --git a/include/linux/iio/consumer.h b/include/linux/iio/consumer.h index a85787ac66ab..833926c91aa8 100644 --- a/include/linux/iio/consumer.h +++ b/include/linux/iio/consumer.h | |||
@@ -31,14 +31,15 @@ struct iio_channel { | |||
31 | 31 | ||
32 | /** | 32 | /** |
33 | * iio_channel_get() - get description of all that is needed to access channel. | 33 | * iio_channel_get() - get description of all that is needed to access channel. |
34 | * @name: Unique name of the device as provided in the iio_map | 34 | * @dev: Pointer to consumer device. Device name must match |
35 | * the name of the device as provided in the iio_map | ||
35 | * with which the desired provider to consumer mapping | 36 | * with which the desired provider to consumer mapping |
36 | * was registered. | 37 | * was registered. |
37 | * @consumer_channel: Unique name to identify the channel on the consumer | 38 | * @consumer_channel: Unique name to identify the channel on the consumer |
38 | * side. This typically describes the channels use within | 39 | * side. This typically describes the channels use within |
39 | * the consumer. E.g. 'battery_voltage' | 40 | * the consumer. E.g. 'battery_voltage' |
40 | */ | 41 | */ |
41 | struct iio_channel *iio_channel_get(const char *name, | 42 | struct iio_channel *iio_channel_get(struct device *dev, |
42 | const char *consumer_channel); | 43 | const char *consumer_channel); |
43 | 44 | ||
44 | /** | 45 | /** |