Commit 6dbe0c4b authored by Laurent Pinchart's avatar Laurent Pinchart Committed by Sam Ravnborg

drm/panel: Initialise panel dev and funcs through drm_panel_init()

Instead of requiring all drivers to set the dev and funcs fields of
drm_panel manually after calling drm_panel_init(), pass the data as
arguments to the function. This simplifies the panel drivers, and will
help future refactoring when adding new arguments to drm_panel_init().

The panel drivers have been updated with the following Coccinelle
semantic patch, with manual inspection to verify that no call to
drm_panel_init() with a single argument still exists.

@@
expression panel;
expression device;
identifier ops;
@@
 drm_panel_init(&panel
+	, device, &ops
 );
 ...
(
-panel.dev = device;
-panel.funcs = &ops;
|
-panel.funcs = &ops;
-panel.dev = device;
)
Suggested-by: default avatarSam Ravnborg <sam@ravnborg.org>
Signed-off-by: default avatarLaurent Pinchart <laurent.pinchart@ideasonboard.com>
Signed-off-by: default avatarSam Ravnborg <sam@ravnborg.org>
Link: https://patchwork.freedesktop.org/patch/msgid/20190823193245.23876-3-laurent.pinchart@ideasonboard.com
parent 65abbda8
......@@ -44,13 +44,18 @@ static LIST_HEAD(panel_list);
/**
* drm_panel_init - initialize a panel
* @panel: DRM panel
* @dev: parent device of the panel
* @funcs: panel operations
*
* Sets up internal fields of the panel so that it can subsequently be added
* to the registry.
* Initialize the panel structure for subsequent registration with
* drm_panel_add().
*/
void drm_panel_init(struct drm_panel *panel)
void drm_panel_init(struct drm_panel *panel, struct device *dev,
const struct drm_panel_funcs *funcs)
{
INIT_LIST_HEAD(&panel->list);
panel->dev = dev;
panel->funcs = funcs;
}
EXPORT_SYMBOL(drm_panel_init);
......
......@@ -350,9 +350,7 @@ static int versatile_panel_probe(struct platform_device *pdev)
dev_info(dev, "panel mounted on IB2 daughterboard\n");
}
drm_panel_init(&vpanel->panel);
vpanel->panel.dev = dev;
vpanel->panel.funcs = &versatile_panel_drm_funcs;
drm_panel_init(&vpanel->panel, dev, &versatile_panel_drm_funcs);
return drm_panel_add(&vpanel->panel);
}
......
......@@ -204,9 +204,7 @@ static int feiyang_dsi_probe(struct mipi_dsi_device *dsi)
mipi_dsi_set_drvdata(dsi, ctx);
ctx->dsi = dsi;
drm_panel_init(&ctx->panel);
ctx->panel.dev = &dsi->dev;
ctx->panel.funcs = &feiyang_funcs;
drm_panel_init(&ctx->panel, &dsi->dev, &feiyang_funcs);
ctx->dvdd = devm_regulator_get(&dsi->dev, "dvdd");
if (IS_ERR(ctx->dvdd)) {
......
......@@ -895,9 +895,7 @@ static int ili9322_probe(struct spi_device *spi)
ili->input = ili->conf->input;
}
drm_panel_init(&ili->panel);
ili->panel.dev = dev;
ili->panel.funcs = &ili9322_drm_funcs;
drm_panel_init(&ili->panel, dev, &ili9322_drm_funcs);
return drm_panel_add(&ili->panel);
}
......
......@@ -433,9 +433,7 @@ static int ili9881c_dsi_probe(struct mipi_dsi_device *dsi)
mipi_dsi_set_drvdata(dsi, ctx);
ctx->dsi = dsi;
drm_panel_init(&ctx->panel);
ctx->panel.dev = &dsi->dev;
ctx->panel.funcs = &ili9881c_funcs;
drm_panel_init(&ctx->panel, &dsi->dev, &ili9881c_funcs);
ctx->power = devm_regulator_get(&dsi->dev, "power");
if (IS_ERR(ctx->power)) {
......
......@@ -487,9 +487,7 @@ static int innolux_panel_add(struct mipi_dsi_device *dsi,
if (IS_ERR(innolux->backlight))
return PTR_ERR(innolux->backlight);
drm_panel_init(&innolux->base);
innolux->base.funcs = &innolux_panel_funcs;
innolux->base.dev = dev;
drm_panel_init(&innolux->base, dev, &innolux_panel_funcs);
err = drm_panel_add(&innolux->base);
if (err < 0)
......
......@@ -437,9 +437,7 @@ static int jdi_panel_add(struct jdi_panel *jdi)
return ret;
}
drm_panel_init(&jdi->base);
jdi->base.funcs = &jdi_panel_funcs;
jdi->base.dev = &jdi->dsi->dev;
drm_panel_init(&jdi->base, &jdi->dsi->dev, &jdi_panel_funcs);
ret = drm_panel_add(&jdi->base);
......
......@@ -391,9 +391,8 @@ static int kingdisplay_panel_add(struct kingdisplay_panel *kingdisplay)
if (IS_ERR(kingdisplay->backlight))
return PTR_ERR(kingdisplay->backlight);
drm_panel_init(&kingdisplay->base);
kingdisplay->base.funcs = &kingdisplay_panel_funcs;
kingdisplay->base.dev = &kingdisplay->link->dev;
drm_panel_init(&kingdisplay->base, &kingdisplay->link->dev,
&kingdisplay_panel_funcs);
return drm_panel_add(&kingdisplay->base);
}
......
......@@ -196,9 +196,7 @@ static int lb035q02_probe(struct spi_device *spi)
if (ret < 0)
return ret;
drm_panel_init(&lcd->panel);
lcd->panel.dev = &lcd->spi->dev;
lcd->panel.funcs = &lb035q02_funcs;
drm_panel_init(&lcd->panel, &lcd->spi->dev, &lb035q02_funcs);
return drm_panel_add(&lcd->panel);
}
......
......@@ -259,9 +259,7 @@ static int lg4573_probe(struct spi_device *spi)
return ret;
}
drm_panel_init(&ctx->panel);
ctx->panel.dev = &spi->dev;
ctx->panel.funcs = &lg4573_drm_funcs;
drm_panel_init(&ctx->panel, &spi->dev, &lg4573_drm_funcs);
return drm_panel_add(&ctx->panel);
}
......
......@@ -260,9 +260,7 @@ static int panel_lvds_probe(struct platform_device *pdev)
*/
/* Register the panel. */
drm_panel_init(&lvds->panel);
lvds->panel.dev = lvds->dev;
lvds->panel.funcs = &panel_lvds_funcs;
drm_panel_init(&lvds->panel, lvds->dev, &panel_lvds_funcs);
ret = drm_panel_add(&lvds->panel);
if (ret < 0)
......
......@@ -205,9 +205,7 @@ static int nl8048_probe(struct spi_device *spi)
if (ret < 0)
return ret;
drm_panel_init(&lcd->panel);
lcd->panel.dev = &lcd->spi->dev;
lcd->panel.funcs = &nl8048_funcs;
drm_panel_init(&lcd->panel, &lcd->spi->dev, &nl8048_funcs);
return drm_panel_add(&lcd->panel);
}
......
......@@ -292,9 +292,7 @@ static int nt39016_probe(struct spi_device *spi)
return err;
}
drm_panel_init(&panel->drm_panel);
panel->drm_panel.dev = dev;
panel->drm_panel.funcs = &nt39016_funcs;
drm_panel_init(&panel->drm_panel, dev, &nt39016_funcs);
err = drm_panel_add(&panel->drm_panel);
if (err < 0) {
......
......@@ -288,9 +288,7 @@ static int lcd_olinuxino_probe(struct i2c_client *client,
if (IS_ERR(lcd->backlight))
return PTR_ERR(lcd->backlight);
drm_panel_init(&lcd->panel);
lcd->panel.dev = dev;
lcd->panel.funcs = &lcd_olinuxino_funcs;
drm_panel_init(&lcd->panel, dev, &lcd_olinuxino_funcs);
return drm_panel_add(&lcd->panel);
}
......
......@@ -455,9 +455,7 @@ static int otm8009a_probe(struct mipi_dsi_device *dsi)
dsi->mode_flags = MIPI_DSI_MODE_VIDEO | MIPI_DSI_MODE_VIDEO_BURST |
MIPI_DSI_MODE_LPM;
drm_panel_init(&ctx->panel);
ctx->panel.dev = dev;
ctx->panel.funcs = &otm8009a_drm_funcs;
drm_panel_init(&ctx->panel, dev, &otm8009a_drm_funcs);
ctx->bl_dev = devm_backlight_device_register(dev, dev_name(dev),
dsi->host->dev, ctx,
......
......@@ -166,9 +166,8 @@ static int osd101t2587_panel_add(struct osd101t2587_panel *osd101t2587)
if (IS_ERR(osd101t2587->backlight))
return PTR_ERR(osd101t2587->backlight);
drm_panel_init(&osd101t2587->base);
osd101t2587->base.funcs = &osd101t2587_panel_funcs;
osd101t2587->base.dev = &osd101t2587->dsi->dev;
drm_panel_init(&osd101t2587->base, &osd101t2587->dsi->dev,
&osd101t2587_panel_funcs);
return drm_panel_add(&osd101t2587->base);
}
......
......@@ -223,9 +223,8 @@ static int wuxga_nt_panel_add(struct wuxga_nt_panel *wuxga_nt)
return -EPROBE_DEFER;
}
drm_panel_init(&wuxga_nt->base);
wuxga_nt->base.funcs = &wuxga_nt_panel_funcs;
wuxga_nt->base.dev = &wuxga_nt->dsi->dev;
drm_panel_init(&wuxga_nt->base, &wuxga_nt->dsi->dev,
&wuxga_nt_panel_funcs);
ret = drm_panel_add(&wuxga_nt->base);
if (ret < 0)
......
......@@ -426,9 +426,7 @@ static int rpi_touchscreen_probe(struct i2c_client *i2c,
return PTR_ERR(ts->dsi);
}
drm_panel_init(&ts->base);
ts->base.dev = dev;
ts->base.funcs = &rpi_touchscreen_funcs;
drm_panel_init(&ts->base, dev, &rpi_touchscreen_funcs);
/* This appears last, as it's what will unblock the DSI host
* driver's component bind function.
......
......@@ -606,9 +606,7 @@ static int rad_panel_probe(struct mipi_dsi_device *dsi)
if (ret)
return ret;
drm_panel_init(&panel->panel);
panel->panel.funcs = &rad_panel_funcs;
panel->panel.dev = dev;
drm_panel_init(&panel->panel, dev, &rad_panel_funcs);
dev_set_drvdata(dev, panel);
ret = drm_panel_add(&panel->panel);
......
......@@ -404,9 +404,7 @@ static int rm68200_probe(struct mipi_dsi_device *dsi)
dsi->mode_flags = MIPI_DSI_MODE_VIDEO | MIPI_DSI_MODE_VIDEO_BURST |
MIPI_DSI_MODE_LPM;
drm_panel_init(&ctx->panel);
ctx->panel.dev = dev;
ctx->panel.funcs = &rm68200_drm_funcs;
drm_panel_init(&ctx->panel, dev, &rm68200_drm_funcs);
drm_panel_add(&ctx->panel);
......
......@@ -343,9 +343,7 @@ static int jh057n_probe(struct mipi_dsi_device *dsi)
return ret;
}
drm_panel_init(&ctx->panel);
ctx->panel.dev = dev;
ctx->panel.funcs = &jh057n_drm_funcs;
drm_panel_init(&ctx->panel, dev, &jh057n_drm_funcs);
drm_panel_add(&ctx->panel);
......
......@@ -173,9 +173,7 @@ static int rb070d30_panel_dsi_probe(struct mipi_dsi_device *dsi)
mipi_dsi_set_drvdata(dsi, ctx);
ctx->dsi = dsi;
drm_panel_init(&ctx->panel);
ctx->panel.dev = &dsi->dev;
ctx->panel.funcs = &rb070d30_panel_funcs;
drm_panel_init(&ctx->panel, &dsi->dev, &rb070d30_panel_funcs);
ctx->gpios.reset = devm_gpiod_get(&dsi->dev, "reset", GPIOD_OUT_LOW);
if (IS_ERR(ctx->gpios.reset)) {
......
......@@ -351,9 +351,7 @@ static int ld9040_probe(struct spi_device *spi)
return ret;
}
drm_panel_init(&ctx->panel);
ctx->panel.dev = dev;
ctx->panel.funcs = &ld9040_drm_funcs;
drm_panel_init(&ctx->panel, dev, &ld9040_drm_funcs);
return drm_panel_add(&ctx->panel);
}
......
......@@ -215,9 +215,7 @@ static int s6d16d0_probe(struct mipi_dsi_device *dsi)
return ret;
}
drm_panel_init(&s6->panel);
s6->panel.dev = dev;
s6->panel.funcs = &s6d16d0_drm_funcs;
drm_panel_init(&s6->panel, dev, &s6d16d0_drm_funcs);
ret = drm_panel_add(&s6->panel);
if (ret < 0)
......
......@@ -732,9 +732,7 @@ static int s6e3ha2_probe(struct mipi_dsi_device *dsi)
ctx->bl_dev->props.brightness = S6E3HA2_DEFAULT_BRIGHTNESS;
ctx->bl_dev->props.power = FB_BLANK_POWERDOWN;
drm_panel_init(&ctx->panel);
ctx->panel.dev = dev;
ctx->panel.funcs = &s6e3ha2_drm_funcs;
drm_panel_init(&ctx->panel, dev, &s6e3ha2_drm_funcs);
ret = drm_panel_add(&ctx->panel);
if (ret < 0)
......
......@@ -466,9 +466,7 @@ static int s6e63j0x03_probe(struct mipi_dsi_device *dsi)
return PTR_ERR(ctx->reset_gpio);
}
drm_panel_init(&ctx->panel);
ctx->panel.dev = dev;
ctx->panel.funcs = &s6e63j0x03_funcs;
drm_panel_init(&ctx->panel, dev, &s6e63j0x03_funcs);
ctx->bl_dev = backlight_device_register("s6e63j0x03", dev, ctx,
&s6e63j0x03_bl_ops, NULL);
......
......@@ -473,9 +473,7 @@ static int s6e63m0_probe(struct spi_device *spi)
return ret;
}
drm_panel_init(&ctx->panel);
ctx->panel.dev = dev;
ctx->panel.funcs = &s6e63m0_drm_funcs;
drm_panel_init(&ctx->panel, dev, &s6e63m0_drm_funcs);
ret = s6e63m0_backlight_register(ctx);
if (ret < 0)
......
......@@ -1017,9 +1017,7 @@ static int s6e8aa0_probe(struct mipi_dsi_device *dsi)
ctx->brightness = GAMMA_LEVEL_NUM - 1;
drm_panel_init(&ctx->panel);
ctx->panel.dev = dev;
ctx->panel.funcs = &s6e8aa0_drm_funcs;
drm_panel_init(&ctx->panel, dev, &s6e8aa0_drm_funcs);
ret = drm_panel_add(&ctx->panel);
if (ret < 0)
......
......@@ -274,9 +274,7 @@ static int seiko_panel_probe(struct device *dev,
return -EPROBE_DEFER;
}
drm_panel_init(&panel->base);
panel->base.dev = dev;
panel->base.funcs = &seiko_panel_funcs;
drm_panel_init(&panel->base, dev, &seiko_panel_funcs);
err = drm_panel_add(&panel->base);
if (err < 0)
......
......@@ -329,9 +329,7 @@ static int sharp_panel_add(struct sharp_panel *sharp)
if (IS_ERR(sharp->backlight))
return PTR_ERR(sharp->backlight);
drm_panel_init(&sharp->base);
sharp->base.funcs = &sharp_panel_funcs;
sharp->base.dev = &sharp->link1->dev;
drm_panel_init(&sharp->base, &sharp->link1->dev, &sharp_panel_funcs);
return drm_panel_add(&sharp->base);
}
......
......@@ -185,9 +185,7 @@ static int ls037v7dw01_probe(struct platform_device *pdev)
return PTR_ERR(lcd->ud_gpio);
}
drm_panel_init(&lcd->panel);
lcd->panel.dev = &pdev->dev;
lcd->panel.funcs = &ls037v7dw01_funcs;
drm_panel_init(&lcd->panel, &pdev->dev, &ls037v7dw01_funcs);
return drm_panel_add(&lcd->panel);
}
......
......@@ -264,9 +264,8 @@ static int sharp_nt_panel_add(struct sharp_nt_panel *sharp_nt)
if (IS_ERR(sharp_nt->backlight))
return PTR_ERR(sharp_nt->backlight);
drm_panel_init(&sharp_nt->base);
sharp_nt->base.funcs = &sharp_nt_panel_funcs;
sharp_nt->base.dev = &sharp_nt->dsi->dev;
drm_panel_init(&sharp_nt->base, &sharp_nt->dsi->dev,
&sharp_nt_panel_funcs);
return drm_panel_add(&sharp_nt->base);
}
......
......@@ -464,9 +464,7 @@ static int panel_simple_probe(struct device *dev, const struct panel_desc *desc)
if (!of_get_display_timing(dev->of_node, "panel-timing", &dt))
panel_simple_parse_panel_timing_node(dev, panel, &dt);
drm_panel_init(&panel->base);
panel->base.dev = dev;
panel->base.funcs = &panel_simple_funcs;
drm_panel_init(&panel->base, dev, &panel_simple_funcs);
err = drm_panel_add(&panel->base);
if (err < 0)
......
......@@ -369,7 +369,7 @@ static int st7701_dsi_probe(struct mipi_dsi_device *dsi)
if (IS_ERR(st7701->backlight))
return PTR_ERR(st7701->backlight);
drm_panel_init(&st7701->panel);
drm_panel_init(&st7701->panel, &dsi->dev, &st7701_funcs);
/**
* Once sleep out has been issued, ST7701 IC required to wait 120ms
......@@ -381,8 +381,6 @@ static int st7701_dsi_probe(struct mipi_dsi_device *dsi)
* ts8550b and there is no valid documentation for that.
*/
st7701->sleep_delay = 120 + desc->panel_sleep_delay;
st7701->panel.funcs = &st7701_funcs;
st7701->panel.dev = &dsi->dev;
ret = drm_panel_add(&st7701->panel);
if (ret < 0)
......
......@@ -381,9 +381,7 @@ static int st7789v_probe(struct spi_device *spi)
spi_set_drvdata(spi, ctx);
ctx->spi = spi;
drm_panel_init(&ctx->panel);
ctx->panel.dev = &spi->dev;
ctx->panel.funcs = &st7789v_drm_funcs;
drm_panel_init(&ctx->panel, &spi->dev, &st7789v_drm_funcs);
ctx->power = devm_regulator_get(&spi->dev, "power");
if (IS_ERR(ctx->power))
......
......@@ -648,9 +648,7 @@ static int acx565akm_probe(struct spi_device *spi)
return ret;
}
drm_panel_init(&lcd->panel);
lcd->panel.dev = &lcd->spi->dev;
lcd->panel.funcs = &acx565akm_funcs;
drm_panel_init(&lcd->panel, &lcd->spi->dev, &acx565akm_funcs);
ret = drm_panel_add(&lcd->panel);
if (ret < 0) {
......
......@@ -347,9 +347,7 @@ static int td028ttec1_probe(struct spi_device *spi)
return ret;
}
drm_panel_init(&lcd->panel);
lcd->panel.dev = &lcd->spi->dev;
lcd->panel.funcs = &td028ttec1_funcs;
drm_panel_init(&lcd->panel, &lcd->spi->dev, &td028ttec1_funcs);
return drm_panel_add(&lcd->panel);
}
......
......@@ -458,9 +458,7 @@ static int td043mtea1_probe(struct spi_device *spi)
return ret;
}
drm_panel_init(&lcd->panel);
lcd->panel.dev = &lcd->spi->dev;
lcd->panel.funcs = &td043mtea1_funcs;
drm_panel_init(&lcd->panel, &lcd->spi->dev, &td043mtea1_funcs);
ret = drm_panel_add(&lcd->panel);
if (ret < 0) {
......
......@@ -457,9 +457,7 @@ static int tpg110_probe(struct spi_device *spi)
if (ret)
return ret;
drm_panel_init(&tpg->panel);
tpg->panel.dev = dev;
tpg->panel.funcs = &tpg110_drm_funcs;
drm_panel_init(&tpg->panel, dev, &tpg110_drm_funcs);
spi_set_drvdata(spi, tpg);
return drm_panel_add(&tpg->panel);
......
......@@ -518,9 +518,7 @@ static int truly_nt35597_panel_add(struct truly_nt35597 *ctx)
/* dual port */
gpiod_set_value(ctx->mode_gpio, 0);
drm_panel_init(&ctx->panel);
ctx->panel.dev = dev;
ctx->panel.funcs = &truly_nt35597_drm_funcs;
drm_panel_init(&ctx->panel, dev, &truly_nt35597_drm_funcs);
drm_panel_add(&ctx->panel);
return 0;
......
......@@ -147,7 +147,8 @@ struct drm_panel {
struct list_head list;
};
void drm_panel_init(struct drm_panel *panel);
void drm_panel_init(struct drm_panel *panel, struct device *dev,
const struct drm_panel_funcs *funcs);
int drm_panel_add(struct drm_panel *panel);
void drm_panel_remove(struct drm_panel *panel);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment