History

iio: at91_adc: remove usage of iio_priv_to_dev() helper

We may want to get rid of the iio_priv_to_dev() helper. The reason is that we will hide some of the members of the iio_dev structure (to prevent drivers from accessing them directly), and that will also mean hiding the implementation of the iio_priv_to_dev() helper inside the IIO core. Hiding the implementation of iio_priv_to_dev() implies that some fast-paths may not be fast anymore, so a general idea is to try to get rid of the iio_priv_to_dev() altogether. The iio_priv() helper won't be affected by the rework, as the iio_dev struct will keep a reference to the private information. For this driver, not using iio_priv_to_dev(), means reworking some paths to pass the iio device and using iio_priv() to access the private information.

Alexandru Ardelean committed 6 years ago

Commit 044d4061 parent 07b6c9d1 file · +15 −15Browse files

Unified · Split

drivers/iio/adc/at91_adc.c+15−15
@@ -287,13 +287,13 @@ static void handle_adc_eoc_trigger(int irq, struct iio_dev *idev) · 286 unmodified lines
287 }287 }
288}288}
289 289
290static int at91_ts_sample(struct at91_adc_state *st)290static int at91_ts_sample(struct iio_dev *idev)
291{291{
292 struct at91_adc_state *st = iio_priv(idev);
292 unsigned int xscale, yscale, reg, z1, z2;293 unsigned int xscale, yscale, reg, z1, z2;
293 unsigned int x, y, pres, xpos, ypos;294 unsigned int x, y, pres, xpos, ypos;
294 unsigned int rxp = 1;295 unsigned int rxp = 1;
295 unsigned int factor = 1000;296 unsigned int factor = 1000;
296 struct iio_dev *idev = iio_priv_to_dev(st);
297 297
298 unsigned int xyz_mask_bits = st->res;298 unsigned int xyz_mask_bits = st->res;
299 unsigned int xyz_mask = (1 << xyz_mask_bits) - 1;299 unsigned int xyz_mask = (1 << xyz_mask_bits) - 1;
@@ -449,7 +449,7 @@ static irqreturn_t at91_adc_9x5_interrupt(int irq, void *private) · 149 unmodified lines
449 449
450 if (status & AT91_ADC_ISR_PENS) {450 if (status & AT91_ADC_ISR_PENS) {
451 /* validate data by pen contact */451 /* validate data by pen contact */
452 at91_ts_sample(st);452 at91_ts_sample(idev);
453 } else {453 } else {
454 /* triggered by event that is no pen contact, just read454 /* triggered by event that is no pen contact, just read
455 * them to clean the interrupt and discard all.455 * them to clean the interrupt and discard all.
@@ -737,10 +737,10 @@ static int at91_adc_read_raw(struct iio_dev *idev, · 281 unmodified lines
737 return -EINVAL;737 return -EINVAL;
738}738}
739 739
740static int at91_adc_of_get_resolution(struct at91_adc_state *st,740static int at91_adc_of_get_resolution(struct iio_dev *idev,
741 struct platform_device *pdev)741 struct platform_device *pdev)
742{742{
743 struct iio_dev *idev = iio_priv_to_dev(st);743 struct at91_adc_state *st = iio_priv(idev);
744 struct device_node *np = pdev->dev.of_node;744 struct device_node *np = pdev->dev.of_node;
745 int count, i, ret = 0;745 int count, i, ret = 0;
746 char *res_name, *s;746 char *res_name, *s;
@@ -866,10 +866,10 @@ static int at91_adc_probe_dt_ts(struct device_node *node, · 119 unmodified lines
866 }866 }
867}867}
868 868
869static int at91_adc_probe_dt(struct at91_adc_state *st,869static int at91_adc_probe_dt(struct iio_dev *idev,
870 struct platform_device *pdev)870 struct platform_device *pdev)
871{871{
872 struct iio_dev *idev = iio_priv_to_dev(st);872 struct at91_adc_state *st = iio_priv(idev);
873 struct device_node *node = pdev->dev.of_node;873 struct device_node *node = pdev->dev.of_node;
874 struct device_node *trig_node;874 struct device_node *trig_node;
875 int i = 0, ret;875 int i = 0, ret;
@@ -910,7 +910,7 @@ static int at91_adc_probe_dt(struct at91_adc_state *st, · 34 unmodified lines
910 }910 }
911 st->vref_mv = prop;911 st->vref_mv = prop;
912 912
913 ret = at91_adc_of_get_resolution(st, pdev);913 ret = at91_adc_of_get_resolution(idev, pdev);
914 if (ret)914 if (ret)
915 goto error_ret;915 goto error_ret;
916 916
@@ -1010,9 +1010,9 @@ static void atmel_ts_close(struct input_dev *dev) · 93 unmodified lines
1010 at91_adc_writel(st, AT91_ADC_IDR, AT91RL_ADC_IER_PEN);1010 at91_adc_writel(st, AT91_ADC_IDR, AT91RL_ADC_IER_PEN);
1011}1011}
1012 1012
1013static int at91_ts_hw_init(struct at91_adc_state *st, u32 adc_clk_khz)1013static int at91_ts_hw_init(struct iio_dev *idev, u32 adc_clk_khz)
1014{1014{
1015 struct iio_dev *idev = iio_priv_to_dev(st);1015 struct at91_adc_state *st = iio_priv(idev);
1016 u32 reg = 0;1016 u32 reg = 0;
1017 u32 tssctim = 0;1017 u32 tssctim = 0;
1018 int i = 0;1018 int i = 0;
@@ -1085,11 +1085,11 @@ static int at91_ts_hw_init(struct at91_adc_state *st, u32 adc_clk_khz) · 66 unmodified lines
1085 return 0;1085 return 0;
1086}1086}
1087 1087
1088static int at91_ts_register(struct at91_adc_state *st,1088static int at91_ts_register(struct iio_dev *idev,
1089 struct platform_device *pdev)1089 struct platform_device *pdev)
1090{1090{
1091 struct at91_adc_state *st = iio_priv(idev);
1091 struct input_dev *input;1092 struct input_dev *input;
1092 struct iio_dev *idev = iio_priv_to_dev(st);
1093 int ret;1093 int ret;
1094 1094
1095 input = input_allocate_device();1095 input = input_allocate_device();
@@ -1161,7 +1161,7 @@ static int at91_adc_probe(struct platform_device *pdev) · 65 unmodified lines
1161 st = iio_priv(idev);1161 st = iio_priv(idev);
1162 1162
1163 if (pdev->dev.of_node)1163 if (pdev->dev.of_node)
1164 ret = at91_adc_probe_dt(st, pdev);1164 ret = at91_adc_probe_dt(idev, pdev);
1165 else1165 else
1166 ret = at91_adc_probe_pdata(st, pdev);1166 ret = at91_adc_probe_pdata(st, pdev);
1167 1167
@@ -1300,11 +1300,11 @@ static int at91_adc_probe(struct platform_device *pdev) · 132 unmodified lines
1300 goto error_disable_adc_clk;1300 goto error_disable_adc_clk;
1301 }1301 }
1302 } else {1302 } else {
1303 ret = at91_ts_register(st, pdev);1303 ret = at91_ts_register(idev, pdev);
1304 if (ret)1304 if (ret)
1305 goto error_disable_adc_clk;1305 goto error_disable_adc_clk;
1306 1306
1307 at91_ts_hw_init(st, adc_clk_khz);1307 at91_ts_hw_init(idev, adc_clk_khz);
1308 }1308 }
1309 1309
1310 ret = iio_device_register(idev);1310 ret = iio_device_register(idev);