Skip to content

Commit 5aa57f0

Browse files
groeckjic23
authored andcommitted
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>
1 parent 860c9c5 commit 5aa57f0

5 files changed

Lines changed: 20 additions & 11 deletions

File tree

‎drivers/extcon/extcon-adc-jack.c‎

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -135,8 +135,7 @@ static int adc_jack_probe(struct platform_device *pdev)
135135
;
136136
data->num_conditions = i;
137137

138-
data->chan = iio_channel_get(dev_name(&pdev->dev),
139-
pdata->consumer_channel);
138+
data->chan = iio_channel_get(&pdev->dev, pdata->consumer_channel);
140139
if (IS_ERR(data->chan)) {
141140
err = PTR_ERR(data->chan);
142141
goto out;

‎drivers/iio/inkern.c‎

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -93,7 +93,8 @@ static const struct iio_chan_spec
9393
}
9494

9595

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)
9798
{
9899
struct iio_map_internal *c_i = NULL, *c = NULL;
99100
struct iio_channel *channel;
@@ -144,6 +145,14 @@ struct iio_channel *iio_channel_get(const char *name, const char *channel_name)
144145
iio_device_put(c->indio_dev);
145146
return ERR_PTR(err);
146147
}
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+
}
147156
EXPORT_SYMBOL_GPL(iio_channel_get);
148157

149158
void iio_channel_release(struct iio_channel *channel)

‎drivers/power/generic-adc-battery.c‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -287,8 +287,8 @@ static int gab_probe(struct platform_device *pdev)
287287
* based on the channel supported by consumer device.
288288
*/
289289
for (chan = 0; chan < ARRAY_SIZE(gab_chan_name); chan++) {
290-
adc_bat->channel[chan] = iio_channel_get(dev_name(&pdev->dev),
291-
gab_chan_name[chan]);
290+
adc_bat->channel[chan] = iio_channel_get(&pdev->dev,
291+
gab_chan_name[chan]);
292292
if (IS_ERR(adc_bat->channel[chan])) {
293293
ret = PTR_ERR(adc_bat->channel[chan]);
294294
} else {

‎drivers/power/lp8788-charger.c‎

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -580,7 +580,7 @@ static void lp8788_irq_unregister(struct platform_device *pdev,
580580
}
581581
}
582582

583-
static void lp8788_setup_adc_channel(const char *consumer_name,
583+
static void lp8788_setup_adc_channel(struct device *dev,
584584
struct lp8788_charger *pchg)
585585
{
586586
struct lp8788_charger_platform_data *pdata = pchg->pdata;
@@ -590,11 +590,11 @@ static void lp8788_setup_adc_channel(const char *consumer_name,
590590
return;
591591

592592
/* ADC channel for battery voltage */
593-
chan = iio_channel_get(consumer_name, pdata->adc_vbatt);
593+
chan = iio_channel_get(dev, pdata->adc_vbatt);
594594
pchg->chan[LP8788_VBATT] = IS_ERR(chan) ? NULL : chan;
595595

596596
/* 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);
598598
pchg->chan[LP8788_BATT_TEMP] = IS_ERR(chan) ? NULL : chan;
599599
}
600600

@@ -704,7 +704,7 @@ static int lp8788_charger_probe(struct platform_device *pdev)
704704
if (ret)
705705
return ret;
706706

707-
lp8788_setup_adc_channel(pdev->name, pchg);
707+
lp8788_setup_adc_channel(&pdev->dev, pchg);
708708

709709
ret = lp8788_psy_register(pdev, pchg);
710710
if (ret)

‎include/linux/iio/consumer.h‎

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,14 +31,15 @@ struct iio_channel {
3131

3232
/**
3333
* 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
3536
* with which the desired provider to consumer mapping
3637
* was registered.
3738
* @consumer_channel: Unique name to identify the channel on the consumer
3839
* side. This typically describes the channels use within
3940
* the consumer. E.g. 'battery_voltage'
4041
*/
41-
struct iio_channel *iio_channel_get(const char *name,
42+
struct iio_channel *iio_channel_get(struct device *dev,
4243
const char *consumer_channel);
4344

4445
/**

0 commit comments

Comments
 (0)