[PATCH v4 4/6] drm/panel: Use managed helpers in Himax and Ilitek panels
Osama Abdelkader <[email protected]>
| Newsgroups | org.freedesktop.lists.dri-devel,org.kernel.vger.linux-kernel |
|---|---|
| Message-ID | <[email protected]> |
Use the managed MIPI DSI attach and panel add helpers in Himax and Ilitek panel drivers and drop the corresponding manual detach and panel remove calls from remove paths. Suggested-by: Luca Ceresoli <[email protected]> Signed-off-by: Osama Abdelkader <[email protected]> --- v4: - use devm_drm_panel_add instead of drm_panel_add. drivers/gpu/drm/panel/panel-himax-hx83102.c | 24 ++--------------- drivers/gpu/drm/panel/panel-himax-hx83112a.c | 24 ++++------------- drivers/gpu/drm/panel/panel-himax-hx83112b.c | 23 ++++------------ drivers/gpu/drm/panel/panel-himax-hx8394.c | 26 +++++-------------- drivers/gpu/drm/panel/panel-ilitek-ili9805.c | 21 +++------------ .../drm/panel/panel-ilitek-ili9806e-core.c | 12 +-------- .../drm/panel/panel-ilitek-ili9806e-core.h | 1 - .../gpu/drm/panel/panel-ilitek-ili9806e-dsi.c | 16 +----------- .../gpu/drm/panel/panel-ilitek-ili9806e-spi.c | 6 ----- drivers/gpu/drm/panel/panel-ilitek-ili9881c.c | 15 +++-------- drivers/gpu/drm/panel/panel-ilitek-ili9882t.c | 24 ++--------------- 11 files changed, 30 insertions(+), 162 deletions(-) diff --git a/drivers/gpu/drm/panel/panel-himax-hx83102.c b/drivers/gpu/drm/panel/panel-himax-hx83102.c index 6a0851ccf9bb..3ef052571ce0 100644 --- a/drivers/gpu/drm/panel/panel-himax-hx83102.c +++ b/drivers/gpu/drm/panel/panel-himax-hx83102.c @@ -1284,9 +1284,7 @@ static int hx83102_panel_add(struct hx83102 *ctx) ctx->base.funcs = &hx83102_drm_funcs; ctx->base.dev = &ctx->dsi->dev; - drm_panel_add(&ctx->base); - - return 0; + return devm_drm_panel_add(dev, &ctx->base); } static int hx83102_probe(struct mipi_dsi_device *dsi) @@ -1318,24 +1316,7 @@ static int hx83102_probe(struct mipi_dsi_device *dsi) mipi_dsi_set_drvdata(dsi, ctx); - ret = mipi_dsi_attach(dsi); - if (ret) - drm_panel_remove(&ctx->base); - - return ret; -} - -static void hx83102_remove(struct mipi_dsi_device *dsi) -{ - struct hx83102 *ctx = mipi_dsi_get_drvdata(dsi); - int ret; - - ret = mipi_dsi_detach(dsi); - if (ret < 0) - dev_err(&dsi->dev, "failed to detach from DSI host: %d\n", ret); - - if (ctx->base.dev) - drm_panel_remove(&ctx->base); + return devm_mipi_dsi_attach(&dsi->dev, dsi); } static const struct of_device_id hx83102_of_match[] = { @@ -1369,7 +1350,6 @@ MODULE_DEVICE_TABLE(of, hx83102_of_match); static struct mipi_dsi_driver hx83102_driver = { .probe = hx83102_probe, - .remove = hx83102_remove, .driver = { .name = "panel-himax-hx83102", .of_match_table = hx83102_of_match, diff --git a/drivers/gpu/drm/panel/panel-himax-hx83112a.c b/drivers/gpu/drm/panel/panel-himax-hx83112a.c index 142cb1cc067a..36ebfad7a3e9 100644 --- a/drivers/gpu/drm/panel/panel-himax-hx83112a.c +++ b/drivers/gpu/drm/panel/panel-himax-hx83112a.c @@ -303,28 +303,15 @@ static int hx83112a_probe(struct mipi_dsi_device *dsi) if (ret) return dev_err_probe(dev, ret, "Failed to get backlight\n"); - drm_panel_add(&ctx->panel); - - ret = mipi_dsi_attach(dsi); - if (ret < 0) { - dev_err_probe(dev, ret, "Failed to attach to DSI host\n"); - drm_panel_remove(&ctx->panel); + ret = devm_drm_panel_add(dev, &ctx->panel); + if (ret) return ret; - } - return 0; -} - -static void hx83112a_remove(struct mipi_dsi_device *dsi) -{ - struct hx83112a_panel *ctx = mipi_dsi_get_drvdata(dsi); - int ret; - - ret = mipi_dsi_detach(dsi); + ret = devm_mipi_dsi_attach(dev, dsi); if (ret < 0) - dev_err(&dsi->dev, "Failed to detach from DSI host: %d\n", ret); + return dev_err_probe(dev, ret, "Failed to attach to DSI host\n"); - drm_panel_remove(&ctx->panel); + return 0; } static const struct of_device_id hx83112a_of_match[] = { @@ -335,7 +322,6 @@ MODULE_DEVICE_TABLE(of, hx83112a_of_match); static struct mipi_dsi_driver hx83112a_driver = { .probe = hx83112a_probe, - .remove = hx83112a_remove, .driver = { .name = "panel-himax-hx83112a", .of_match_table = hx83112a_of_match, diff --git a/drivers/gpu/drm/panel/panel-himax-hx83112b.c b/drivers/gpu/drm/panel/panel-himax-hx83112b.c index 41f21f8c1373..569ed2dec87c 100644 --- a/drivers/gpu/drm/panel/panel-himax-hx83112b.c +++ b/drivers/gpu/drm/panel/panel-himax-hx83112b.c @@ -386,29 +386,17 @@ static int hx83112b_probe(struct mipi_dsi_device *dsi) return dev_err_probe(dev, PTR_ERR(ctx->panel.backlight), "Failed to create backlight\n"); - drm_panel_add(&ctx->panel); + ret = devm_drm_panel_add(dev, &ctx->panel); + if (ret) + return ret; - ret = mipi_dsi_attach(dsi); - if (ret < 0) { - drm_panel_remove(&ctx->panel); + ret = devm_mipi_dsi_attach(dev, dsi); + if (ret < 0) return dev_err_probe(dev, ret, "Failed to attach to DSI host\n"); - } return 0; } -static void hx83112b_remove(struct mipi_dsi_device *dsi) -{ - struct hx83112b_panel *ctx = mipi_dsi_get_drvdata(dsi); - int ret; - - ret = mipi_dsi_detach(dsi); - if (ret < 0) - dev_err(&dsi->dev, "Failed to detach from DSI host: %d\n", ret); - - drm_panel_remove(&ctx->panel); -} - static const struct of_device_id hx83112b_of_match[] = { { .compatible = "djn,98-03057-6598b-i" }, { /* sentinel */ } @@ -417,7 +405,6 @@ MODULE_DEVICE_TABLE(of, hx83112b_of_match); static struct mipi_dsi_driver hx83112b_driver = { .probe = hx83112b_probe, - .remove = hx83112b_remove, .driver = { .name = "panel-himax-hx83112b", .of_match_table = hx83112b_of_match, diff --git a/drivers/gpu/drm/panel/panel-himax-hx8394.c b/drivers/gpu/drm/panel/panel-himax-hx8394.c index 09124610fdc8..4180d4aadf5e 100644 --- a/drivers/gpu/drm/panel/panel-himax-hx8394.c +++ b/drivers/gpu/drm/panel/panel-himax-hx8394.c @@ -1023,14 +1023,13 @@ static int hx8394_probe(struct mipi_dsi_device *dsi) ctx->panel.prepare_prev_first = true; - drm_panel_add(&ctx->panel); - - ret = mipi_dsi_attach(dsi); - if (ret < 0) { - dev_err_probe(dev, ret, "mipi_dsi_attach failed\n"); - drm_panel_remove(&ctx->panel); + ret = devm_drm_panel_add(dev, &ctx->panel); + if (ret) return ret; - } + + ret = devm_mipi_dsi_attach(dev, dsi); + if (ret < 0) + return dev_err_probe(dev, ret, "mipi_dsi_attach failed\n"); dev_dbg(dev, "%ux%u@%u %ubpp dsi %udl - ready\n", ctx->desc->mode->hdisplay, ctx->desc->mode->vdisplay, @@ -1040,18 +1039,6 @@ static int hx8394_probe(struct mipi_dsi_device *dsi) return 0; } -static void hx8394_remove(struct mipi_dsi_device *dsi) -{ - struct hx8394 *ctx = mipi_dsi_get_drvdata(dsi); - int ret; - - ret = mipi_dsi_detach(dsi); - if (ret < 0) - dev_err(&dsi->dev, "Failed to detach from DSI host: %d\n", ret); - - drm_panel_remove(&ctx->panel); -} - static const struct of_device_id hx8394_of_match[] = { { .compatible = "hannstar,hsd060bhw4", .data = &hsd060bhw4_desc }, { .compatible = "huiling,hl055fhav028c", .data = &hl055fhav028c_desc }, @@ -1065,7 +1052,6 @@ MODULE_DEVICE_TABLE(of, hx8394_of_match); static struct mipi_dsi_driver hx8394_driver = { .probe = hx8394_probe, - .remove = hx8394_remove, .driver = { .name = DRV_NAME, .of_match_table = hx8394_of_match, diff --git a/drivers/gpu/drm/panel/panel-ilitek-ili9805.c b/drivers/gpu/drm/panel/panel-ilitek-ili9805.c index 5610a225f77b..976305991b7f 100644 --- a/drivers/gpu/drm/panel/panel-ilitek-ili9805.c +++ b/drivers/gpu/drm/panel/panel-ilitek-ili9805.c @@ -305,31 +305,19 @@ static int ili9805_dsi_probe(struct mipi_dsi_device *dsi) if (ret) return ret; - drm_panel_add(&ctx->panel); + ret = devm_drm_panel_add(&dsi->dev, &ctx->panel); + if (ret) + return ret; - ret = mipi_dsi_attach(dsi); + ret = devm_mipi_dsi_attach(&dsi->dev, dsi); if (ret < 0) { dev_err(&dsi->dev, "mipi_dsi_attach failed: %d\n", ret); - drm_panel_remove(&ctx->panel); return ret; } return 0; } -static void ili9805_dsi_remove(struct mipi_dsi_device *dsi) -{ - struct ili9805 *ctx = mipi_dsi_get_drvdata(dsi); - int ret; - - ret = mipi_dsi_detach(dsi); - if (ret < 0) - dev_err(&dsi->dev, "failed to detach from DSI host: %d\n", - ret); - - drm_panel_remove(&ctx->panel); -} - static const struct ili9805_desc gpm1780a0_desc = { .init = gpm1780a0_init, .mode = &gpm1780a0_timing, @@ -353,7 +341,6 @@ MODULE_DEVICE_TABLE(of, ili9805_of_match); static struct mipi_dsi_driver ili9805_dsi_driver = { .probe = ili9805_dsi_probe, - .remove = ili9805_dsi_remove, .driver = { .name = "ili9805-dsi", .of_match_table = ili9805_of_match, diff --git a/drivers/gpu/drm/panel/panel-ilitek-ili9806e-core.c b/drivers/gpu/drm/panel/panel-ilitek-ili9806e-core.c index 53e25d1086db..81d48c402aec 100644 --- a/drivers/gpu/drm/panel/panel-ilitek-ili9806e-core.c +++ b/drivers/gpu/drm/panel/panel-ilitek-ili9806e-core.c @@ -112,21 +112,11 @@ int ili9806e_probe(struct device *dev, void *transport, if (set_prepare_prev_first) ctx->panel.prepare_prev_first = true; - drm_panel_add(&ctx->panel); - - return 0; + return devm_drm_panel_add(dev, &ctx->panel); } EXPORT_SYMBOL_GPL(ili9806e_probe); -void ili9806e_remove(struct device *dev) -{ - struct ili9806e *ctx = dev_get_drvdata(dev); - - drm_panel_remove(&ctx->panel); -} -EXPORT_SYMBOL_GPL(ili9806e_remove); - MODULE_AUTHOR("Dario Binacchi <[email protected]>"); MODULE_AUTHOR("Gunnar Dibbern <[email protected]>"); MODULE_AUTHOR("Michael Walle <[email protected]>"); diff --git a/drivers/gpu/drm/panel/panel-ilitek-ili9806e-core.h b/drivers/gpu/drm/panel/panel-ilitek-ili9806e-core.h index dddece62cf42..fded4b6793e7 100644 --- a/drivers/gpu/drm/panel/panel-ilitek-ili9806e-core.h +++ b/drivers/gpu/drm/panel/panel-ilitek-ili9806e-core.h @@ -10,6 +10,5 @@ int ili9806e_power_on(struct device *dev); int ili9806e_probe(struct device *dev, void *transport, const struct drm_panel_funcs *funcs, int connector_type); -void ili9806e_remove(struct device *dev); #endif /* _PANEL_ILITEK_ILI9806E_CORE_H */ diff --git a/drivers/gpu/drm/panel/panel-ilitek-ili9806e-dsi.c b/drivers/gpu/drm/panel/panel-ilitek-ili9806e-dsi.c index 0fb06c425545..89915d58f69d 100644 --- a/drivers/gpu/drm/panel/panel-ilitek-ili9806e-dsi.c +++ b/drivers/gpu/drm/panel/panel-ilitek-ili9806e-dsi.c @@ -141,20 +141,7 @@ static int ili9806e_dsi_probe(struct mipi_dsi_device *dsi) if (ret) return ret; - ret = mipi_dsi_attach(dsi); - if (ret < 0) { - dev_err_probe(dev, ret, "Failed to attach to DSI host\n"); - ili9806e_remove(dev); - return ret; - } - - return 0; -} - -static void ili9806e_dsi_remove(struct mipi_dsi_device *dsi) -{ - mipi_dsi_detach(dsi); - ili9806e_remove(&dsi->dev); + return devm_mipi_dsi_attach(dev, dsi); } static void com35h3p70ulc_init(struct mipi_dsi_multi_context *ctx) @@ -490,7 +477,6 @@ static struct mipi_dsi_driver ili9806e_dsi_driver = { .of_match_table = ili9806e_dsi_of_match, }, .probe = ili9806e_dsi_probe, - .remove = ili9806e_dsi_remove, }; module_mipi_dsi_driver(ili9806e_dsi_driver); diff --git a/drivers/gpu/drm/panel/panel-ilitek-ili9806e-spi.c b/drivers/gpu/drm/panel/panel-ilitek-ili9806e-spi.c index 9d10b0d28f52..187bcb084dd9 100644 --- a/drivers/gpu/drm/panel/panel-ilitek-ili9806e-spi.c +++ b/drivers/gpu/drm/panel/panel-ilitek-ili9806e-spi.c @@ -124,11 +124,6 @@ static int ili9806e_spi_probe(struct spi_device *spi) DRM_MODE_CONNECTOR_DPI); } -static void ili9806e_spi_remove(struct spi_device *spi) -{ - ili9806e_remove(&spi->dev); -} - static void rk050hr345_ct106a_init(struct ili9806e_spi_panel *ctx) { struct mipi_dbi *dbi = &ctx->dbi; @@ -313,7 +308,6 @@ static struct spi_driver ili9806e_spi_driver = { .of_match_table = ili9806e_spi_of_match, }, .probe = ili9806e_spi_probe, - .remove = ili9806e_spi_remove, .id_table = ili9806e_spi_ids, }; module_spi_driver(ili9806e_spi_driver); diff --git a/drivers/gpu/drm/panel/panel-ilitek-ili9881c.c b/drivers/gpu/drm/panel/panel-ilitek-ili9881c.c index 3abdd0870e83..aee114a40cfd 100644 --- a/drivers/gpu/drm/panel/panel-ilitek-ili9881c.c +++ b/drivers/gpu/drm/panel/panel-ilitek-ili9881c.c @@ -2591,21 +2591,15 @@ static int ili9881c_dsi_probe(struct mipi_dsi_device *dsi) if (ret) return ret; - drm_panel_add(&ctx->panel); + ret = devm_drm_panel_add(&dsi->dev, &ctx->panel); + if (ret) + return ret; dsi->mode_flags = ctx->desc->mode_flags; dsi->format = MIPI_DSI_FMT_RGB888; dsi->lanes = ctx->desc->lanes; - return mipi_dsi_attach(dsi); -} - -static void ili9881c_dsi_remove(struct mipi_dsi_device *dsi) -{ - struct ili9881c *ctx = mipi_dsi_get_drvdata(dsi); - - mipi_dsi_detach(dsi); - drm_panel_remove(&ctx->panel); + return devm_mipi_dsi_attach(&dsi->dev, dsi); } static const struct ili9881c_desc lhr050h41_desc = { @@ -2719,7 +2713,6 @@ MODULE_DEVICE_TABLE(of, ili9881c_of_match); static struct mipi_dsi_driver ili9881c_dsi_driver = { .probe = ili9881c_dsi_probe, - .remove = ili9881c_dsi_remove, .driver = { .name = "ili9881c-dsi", .of_match_table = ili9881c_of_match, diff --git a/drivers/gpu/drm/panel/panel-ilitek-ili9882t.c b/drivers/gpu/drm/panel/panel-ilitek-ili9882t.c index 6d07fe901357..d4b383138488 100644 --- a/drivers/gpu/drm/panel/panel-ilitek-ili9882t.c +++ b/drivers/gpu/drm/panel/panel-ilitek-ili9882t.c @@ -809,9 +809,7 @@ static int ili9882t_add(struct ili9882t *ili) ili->base.funcs = &ili9882t_funcs; ili->base.dev = &ili->dsi->dev; - drm_panel_add(&ili->base); - - return 0; + return devm_drm_panel_add(dev, &ili->base); } static int ili9882t_probe(struct mipi_dsi_device *dsi) @@ -844,24 +842,7 @@ static int ili9882t_probe(struct mipi_dsi_device *dsi) mipi_dsi_set_drvdata(dsi, ili); - ret = mipi_dsi_attach(dsi); - if (ret) - drm_panel_remove(&ili->base); - - return ret; -} - -static void ili9882t_remove(struct mipi_dsi_device *dsi) -{ - struct ili9882t *ili = mipi_dsi_get_drvdata(dsi); - int ret; - - ret = mipi_dsi_detach(dsi); - if (ret < 0) - dev_err(&dsi->dev, "failed to detach from DSI host: %d\n", ret); - - if (ili->base.dev) - drm_panel_remove(&ili->base); + return devm_mipi_dsi_attach(&dsi->dev, dsi); } static const struct of_device_id ili9882t_of_match[] = { @@ -881,7 +862,6 @@ static struct mipi_dsi_driver ili9882t_driver = { .of_match_table = ili9882t_of_match, }, .probe = ili9882t_probe, - .remove = ili9882t_remove, }; module_mipi_dsi_driver(ili9882t_driver); -- 2.43.0