Re: [PATCH] drm/bridge/synopsis: stop clobbering drvdata
From: Philippe CORNU
Date: Tue Jan 09 2018 - 08:01:48 EST
Hi Archit, Andrzej & Laurent,
Regarding this patch from Brian, I think it could be nice to merge it
(1xAcked-by, 2xReviewed-by).
Could you please have a look?
Only the small "typo" in the headline needs to be changed.
Many thanks,
Philippe :-)
On 11/28/2017 10:34 AM, Philippe CORNU wrote:
> Hi Brian,
>
> On 11/28/2017 02:05 AM, Brian Norris wrote:
>> 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.
>
> And many thanks for this cleanup.
> (please update the headline with "synopsys")
>
> Successfully tested on stm.
>
> Acked-by: Philippe Cornu <philippe.cornu@xxxxxx>
>
> Many thanks,
> Philippe :-)
>>
>> Signed-off-by: Brian Norris <briannorris@xxxxxxxxxxxx>
>> ---
>> Â 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__ */
>>