Commit 34b6eb89 authored by Nuno Sá's avatar Nuno Sá Committed by Jonathan Cameron

iio: adc: at91-sama5d2_adc: convert to device properties

Make the conversion to firmware agnostic device properties. As part of
the conversion the IIO inkern interface 'of_xlate()' is also converted to
'fwnode_xlate()'. The goal is to completely drop 'of_xlate' and hence OF
dependencies from IIO.
Signed-off-by: default avatarNuno Sá <nuno.sa@analog.com>
Reviewed-by: default avatarAndy Shevchenko <andy.shevchenko@gmail.com>
Reviewed-by: default avatarClaudiu Beznea <claudiu.beznea@microchip.com>
Link: https://lore.kernel.org/r/20220715122903.332535-10-nuno.sa@analog.comSigned-off-by: default avatarJonathan Cameron <Jonathan.Cameron@huawei.com>
parent dec7e2c8
...@@ -16,8 +16,9 @@ ...@@ -16,8 +16,9 @@
#include <linux/interrupt.h> #include <linux/interrupt.h>
#include <linux/io.h> #include <linux/io.h>
#include <linux/module.h> #include <linux/module.h>
#include <linux/of_device.h> #include <linux/mod_devicetable.h>
#include <linux/platform_device.h> #include <linux/platform_device.h>
#include <linux/property.h>
#include <linux/sched.h> #include <linux/sched.h>
#include <linux/units.h> #include <linux/units.h>
#include <linux/wait.h> #include <linux/wait.h>
...@@ -763,8 +764,8 @@ at91_adc_chan_get(struct iio_dev *indio_dev, int chan) ...@@ -763,8 +764,8 @@ at91_adc_chan_get(struct iio_dev *indio_dev, int chan)
return indio_dev->channels + index; return indio_dev->channels + index;
} }
static inline int at91_adc_of_xlate(struct iio_dev *indio_dev, static inline int at91_adc_fwnode_xlate(struct iio_dev *indio_dev,
const struct of_phandle_args *iiospec) const struct fwnode_reference_args *iiospec)
{ {
return at91_adc_chan_xlate(indio_dev, iiospec->args[0]); return at91_adc_chan_xlate(indio_dev, iiospec->args[0]);
} }
...@@ -2213,7 +2214,7 @@ static const struct iio_info at91_adc_info = { ...@@ -2213,7 +2214,7 @@ static const struct iio_info at91_adc_info = {
.read_raw = &at91_adc_read_raw, .read_raw = &at91_adc_read_raw,
.write_raw = &at91_adc_write_raw, .write_raw = &at91_adc_write_raw,
.update_scan_mode = &at91_adc_update_scan_mode, .update_scan_mode = &at91_adc_update_scan_mode,
.of_xlate = &at91_adc_of_xlate, .fwnode_xlate = &at91_adc_fwnode_xlate,
.hwfifo_set_watermark = &at91_adc_set_watermark, .hwfifo_set_watermark = &at91_adc_set_watermark,
}; };
...@@ -2306,6 +2307,7 @@ static int at91_adc_temp_sensor_init(struct at91_adc_state *st, ...@@ -2306,6 +2307,7 @@ static int at91_adc_temp_sensor_init(struct at91_adc_state *st,
static int at91_adc_probe(struct platform_device *pdev) static int at91_adc_probe(struct platform_device *pdev)
{ {
struct device *dev = &pdev->dev;
struct iio_dev *indio_dev; struct iio_dev *indio_dev;
struct at91_adc_state *st; struct at91_adc_state *st;
struct resource *res; struct resource *res;
...@@ -2319,7 +2321,7 @@ static int at91_adc_probe(struct platform_device *pdev) ...@@ -2319,7 +2321,7 @@ static int at91_adc_probe(struct platform_device *pdev)
st = iio_priv(indio_dev); st = iio_priv(indio_dev);
st->indio_dev = indio_dev; st->indio_dev = indio_dev;
st->soc_info.platform = of_device_get_match_data(&pdev->dev); st->soc_info.platform = device_get_match_data(dev);
ret = at91_adc_temp_sensor_init(st, &pdev->dev); ret = at91_adc_temp_sensor_init(st, &pdev->dev);
/* Don't register temperature channel if initialization failed. */ /* Don't register temperature channel if initialization failed. */
...@@ -2343,34 +2345,32 @@ static int at91_adc_probe(struct platform_device *pdev) ...@@ -2343,34 +2345,32 @@ static int at91_adc_probe(struct platform_device *pdev)
st->oversampling_ratio = 1; st->oversampling_ratio = 1;
ret = of_property_read_u32(pdev->dev.of_node, ret = device_property_read_u32(dev, "atmel,min-sample-rate-hz",
"atmel,min-sample-rate-hz", &st->soc_info.min_sample_rate);
&st->soc_info.min_sample_rate);
if (ret) { if (ret) {
dev_err(&pdev->dev, dev_err(&pdev->dev,
"invalid or missing value for atmel,min-sample-rate-hz\n"); "invalid or missing value for atmel,min-sample-rate-hz\n");
return ret; return ret;
} }
ret = of_property_read_u32(pdev->dev.of_node, ret = device_property_read_u32(dev, "atmel,max-sample-rate-hz",
"atmel,max-sample-rate-hz", &st->soc_info.max_sample_rate);
&st->soc_info.max_sample_rate);
if (ret) { if (ret) {
dev_err(&pdev->dev, dev_err(&pdev->dev,
"invalid or missing value for atmel,max-sample-rate-hz\n"); "invalid or missing value for atmel,max-sample-rate-hz\n");
return ret; return ret;
} }
ret = of_property_read_u32(pdev->dev.of_node, "atmel,startup-time-ms", ret = device_property_read_u32(dev, "atmel,startup-time-ms",
&st->soc_info.startup_time); &st->soc_info.startup_time);
if (ret) { if (ret) {
dev_err(&pdev->dev, dev_err(&pdev->dev,
"invalid or missing value for atmel,startup-time-ms\n"); "invalid or missing value for atmel,startup-time-ms\n");
return ret; return ret;
} }
ret = of_property_read_u32(pdev->dev.of_node, ret = device_property_read_u32(dev, "atmel,trigger-edge-type",
"atmel,trigger-edge-type", &edge_type); &edge_type);
if (ret) { if (ret) {
dev_dbg(&pdev->dev, dev_dbg(&pdev->dev,
"atmel,trigger-edge-type not specified, only software trigger available\n"); "atmel,trigger-edge-type not specified, only software trigger available\n");
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment