Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

iio: adc: twl4030-madc: Make use of device properties

Convert the module to be property provider agnostic and allow
it to be used on non-OF platforms.

Include mod_devicetable.h explicitly to replace the dropped of.h
which included mod_devicetable.h indirectly.

Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Link: https://lore.kernel.org/r/20240304144037.1036390-1-andriy.shevchenko@linux.intel.com
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>

authored by

Andy Shevchenko and committed by
Jonathan Cameron
1c5aa559 37ae8381

+9 -10
+9 -10
drivers/iio/adc/twl4030-madc.c
··· 19 19 #include <linux/interrupt.h> 20 20 #include <linux/kernel.h> 21 21 #include <linux/delay.h> 22 + #include <linux/mod_devicetable.h> 23 + #include <linux/module.h> 22 24 #include <linux/platform_device.h> 25 + #include <linux/property.h> 23 26 #include <linux/slab.h> 24 27 #include <linux/mfd/twl.h> 25 - #include <linux/module.h> 26 28 #include <linux/stddef.h> 27 29 #include <linux/mutex.h> 28 30 #include <linux/bitops.h> ··· 32 30 #include <linux/types.h> 33 31 #include <linux/gfp.h> 34 32 #include <linux/err.h> 35 - #include <linux/of.h> 36 33 #include <linux/regulator/consumer.h> 37 34 38 35 #include <linux/iio/iio.h> ··· 745 744 */ 746 745 static int twl4030_madc_probe(struct platform_device *pdev) 747 746 { 747 + struct device *dev = &pdev->dev; 748 + struct twl4030_madc_platform_data *pdata = dev_get_platdata(dev); 748 749 struct twl4030_madc_data *madc; 749 - struct twl4030_madc_platform_data *pdata = dev_get_platdata(&pdev->dev); 750 - struct device_node *np = pdev->dev.of_node; 751 750 int irq, ret; 752 751 u8 regval; 753 752 struct iio_dev *iio_dev = NULL; 754 753 755 - if (!pdata && !np) { 754 + if (!pdata && !dev_fwnode(dev)) { 756 755 dev_err(&pdev->dev, "neither platform data nor Device Tree node available\n"); 757 756 return -EINVAL; 758 757 } ··· 780 779 if (pdata) 781 780 madc->use_second_irq = (pdata->irq_line != 1); 782 781 else 783 - madc->use_second_irq = of_property_read_bool(np, 782 + madc->use_second_irq = device_property_read_bool(dev, 784 783 "ti,system-uses-second-madc-irq"); 785 784 786 785 madc->imr = madc->use_second_irq ? TWL4030_MADC_IMR2 : ··· 906 905 regulator_disable(madc->usb3v1); 907 906 } 908 907 909 - #ifdef CONFIG_OF 910 908 static const struct of_device_id twl_madc_of_match[] = { 911 909 { .compatible = "ti,twl4030-madc", }, 912 - { }, 910 + { } 913 911 }; 914 912 MODULE_DEVICE_TABLE(of, twl_madc_of_match); 915 - #endif 916 913 917 914 static struct platform_driver twl4030_madc_driver = { 918 915 .probe = twl4030_madc_probe, 919 916 .remove_new = twl4030_madc_remove, 920 917 .driver = { 921 918 .name = "twl4030_madc", 922 - .of_match_table = of_match_ptr(twl_madc_of_match), 919 + .of_match_table = twl_madc_of_match, 923 920 }, 924 921 }; 925 922