Re: [PATCH v2 01/25] drm/drm_panel: no error when no callback

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Sat, Dec 07, 2019 at 03:03:29PM +0100, Sam Ravnborg wrote:
> The callbacks in drm_panel_funcs are optional, so do not
> return an error just because no callback is assigned.
[...]
> diff --git a/drivers/gpu/drm/drm_panel.c b/drivers/gpu/drm/drm_panel.c
> index ed7985c0535a..4ab7229fb22b 100644
> --- a/drivers/gpu/drm/drm_panel.c
> +++ b/drivers/gpu/drm/drm_panel.c
[...]  
> @@ -228,10 +240,13 @@ EXPORT_SYMBOL(drm_panel_disable);
>   */
>  int drm_panel_get_modes(struct drm_panel *panel)
>  {
> -	if (panel && panel->funcs && panel->funcs->get_modes)
> +	if (!panel)
> +		return -EINVAL;
> +
> +	if (panel->funcs && panel->funcs->get_modes)
>  		return panel->funcs->get_modes(panel);
>  
> -	return panel ? -ENOSYS : -EINVAL;
> +	return -EOPNOTSUPP;
>  }
>  EXPORT_SYMBOL(drm_panel_get_modes);
>  
> diff --git a/include/drm/drm_panel.h b/include/drm/drm_panel.h
> index ce8da64022b4..d71655b2634c 100644
> --- a/include/drm/drm_panel.h
> +++ b/include/drm/drm_panel.ha
[...]
>  	/**
>  	 * @get_modes:
>  	 *
> -	 * Add modes to the connector that the panel is attached to and
> -	 * return the number of modes added.
> +	 * Add modes to the connector that the panel is attached to.
> +	 *
> +	 * This function is mandatory.
> +	 *
> +	 * Returns the number of modes added, -EOPNOTSUPP if callback
> +	 * is missing, -EINVAL if panel is NULL.
>  	 */
>  	int (*get_modes)(struct drm_panel *panel);
>  

Hi!

If .get_modes is mandatory, then panel->func != NULL checks can be removed
if panel->func and .get_modes presence gets checked at panel probe time.

Best Regards,
Michał Mirosław
_______________________________________________
dri-devel mailing list
dri-devel@xxxxxxxxxxxxxxxxxxxxx
https://lists.freedesktop.org/mailman/listinfo/dri-devel




[Index of Archives]     [Linux DRI Users]     [Linux Intel Graphics]     [Linux USB Devel]     [Video for Linux]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]     [XFree86]     [Linux USB Devel]     [Video for Linux]     [Linux Audio Users]     [Linux Kernel]     [Linux SCSI]     [XFree86]
  Powered by Linux