diff mbox series

[v1,18/26] drm/panel: rocktech-jh057n00900: use drm_panel backlight support

Message ID 20191202193230.21310-19-sam@ravnborg.org (mailing list archive)
State New, archived
Headers show
Series drm/panel infrastructure + backlight update | expand

Commit Message

Sam Ravnborg Dec. 2, 2019, 7:32 p.m. UTC
Use the backlight support in drm_panel to simplify the driver.
While touching the include files sort them
and divide them up in blocks.

Signed-off-by: Sam Ravnborg <sam@ravnborg.org>
Cc: "Guido Günther" <agx@sigxcpu.org>
Cc: Purism Kernel Team <kernel@puri.sm>
Cc: Thierry Reding <thierry.reding@gmail.com>
Cc: Sam Ravnborg <sam@ravnborg.org>
---
 .../drm/panel/panel-rocktech-jh057n00900.c    | 24 +++++++++----------
 1 file changed, 12 insertions(+), 12 deletions(-)

Comments

Guido Günther Dec. 4, 2019, 12:04 p.m. UTC | #1
Hi,
On Mon, Dec 02, 2019 at 08:32:22PM +0100, Sam Ravnborg wrote:
> Use the backlight support in drm_panel to simplify the driver.
> While touching the include files sort them
> and divide them up in blocks.
> 
> Signed-off-by: Sam Ravnborg <sam@ravnborg.org>
> Cc: "Guido Günther" <agx@sigxcpu.org>
> Cc: Purism Kernel Team <kernel@puri.sm>
> Cc: Thierry Reding <thierry.reding@gmail.com>
> Cc: Sam Ravnborg <sam@ravnborg.org>
> ---
>  .../drm/panel/panel-rocktech-jh057n00900.c    | 24 +++++++++----------
>  1 file changed, 12 insertions(+), 12 deletions(-)
> 
> diff --git a/drivers/gpu/drm/panel/panel-rocktech-jh057n00900.c b/drivers/gpu/drm/panel/panel-rocktech-jh057n00900.c
> index 3a4f1c0fce86..38ff742bc120 100644
> --- a/drivers/gpu/drm/panel/panel-rocktech-jh057n00900.c
> +++ b/drivers/gpu/drm/panel/panel-rocktech-jh057n00900.c
> @@ -5,20 +5,22 @@
>   * Copyright (C) Purism SPC 2019
>   */
>  
> -#include <drm/drm_mipi_dsi.h>
> -#include <drm/drm_modes.h>
> -#include <drm/drm_panel.h>
> -#include <drm/drm_print.h>
> -#include <linux/backlight.h>
>  #include <linux/debugfs.h>
>  #include <linux/delay.h>
>  #include <linux/gpio/consumer.h>
>  #include <linux/media-bus-format.h>
> +#include <linux/mod_devicetable.h>
>  #include <linux/module.h>
>  #include <linux/regulator/consumer.h>
> +
>  #include <video/display_timing.h>
>  #include <video/mipi_display.h>
>  
> +#include <drm/drm_mipi_dsi.h>
> +#include <drm/drm_modes.h>
> +#include <drm/drm_panel.h>
> +#include <drm/drm_print.h>
> +
>  #define DRV_NAME "panel-rocktech-jh057n00900"
>  
>  /* Manufacturer specific Commands send via DSI */
> @@ -47,7 +49,6 @@ struct jh057n {
>  	struct device *dev;
>  	struct drm_panel panel;
>  	struct gpio_desc *reset_gpio;
> -	struct backlight_device *backlight;
>  	struct regulator *vcc;
>  	struct regulator *iovcc;
>  	bool prepared;
> @@ -152,7 +153,7 @@ static int jh057n_enable(struct drm_panel *panel)
>  		return ret;
>  	}
>  
> -	return backlight_enable(ctx->backlight);
> +	return 0;
>  }
>  
>  static int jh057n_disable(struct drm_panel *panel)
> @@ -160,7 +161,6 @@ static int jh057n_disable(struct drm_panel *panel)
>  	struct jh057n *ctx = panel_to_jh057n(panel);
>  	struct mipi_dsi_device *dsi = to_mipi_dsi_device(ctx->dev);
>  
> -	backlight_disable(ctx->backlight);
>  	return mipi_dsi_dcs_set_display_off(dsi);
>  }
>  
> @@ -321,10 +321,6 @@ static int jh057n_probe(struct mipi_dsi_device *dsi)
>  	dsi->mode_flags = MIPI_DSI_MODE_VIDEO |
>  		MIPI_DSI_MODE_VIDEO_BURST | MIPI_DSI_MODE_VIDEO_SYNC_PULSE;
>  
> -	ctx->backlight = devm_of_find_backlight(dev);
> -	if (IS_ERR(ctx->backlight))
> -		return PTR_ERR(ctx->backlight);
> -
>  	ctx->vcc = devm_regulator_get(dev, "vcc");
>  	if (IS_ERR(ctx->vcc)) {
>  		ret = PTR_ERR(ctx->vcc);
> @@ -347,6 +343,10 @@ static int jh057n_probe(struct mipi_dsi_device *dsi)
>  	drm_panel_init(&ctx->panel, dev, &jh057n_drm_funcs,
>  		       DRM_MODE_CONNECTOR_DSI);
>  
> +	ret = drm_panel_of_backlight(&ctx->panel);
> +	if (ret)
> +		return ret;
> +
>  	drm_panel_add(&ctx->panel);
>  
>  	ret = mipi_dsi_attach(dsi);

Reviewed-by: Guido Günther <agx@sigxcpu.org> 

> -- 
> 2.20.1
>
diff mbox series

Patch

diff --git a/drivers/gpu/drm/panel/panel-rocktech-jh057n00900.c b/drivers/gpu/drm/panel/panel-rocktech-jh057n00900.c
index 3a4f1c0fce86..38ff742bc120 100644
--- a/drivers/gpu/drm/panel/panel-rocktech-jh057n00900.c
+++ b/drivers/gpu/drm/panel/panel-rocktech-jh057n00900.c
@@ -5,20 +5,22 @@ 
  * Copyright (C) Purism SPC 2019
  */
 
-#include <drm/drm_mipi_dsi.h>
-#include <drm/drm_modes.h>
-#include <drm/drm_panel.h>
-#include <drm/drm_print.h>
-#include <linux/backlight.h>
 #include <linux/debugfs.h>
 #include <linux/delay.h>
 #include <linux/gpio/consumer.h>
 #include <linux/media-bus-format.h>
+#include <linux/mod_devicetable.h>
 #include <linux/module.h>
 #include <linux/regulator/consumer.h>
+
 #include <video/display_timing.h>
 #include <video/mipi_display.h>
 
+#include <drm/drm_mipi_dsi.h>
+#include <drm/drm_modes.h>
+#include <drm/drm_panel.h>
+#include <drm/drm_print.h>
+
 #define DRV_NAME "panel-rocktech-jh057n00900"
 
 /* Manufacturer specific Commands send via DSI */
@@ -47,7 +49,6 @@  struct jh057n {
 	struct device *dev;
 	struct drm_panel panel;
 	struct gpio_desc *reset_gpio;
-	struct backlight_device *backlight;
 	struct regulator *vcc;
 	struct regulator *iovcc;
 	bool prepared;
@@ -152,7 +153,7 @@  static int jh057n_enable(struct drm_panel *panel)
 		return ret;
 	}
 
-	return backlight_enable(ctx->backlight);
+	return 0;
 }
 
 static int jh057n_disable(struct drm_panel *panel)
@@ -160,7 +161,6 @@  static int jh057n_disable(struct drm_panel *panel)
 	struct jh057n *ctx = panel_to_jh057n(panel);
 	struct mipi_dsi_device *dsi = to_mipi_dsi_device(ctx->dev);
 
-	backlight_disable(ctx->backlight);
 	return mipi_dsi_dcs_set_display_off(dsi);
 }
 
@@ -321,10 +321,6 @@  static int jh057n_probe(struct mipi_dsi_device *dsi)
 	dsi->mode_flags = MIPI_DSI_MODE_VIDEO |
 		MIPI_DSI_MODE_VIDEO_BURST | MIPI_DSI_MODE_VIDEO_SYNC_PULSE;
 
-	ctx->backlight = devm_of_find_backlight(dev);
-	if (IS_ERR(ctx->backlight))
-		return PTR_ERR(ctx->backlight);
-
 	ctx->vcc = devm_regulator_get(dev, "vcc");
 	if (IS_ERR(ctx->vcc)) {
 		ret = PTR_ERR(ctx->vcc);
@@ -347,6 +343,10 @@  static int jh057n_probe(struct mipi_dsi_device *dsi)
 	drm_panel_init(&ctx->panel, dev, &jh057n_drm_funcs,
 		       DRM_MODE_CONNECTOR_DSI);
 
+	ret = drm_panel_of_backlight(&ctx->panel);
+	if (ret)
+		return ret;
+
 	drm_panel_add(&ctx->panel);
 
 	ret = mipi_dsi_attach(dsi);