Hi, On Fri, Oct 13, 2017 at 05:59:44PM +0300, Laurent Pinchart wrote: > As part of an effort to remove the usage of global variables in the > driver, store the registered plls array in the dss_device structure > instead of a global variable. > > Signed-off-by: Laurent Pinchart <laurent.pinchart@xxxxxxxxxxxxxxxx> > --- Reviewed-by: Sebastian Reichel <sebastian.reichel@xxxxxxxxxxxxxxx> -- Sebastian > drivers/gpu/drm/omapdrm/dss/dispc.c | 4 ++-- > drivers/gpu/drm/omapdrm/dss/dpi.c | 17 +++++++------- > drivers/gpu/drm/omapdrm/dss/dsi.c | 3 +-- > drivers/gpu/drm/omapdrm/dss/dss.h | 12 +++++----- > drivers/gpu/drm/omapdrm/dss/hdmi_pll.c | 3 +-- > drivers/gpu/drm/omapdrm/dss/pll.c | 40 +++++++++++++++++---------------- > drivers/gpu/drm/omapdrm/dss/video-pll.c | 3 +-- > 7 files changed, 42 insertions(+), 40 deletions(-) > > diff --git a/drivers/gpu/drm/omapdrm/dss/dispc.c b/drivers/gpu/drm/omapdrm/dss/dispc.c > index 5eacf4cdac54..181a8ea072b1 100644 > --- a/drivers/gpu/drm/omapdrm/dss/dispc.c > +++ b/drivers/gpu/drm/omapdrm/dss/dispc.c > @@ -3252,7 +3252,7 @@ static unsigned long dispc_fclk_rate(struct dispc_device *dispc) > struct dss_pll *pll; > unsigned int clkout_idx; > > - pll = dss_pll_find_by_src(src); > + pll = dss_pll_find_by_src(dispc->dss, src); > clkout_idx = dss_pll_get_clkout_idx_for_src(src); > > r = pll->cinfo.clkout[clkout_idx]; > @@ -3280,7 +3280,7 @@ static unsigned long dispc_mgr_lclk_rate(struct dispc_device *dispc, > struct dss_pll *pll; > unsigned int clkout_idx; > > - pll = dss_pll_find_by_src(src); > + pll = dss_pll_find_by_src(dispc->dss, src); > clkout_idx = dss_pll_get_clkout_idx_for_src(src); > > r = pll->cinfo.clkout[clkout_idx]; > diff --git a/drivers/gpu/drm/omapdrm/dss/dpi.c b/drivers/gpu/drm/omapdrm/dss/dpi.c > index 66183fc77bb2..2fb9406d2059 100644 > --- a/drivers/gpu/drm/omapdrm/dss/dpi.c > +++ b/drivers/gpu/drm/omapdrm/dss/dpi.c > @@ -60,7 +60,8 @@ static struct dpi_data *dpi_get_data_from_dssdev(struct omap_dss_device *dssdev) > return container_of(dssdev, struct dpi_data, output); > } > > -static enum dss_clk_source dpi_get_clk_src_dra7xx(enum omap_channel channel) > +static enum dss_clk_source dpi_get_clk_src_dra7xx(struct dpi_data *dpi, > + enum omap_channel channel) > { > /* > * Possible clock sources: > @@ -72,23 +73,23 @@ static enum dss_clk_source dpi_get_clk_src_dra7xx(enum omap_channel channel) > switch (channel) { > case OMAP_DSS_CHANNEL_LCD: > { > - if (dss_pll_find_by_src(DSS_CLK_SRC_PLL1_1)) > + if (dss_pll_find_by_src(dpi->dss, DSS_CLK_SRC_PLL1_1)) > return DSS_CLK_SRC_PLL1_1; > break; > } > case OMAP_DSS_CHANNEL_LCD2: > { > - if (dss_pll_find_by_src(DSS_CLK_SRC_PLL1_3)) > + if (dss_pll_find_by_src(dpi->dss, DSS_CLK_SRC_PLL1_3)) > return DSS_CLK_SRC_PLL1_3; > - if (dss_pll_find_by_src(DSS_CLK_SRC_PLL2_3)) > + if (dss_pll_find_by_src(dpi->dss, DSS_CLK_SRC_PLL2_3)) > return DSS_CLK_SRC_PLL2_3; > break; > } > case OMAP_DSS_CHANNEL_LCD3: > { > - if (dss_pll_find_by_src(DSS_CLK_SRC_PLL2_1)) > + if (dss_pll_find_by_src(dpi->dss, DSS_CLK_SRC_PLL2_1)) > return DSS_CLK_SRC_PLL2_1; > - if (dss_pll_find_by_src(DSS_CLK_SRC_PLL1_3)) > + if (dss_pll_find_by_src(dpi->dss, DSS_CLK_SRC_PLL1_3)) > return DSS_CLK_SRC_PLL1_3; > break; > } > @@ -135,7 +136,7 @@ static enum dss_clk_source dpi_get_clk_src(struct dpi_data *dpi) > } > > case DSS_MODEL_DRA7: > - return dpi_get_clk_src_dra7xx(channel); > + return dpi_get_clk_src_dra7xx(dpi, channel); > > default: > return DSS_CLK_SRC_FCK; > @@ -603,7 +604,7 @@ static void dpi_init_pll(struct dpi_data *dpi) > > dpi->clk_src = dpi_get_clk_src(dpi); > > - pll = dss_pll_find_by_src(dpi->clk_src); > + pll = dss_pll_find_by_src(dpi->dss, dpi->clk_src); > if (!pll) > return; > > diff --git a/drivers/gpu/drm/omapdrm/dss/dsi.c b/drivers/gpu/drm/omapdrm/dss/dsi.c > index 48ea5285cf20..bc9d6b7ce6a9 100644 > --- a/drivers/gpu/drm/omapdrm/dss/dsi.c > +++ b/drivers/gpu/drm/omapdrm/dss/dsi.c > @@ -5226,9 +5226,8 @@ static int dsi_init_pll_data(struct dss_device *dss, struct dsi_data *dsi) > pll->base = dsi->pll_base; > pll->hw = dsi->data->pll_hw; > pll->ops = &dsi_pll_ops; > - pll->dss = dss; > > - r = dss_pll_register(pll); > + r = dss_pll_register(dss, pll); > if (r) > return r; > > diff --git a/drivers/gpu/drm/omapdrm/dss/dss.h b/drivers/gpu/drm/omapdrm/dss/dss.h > index 76a2561dfd22..9ca4391624cc 100644 > --- a/drivers/gpu/drm/omapdrm/dss/dss.h > +++ b/drivers/gpu/drm/omapdrm/dss/dss.h > @@ -276,8 +276,9 @@ struct dss_device { > struct dss_debugfs_entry *dss; > } debugfs; > > - struct dss_pll *video1_pll; > - struct dss_pll *video2_pll; > + struct dss_pll *plls[4]; > + struct dss_pll *video1_pll; > + struct dss_pll *video2_pll; > > struct dispc_device *dispc; > }; > @@ -499,10 +500,11 @@ typedef bool (*dss_pll_calc_func)(int n, int m, unsigned long fint, > typedef bool (*dss_hsdiv_calc_func)(int m_dispc, unsigned long dispc, > void *data); > > -int dss_pll_register(struct dss_pll *pll); > +int dss_pll_register(struct dss_device *dss, struct dss_pll *pll); > void dss_pll_unregister(struct dss_pll *pll); > -struct dss_pll *dss_pll_find(const char *name); > -struct dss_pll *dss_pll_find_by_src(enum dss_clk_source src); > +struct dss_pll *dss_pll_find(struct dss_device *dss, const char *name); > +struct dss_pll *dss_pll_find_by_src(struct dss_device *dss, > + enum dss_clk_source src); > unsigned int dss_pll_get_clkout_idx_for_src(enum dss_clk_source src); > int dss_pll_enable(struct dss_pll *pll); > void dss_pll_disable(struct dss_pll *pll); > diff --git a/drivers/gpu/drm/omapdrm/dss/hdmi_pll.c b/drivers/gpu/drm/omapdrm/dss/hdmi_pll.c > index 4da32c261c30..d1116757182e 100644 > --- a/drivers/gpu/drm/omapdrm/dss/hdmi_pll.c > +++ b/drivers/gpu/drm/omapdrm/dss/hdmi_pll.c > @@ -146,7 +146,6 @@ static int hdmi_init_pll_data(struct dss_device *dss, > pll->id = DSS_PLL_HDMI; > pll->base = hpll->base; > pll->clkin = clk; > - pll->dss = dss; > > if (hpll->wp->version == 4) > pll->hw = &dss_omap4_hdmi_pll_hw; > @@ -155,7 +154,7 @@ static int hdmi_init_pll_data(struct dss_device *dss, > > pll->ops = &hdmi_pll_ops; > > - r = dss_pll_register(pll); > + r = dss_pll_register(dss, pll); > if (r) > return r; > > diff --git a/drivers/gpu/drm/omapdrm/dss/pll.c b/drivers/gpu/drm/omapdrm/dss/pll.c > index d298cd5a927a..56fc2fccd0e0 100644 > --- a/drivers/gpu/drm/omapdrm/dss/pll.c > +++ b/drivers/gpu/drm/omapdrm/dss/pll.c > @@ -35,15 +35,14 @@ > #define PLL_SSC_CONFIGURATION2 0x001C > #define PLL_CONFIGURATION4 0x0020 > > -static struct dss_pll *dss_plls[4]; > - > -int dss_pll_register(struct dss_pll *pll) > +int dss_pll_register(struct dss_device *dss, struct dss_pll *pll) > { > int i; > > - for (i = 0; i < ARRAY_SIZE(dss_plls); ++i) { > - if (!dss_plls[i]) { > - dss_plls[i] = pll; > + for (i = 0; i < ARRAY_SIZE(dss->plls); ++i) { > + if (!dss->plls[i]) { > + dss->plls[i] = pll; > + pll->dss = dss; > return 0; > } > } > @@ -53,29 +52,32 @@ int dss_pll_register(struct dss_pll *pll) > > void dss_pll_unregister(struct dss_pll *pll) > { > + struct dss_device *dss = pll->dss; > int i; > > - for (i = 0; i < ARRAY_SIZE(dss_plls); ++i) { > - if (dss_plls[i] == pll) { > - dss_plls[i] = NULL; > + for (i = 0; i < ARRAY_SIZE(dss->plls); ++i) { > + if (dss->plls[i] == pll) { > + dss->plls[i] = NULL; > + pll->dss = NULL; > return; > } > } > } > > -struct dss_pll *dss_pll_find(const char *name) > +struct dss_pll *dss_pll_find(struct dss_device *dss, const char *name) > { > int i; > > - for (i = 0; i < ARRAY_SIZE(dss_plls); ++i) { > - if (dss_plls[i] && strcmp(dss_plls[i]->name, name) == 0) > - return dss_plls[i]; > + for (i = 0; i < ARRAY_SIZE(dss->plls); ++i) { > + if (dss->plls[i] && strcmp(dss->plls[i]->name, name) == 0) > + return dss->plls[i]; > } > > return NULL; > } > > -struct dss_pll *dss_pll_find_by_src(enum dss_clk_source src) > +struct dss_pll *dss_pll_find_by_src(struct dss_device *dss, > + enum dss_clk_source src) > { > struct dss_pll *pll; > > @@ -85,22 +87,22 @@ struct dss_pll *dss_pll_find_by_src(enum dss_clk_source src) > return NULL; > > case DSS_CLK_SRC_HDMI_PLL: > - return dss_pll_find("hdmi"); > + return dss_pll_find(dss, "hdmi"); > > case DSS_CLK_SRC_PLL1_1: > case DSS_CLK_SRC_PLL1_2: > case DSS_CLK_SRC_PLL1_3: > - pll = dss_pll_find("dsi0"); > + pll = dss_pll_find(dss, "dsi0"); > if (!pll) > - pll = dss_pll_find("video0"); > + pll = dss_pll_find(dss, "video0"); > return pll; > > case DSS_CLK_SRC_PLL2_1: > case DSS_CLK_SRC_PLL2_2: > case DSS_CLK_SRC_PLL2_3: > - pll = dss_pll_find("dsi1"); > + pll = dss_pll_find(dss, "dsi1"); > if (!pll) > - pll = dss_pll_find("video1"); > + pll = dss_pll_find(dss, "video1"); > return pll; > } > } > diff --git a/drivers/gpu/drm/omapdrm/dss/video-pll.c b/drivers/gpu/drm/omapdrm/dss/video-pll.c > index 989a5ee4433a..2ea50cbe53ab 100644 > --- a/drivers/gpu/drm/omapdrm/dss/video-pll.c > +++ b/drivers/gpu/drm/omapdrm/dss/video-pll.c > @@ -188,9 +188,8 @@ struct dss_pll *dss_video_pll_init(struct dss_device *dss, > pll->base = pll_base; > pll->hw = &dss_dra7_video_pll_hw; > pll->ops = &dss_pll_ops; > - pll->dss = dss; > > - r = dss_pll_register(pll); > + r = dss_pll_register(dss, pll); > if (r) > return ERR_PTR(r); > > -- > Regards, > > Laurent Pinchart > > _______________________________________________ > dri-devel mailing list > dri-devel@xxxxxxxxxxxxxxxxxxxxx > https://lists.freedesktop.org/mailman/listinfo/dri-devel
Attachment:
signature.asc
Description: PGP signature
_______________________________________________ dri-devel mailing list dri-devel@xxxxxxxxxxxxxxxxxxxxx https://lists.freedesktop.org/mailman/listinfo/dri-devel