linux-fbdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Dmitry Torokhov <dmitry.torokhov@gmail.com>
To: Laurent Pinchart <laurent.pinchart@ideasonboard.com>,
	Lee Jones <lee.jones@linaro.org>
Cc: Daniel Thompson <daniel.thompson@linaro.org>,
	Jingoo Han <jingoohan1@gmail.com>,
	linux-fbdev@vger.kernel.org, linux-kernel@vger.kernel.org,
	linux-sh@vger.kernel.org,
	Yoshinori Sato <ysato@users.sourceforge.jp>,
	Rich Felker <dalias@libc.org>,
	Linus Walleij <linus.walleij@linaro.org>
Subject: [RFC 4/4] backlight: gpio_backlight: remove platform data support
Date: Thu, 15 Mar 2018 22:42:02 +0000	[thread overview]
Message-ID: <20180315224202.96668-5-dmitry.torokhov@gmail.com> (raw)
In-Reply-To: <20180315224202.96668-1-dmitry.torokhov@gmail.com>

Legacy boards can use static property sets/GPIO lookup tables to describe
backlight connections, there is no need to maintain legacy platform data.

Signed-off-by: Dmitry Torokhov <dmitry.torokhov@gmail.com>
---
 drivers/video/backlight/gpio_backlight.c     | 85 ++++----------------
 include/linux/platform_data/gpio_backlight.h | 20 -----
 2 files changed, 14 insertions(+), 91 deletions(-)
 delete mode 100644 include/linux/platform_data/gpio_backlight.h

diff --git a/drivers/video/backlight/gpio_backlight.c b/drivers/video/backlight/gpio_backlight.c
index 173fc4aafb89b..795359deeb700 100644
--- a/drivers/video/backlight/gpio_backlight.c
+++ b/drivers/video/backlight/gpio_backlight.c
@@ -15,17 +15,12 @@
 #include <linux/kernel.h>
 #include <linux/module.h>
 #include <linux/of.h>
-#include <linux/of_gpio.h>
-#include <linux/platform_data/gpio_backlight.h>
 #include <linux/platform_device.h>
+#include <linux/property.h>
 #include <linux/slab.h>
 
 struct gpio_backlight {
-	struct device *dev;
-	struct device *fbdev;
-
 	struct gpio_desc *gpiod;
-	int def_value;
 };
 
 static int gpio_backlight_update_status(struct backlight_device *bl)
@@ -43,84 +38,32 @@ static int gpio_backlight_update_status(struct backlight_device *bl)
 	return 0;
 }
 
-static int gpio_backlight_check_fb(struct backlight_device *bl,
-				   struct fb_info *info)
-{
-	struct gpio_backlight *gbl = bl_get_data(bl);
-
-	return gbl->fbdev = NULL || gbl->fbdev = info->dev;
-}
-
 static const struct backlight_ops gpio_backlight_ops = {
 	.options	= BL_CORE_SUSPENDRESUME,
 	.update_status	= gpio_backlight_update_status,
-	.check_fb	= gpio_backlight_check_fb,
 };
 
-static int gpio_backlight_probe_dt(struct platform_device *pdev,
-				   struct gpio_backlight *gbl)
-{
-	struct device *dev = &pdev->dev;
-	enum gpiod_flags flags;
-	int ret;
-
-	gbl->def_value = device_property_read_bool(dev, "default-on");
-	flags = gbl->def_value ? GPIOD_OUT_HIGH : GPIOD_OUT_LOW;
-
-	gbl->gpiod = devm_gpiod_get(dev, NULL, flags);
-	if (IS_ERR(gbl->gpiod)) {
-		ret = PTR_ERR(gbl->gpiod);
-
-		if (ret != -EPROBE_DEFER) {
-			dev_err(dev,
-				"Error: The gpios parameter is missing or invalid.\n");
-		}
-		return ret;
-	}
-
-	return 0;
-}
-
 static int gpio_backlight_probe(struct platform_device *pdev)
 {
-	struct gpio_backlight_platform_data *pdata -		dev_get_platdata(&pdev->dev);
+	struct device *dev = &pdev->dev;
 	struct backlight_properties props;
 	struct backlight_device *bl;
 	struct gpio_backlight *gbl;
+	int def_value;
 	int ret;
 
-	gbl = devm_kzalloc(&pdev->dev, sizeof(*gbl), GFP_KERNEL);
-	if (gbl = NULL)
+	gbl = devm_kzalloc(dev, sizeof(*gbl), GFP_KERNEL);
+	if (!gbl)
 		return -ENOMEM;
 
-	gbl->dev = &pdev->dev;
-
-	if (!pdata) {
-		ret = gpio_backlight_probe_dt(pdev, gbl);
-		if (ret)
-			return ret;
-	} else {
-		/*
-		 * Legacy platform data GPIO retrieveal. Do not expand
-		 * the use of this code path, currently only used by one
-		 * SH board.
-		 */
-		unsigned long flags = GPIOF_DIR_OUT;
-
-		gbl->fbdev = pdata->fbdev;
-		gbl->def_value = pdata->def_value;
-		flags |= gbl->def_value ? GPIOF_INIT_HIGH : GPIOF_INIT_LOW;
-
-		ret = devm_gpio_request_one(gbl->dev, pdata->gpio, flags,
-					    pdata ? pdata->name : "backlight");
-		if (ret < 0) {
-			dev_err(&pdev->dev, "unable to request GPIO\n");
-			return ret;
-		}
-		gbl->gpiod = gpio_to_desc(pdata->gpio);
-		if (!gbl->gpiod)
-			return -EINVAL;
+	def_value = device_property_read_bool(dev, "default-on");
+	gbl->gpiod = devm_gpiod_get(dev, NULL,
+				    def_value ? GPIOD_OUT_HIGH : GPIOD_OUT_LOW);
+	if (IS_ERR(gbl->gpiod)) {
+		ret = PTR_ERR(gbl->gpiod);
+		if (ret != -EPROBE_DEFER)
+			dev_err(dev, "unable to request GPIO: %d\n", ret);
+		return ret;
 	}
 
 	memset(&props, 0, sizeof(props));
@@ -134,7 +77,7 @@ static int gpio_backlight_probe(struct platform_device *pdev)
 		return PTR_ERR(bl);
 	}
 
-	bl->props.brightness = gbl->def_value;
+	bl->props.brightness = def_value;
 	backlight_update_status(bl);
 
 	platform_set_drvdata(pdev, bl);
diff --git a/include/linux/platform_data/gpio_backlight.h b/include/linux/platform_data/gpio_backlight.h
deleted file mode 100644
index 683d90453c419..0000000000000
--- a/include/linux/platform_data/gpio_backlight.h
+++ /dev/null
@@ -1,20 +0,0 @@
-/*
- * gpio_backlight.h - Simple GPIO-controlled backlight
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License version 2 as
- * published by the Free Software Foundation.
- */
-#ifndef __GPIO_BACKLIGHT_H__
-#define __GPIO_BACKLIGHT_H__
-
-struct device;
-
-struct gpio_backlight_platform_data {
-	struct device *fbdev;
-	int gpio;
-	int def_value;
-	const char *name;
-};
-
-#endif
-- 
2.16.2.804.g6dcf76e118-goog


  parent reply	other threads:[~2018-03-15 22:42 UTC|newest]

Thread overview: 22+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-03-15 22:41 [RFC 0/4] gpio-backlight: remove platform data support Dmitry Torokhov
2018-03-15 22:41 ` [RFC 1/4] backlight: gpio_backlight: use generic device properties Dmitry Torokhov
2018-03-27 11:53   ` Linus Walleij
2018-03-15 22:42 ` [RFC 2/4] sh: ecovec24: conditionally register backlight device Dmitry Torokhov
2018-03-16 10:07   ` jacopo mondi
2018-03-16 23:38     ` Dmitry Torokhov
2018-03-17  9:25       ` jacopo mondi
2018-03-17 10:21         ` John Paul Adrian Glaubitz
2018-03-17 17:16           ` Rich Felker
2018-03-17 17:33             ` Dmitry Torokhov
2018-03-17 17:55             ` John Paul Adrian Glaubitz
2018-03-18 10:54           ` jacopo mondi
2018-03-18 11:12             ` John Paul Adrian Glaubitz
2018-03-17 17:37         ` Dmitry Torokhov
2018-03-15 22:42 ` [RFC 3/4] sh: ecovec24: convert backlight to use device properties Dmitry Torokhov
2018-03-16  8:50   ` Geert Uytterhoeven
2018-03-16 23:40     ` Dmitry Torokhov
2018-03-16 10:08   ` jacopo mondi
2018-03-15 22:42 ` Dmitry Torokhov [this message]
2018-03-27 11:55   ` [RFC 4/4] backlight: gpio_backlight: remove platform data support Linus Walleij
2018-03-16 11:11 ` [RFC 0/4] gpio-backlight: " Daniel Thompson
2018-03-27 11:59 ` Linus Walleij

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20180315224202.96668-5-dmitry.torokhov@gmail.com \
    --to=dmitry.torokhov@gmail.com \
    --cc=dalias@libc.org \
    --cc=daniel.thompson@linaro.org \
    --cc=jingoohan1@gmail.com \
    --cc=laurent.pinchart@ideasonboard.com \
    --cc=lee.jones@linaro.org \
    --cc=linus.walleij@linaro.org \
    --cc=linux-fbdev@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-sh@vger.kernel.org \
    --cc=ysato@users.sourceforge.jp \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).