Switch from a generic platform driver to a dedicated MIPI DBI Type B
driver.

Signed-off-by: Svyatoslav Ryhel <[email protected]>
---
 drivers/gpu/drm/panel/panel-lg-lh400wv3.c | 27 +++++++++++------------
 1 file changed, 13 insertions(+), 14 deletions(-)

diff --git a/drivers/gpu/drm/panel/panel-lg-lh400wv3.c 
b/drivers/gpu/drm/panel/panel-lg-lh400wv3.c
index 557bcb6f2ca70..63efeb434be13 100644
--- a/drivers/gpu/drm/panel/panel-lg-lh400wv3.c
+++ b/drivers/gpu/drm/panel/panel-lg-lh400wv3.c
@@ -14,6 +14,7 @@
 #include <video/mipi_display.h>
 
 #include <drm/drm_mipi_dbi.h>
+#include <drm/drm_mipi_dbi_bus.h>
 #include <drm/drm_modes.h>
 #include <drm/drm_of.h>
 #include <drm/drm_panel.h>
@@ -25,7 +26,7 @@ static const struct regulator_bulk_data 
lg_lh400wv3_supplies[] = {
 
 struct lg_lh400wv3 {
        struct drm_panel panel;
-       struct mipi_dbi *dbi;
+       struct mipi_dbi_device *dbidev;
 
        struct regulator_bulk_data *supplies;
        struct gpio_desc *reset_gpio;
@@ -40,9 +41,10 @@ static inline struct lg_lh400wv3 *to_lg_lh400wv3(struct 
drm_panel *panel)
 ({ \
        const u8 d[] = { seq }; \
        struct drm_panel *panel = &(priv)->panel; \
+       struct mipi_dbi_device *dbidev = (priv)->dbidev; \
        struct device *dev = panel->dev; \
        int ret; \
-       ret = mipi_dbi_command_stackbuf((priv)->dbi, cmd, d, ARRAY_SIZE(d)); \
+       ret = mipi_dbi_command_stackbuf((dbidev)->dbi, cmd, d, ARRAY_SIZE(d)); \
        if (ret) \
                dev_err_ratelimited(dev, "error %d when sending command 
%#02x\n", ret, cmd); \
        ret; \
@@ -54,10 +56,6 @@ static int lg_lh400wv3_prepare(struct drm_panel *panel)
        struct device *dev = panel->dev;
        int ret;
 
-       priv->dbi = dev_get_drvdata(dev->parent);
-       if (!priv->dbi)
-               return -ENODEV;
-
        gpiod_set_value_cansleep(priv->reset_gpio, 1);
 
        ret = regulator_bulk_enable(ARRAY_SIZE(lg_lh400wv3_supplies), 
priv->supplies);
@@ -129,7 +127,7 @@ static int lg_lh400wv3_disable(struct drm_panel *panel)
        usleep_range(10000, 11000);
 
        return 0;
-};
+}
 
 static int lg_lh400wv3_unprepare(struct drm_panel *panel)
 {
@@ -182,9 +180,9 @@ static const struct drm_panel_funcs lg_lh400wv3_panel_funcs 
= {
        .get_modes = lg_lh400wv3_get_modes,
 };
 
-static int lg_lh400wv3_probe(struct platform_device *pdev)
+static int lg_lh400wv3_probe(struct mipi_dbi_device *dbidev)
 {
-       struct device *dev = &pdev->dev;
+       struct device *dev = &dbidev->dev;
        struct lg_lh400wv3 *priv;
        int ret;
 
@@ -203,6 +201,9 @@ static int lg_lh400wv3_probe(struct platform_device *pdev)
                return dev_err_probe(dev, PTR_ERR(priv->reset_gpio),
                                     "Failed to get reset gpio\n");
 
+       priv->dbidev = dbidev;
+       mipi_dbi_set_drvdata(dbidev, priv);
+
        ret = drm_panel_of_backlight(&priv->panel);
        if (ret)
                return dev_err_probe(dev, ret, "Failed to get backlight\n");
@@ -211,9 +212,7 @@ static int lg_lh400wv3_probe(struct platform_device *pdev)
        if (ret)
                return dev_err_probe(dev, ret, "Failed to add panel\n");
 
-       platform_set_drvdata(pdev, priv);
-
-       return 0;
+       return devm_mipi_dbi_attach(dev, dbidev);
 }
 
 static const struct of_device_id lg_lh400wv3_of_match[] = {
@@ -222,14 +221,14 @@ static const struct of_device_id lg_lh400wv3_of_match[] = 
{
 };
 MODULE_DEVICE_TABLE(of, lg_lh400wv3_of_match);
 
-static struct platform_driver lg_lh400wv3_driver = {
+static struct mipi_dbi_driver lg_lh400wv3_driver = {
        .driver = {
                .name = "panel-lg-lh400wv3",
                .of_match_table = lg_lh400wv3_of_match,
        },
        .probe = lg_lh400wv3_probe,
 };
-module_platform_driver(lg_lh400wv3_driver);
+module_mipi_dbi_driver(lg_lh400wv3_driver);
 
 MODULE_AUTHOR("Svyatoslav Ryhel <[email protected]>");
 MODULE_DESCRIPTION("LG LH400WV3-SD04 MIPI DBI Type B panel driver");
-- 
2.53.0

Reply via email to