Skip to content

Commit 5d343f7

Browse files
geertuojeda
authored andcommitted
auxdisplay: ht16k33: Make use of device properties
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 <[email protected]> Signed-off-by: Geert Uytterhoeven <[email protected]> Reviewed-by: Andy Shevchenko <[email protected]> Acked-by: Robin van der Gracht <[email protected]> Signed-off-by: Miguel Ojeda <[email protected]>
1 parent c223d9c commit 5d343f7

File tree

2 files changed

+13
-16
lines changed

2 files changed

+13
-16
lines changed

drivers/auxdisplay/Kconfig

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -169,7 +169,7 @@ config IMG_ASCII_LCD
169169

170170
config HT16K33
171171
tristate "Holtek Ht16K33 LED controller with keyscan"
172-
depends on FB && OF && I2C && INPUT
172+
depends on FB && I2C && INPUT
173173
select FB_SYS_FOPS
174174
select FB_SYS_FILLRECT
175175
select FB_SYS_COPYAREA

drivers/auxdisplay/ht16k33.c

Lines changed: 12 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
#include <linux/module.h>
1313
#include <linux/interrupt.h>
1414
#include <linux/i2c.h>
15-
#include <linux/of.h>
15+
#include <linux/property.h>
1616
#include <linux/fb.h>
1717
#include <linux/slab.h>
1818
#include <linux/backlight.h>
@@ -491,15 +491,13 @@ static int ht16k33_led_probe(struct device *dev, struct led_classdev *led,
491491
unsigned int brightness)
492492
{
493493
struct led_init_data init_data = {};
494-
struct device_node *node;
495494
int err;
496495

497496
/* The LED is optional */
498-
node = of_get_child_by_name(dev->of_node, "led");
499-
if (!node)
497+
init_data.fwnode = device_get_named_child_node(dev, "led");
498+
if (!init_data.fwnode)
500499
return 0;
501500

502-
init_data.fwnode = of_fwnode_handle(node);
503501
init_data.devicename = "auxdisplay";
504502
init_data.devname_mandatory = true;
505503

@@ -520,7 +518,6 @@ static int ht16k33_keypad_probe(struct i2c_client *client,
520518
struct ht16k33_keypad *keypad)
521519
{
522520
struct device *dev = &client->dev;
523-
struct device_node *node = dev->of_node;
524521
u32 rows = HT16K33_MATRIX_KEYPAD_MAX_ROWS;
525522
u32 cols = HT16K33_MATRIX_KEYPAD_MAX_COLS;
526523
int err;
@@ -539,17 +536,17 @@ static int ht16k33_keypad_probe(struct i2c_client *client,
539536
keypad->dev->open = ht16k33_keypad_start;
540537
keypad->dev->close = ht16k33_keypad_stop;
541538

542-
if (!of_get_property(node, "linux,no-autorepeat", NULL))
539+
if (!device_property_read_bool(dev, "linux,no-autorepeat"))
543540
__set_bit(EV_REP, keypad->dev->evbit);
544541

545-
err = of_property_read_u32(node, "debounce-delay-ms",
546-
&keypad->debounce_ms);
542+
err = device_property_read_u32(dev, "debounce-delay-ms",
543+
&keypad->debounce_ms);
547544
if (err) {
548545
dev_err(dev, "key debounce delay not specified\n");
549546
return err;
550547
}
551548

552-
err = matrix_keypad_parse_of_params(dev, &rows, &cols);
549+
err = matrix_keypad_parse_properties(dev, &rows, &cols);
553550
if (err)
554551
return err;
555552
if (rows > HT16K33_MATRIX_KEYPAD_MAX_ROWS ||
@@ -634,8 +631,8 @@ static int ht16k33_fbdev_probe(struct device *dev, struct ht16k33_priv *priv,
634631
goto err_fbdev_buffer;
635632
}
636633

637-
err = of_property_read_u32(dev->of_node, "refresh-rate-hz",
638-
&fbdev->refresh_rate);
634+
err = device_property_read_u32(dev, "refresh-rate-hz",
635+
&fbdev->refresh_rate);
639636
if (err) {
640637
dev_err(dev, "refresh rate not specified\n");
641638
goto err_fbdev_info;
@@ -741,8 +738,8 @@ static int ht16k33_probe(struct i2c_client *client)
741738
if (err)
742739
return err;
743740

744-
err = of_property_read_u32(dev->of_node, "default-brightness-level",
745-
&dft_brightness);
741+
err = device_property_read_u32(dev, "default-brightness-level",
742+
&dft_brightness);
746743
if (err) {
747744
dft_brightness = MAX_BRIGHTNESS;
748745
} else if (dft_brightness > MAX_BRIGHTNESS) {
@@ -830,7 +827,7 @@ static struct i2c_driver ht16k33_driver = {
830827
.remove = ht16k33_remove,
831828
.driver = {
832829
.name = DRIVER_NAME,
833-
.of_match_table = of_match_ptr(ht16k33_of_match),
830+
.of_match_table = ht16k33_of_match,
834831
},
835832
.id_table = ht16k33_i2c_match,
836833
};

0 commit comments

Comments
 (0)