lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20171129015222.c4iohxyai5gw3idi@art_vandelay>
Date:   Tue, 28 Nov 2017 20:52:22 -0500
From:   Sean Paul <seanpaul@...omium.org>
To:     Nickey Yang <nickey.yang@...k-chips.com>
Cc:     robh+dt@...nel.org, heiko@...ech.de, mark.rutland@....com,
        airlied@...ux.ie, linux-kernel@...r.kernel.org,
        dri-devel@...ts.freedesktop.org,
        linux-rockchip@...ts.infradead.org, seanpaul@...omium.org,
        briannorris@...omium.org, mka@...omium.org, hoegsberg@...il.com,
        architt@...eaurora.org, philippe.cornu@...com,
        yannick.fertre@...com, hl@...k-chips.com, zyw@...k-chips.com,
        xbl@...k-chips.com
Subject: Re: [PATCH v3 1/5] drm/bridge/synopsys: stop clobbering drvdata

On Tue, Nov 28, 2017 at 07:20:02PM +0800, Nickey Yang wrote:

Looks like you paved the author. This should be From: Brian.

Sean

> Bridge drivers/helpers shouldn't be clobbering the drvdata, since a
> parent driver might need to own this. Instead, let's return our
> 'dw_mipi_dsi' object and have callers pass that back to us for removal.
> 
> Signed-off-by: Brian Norris <briannorris@...omium.org>
> Reviewed-by: Matthias Kaehlcke <mka@...omium.org>
> Reviewed-by: Archit Taneja <architt@...eaurora.org>
> Acked-by: Philippe Cornu <philippe.cornu@...com>
> Link:https://patchwork.kernel.org/patch/10078493/
> ---
>  drivers/gpu/drm/bridge/synopsys/dw-mipi-dsi.c | 36 ++++++++++-----------------
>  include/drm/bridge/dw_mipi_dsi.h              | 17 ++++++++-----
>  2 files changed, 24 insertions(+), 29 deletions(-)
> 
> diff --git a/drivers/gpu/drm/bridge/synopsys/dw-mipi-dsi.c b/drivers/gpu/drm/bridge/synopsys/dw-mipi-dsi.c
> index d9cca4f..c39c7dc 100644
> --- a/drivers/gpu/drm/bridge/synopsys/dw-mipi-dsi.c
> +++ b/drivers/gpu/drm/bridge/synopsys/dw-mipi-dsi.c
> @@ -922,8 +922,6 @@ static int dw_mipi_dsi_bridge_attach(struct drm_bridge *bridge)
>  	dsi->bridge.of_node = pdev->dev.of_node;
>  #endif
>  
> -	dev_set_drvdata(dev, dsi);
> -
>  	return dsi;
>  }
>  
> @@ -935,23 +933,16 @@ static void __dw_mipi_dsi_remove(struct dw_mipi_dsi *dsi)
>  /*
>   * Probe/remove API, used from platforms based on the DRM bridge API.
>   */
> -int dw_mipi_dsi_probe(struct platform_device *pdev,
> -		      const struct dw_mipi_dsi_plat_data *plat_data)
> +struct dw_mipi_dsi *
> +dw_mipi_dsi_probe(struct platform_device *pdev,
> +		  const struct dw_mipi_dsi_plat_data *plat_data)
>  {
> -	struct dw_mipi_dsi *dsi;
> -
> -	dsi = __dw_mipi_dsi_probe(pdev, plat_data);
> -	if (IS_ERR(dsi))
> -		return PTR_ERR(dsi);
> -
> -	return 0;
> +	return __dw_mipi_dsi_probe(pdev, plat_data);
>  }
>  EXPORT_SYMBOL_GPL(dw_mipi_dsi_probe);
>  
> -void dw_mipi_dsi_remove(struct platform_device *pdev)
> +void dw_mipi_dsi_remove(struct dw_mipi_dsi *dsi)
>  {
> -	struct dw_mipi_dsi *dsi = platform_get_drvdata(pdev);
> -
>  	mipi_dsi_host_unregister(&dsi->dsi_host);
>  
>  	__dw_mipi_dsi_remove(dsi);
> @@ -961,31 +952,30 @@ void dw_mipi_dsi_remove(struct platform_device *pdev)
>  /*
>   * Bind/unbind API, used from platforms based on the component framework.
>   */
> -int dw_mipi_dsi_bind(struct platform_device *pdev, struct drm_encoder *encoder,
> -		     const struct dw_mipi_dsi_plat_data *plat_data)
> +struct dw_mipi_dsi *
> +dw_mipi_dsi_bind(struct platform_device *pdev, struct drm_encoder *encoder,
> +		 const struct dw_mipi_dsi_plat_data *plat_data)
>  {
>  	struct dw_mipi_dsi *dsi;
>  	int ret;
>  
>  	dsi = __dw_mipi_dsi_probe(pdev, plat_data);
>  	if (IS_ERR(dsi))
> -		return PTR_ERR(dsi);
> +		return dsi;
>  
>  	ret = drm_bridge_attach(encoder, &dsi->bridge, NULL);
>  	if (ret) {
> -		dw_mipi_dsi_remove(pdev);
> +		dw_mipi_dsi_remove(dsi);
>  		DRM_ERROR("Failed to initialize bridge with drm\n");
> -		return ret;
> +		return ERR_PTR(ret);
>  	}
>  
> -	return 0;
> +	return dsi;
>  }
>  EXPORT_SYMBOL_GPL(dw_mipi_dsi_bind);
>  
> -void dw_mipi_dsi_unbind(struct device *dev)
> +void dw_mipi_dsi_unbind(struct dw_mipi_dsi *dsi)
>  {
> -	struct dw_mipi_dsi *dsi = dev_get_drvdata(dev);
> -
>  	__dw_mipi_dsi_remove(dsi);
>  }
>  EXPORT_SYMBOL_GPL(dw_mipi_dsi_unbind);
> diff --git a/include/drm/bridge/dw_mipi_dsi.h b/include/drm/bridge/dw_mipi_dsi.h
> index 9b30fec..d9c6d54 100644
> --- a/include/drm/bridge/dw_mipi_dsi.h
> +++ b/include/drm/bridge/dw_mipi_dsi.h
> @@ -10,6 +10,8 @@
>  #ifndef __DW_MIPI_DSI__
>  #define __DW_MIPI_DSI__
>  
> +struct dw_mipi_dsi;
> +
>  struct dw_mipi_dsi_phy_ops {
>  	int (*init)(void *priv_data);
>  	int (*get_lane_mbps)(void *priv_data, struct drm_display_mode *mode,
> @@ -29,11 +31,14 @@ struct dw_mipi_dsi_plat_data {
>  	void *priv_data;
>  };
>  
> -int dw_mipi_dsi_probe(struct platform_device *pdev,
> -		      const struct dw_mipi_dsi_plat_data *plat_data);
> -void dw_mipi_dsi_remove(struct platform_device *pdev);
> -int dw_mipi_dsi_bind(struct platform_device *pdev, struct drm_encoder *encoder,
> -		     const struct dw_mipi_dsi_plat_data *plat_data);
> -void dw_mipi_dsi_unbind(struct device *dev);
> +struct dw_mipi_dsi *dw_mipi_dsi_probe(struct platform_device *pdev,
> +				      const struct dw_mipi_dsi_plat_data
> +				      *plat_data);
> +void dw_mipi_dsi_remove(struct dw_mipi_dsi *dsi);
> +struct dw_mipi_dsi *dw_mipi_dsi_bind(struct platform_device *pdev,
> +				     struct drm_encoder *encoder,
> +				     const struct dw_mipi_dsi_plat_data
> +				     *plat_data);
> +void dw_mipi_dsi_unbind(struct dw_mipi_dsi *dsi);
>  
>  #endif /* __DW_MIPI_DSI__ */
> -- 
> 1.9.1
> 

-- 
Sean Paul, Software Engineer, Google / Chromium OS

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ