[linux-next] drm/imx: Use device_match_of_node()

Message ID 202211171511333735699@zte.com.cn
State New
Headers
Series [linux-next] drm/imx: Use device_match_of_node() |

Commit Message

ye.xingchen@zte.com.cn Nov. 17, 2022, 7:11 a.m. UTC
  From: ye xingchen <ye.xingchen@zte.com.cn>

Replace the open-code with device_match_of_node().

Signed-off-by: ye xingchen <ye.xingchen@zte.com.cn>
---
 drivers/gpu/drm/imx/imx-drm-core.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
  

Comments

kernel test robot Nov. 20, 2022, 10:54 a.m. UTC | #1
Hi,

Thank you for the patch! Yet something to improve:

[auto build test ERROR on next-20221116]

url:    https://github.com/intel-lab-lkp/linux/commits/ye-xingchen-zte-com-cn/drm-imx-Use-device_match_of_node/20221117-151254
patch link:    https://lore.kernel.org/r/202211171511333735699%40zte.com.cn
patch subject: [PATCH linux-next] drm/imx: Use device_match_of_node()
config: microblaze-allmodconfig
compiler: microblaze-linux-gcc (GCC) 12.1.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/intel-lab-lkp/linux/commit/94ad00c926678ebff17e91e24878777fb900936a
        git remote add linux-review https://github.com/intel-lab-lkp/linux
        git fetch --no-tags linux-review ye-xingchen-zte-com-cn/drm-imx-Use-device_match_of_node/20221117-151254
        git checkout 94ad00c926678ebff17e91e24878777fb900936a
        # save the config file
        mkdir build_dir && cp config build_dir/.config
        COMPILER_INSTALL_PATH=$HOME/0day COMPILER=gcc-12.1.0 make.cross W=1 O=build_dir ARCH=microblaze SHELL=/bin/bash drivers/gpu/drm/imx/

If you fix the issue, kindly add following tag where applicable
| Reported-by: kernel test robot <lkp@intel.com>

All errors (new ones prefixed by >>):

   drivers/gpu/drm/imx/imx-drm-core.c: In function 'compare_of':
>> drivers/gpu/drm/imx/imx-drm-core.c:185:45: error: passing argument 1 of 'device_match_of_node' from incompatible pointer type [-Werror=incompatible-pointer-types]
     185 |                 return device_match_of_node(pdata, np);
         |                                             ^~~~~
         |                                             |
         |                                             struct ipu_client_platformdata *
   In file included from include/linux/device.h:30,
                    from drivers/gpu/drm/imx/imx-drm-core.c:9:
   include/linux/device/bus.h:145:41: note: expected 'struct device *' but argument is of type 'struct ipu_client_platformdata *'
     145 | int device_match_of_node(struct device *dev, const void *np);
         |                          ~~~~~~~~~~~~~~~^~~
   cc1: some warnings being treated as errors


vim +/device_match_of_node +185 drivers/gpu/drm/imx/imx-drm-core.c

   176	
   177	static int compare_of(struct device *dev, void *data)
   178	{
   179		struct device_node *np = data;
   180	
   181		/* Special case for DI, dev->of_node may not be set yet */
   182		if (strcmp(dev->driver->name, "imx-ipuv3-crtc") == 0) {
   183			struct ipu_client_platformdata *pdata = dev->platform_data;
   184	
 > 185			return device_match_of_node(pdata, np);
   186		}
   187	
   188		/* Special case for LDB, one device for two channels */
   189		if (of_node_name_eq(np, "lvds-channel")) {
   190			np = of_get_parent(np);
   191			of_node_put(np);
   192		}
   193	
   194		return device_match_of_node(dev, np);
   195	}
   196
  
Ahmad Fatoum Nov. 28, 2022, 9:03 a.m. UTC | #2
Hello,

On 17.11.22 08:11, ye.xingchen@zte.com.cn wrote:
> From: ye xingchen <ye.xingchen@zte.com.cn>
> 
> Replace the open-code with device_match_of_node().

device_match_of_node() exists so a pointer to the function can be passed
to class/driver_find_device. I see no reason to call it directly.

I don't think you should pursue any patches, where you do this
transformation even if they pass a compile test unlike the patch here.

Thanks,
Ahmad

> 
> Signed-off-by: ye xingchen <ye.xingchen@zte.com.cn>
> ---
>  drivers/gpu/drm/imx/imx-drm-core.c | 4 ++--
>  1 file changed, 2 insertions(+), 2 deletions(-)
> 
> diff --git a/drivers/gpu/drm/imx/imx-drm-core.c b/drivers/gpu/drm/imx/imx-drm-core.c
> index e060fa6cbcb9..2e4f5af894b0 100644
> --- a/drivers/gpu/drm/imx/imx-drm-core.c
> +++ b/drivers/gpu/drm/imx/imx-drm-core.c
> @@ -182,7 +182,7 @@ static int compare_of(struct device *dev, void *data)
>  	if (strcmp(dev->driver->name, "imx-ipuv3-crtc") == 0) {
>  		struct ipu_client_platformdata *pdata = dev->platform_data;
> 
> -		return pdata->of_node == np;
> +		return device_match_of_node(pdata, np);
>  	}
> 
>  	/* Special case for LDB, one device for two channels */
> @@ -191,7 +191,7 @@ static int compare_of(struct device *dev, void *data)
>  		of_node_put(np);
>  	}
> 
> -	return dev->of_node == np;
> +	return device_match_of_node(dev, np);
>  }
> 
>  static int imx_drm_bind(struct device *dev)
  

Patch

diff --git a/drivers/gpu/drm/imx/imx-drm-core.c b/drivers/gpu/drm/imx/imx-drm-core.c
index e060fa6cbcb9..2e4f5af894b0 100644
--- a/drivers/gpu/drm/imx/imx-drm-core.c
+++ b/drivers/gpu/drm/imx/imx-drm-core.c
@@ -182,7 +182,7 @@  static int compare_of(struct device *dev, void *data)
 	if (strcmp(dev->driver->name, "imx-ipuv3-crtc") == 0) {
 		struct ipu_client_platformdata *pdata = dev->platform_data;

-		return pdata->of_node == np;
+		return device_match_of_node(pdata, np);
 	}

 	/* Special case for LDB, one device for two channels */
@@ -191,7 +191,7 @@  static int compare_of(struct device *dev, void *data)
 		of_node_put(np);
 	}

-	return dev->of_node == np;
+	return device_match_of_node(dev, np);
 }

 static int imx_drm_bind(struct device *dev)