Message ID | 20201116175128.4824-1-festevam@gmail.com |
---|---|
State | New |
Headers | show |
Series | [v2] gpio: mxc: Remove unused .id_table support | expand |
On Mon, Nov 16, 2020 at 7:53 PM Fabio Estevam <festevam@gmail.com> wrote: > > Since 5.10-rc1 i.MX is a devicetree-only platform and the existing > .id_table support in this driver was only useful for old non-devicetree > platforms. > > Get rid of the .id_table since it is no longer used. ... Actually I would rather add IMX_UNKNOWN_GPIO as 0 for enum and... > const struct of_device_id *of_id = > of_match_device(mxc_gpio_dt_ids, &pdev->dev); ...use of_device_get_match_data() here. > + enum mxc_gpio_hwtype hwtype = (enum mxc_gpio_hwtype)of_id->data; ... Another (and I think better variant) is to switch .data to be a pointer to the corresponding struct, then you may drop enum and hwtype completely.
On Mon, Nov 16, 2020 at 8:07 PM Andy Shevchenko <andy.shevchenko@gmail.com> wrote: > On Mon, Nov 16, 2020 at 7:53 PM Fabio Estevam <festevam@gmail.com> wrote: > Another (and I think better variant) is to switch .data to be a > pointer to the corresponding struct, then you may drop enum and hwtype > completely. In this case you also don't need explicit ugly casting for .data.
Hi Andy, On Mon, Nov 16, 2020 at 3:07 PM Andy Shevchenko <andy.shevchenko@gmail.com> wrote: > Another (and I think better variant) is to switch .data to be a > pointer to the corresponding struct, then you may drop enum and hwtype > completely. I did as you suggested and sent a v3. Thanks
Hi Fabio, I love your patch! Perhaps something to improve: [auto build test WARNING on gpio/for-next] [also build test WARNING on v5.10-rc4 next-20201116] [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/Fabio-Estevam/gpio-mxc-Remove-unused-id_table-support/20201117-015424 base: https://git.kernel.org/pub/scm/linux/kernel/git/linusw/linux-gpio.git for-next config: powerpc-randconfig-r015-20201116 (attached as .config) compiler: clang version 12.0.0 (https://github.com/llvm/llvm-project c044709b8fbea2a9a375e4173a6bd735f6866c0c) 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 powerpc cross compiling tool for clang build # apt-get install binutils-powerpc-linux-gnu # https://github.com/0day-ci/linux/commit/a6943017beed6fb9b48fc297c02ac3f0f4e680cb git remote add linux-review https://github.com/0day-ci/linux git fetch --no-tags linux-review Fabio-Estevam/gpio-mxc-Remove-unused-id_table-support/20201117-015424 git checkout a6943017beed6fb9b48fc297c02ac3f0f4e680cb # save the attached .config to linux build tree COMPILER_INSTALL_PATH=$HOME/0day COMPILER=clang make.cross ARCH=powerpc If you fix the issue, kindly add following tag as appropriate Reported-by: kernel test robot <lkp@intel.com> All warnings (new ones prefixed by >>): >> drivers/gpio/gpio-mxc.c:361:32: warning: cast to smaller integer type 'enum mxc_gpio_hwtype' from 'const void *' [-Wvoid-pointer-to-enum-cast] enum mxc_gpio_hwtype hwtype = (enum mxc_gpio_hwtype)of_id->data; ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 1 warning generated. vim +361 drivers/gpio/gpio-mxc.c 356 357 static void mxc_gpio_get_hw(struct platform_device *pdev) 358 { 359 const struct of_device_id *of_id = 360 of_match_device(mxc_gpio_dt_ids, &pdev->dev); > 361 enum mxc_gpio_hwtype hwtype = (enum mxc_gpio_hwtype)of_id->data; 362 363 if (mxc_gpio_hwtype) { 364 /* 365 * The driver works with a reasonable presupposition, 366 * that is all gpio ports must be the same type when 367 * running on one soc. 368 */ 369 BUG_ON(mxc_gpio_hwtype != hwtype); 370 return; 371 } 372 373 if (hwtype == IMX35_GPIO) 374 mxc_gpio_hwdata = &imx35_gpio_hwdata; 375 else if (hwtype == IMX31_GPIO) 376 mxc_gpio_hwdata = &imx31_gpio_hwdata; 377 else 378 mxc_gpio_hwdata = &imx1_imx21_gpio_hwdata; 379 380 mxc_gpio_hwtype = hwtype; 381 } 382 --- 0-DAY CI Kernel Test Service, Intel Corporation https://lists.01.org/hyperkitty/list/kbuild-all@lists.01.org
diff --git a/drivers/gpio/gpio-mxc.c b/drivers/gpio/gpio-mxc.c index 643f4c557ac2..2ed4d920861e 100644 --- a/drivers/gpio/gpio-mxc.c +++ b/drivers/gpio/gpio-mxc.c @@ -133,30 +133,12 @@ static struct mxc_gpio_hwdata *mxc_gpio_hwdata; #define GPIO_INT_FALL_EDGE (mxc_gpio_hwdata->fall_edge) #define GPIO_INT_BOTH_EDGES 0x4 -static const struct platform_device_id mxc_gpio_devtype[] = { - { - .name = "imx1-gpio", - .driver_data = IMX1_GPIO, - }, { - .name = "imx21-gpio", - .driver_data = IMX21_GPIO, - }, { - .name = "imx31-gpio", - .driver_data = IMX31_GPIO, - }, { - .name = "imx35-gpio", - .driver_data = IMX35_GPIO, - }, { - /* sentinel */ - } -}; - static const struct of_device_id mxc_gpio_dt_ids[] = { - { .compatible = "fsl,imx1-gpio", .data = &mxc_gpio_devtype[IMX1_GPIO], }, - { .compatible = "fsl,imx21-gpio", .data = &mxc_gpio_devtype[IMX21_GPIO], }, - { .compatible = "fsl,imx31-gpio", .data = &mxc_gpio_devtype[IMX31_GPIO], }, - { .compatible = "fsl,imx35-gpio", .data = &mxc_gpio_devtype[IMX35_GPIO], }, - { .compatible = "fsl,imx7d-gpio", .data = &mxc_gpio_devtype[IMX35_GPIO], }, + { .compatible = "fsl,imx1-gpio", .data = (const void *)IMX1_GPIO }, + { .compatible = "fsl,imx21-gpio", .data = (const void *)IMX21_GPIO }, + { .compatible = "fsl,imx31-gpio", .data = (const void *)IMX31_GPIO }, + { .compatible = "fsl,imx35-gpio", .data = (const void *)IMX35_GPIO }, + { .compatible = "fsl,imx7d-gpio", .data = (const void *)IMX35_GPIO }, { /* sentinel */ } }; MODULE_DEVICE_TABLE(of, mxc_gpio_dt_ids); @@ -376,11 +358,7 @@ static void mxc_gpio_get_hw(struct platform_device *pdev) { const struct of_device_id *of_id = of_match_device(mxc_gpio_dt_ids, &pdev->dev); - enum mxc_gpio_hwtype hwtype; - - if (of_id) - pdev->id_entry = of_id->data; - hwtype = pdev->id_entry->driver_data; + enum mxc_gpio_hwtype hwtype = (enum mxc_gpio_hwtype)of_id->data; if (mxc_gpio_hwtype) { /* @@ -596,7 +574,6 @@ static struct platform_driver mxc_gpio_driver = { .suppress_bind_attrs = true, }, .probe = mxc_gpio_probe, - .id_table = mxc_gpio_devtype, }; static int __init gpio_mxc_init(void)
Since 5.10-rc1 i.MX is a devicetree-only platform and the existing .id_table support in this driver was only useful for old non-devicetree platforms. Get rid of the .id_table since it is no longer used. Signed-off-by: Fabio Estevam <festevam@gmail.com> --- Changes since v1: - Configure hw_type to of_id - Phillip drivers/gpio/gpio-mxc.c | 35 ++++++----------------------------- 1 file changed, 6 insertions(+), 29 deletions(-)