[PATCH] drm/sun4i: Add error handling in sun4i_layer_init_one()

liuhaoran posted 1 patch 2 years, 4 months ago
drivers/gpu/drm/sun4i/sun4i_layer.c | 19 ++++++++++++++++---
1 file changed, 16 insertions(+), 3 deletions(-)
[PATCH] drm/sun4i: Add error handling in sun4i_layer_init_one()
Posted by liuhaoran 2 years, 4 months ago
This patch adds error-handling for the drm_plane_create_alpha_property()
and drm_plane_create_zpos_property() inside the dw_hdmi_imx_probe().

Signed-off-by: liuhaoran <liuhaoran14@163.com>
---
 drivers/gpu/drm/sun4i/sun4i_layer.c | 19 ++++++++++++++++---
 1 file changed, 16 insertions(+), 3 deletions(-)

diff --git a/drivers/gpu/drm/sun4i/sun4i_layer.c b/drivers/gpu/drm/sun4i/sun4i_layer.c
index 98f3176366c0..a3343afb7935 100644
--- a/drivers/gpu/drm/sun4i/sun4i_layer.c
+++ b/drivers/gpu/drm/sun4i/sun4i_layer.c
@@ -224,9 +224,22 @@ static struct sun4i_layer *sun4i_layer_init_one(struct drm_device *drm,
 	drm_plane_helper_add(&layer->plane,
 			     &sun4i_backend_layer_helper_funcs);
 
-	drm_plane_create_alpha_property(&layer->plane);
-	drm_plane_create_zpos_property(&layer->plane, layer->id,
-				       0, SUN4I_BACKEND_NUM_LAYERS - 1);
+	ret = drm_plane_create_alpha_property(&layer->plane);
+
+	if (ret) {
+		dev_err(drm->dev, "Failed to install alpha property,
+			rc = %d\n", ret);
+		return ERR_PTR(ret);
+	}
+
+	ret = drm_plane_create_zpos_property(&layer->plane, layer->id, 0,
+					     SUN4I_BACKEND_NUM_LAYERS - 1);
+
+	if (ret) {
+		dev_err(drm->dev, "Failed to install zpos property,
+			rc = %d\n", ret);
+		return ERR_PTR(ret);
+	}
 
 	return layer;
 }
-- 
2.17.1
Re: [PATCH] drm/sun4i: Add error handling in sun4i_layer_init_one()
Posted by Jernej Škrabec 2 years, 4 months ago
Hi!

Dne nedelja, 24. september 2023 ob 09:42:16 CEST je liuhaoran napisal(a):
> This patch adds error-handling for the drm_plane_create_alpha_property()
> and drm_plane_create_zpos_property() inside the dw_hdmi_imx_probe().

dw_hdmi_imx_probe() is not from this driver.

Best regards,
Jernej

> 
> Signed-off-by: liuhaoran <liuhaoran14@163.com>
> ---
>  drivers/gpu/drm/sun4i/sun4i_layer.c | 19 ++++++++++++++++---
>  1 file changed, 16 insertions(+), 3 deletions(-)
> 
> diff --git a/drivers/gpu/drm/sun4i/sun4i_layer.c b/drivers/gpu/drm/sun4i/sun4i_layer.c
> index 98f3176366c0..a3343afb7935 100644
> --- a/drivers/gpu/drm/sun4i/sun4i_layer.c
> +++ b/drivers/gpu/drm/sun4i/sun4i_layer.c
> @@ -224,9 +224,22 @@ static struct sun4i_layer *sun4i_layer_init_one(struct drm_device *drm,
>  	drm_plane_helper_add(&layer->plane,
>  			     &sun4i_backend_layer_helper_funcs);
>  
> -	drm_plane_create_alpha_property(&layer->plane);
> -	drm_plane_create_zpos_property(&layer->plane, layer->id,
> -				       0, SUN4I_BACKEND_NUM_LAYERS - 1);
> +	ret = drm_plane_create_alpha_property(&layer->plane);
> +
> +	if (ret) {
> +		dev_err(drm->dev, "Failed to install alpha property,
> +			rc = %d\n", ret);
> +		return ERR_PTR(ret);
> +	}
> +
> +	ret = drm_plane_create_zpos_property(&layer->plane, layer->id, 0,
> +					     SUN4I_BACKEND_NUM_LAYERS - 1);
> +
> +	if (ret) {
> +		dev_err(drm->dev, "Failed to install zpos property,
> +			rc = %d\n", ret);
> +		return ERR_PTR(ret);
> +	}
>  
>  	return layer;
>  }
>
Re: [PATCH] drm/sun4i: Add error handling in sun4i_layer_init_one()
Posted by kernel test robot 2 years, 4 months ago
Hi liuhaoran,

kernel test robot noticed the following build warnings:

[auto build test WARNING on sunxi/sunxi/for-next]
[also build test WARNING on linus/master v6.6-rc2 next-20230921]
[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#_base_tree_information]

url:    https://github.com/intel-lab-lkp/linux/commits/liuhaoran/drm-sun4i-Add-error-handling-in-sun4i_layer_init_one/20230924-154504
base:   https://git.kernel.org/pub/scm/linux/kernel/git/sunxi/linux.git sunxi/for-next
patch link:    https://lore.kernel.org/r/20230924074216.17390-1-liuhaoran14%40163.com
patch subject: [PATCH] drm/sun4i: Add error handling in sun4i_layer_init_one()
config: m68k-allyesconfig (https://download.01.org/0day-ci/archive/20230924/202309241647.QEGaCh1E-lkp@intel.com/config)
compiler: m68k-linux-gcc (GCC) 13.2.0
reproduce (this is a W=1 build): (https://download.01.org/0day-ci/archive/20230924/202309241647.QEGaCh1E-lkp@intel.com/reproduce)

If you fix the issue in a separate patch/commit (i.e. not just a new version of
the same patch/commit), kindly add following tags
| Reported-by: kernel test robot <lkp@intel.com>
| Closes: https://lore.kernel.org/oe-kbuild-all/202309241647.QEGaCh1E-lkp@intel.com/

All warnings (new ones prefixed by >>):

   drivers/gpu/drm/sun4i/sun4i_layer.c: In function 'sun4i_layer_init_one':
>> drivers/gpu/drm/sun4i/sun4i_layer.c:230:35: warning: missing terminating " character
     230 |                 dev_err(drm->dev, "Failed to install alpha property,
         |                                   ^
   drivers/gpu/drm/sun4i/sun4i_layer.c:231:34: warning: missing terminating " character
     231 |                         rc = %d\n", ret);
         |                                  ^
   drivers/gpu/drm/sun4i/sun4i_layer.c:239:35: warning: missing terminating " character
     239 |                 dev_err(drm->dev, "Failed to install zpos property,
         |                                   ^
   drivers/gpu/drm/sun4i/sun4i_layer.c:240:34: warning: missing terminating " character
     240 |                         rc = %d\n", ret);
         |                                  ^
   drivers/gpu/drm/sun4i/sun4i_layer.c:275:2: error: unterminated argument list invoking macro "dev_err"
     275 | }
         |  ^
   drivers/gpu/drm/sun4i/sun4i_layer.c:230:17: error: 'dev_err' undeclared (first use in this function); did you mean '_dev_err'?
     230 |                 dev_err(drm->dev, "Failed to install alpha property,
         |                 ^~~~~~~
         |                 _dev_err
   drivers/gpu/drm/sun4i/sun4i_layer.c:230:17: note: each undeclared identifier is reported only once for each function it appears in
   drivers/gpu/drm/sun4i/sun4i_layer.c:230:24: error: expected ';' at end of input
     230 |                 dev_err(drm->dev, "Failed to install alpha property,
         |                        ^
         |                        ;
   ......
   drivers/gpu/drm/sun4i/sun4i_layer.c:230:17: error: expected declaration or statement at end of input
     230 |                 dev_err(drm->dev, "Failed to install alpha property,
         |                 ^~~~~~~
   drivers/gpu/drm/sun4i/sun4i_layer.c:230:17: error: expected declaration or statement at end of input
   drivers/gpu/drm/sun4i/sun4i_layer.c: At top level:
>> drivers/gpu/drm/sun4i/sun4i_layer.c:190:28: warning: 'sun4i_layer_init_one' defined but not used [-Wunused-function]
     190 | static struct sun4i_layer *sun4i_layer_init_one(struct drm_device *drm,
         |                            ^~~~~~~~~~~~~~~~~~~~


vim +230 drivers/gpu/drm/sun4i/sun4i_layer.c

   189	
 > 190	static struct sun4i_layer *sun4i_layer_init_one(struct drm_device *drm,
   191							struct sun4i_backend *backend,
   192							enum drm_plane_type type,
   193							unsigned int id)
   194	{
   195		const uint64_t *modifiers = sun4i_layer_modifiers;
   196		const uint32_t *formats = sun4i_layer_formats;
   197		unsigned int formats_len = ARRAY_SIZE(sun4i_layer_formats);
   198		struct sun4i_layer *layer;
   199		int ret;
   200	
   201		layer = devm_kzalloc(drm->dev, sizeof(*layer), GFP_KERNEL);
   202		if (!layer)
   203			return ERR_PTR(-ENOMEM);
   204	
   205		layer->id = id;
   206		layer->backend = backend;
   207	
   208		if (IS_ERR_OR_NULL(backend->frontend)) {
   209			formats = sun4i_backend_layer_formats;
   210			formats_len = ARRAY_SIZE(sun4i_backend_layer_formats);
   211			modifiers = NULL;
   212		}
   213	
   214		/* possible crtcs are set later */
   215		ret = drm_universal_plane_init(drm, &layer->plane, 0,
   216					       &sun4i_backend_layer_funcs,
   217					       formats, formats_len,
   218					       modifiers, type, NULL);
   219		if (ret) {
   220			dev_err(drm->dev, "Couldn't initialize layer\n");
   221			return ERR_PTR(ret);
   222		}
   223	
   224		drm_plane_helper_add(&layer->plane,
   225				     &sun4i_backend_layer_helper_funcs);
   226	
   227		ret = drm_plane_create_alpha_property(&layer->plane);
   228	
   229		if (ret) {
 > 230			dev_err(drm->dev, "Failed to install alpha property,
   231				rc = %d\n", ret);
   232			return ERR_PTR(ret);
   233		}
   234	
   235		ret = drm_plane_create_zpos_property(&layer->plane, layer->id, 0,
   236						     SUN4I_BACKEND_NUM_LAYERS - 1);
   237	
   238		if (ret) {
   239			dev_err(drm->dev, "Failed to install zpos property,
   240				rc = %d\n", ret);
   241			return ERR_PTR(ret);
   242		}
   243	
   244		return layer;
   245	}
   246	

-- 
0-DAY CI Kernel Test Service
https://github.com/intel/lkp-tests/wiki