From c726031a9d15c243e69c3755d94f7b0b170dd003 Mon Sep 17 00:00:00 2001 From: Andy Shevchenko Date: Tue, 8 Mar 2022 17:12:33 +0200 Subject: auxdisplay: lcd2s: Fix multi-line comment style Fix multi-line comment style: - start sentences with Capital letter - use non-networking style of the first line Signed-off-by: Andy Shevchenko Signed-off-by: Miguel Ojeda --- drivers/auxdisplay/lcd2s.c | 21 ++++++++++----------- 1 file changed, 10 insertions(+), 11 deletions(-) (limited to 'drivers') diff --git a/drivers/auxdisplay/lcd2s.c b/drivers/auxdisplay/lcd2s.c index 2578b2d45439..e28ec8452d46 100644 --- a/drivers/auxdisplay/lcd2s.c +++ b/drivers/auxdisplay/lcd2s.c @@ -1,10 +1,10 @@ // SPDX-License-Identifier: GPL-2.0 /* - * console driver for LCD2S 4x20 character displays connected through i2c. - * The display also has a spi interface, but the driver does not support + * Console driver for LCD2S 4x20 character displays connected through i2c. + * The display also has a SPI interface, but the driver does not support * this yet. * - * This is a driver allowing you to use a LCD2S 4x20 from modtronix + * This is a driver allowing you to use a LCD2S 4x20 from Modtronix * engineering as auxdisplay character device. * * (C) 2019 by Lemonage Software GmbH @@ -214,16 +214,15 @@ static int lcd2s_lines(struct charlcd *lcd, enum charlcd_lines lines) return 0; } +/* + * Generator: LGcxxxxx...xx; must have between '0' and '7', + * representing the numerical ASCII code of the redefined character, + * and a sequence of 16 hex digits representing 8 bytes + * for each character. Most LCDs will only use 5 lower bits of + * the 7 first bytes. + */ static int lcd2s_redefine_char(struct charlcd *lcd, char *esc) { - /* Generator : LGcxxxxx...xx; must have between '0' - * and '7', representing the numerical ASCII code of the - * redefined character, and a sequence of 16 - * hex digits representing 8 bytes for each character. - * Most LCDs will only use 5 lower bits of the 7 first - * bytes. - */ - struct lcd2s_data *lcd2s = lcd->drvdata; u8 buf[LCD2S_CHARACTER_SIZE + 2] = { LCD2S_CMD_DEF_CUSTOM_CHAR }; u8 value; -- cgit v1.2.3-70-g09d2 From 44bb3f038eb5583ae1fdd74f088e9e6235c3875e Mon Sep 17 00:00:00 2001 From: Andy Shevchenko Date: Tue, 8 Mar 2022 17:11:16 +0200 Subject: auxdisplay: lcd2s: make use of device property API Make use of device property API in this driver so that both OF based system and ACPI based system can use this driver. Signed-off-by: Andy Shevchenko Signed-off-by: Miguel Ojeda --- drivers/auxdisplay/lcd2s.c | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) (limited to 'drivers') diff --git a/drivers/auxdisplay/lcd2s.c b/drivers/auxdisplay/lcd2s.c index e28ec8452d46..70dd81f7e426 100644 --- a/drivers/auxdisplay/lcd2s.c +++ b/drivers/auxdisplay/lcd2s.c @@ -12,7 +12,9 @@ * All rights reserved. */ #include +#include #include +#include #include #include #include @@ -354,20 +356,16 @@ static const struct i2c_device_id lcd2s_i2c_id[] = { }; MODULE_DEVICE_TABLE(i2c, lcd2s_i2c_id); -#ifdef CONFIG_OF static const struct of_device_id lcd2s_of_table[] = { { .compatible = "modtronix,lcd2s" }, { } }; MODULE_DEVICE_TABLE(of, lcd2s_of_table); -#endif static struct i2c_driver lcd2s_i2c_driver = { .driver = { .name = "lcd2s", -#ifdef CONFIG_OF - .of_match_table = of_match_ptr(lcd2s_of_table), -#endif + .of_match_table = lcd2s_of_table, }, .probe = lcd2s_i2c_probe, .remove = lcd2s_i2c_remove, -- cgit v1.2.3-70-g09d2 From f15c3dea5ed75d6f646802656d97d779dd69e683 Mon Sep 17 00:00:00 2001 From: Andy Shevchenko Date: Tue, 8 Mar 2022 17:11:17 +0200 Subject: auxdisplay: lcd2s: use module_i2c_driver to simplify the code Use the module_i2c_driver() macro to make the code smaller and a bit simpler. Signed-off-by: Andy Shevchenko Signed-off-by: Miguel Ojeda --- drivers/auxdisplay/lcd2s.c | 19 +------------------ 1 file changed, 1 insertion(+), 18 deletions(-) (limited to 'drivers') diff --git a/drivers/auxdisplay/lcd2s.c b/drivers/auxdisplay/lcd2s.c index 70dd81f7e426..bf484286c6e4 100644 --- a/drivers/auxdisplay/lcd2s.c +++ b/drivers/auxdisplay/lcd2s.c @@ -371,24 +371,7 @@ static struct i2c_driver lcd2s_i2c_driver = { .remove = lcd2s_i2c_remove, .id_table = lcd2s_i2c_id, }; - -static int __init lcd2s_modinit(void) -{ - int ret = 0; - - ret = i2c_add_driver(&lcd2s_i2c_driver); - if (ret != 0) - pr_err("Failed to register lcd2s driver\n"); - - return ret; -} -module_init(lcd2s_modinit) - -static void __exit lcd2s_exit(void) -{ - i2c_del_driver(&lcd2s_i2c_driver); -} -module_exit(lcd2s_exit) +module_i2c_driver(lcd2s_i2c_driver); MODULE_DESCRIPTION("LCD2S character display driver"); MODULE_AUTHOR("Lars Poeschel"); -- cgit v1.2.3-70-g09d2 From 8fefb3134f3493bd2e5e26de308ebfbe8c562b8f Mon Sep 17 00:00:00 2001 From: Andy Shevchenko Date: Tue, 8 Mar 2022 17:11:18 +0200 Subject: auxdisplay: lcd2s: Switch to i2c ->probe_new() The deprecated i2c ->probe() functionality doesn't work with OF compatible strings, as it only checks for the i2c device id. While it's not a problem right now, it would still bring a better code. Switch to the new way of probing. Signed-off-by: Andy Shevchenko Signed-off-by: Miguel Ojeda --- drivers/auxdisplay/lcd2s.c | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) (limited to 'drivers') diff --git a/drivers/auxdisplay/lcd2s.c b/drivers/auxdisplay/lcd2s.c index bf484286c6e4..91381d323566 100644 --- a/drivers/auxdisplay/lcd2s.c +++ b/drivers/auxdisplay/lcd2s.c @@ -287,8 +287,7 @@ static const struct charlcd_ops lcd2s_ops = { .redefine_char = lcd2s_redefine_char, }; -static int lcd2s_i2c_probe(struct i2c_client *i2c, - const struct i2c_device_id *id) +static int lcd2s_i2c_probe(struct i2c_client *i2c) { struct charlcd *lcd; struct lcd2s_data *lcd2s; @@ -367,7 +366,7 @@ static struct i2c_driver lcd2s_i2c_driver = { .name = "lcd2s", .of_match_table = lcd2s_of_table, }, - .probe = lcd2s_i2c_probe, + .probe_new = lcd2s_i2c_probe, .remove = lcd2s_i2c_remove, .id_table = lcd2s_i2c_id, }; -- cgit v1.2.3-70-g09d2 From 13de23494f387315c6cfab6fe78fbed7d1b25586 Mon Sep 17 00:00:00 2001 From: Andy Shevchenko Date: Tue, 8 Mar 2022 17:11:19 +0200 Subject: auxdisplay: lcd2s: Use array size explicitly in lcd2s_gotoxy() Currently the reading of the onstack array is confusing since two out of three members are of different types. Let it be more clear by explicitly set the array size, so everybody will understand that parameters are cast to the type of the array. While at it, add a missed space. Signed-off-by: Andy Shevchenko Signed-off-by: Miguel Ojeda --- drivers/auxdisplay/lcd2s.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'drivers') diff --git a/drivers/auxdisplay/lcd2s.c b/drivers/auxdisplay/lcd2s.c index 91381d323566..e465108d9998 100644 --- a/drivers/auxdisplay/lcd2s.c +++ b/drivers/auxdisplay/lcd2s.c @@ -106,7 +106,7 @@ static int lcd2s_print(struct charlcd *lcd, int c) static int lcd2s_gotoxy(struct charlcd *lcd, unsigned int x, unsigned int y) { struct lcd2s_data *lcd2s = lcd->drvdata; - u8 buf[] = { LCD2S_CMD_CUR_POS, y + 1, x + 1}; + u8 buf[3] = { LCD2S_CMD_CUR_POS, y + 1, x + 1 }; lcd2s_i2c_master_send(lcd2s->i2c, buf, sizeof(buf)); -- cgit v1.2.3-70-g09d2