iio: frequency: adf4350: Make use of device properties
Subsystems (2)
PATCH 1/1 iio: frequency: adf4350: Make use of device properties
Convert the module to be property provider agnostic and allow it to be used on non-OF platforms.
--- drivers/iio/frequency/adf4350.c | 103 +++++++++++++------------------- 1 file changed, 42 insertions(+), 61 deletions(-)
drivers/iio/frequency/adf4350.c +42 -61
@@ -7,17 +7,18 @@#include <linux/device.h> #include <linux/kernel.h> +#include <linux/mod_devicetable.h> +#include <linux/module.h> +#include <linux/property.h> #include <linux/slab.h> #include <linux/sysfs.h> #include <linux/spi/spi.h> #include <linux/regulator/consumer.h> #include <linux/err.h> -#include <linux/module.h> #include <linux/gcd.h> #include <linux/gpio/consumer.h> #include <asm/div64.h> #include <linux/clk.h> -#include <linux/of.h> #include <linux/iio/iio.h> #include <linux/iio/sysfs.h>
@@ -381,10 +382,8 @@ static const struct iio_info adf4350_info = { .debugfs_reg_access = &adf4350_reg_access, }; -#ifdef CONFIG_OF static struct adf4350_platform_data *adf4350_parse_dt (struct device *dev) { -struct device_node *np = dev->of_node;struct adf4350_platform_data *pdata;unsigned int tmp;
@@ -392,101 +391,83 @@ static struct adf4350_platform_data *adf4350_parse_dt(struct device *dev)if (!pdata)return NULL ; -snprintf (&pdata->name[0 ],SPI_NAME_SIZE -1 ,"%pOFn" , np); +snprintf (pdata->name,sizeof (pdata->name),"%pfw" ,dev_fwnode (dev)); tmp =10000 ; -of_property_read_u32 (np,"adi,channel-spacing" , &tmp); +device_property_read_u32 (dev,"adi,channel-spacing" , &tmp); pdata->channel_spacing = tmp; tmp =0 ; -of_property_read_u32 (np,"adi,power-up-frequency" , &tmp); +device_property_read_u32 (dev,"adi,power-up-frequency" , &tmp); pdata->power_up_frequency = tmp; tmp =0 ; -of_property_read_u32 (np,"adi,reference-div-factor" , &tmp); +device_property_read_u32 (dev,"adi,reference-div-factor" , &tmp); pdata->ref_div_factor = tmp; - pdata->ref_doubler_en =of_property_read_bool (np, -"adi,reference-doubler-enable" ); - pdata->ref_div2_en =of_property_read_bool (np, -"adi,reference-div2-enable" ); + pdata->ref_doubler_en =device_property_read_bool (dev,"adi,reference-doubler-enable" ); + pdata->ref_div2_en =device_property_read_bool (dev,"adi,reference-div2-enable" );/* r2_user_settings */ - pdata->r2_user_settings =of_property_read_bool (np, -"adi,phase-detector-polarity-positive-enable" ) ? -ADF4350_REG2_PD_POLARITY_POS :0 ; - pdata->r2_user_settings |=of_property_read_bool (np, -"adi,lock-detect-precision-6ns-enable" ) ? - ADF4350_REG2_LDP_6ns :0 ; - pdata->r2_user_settings |=of_property_read_bool (np, -"adi,lock-detect-function-integer-n-enable" ) ? -ADF4350_REG2_LDF_INT_N :0 ; + pdata->r2_user_settings =0 ; +if (deivice_property_read_bool (dev,"adi,phase-detector-polarity-positive-enable" )) + pdata->r2_user_settings |=ADF4350_REG2_PD_POLARITY_POS ; +if (device_property_read_bool (dev,"adi,lock-detect-precision-6ns-enable" )) + pdata->r2_user_settings |= ADF4350_REG2_LDP_6ns; +if (device_property_read_bool (dev,"adi,lock-detect-function-integer-n-enable" )) + pdata->r2_user_settings |=ADF4350_REG2_LDF_INT_N ; tmp =2500 ; -of_property_read_u32 (np,"adi,charge-pump-current" , &tmp); +device_property_read_u32 (dev,"adi,charge-pump-current" , &tmp); pdata->r2_user_settings |=ADF4350_REG2_CHARGE_PUMP_CURR_uA (tmp); tmp =0 ; -of_property_read_u32 (np,"adi,muxout-select" , &tmp); +device_property_read_u32 (dev,"adi,muxout-select" , &tmp); pdata->r2_user_settings |=ADF4350_REG2_MUXOUT (tmp); - pdata->r2_user_settings |=of_property_read_bool (np, -"adi,low-spur-mode-enable" ) ? -ADF4350_REG2_NOISE_MODE (0x3 ) :0 ; +if (device_property_read_bool (dev,"adi,low-spur-mode-enable" )) + pdata->r2_user_settings |=ADF4350_REG2_NOISE_MODE (0x3 );/* r3_user_settings */ - pdata->r3_user_settings =of_property_read_bool (np, -"adi,cycle-slip-reduction-enable" ) ? -ADF4350_REG3_12BIT_CSR_EN :0 ; - pdata->r3_user_settings |=of_property_read_bool (np, -"adi,charge-cancellation-enable" ) ? -ADF4351_REG3_CHARGE_CANCELLATION_EN :0 ; - - pdata->r3_user_settings |=of_property_read_bool (np, -"adi,anti-backlash-3ns-enable" ) ? - ADF4351_REG3_ANTI_BACKLASH_3ns_EN :0 ; - pdata->r3_user_settings |=of_property_read_bool (np, -"adi,band-select-clock-mode-high-enable" ) ? -ADF4351_REG3_BAND_SEL_CLOCK_MODE_HIGH :0 ; + pdata->r3_user_settings =0 ; +if (device_property_read_bool (dev,"adi,cycle-slip-reduction-enable" )) + pdata->r3_user_settings |=ADF4350_REG3_12BIT_CSR_EN ; +if (device_property_read_bool (dev,"adi,charge-cancellation-enable" )) + pdata->r3_user_settings |=ADF4351_REG3_CHARGE_CANCELLATION_EN ; +if (device_property_read_bool (dev,"adi,anti-backlash-3ns-enable" )) + pdata->r3_user_settings |= ADF4351_REG3_ANTI_BACKLASH_3ns_EN; +if (device_property_read_bool (dev,"adi,band-select-clock-mode-high-enable" )) + pdata->r3_user_settings |=ADF4351_REG3_BAND_SEL_CLOCK_MODE_HIGH ; tmp =0 ; -of_property_read_u32 (np,"adi,12bit-clk-divider" , &tmp); +device_property_read_u32 (dev,"adi,12bit-clk-divider" , &tmp); pdata->r3_user_settings |=ADF4350_REG3_12BIT_CLKDIV (tmp); tmp =0 ; -of_property_read_u32 (np,"adi,clk-divider-mode" , &tmp); +device_property_read_u32 (dev,"adi,clk-divider-mode" , &tmp); pdata->r3_user_settings |=ADF4350_REG3_12BIT_CLKDIV_MODE (tmp);/* r4_user_settings */ - pdata->r4_user_settings =of_property_read_bool (np, -"adi,aux-output-enable" ) ? -ADF4350_REG4_AUX_OUTPUT_EN :0 ; - pdata->r4_user_settings |=of_property_read_bool (np, -"adi,aux-output-fundamental-enable" ) ? -ADF4350_REG4_AUX_OUTPUT_FUND :0 ; - pdata->r4_user_settings |=of_property_read_bool (np, -"adi,mute-till-lock-enable" ) ? -ADF4350_REG4_MUTE_TILL_LOCK_EN :0 ; + pdata->r4_user_settings =0 ; +if (device_property_read_bool (dev,"adi,aux-output-enable" )) + pdata->r4_user_settings |=ADF4350_REG4_AUX_OUTPUT_EN ; +if (device_property_read_bool (dev,"adi,aux-output-fundamental-enable" )) + pdata->r4_user_settings |=ADF4350_REG4_AUX_OUTPUT_FUND ; +if (device_property_read_bool (dev,"adi,mute-till-lock-enable" )) + pdata->r4_user_settings |=ADF4350_REG4_MUTE_TILL_LOCK_EN ; tmp =0 ; -of_property_read_u32 (np,"adi,output-power" , &tmp); +device_property_read_u32 (dev,"adi,output-power" , &tmp); pdata->r4_user_settings |=ADF4350_REG4_OUTPUT_PWR (tmp); tmp =0 ; -of_property_read_u32 (np,"adi,aux-output-power" , &tmp); +device_property_read_u32 (dev,"adi,aux-output-power" , &tmp); pdata->r4_user_settings |=ADF4350_REG4_AUX_OUTPUT_PWR (tmp);return pdata; } -#else -static -struct adf4350_platform_data *adf4350_parse_dt (struct device *dev) -{ -return NULL ; -} -#endif static int adf4350_probe (struct spi_device *spi) {
@@ -496,7 +477,7 @@ static int adf4350_probe(struct spi_device *spi)struct clk *clk =NULL ;int ret; -if (spi->dev.of_node) { +if (dev_fwnode (&spi->dev)) { pdata =adf4350_parse_dt (&spi->dev);if (pdata ==NULL )return -EINVAL ;
@@ -625,7 +606,7 @@ MODULE_DEVICE_TABLE(spi, adf4350_id);static struct spi_driver adf4350_driver = { .driver = { .name ="adf4350" , - .of_match_table =of_match_ptr (adf4350_of_match), + .of_match_table = adf4350_of_match, }, .probe = adf4350_probe, .remove = adf4350_remove,
Signature · 1 line
2.34.1
kernel test robot
build botI love your patch! Yet something to improve:
Hi Andy,
I love your patch! Yet something to improve:
[auto build test ERROR on jic23-iio/togreg]
[also build test ERROR on v5.17-rc2 next-20220202]
[If your patch is applied to the wrong git tree, kindly drop us a note. And when submitting patch, we suggest to use '--base' as documented in
https://git-scm.com/docs/git-format-patch]
url: https://github.com/0day-ci/linux/commits/Andy-Shevchenko/iio-frequency-adf4350-Make-use-of-device-properties/20220203-042942 base: https://git.kernel.org/pub/scm/linux/kernel/git/jic23/iio.git togreg config: arc-allyesconfig (https://download.01.org/0day-ci/archive/20220203/202202031246.wxrLxVsl-lkp(a)intel.com/config) compiler: arceb-elf-gcc (GCC) 11.2.0
reproduce (this is a W=1 build):
wget https://raw.githubusercontent.com/intel/lkp-tests/master/sbin/make.cross -O ~/bin/make.cross chmod +x ~/bin/make.cross
# https://github.com/0day-ci/linux/commit/45963437d849912f2763fe06c25f9e30c383b0f5
git remote add linux-review https://github.com/0day-ci/linux
git fetch --no-tags linux-review Andy-Shevchenko/iio-frequency-adf4350-Make-use-of-device-properties/20220203-042942 git checkout 45963437d849912f2763fe06c25f9e30c383b0f5
# save the config file to linux build tree
mkdir build_dir
COMPILER_INSTALL_PATH=$HOME/0day COMPILER=gcc-11.2.0 make.cross O=build_dir ARCH=arc SHELL=/bin/bash
If you fix the issue, kindly add following tag as appropriate
All errors (new ones prefixed by >>):
drivers/iio/frequency/adf4350.c: In function 'adf4350_parse_dt':
>> drivers/iio/frequency/adf4350.c:413:13: error: implicit declaration of function 'deivice_property_read_bool'; did you mean 'device_property_read_bool'? [-Werror=implicit-function-declaration]
413 | if (deivice_property_read_bool(dev, "adi,phase-detector-polarity-positive-enable"))
| ^~~~~~~~~~~~~~~~~~~~~~~~~~
| device_property_read_boolcc1: some warnings being treated as errors
vim +413 drivers/iio/frequency/adf4350.c
384
385 static struct adf4350_platform_data *adf4350_parse_dt(struct device *dev)
386 {
387 struct adf4350_platform_data *pdata;
388 unsigned int tmp;
389
390 pdata = devm_kzalloc(dev, sizeof(*pdata), GFP_KERNEL);
391 if (!pdata)
392 return NULL;
393
394 snprintf(pdata->name, sizeof(pdata->name), "%pfw", dev_fwnode(dev));
395
396 tmp = 10000;
397 device_property_read_u32(dev, "adi,channel-spacing", &tmp);
398 pdata->channel_spacing = tmp;
399
400 tmp = 0;
401 device_property_read_u32(dev, "adi,power-up-frequency", &tmp);
402 pdata->power_up_frequency = tmp;
403
404 tmp = 0;
405 device_property_read_u32(dev, "adi,reference-div-factor", &tmp);
406 pdata->ref_div_factor = tmp;
407
408 pdata->ref_doubler_en = device_property_read_bool(dev, "adi,reference-doubler-enable");
409 pdata->ref_div2_en = device_property_read_bool(dev, "adi,reference-div2-enable");
410
411 /* r2_user_settings */
412 pdata->r2_user_settings = 0;
> 413 if (deivice_property_read_bool(dev, "adi,phase-detector-polarity-positive-enable"))
414 pdata->r2_user_settings |= ADF4350_REG2_PD_POLARITY_POS;
415 if (device_property_read_bool(dev, "adi,lock-detect-precision-6ns-enable"))
416 pdata->r2_user_settings |= ADF4350_REG2_LDP_6ns;
417 if (device_property_read_bool(dev, "adi,lock-detect-function-integer-n-enable"))
418 pdata->r2_user_settings |= ADF4350_REG2_LDF_INT_N;
419
420 tmp = 2500;
421 device_property_read_u32(dev, "adi,charge-pump-current", &tmp);
422 pdata->r2_user_settings |= ADF4350_REG2_CHARGE_PUMP_CURR_uA(tmp);
423
424 tmp = 0;
425 device_property_read_u32(dev, "adi,muxout-select", &tmp);
426 pdata->r2_user_settings |= ADF4350_REG2_MUXOUT(tmp);
427
428 if (device_property_read_bool(dev, "adi,low-spur-mode-enable"))
429 pdata->r2_user_settings |= ADF4350_REG2_NOISE_MODE(0x3);
430
431 /* r3_user_settings */
432
433 pdata->r3_user_settings = 0;
434 if (device_property_read_bool(dev, "adi,cycle-slip-reduction-enable"))
435 pdata->r3_user_settings |= ADF4350_REG3_12BIT_CSR_EN;
436 if (device_property_read_bool(dev, "adi,charge-cancellation-enable"))
437 pdata->r3_user_settings |= ADF4351_REG3_CHARGE_CANCELLATION_EN;
438 if (device_property_read_bool(dev, "adi,anti-backlash-3ns-enable"))
439 pdata->r3_user_settings |= ADF4351_REG3_ANTI_BACKLASH_3ns_EN;
440 if (device_property_read_bool(dev, "adi,band-select-clock-mode-high-enable"))
441 pdata->r3_user_settings |= ADF4351_REG3_BAND_SEL_CLOCK_MODE_HIGH;
442
443 tmp = 0;
444 device_property_read_u32(dev, "adi,12bit-clk-divider", &tmp);
445 pdata->r3_user_settings |= ADF4350_REG3_12BIT_CLKDIV(tmp);
446
447 tmp = 0;
448 device_property_read_u32(dev, "adi,clk-divider-mode", &tmp);
449 pdata->r3_user_settings |= ADF4350_REG3_12BIT_CLKDIV_MODE(tmp);
450
451 /* r4_user_settings */
452
453 pdata->r4_user_settings = 0;
454 if (device_property_read_bool(dev, "adi,aux-output-enable"))
455 pdata->r4_user_settings |= ADF4350_REG4_AUX_OUTPUT_EN;
456 if (device_property_read_bool(dev, "adi,aux-output-fundamental-enable"))
457 pdata->r4_user_settings |= ADF4350_REG4_AUX_OUTPUT_FUND;
458 if (device_property_read_bool(dev, "adi,mute-till-lock-enable"))
459 pdata->r4_user_settings |= ADF4350_REG4_MUTE_TILL_LOCK_EN;
460
461 tmp = 0;
462 device_property_read_u32(dev, "adi,output-power", &tmp);
463 pdata->r4_user_settings |= ADF4350_REG4_OUTPUT_PWR(tmp);
464
465 tmp = 0;
466 device_property_read_u32(dev, "adi,aux-output-power", &tmp);
467 pdata->r4_user_settings |= ADF4350_REG4_AUX_OUTPUT_PWR(tmp);
468
469 return pdata;
470 }
471
---
0-DAY CI Kernel Test Service, Intel Corporation
https://lists.01.org/hyperkitty/list/kbuild-all(a)lists.01.org
kernel test robot
build botI love your patch! Yet something to improve:
Hi Andy,
I love your patch! Yet something to improve:
[auto build test ERROR on jic23-iio/togreg]
[also build test ERROR on v5.17-rc2 next-20220203]
[If your patch is applied to the wrong git tree, kindly drop us a note. And when submitting patch, we suggest to use '--base' as documented in
https://git-scm.com/docs/git-format-patch]
url: https://github.com/0day-ci/linux/commits/Andy-Shevchenko/iio-frequency-adf4350-Make-use-of-device-properties/20220203-042942 base: https://git.kernel.org/pub/scm/linux/kernel/git/jic23/iio.git togreg config: arm64-randconfig-r031-20220130 (https://download.01.org/0day-ci/archive/20220203/202202031457.yUDGy1we-lkp(a)intel.com/config) compiler: clang version 15.0.0 (https://github.com/llvm/llvm-project a73e4ce6a59b01f0e37037761c1e6889d539d233)
reproduce (this is a W=1 build):
wget https://raw.githubusercontent.com/intel/lkp-tests/master/sbin/make.cross -O ~/bin/make.cross chmod +x ~/bin/make.cross
# install arm64 cross compiling tool for clang build
# apt-get install binutils-aarch64-linux-gnu
# https://github.com/0day-ci/linux/commit/45963437d849912f2763fe06c25f9e30c383b0f5
git remote add linux-review https://github.com/0day-ci/linux
git fetch --no-tags linux-review Andy-Shevchenko/iio-frequency-adf4350-Make-use-of-device-properties/20220203-042942 git checkout 45963437d849912f2763fe06c25f9e30c383b0f5
# save the config file to linux build tree
mkdir build_dir
COMPILER_INSTALL_PATH=$HOME/0day COMPILER=clang make.cross W=1 O=build_dir ARCH=arm64 SHELL=/bin/bash drivers/iio/frequency/
If you fix the issue, kindly add following tag as appropriate
All errors (new ones prefixed by >>):
>> drivers/iio/frequency/adf4350.c:413:6: error: implicit declaration of function 'deivice_property_read_bool' [-Werror,-Wimplicit-function-declaration]
if (deivice_property_read_bool(dev, "adi,phase-detector-polarity-positive-enable"))
^
drivers/iio/frequency/adf4350.c:413:6: note: did you mean 'device_property_read_bool'?
include/linux/property.h:129:20: note: 'device_property_read_bool' declared here
static inline bool device_property_read_bool(struct device *dev,
^1 error generated.
vim +/deivice_property_read_bool +413 drivers/iio/frequency/adf4350.c
384
385 static struct adf4350_platform_data *adf4350_parse_dt(struct device *dev)
386 {
387 struct adf4350_platform_data *pdata;
388 unsigned int tmp;
389
390 pdata = devm_kzalloc(dev, sizeof(*pdata), GFP_KERNEL);
391 if (!pdata)
392 return NULL;
393
394 snprintf(pdata->name, sizeof(pdata->name), "%pfw", dev_fwnode(dev));
395
396 tmp = 10000;
397 device_property_read_u32(dev, "adi,channel-spacing", &tmp);
398 pdata->channel_spacing = tmp;
399
400 tmp = 0;
401 device_property_read_u32(dev, "adi,power-up-frequency", &tmp);
402 pdata->power_up_frequency = tmp;
403
404 tmp = 0;
405 device_property_read_u32(dev, "adi,reference-div-factor", &tmp);
406 pdata->ref_div_factor = tmp;
407
408 pdata->ref_doubler_en = device_property_read_bool(dev, "adi,reference-doubler-enable");
409 pdata->ref_div2_en = device_property_read_bool(dev, "adi,reference-div2-enable");
410
411 /* r2_user_settings */
412 pdata->r2_user_settings = 0;
> 413 if (deivice_property_read_bool(dev, "adi,phase-detector-polarity-positive-enable"))
414 pdata->r2_user_settings |= ADF4350_REG2_PD_POLARITY_POS;
415 if (device_property_read_bool(dev, "adi,lock-detect-precision-6ns-enable"))
416 pdata->r2_user_settings |= ADF4350_REG2_LDP_6ns;
417 if (device_property_read_bool(dev, "adi,lock-detect-function-integer-n-enable"))
418 pdata->r2_user_settings |= ADF4350_REG2_LDF_INT_N;
419
420 tmp = 2500;
421 device_property_read_u32(dev, "adi,charge-pump-current", &tmp);
422 pdata->r2_user_settings |= ADF4350_REG2_CHARGE_PUMP_CURR_uA(tmp);
423
424 tmp = 0;
425 device_property_read_u32(dev, "adi,muxout-select", &tmp);
426 pdata->r2_user_settings |= ADF4350_REG2_MUXOUT(tmp);
427
428 if (device_property_read_bool(dev, "adi,low-spur-mode-enable"))
429 pdata->r2_user_settings |= ADF4350_REG2_NOISE_MODE(0x3);
430
431 /* r3_user_settings */
432
433 pdata->r3_user_settings = 0;
434 if (device_property_read_bool(dev, "adi,cycle-slip-reduction-enable"))
435 pdata->r3_user_settings |= ADF4350_REG3_12BIT_CSR_EN;
436 if (device_property_read_bool(dev, "adi,charge-cancellation-enable"))
437 pdata->r3_user_settings |= ADF4351_REG3_CHARGE_CANCELLATION_EN;
438 if (device_property_read_bool(dev, "adi,anti-backlash-3ns-enable"))
439 pdata->r3_user_settings |= ADF4351_REG3_ANTI_BACKLASH_3ns_EN;
440 if (device_property_read_bool(dev, "adi,band-select-clock-mode-high-enable"))
441 pdata->r3_user_settings |= ADF4351_REG3_BAND_SEL_CLOCK_MODE_HIGH;
442
443 tmp = 0;
444 device_property_read_u32(dev, "adi,12bit-clk-divider", &tmp);
445 pdata->r3_user_settings |= ADF4350_REG3_12BIT_CLKDIV(tmp);
446
447 tmp = 0;
448 device_property_read_u32(dev, "adi,clk-divider-mode", &tmp);
449 pdata->r3_user_settings |= ADF4350_REG3_12BIT_CLKDIV_MODE(tmp);
450
451 /* r4_user_settings */
452
453 pdata->r4_user_settings = 0;
454 if (device_property_read_bool(dev, "adi,aux-output-enable"))
455 pdata->r4_user_settings |= ADF4350_REG4_AUX_OUTPUT_EN;
456 if (device_property_read_bool(dev, "adi,aux-output-fundamental-enable"))
457 pdata->r4_user_settings |= ADF4350_REG4_AUX_OUTPUT_FUND;
458 if (device_property_read_bool(dev, "adi,mute-till-lock-enable"))
459 pdata->r4_user_settings |= ADF4350_REG4_MUTE_TILL_LOCK_EN;
460
461 tmp = 0;
462 device_property_read_u32(dev, "adi,output-power", &tmp);
463 pdata->r4_user_settings |= ADF4350_REG4_OUTPUT_PWR(tmp);
464
465 tmp = 0;
466 device_property_read_u32(dev, "adi,aux-output-power", &tmp);
467 pdata->r4_user_settings |= ADF4350_REG4_AUX_OUTPUT_PWR(tmp);
468
469 return pdata;
470 }
471
---
0-DAY CI Kernel Test Service, Intel Corporation
https://lists.01.org/hyperkitty/list/kbuild-all(a)lists.01.org