linux-leds.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Geert Uytterhoeven <geert@linux-m68k.org>
To: Miguel Ojeda <ojeda@kernel.org>
Cc: "Robin van der Gracht" <robin@protonic.nl>,
	"Rob Herring" <robh+dt@kernel.org>,
	"Paul Burton" <paulburton@kernel.org>,
	"Greg Kroah-Hartman" <gregkh@linuxfoundation.org>,
	"Pavel Machek" <pavel@ucw.cz>, "Marek Behun" <marek.behun@nic.cz>,
	devicetree@vger.kernel.org, linux-leds@vger.kernel.org,
	linux-mips@vger.kernel.org, linux-kernel@vger.kernel.org,
	"Geert Uytterhoeven" <geert@linux-m68k.org>,
	"Marek Behún" <kabel@kernel.org>,
	"Andy Shevchenko" <andy.shevchenko@gmail.com>
Subject: [PATCH v7 21/21] auxdisplay: ht16k33: Make use of device properties
Date: Tue, 12 Oct 2021 20:33:27 +0200	[thread overview]
Message-ID: <20211012183327.649865-22-geert@linux-m68k.org> (raw)
In-Reply-To: <20211012183327.649865-1-geert@linux-m68k.org>

The device property API allows drivers to gather device resources from
different sources, such as ACPI, and lift the dependency on Device Tree.
Convert the driver to unleash the power of the device property API.

Suggested-by: Marek Behún <kabel@kernel.org>
Signed-off-by: Geert Uytterhoeven <geert@linux-m68k.org>
Reviewed-by: Andy Shevchenko <andy.shevchenko@gmail.com>
---
v7:
  - Integrate into this series,
  - Add Reviewed-by,
  - Use device_property_read_bool() as replacement for
    of_get_property(),
  - Call matrix_keypad_parse_properties() instead of
    matrix_keypad_parse_of_params().
---
 drivers/auxdisplay/Kconfig   |  2 +-
 drivers/auxdisplay/ht16k33.c | 27 ++++++++++++---------------
 2 files changed, 13 insertions(+), 16 deletions(-)

diff --git a/drivers/auxdisplay/Kconfig b/drivers/auxdisplay/Kconfig
index e32ef7f9945d49b2..64012cda4d126707 100644
--- a/drivers/auxdisplay/Kconfig
+++ b/drivers/auxdisplay/Kconfig
@@ -169,7 +169,7 @@ config IMG_ASCII_LCD
 
 config HT16K33
 	tristate "Holtek Ht16K33 LED controller with keyscan"
-	depends on FB && OF && I2C && INPUT
+	depends on FB && I2C && INPUT
 	select FB_SYS_FOPS
 	select FB_SYS_FILLRECT
 	select FB_SYS_COPYAREA
diff --git a/drivers/auxdisplay/ht16k33.c b/drivers/auxdisplay/ht16k33.c
index aef3dc87dc9f5ed2..1134ae9f30de4baa 100644
--- a/drivers/auxdisplay/ht16k33.c
+++ b/drivers/auxdisplay/ht16k33.c
@@ -12,7 +12,7 @@
 #include <linux/module.h>
 #include <linux/interrupt.h>
 #include <linux/i2c.h>
-#include <linux/of.h>
+#include <linux/property.h>
 #include <linux/fb.h>
 #include <linux/slab.h>
 #include <linux/backlight.h>
@@ -491,15 +491,13 @@ static int ht16k33_led_probe(struct device *dev, struct led_classdev *led,
 			     unsigned int brightness)
 {
 	struct led_init_data init_data = {};
-	struct device_node *node;
 	int err;
 
 	/* The LED is optional */
-	node = of_get_child_by_name(dev->of_node, "led");
-	if (!node)
+	init_data.fwnode = device_get_named_child_node(dev, "led");
+	if (!init_data.fwnode)
 		return 0;
 
-	init_data.fwnode = of_fwnode_handle(node);
 	init_data.devicename = "auxdisplay";
 	init_data.devname_mandatory = true;
 
@@ -520,7 +518,6 @@ static int ht16k33_keypad_probe(struct i2c_client *client,
 				struct ht16k33_keypad *keypad)
 {
 	struct device *dev = &client->dev;
-	struct device_node *node = dev->of_node;
 	u32 rows = HT16K33_MATRIX_KEYPAD_MAX_ROWS;
 	u32 cols = HT16K33_MATRIX_KEYPAD_MAX_COLS;
 	int err;
@@ -539,17 +536,17 @@ static int ht16k33_keypad_probe(struct i2c_client *client,
 	keypad->dev->open = ht16k33_keypad_start;
 	keypad->dev->close = ht16k33_keypad_stop;
 
-	if (!of_get_property(node, "linux,no-autorepeat", NULL))
+	if (!device_property_read_bool(dev, "linux,no-autorepeat"))
 		__set_bit(EV_REP, keypad->dev->evbit);
 
-	err = of_property_read_u32(node, "debounce-delay-ms",
-				   &keypad->debounce_ms);
+	err = device_property_read_u32(dev, "debounce-delay-ms",
+				       &keypad->debounce_ms);
 	if (err) {
 		dev_err(dev, "key debounce delay not specified\n");
 		return err;
 	}
 
-	err = matrix_keypad_parse_of_params(dev, &rows, &cols);
+	err = matrix_keypad_parse_properties(dev, &rows, &cols);
 	if (err)
 		return err;
 	if (rows > HT16K33_MATRIX_KEYPAD_MAX_ROWS ||
@@ -634,8 +631,8 @@ static int ht16k33_fbdev_probe(struct device *dev, struct ht16k33_priv *priv,
 		goto err_fbdev_buffer;
 	}
 
-	err = of_property_read_u32(dev->of_node, "refresh-rate-hz",
-				   &fbdev->refresh_rate);
+	err = device_property_read_u32(dev, "refresh-rate-hz",
+				       &fbdev->refresh_rate);
 	if (err) {
 		dev_err(dev, "refresh rate not specified\n");
 		goto err_fbdev_info;
@@ -741,8 +738,8 @@ static int ht16k33_probe(struct i2c_client *client)
 	if (err)
 		return err;
 
-	err = of_property_read_u32(dev->of_node, "default-brightness-level",
-				   &dft_brightness);
+	err = device_property_read_u32(dev, "default-brightness-level",
+				       &dft_brightness);
 	if (err) {
 		dft_brightness = MAX_BRIGHTNESS;
 	} else if (dft_brightness > MAX_BRIGHTNESS) {
@@ -830,7 +827,7 @@ static struct i2c_driver ht16k33_driver = {
 	.remove		= ht16k33_remove,
 	.driver		= {
 		.name		= DRIVER_NAME,
-		.of_match_table	= of_match_ptr(ht16k33_of_match),
+		.of_match_table	= ht16k33_of_match,
 	},
 	.id_table = ht16k33_i2c_match,
 };
-- 
2.25.1


  parent reply	other threads:[~2021-10-12 18:48 UTC|newest]

Thread overview: 26+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-10-12 18:33 [PATCH v7 00/21] auxdisplay: ht16k33: Add character display support Geert Uytterhoeven
2021-10-12 18:33 ` [PATCH v7 01/21] uapi: Add <linux/map_to_14segment.h> Geert Uytterhoeven
2021-10-12 18:33 ` [PATCH v7 02/21] dt-bindings: auxdisplay: ht16k33: Document Adafruit segment displays Geert Uytterhoeven
2021-10-12 18:33 ` [PATCH v7 03/21] auxdisplay: img-ascii-lcd: Fix lock-up when displaying empty string Geert Uytterhoeven
2021-10-12 18:33 ` [PATCH v7 04/21] auxdisplay: img-ascii-lcd: Add helper variable dev Geert Uytterhoeven
2021-10-12 18:33 ` [PATCH v7 05/21] auxdisplay: img-ascii-lcd: Convert device attribute to sysfs_emit() Geert Uytterhoeven
2021-10-12 18:33 ` [PATCH v7 06/21] auxdisplay: Extract character line display core support Geert Uytterhoeven
2021-10-12 18:33 ` [PATCH v7 07/21] auxdisplay: linedisp: Use kmemdup_nul() helper Geert Uytterhoeven
2021-10-12 18:33 ` [PATCH v7 08/21] auxdisplay: linedisp: Add support for changing scroll rate Geert Uytterhoeven
2021-10-12 18:33 ` [PATCH v7 09/21] auxdisplay: ht16k33: Connect backlight to fbdev Geert Uytterhoeven
2021-10-12 18:33 ` [PATCH v7 10/21] auxdisplay: ht16k33: Fix frame buffer device blanking Geert Uytterhoeven
2021-10-12 18:33 ` [PATCH v7 11/21] auxdisplay: ht16k33: Use HT16K33_FB_SIZE in ht16k33_initialize() Geert Uytterhoeven
2021-10-12 18:33 ` [PATCH v7 12/21] auxdisplay: ht16k33: Remove unneeded error check in keypad probe() Geert Uytterhoeven
2021-10-12 18:33 ` [PATCH v7 13/21] auxdisplay: ht16k33: Convert to simple i2c probe function Geert Uytterhoeven
2021-10-12 18:33 ` [PATCH v7 14/21] auxdisplay: ht16k33: Add helper variable dev Geert Uytterhoeven
2021-10-12 18:33 ` [PATCH v7 15/21] auxdisplay: ht16k33: Move delayed work Geert Uytterhoeven
2021-10-12 18:33 ` [PATCH v7 16/21] auxdisplay: ht16k33: Extract ht16k33_brightness_set() Geert Uytterhoeven
2021-10-12 18:33 ` [PATCH v7 17/21] auxdisplay: ht16k33: Extract frame buffer probing Geert Uytterhoeven
2021-10-12 18:33 ` [PATCH v7 18/21] auxdisplay: ht16k33: Add support for segment displays Geert Uytterhoeven
2021-10-15  8:47   ` Dan Carpenter
2021-10-15  8:59     ` Geert Uytterhoeven
2021-10-12 18:33 ` [PATCH v7 19/21] dt-bindings: auxdisplay: ht16k33: Document LED subnode Geert Uytterhoeven
2021-10-12 18:33 ` [PATCH v7 20/21] auxdisplay: ht16k33: Add LED support Geert Uytterhoeven
2021-10-13  7:27   ` Robin van der Gracht
2021-10-12 18:33 ` Geert Uytterhoeven [this message]
2021-10-13  7:28   ` [PATCH v7 21/21] auxdisplay: ht16k33: Make use of device properties Robin van der Gracht

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=20211012183327.649865-22-geert@linux-m68k.org \
    --to=geert@linux-m68k.org \
    --cc=andy.shevchenko@gmail.com \
    --cc=devicetree@vger.kernel.org \
    --cc=gregkh@linuxfoundation.org \
    --cc=kabel@kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-leds@vger.kernel.org \
    --cc=linux-mips@vger.kernel.org \
    --cc=marek.behun@nic.cz \
    --cc=ojeda@kernel.org \
    --cc=paulburton@kernel.org \
    --cc=pavel@ucw.cz \
    --cc=robh+dt@kernel.org \
    --cc=robin@protonic.nl \
    /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).