public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
To: Brian Norris <briannorris@chromium.org>
Cc: Archit Taneja <architt@codeaurora.org>,
	Andrzej Hajda <a.hajda@samsung.com>,
	David Airlie <airlied@linux.ie>,
	Yannick Fertre <yannick.fertre@st.com>,
	Philippe Cornu <philippe.cornu@st.com>,
	Benjamin Gaignard <benjamin.gaignard@linaro.org>,
	Vincent Abriou <vincent.abriou@st.com>,
	dri-devel@lists.freedesktop.org, linux-kernel@vger.kernel.org,
	Sean Paul <seanpaul@chromium.org>,
	Nickey Yang <nickey.yang@rock-chips.com>,
	hl@rock-chips.com, linux-rockchip@lists.infradead.org,
	mka@chromium.org
Subject: Re: [PATCH] drm/bridge/synopsis: stop clobbering drvdata
Date: Tue, 28 Nov 2017 14:51:46 +0200	[thread overview]
Message-ID: <1743921.AofnJoQ8Rz@avalon> (raw)
In-Reply-To: <20171128010538.119114-1-briannorris@chromium.org>

Hi Brian,

Thank you for the patch.

I'd mention dw-mipi-dsi in the subject line as the directory contains the dw-
hdmi driver as well that this patch doesn't touch.

On Tuesday, 28 November 2017 03:05:38 EET Brian Norris wrote:
> Bridge drivers/helpers shouldn't be clobbering the drvdata, since a
> parent driver might need to own this.

By parent driver I assume you mean a glue driver that binds to the SoC-
specific compatible string for the DSI transmitter.

> 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@chromium.org>

Wouldn't it be cleaner to embed the dw_mipi_dsi structure in the parent-
specific data structure (struct dw_mipi_dsi_stm and struct 
dw_mipi_dsi_rockchip when the "[PATCH v3 0/5] Update ROCKCHIP DSI driver that 
uses dw-mipi-dsi bridge" patch series will land) instead of allocating it 
dynamically ? We would then have a single object to track.

> ---
>  drivers/gpu/drm/bridge/synopsys/dw-mipi-dsi.c | 36 ++++++++++--------------
>  drivers/gpu/drm/stm/dw_mipi_dsi-stm.c         | 14 +++++++----
>  include/drm/bridge/dw_mipi_dsi.h              | 17 ++++++++-----
>  3 files changed, 33 insertions(+), 34 deletions(-)
> 
> diff --git a/drivers/gpu/drm/bridge/synopsys/dw-mipi-dsi.c
> b/drivers/gpu/drm/bridge/synopsys/dw-mipi-dsi.c index
> d9cca4fd66ec..c39c7dce20ed 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 @@ __dw_mipi_dsi_probe(struct platform_device *pdev,
>  	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 @@ EXPORT_SYMBOL_GPL(dw_mipi_dsi_remove);
>  /*
>   * 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/drivers/gpu/drm/stm/dw_mipi_dsi-stm.c
> b/drivers/gpu/drm/stm/dw_mipi_dsi-stm.c index e5b6310240fe..7ed0ef7f6ec2
> 100644
> --- a/drivers/gpu/drm/stm/dw_mipi_dsi-stm.c
> +++ b/drivers/gpu/drm/stm/dw_mipi_dsi-stm.c
> @@ -66,6 +66,7 @@ enum dsi_color {
>  struct dw_mipi_dsi_stm {
>  	void __iomem *base;
>  	struct clk *pllref_clk;
> +	struct dw_mipi_dsi *dsi;
>  };
> 
>  static inline void dsi_write(struct dw_mipi_dsi_stm *dsi, u32 reg, u32 val)
> @@ -318,21 +319,24 @@ static int dw_mipi_dsi_stm_probe(struct
> platform_device *pdev) dw_mipi_dsi_stm_plat_data.base = dsi->base;
>  	dw_mipi_dsi_stm_plat_data.priv_data = dsi;
> 
> -	ret = dw_mipi_dsi_probe(pdev, &dw_mipi_dsi_stm_plat_data);
> -	if (ret) {
> +	platform_set_drvdata(pdev, dsi);
> +
> +	dsi->dsi = dw_mipi_dsi_probe(pdev, &dw_mipi_dsi_stm_plat_data);
> +	if (IS_ERR(dsi->dsi)) {
>  		DRM_ERROR("Failed to initialize mipi dsi host\n");
>  		clk_disable_unprepare(dsi->pllref_clk);
> +		return PTR_ERR(dsi->dsi);
>  	}
> 
> -	return ret;
> +	return 0;
>  }
> 
>  static int dw_mipi_dsi_stm_remove(struct platform_device *pdev)
>  {
> -	struct dw_mipi_dsi_stm *dsi = dw_mipi_dsi_stm_plat_data.priv_data;
> +	struct dw_mipi_dsi_stm *dsi = platform_get_drvdata(pdev);
> 
>  	clk_disable_unprepare(dsi->pllref_clk);
> -	dw_mipi_dsi_remove(pdev);
> +	dw_mipi_dsi_remove(dsi->dsi);
> 
>  	return 0;
>  }
> diff --git a/include/drm/bridge/dw_mipi_dsi.h
> b/include/drm/bridge/dw_mipi_dsi.h index 9b30fec302c8..d9c6d549f971 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__ */

-- 
Regards,

Laurent Pinchart

  parent reply	other threads:[~2017-11-28 12:51 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-11-28  1:05 [PATCH] drm/bridge/synopsis: stop clobbering drvdata Brian Norris
2017-11-28  2:25 ` Matthias Kaehlcke
2017-11-28  6:27 ` Archit Taneja
2017-11-28  9:34 ` Philippe CORNU
2018-01-09 13:01   ` Philippe CORNU
2018-01-09 13:37     ` Laurent Pinchart
2018-01-09 13:45       ` Andrzej Hajda
2017-11-28 12:51 ` Laurent Pinchart [this message]
2017-11-28 18:21   ` Brian Norris
2018-01-09 13:36     ` Laurent Pinchart

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1743921.AofnJoQ8Rz@avalon \
    --to=laurent.pinchart@ideasonboard.com \
    --cc=a.hajda@samsung.com \
    --cc=airlied@linux.ie \
    --cc=architt@codeaurora.org \
    --cc=benjamin.gaignard@linaro.org \
    --cc=briannorris@chromium.org \
    --cc=dri-devel@lists.freedesktop.org \
    --cc=hl@rock-chips.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-rockchip@lists.infradead.org \
    --cc=mka@chromium.org \
    --cc=nickey.yang@rock-chips.com \
    --cc=philippe.cornu@st.com \
    --cc=seanpaul@chromium.org \
    --cc=vincent.abriou@st.com \
    --cc=yannick.fertre@st.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox