Skip to content

Commit d4f1db7

Browse files
committed
Merge tag 'auxdisplay-for-linus-v5.18-rc1' of https://github.com/ojeda/linux
Pull auxdisplay updates from Miguel Ojeda: "A few auxdisplay lcd2s improvements from Andy Shevchenko" * tag 'auxdisplay-for-linus-v5.18-rc1' of https://github.com/ojeda/linux: auxdisplay: lcd2s: Use array size explicitly in lcd2s_gotoxy() auxdisplay: lcd2s: Switch to i2c ->probe_new() auxdisplay: lcd2s: use module_i2c_driver to simplify the code auxdisplay: lcd2s: make use of device property API auxdisplay: lcd2s: Fix multi-line comment style
2 parents f4f5d7c + 13de234 commit d4f1db7

File tree

1 file changed

+17
-38
lines changed

1 file changed

+17
-38
lines changed

drivers/auxdisplay/lcd2s.c

Lines changed: 17 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,20 @@
11
// SPDX-License-Identifier: GPL-2.0
22
/*
3-
* console driver for LCD2S 4x20 character displays connected through i2c.
4-
* The display also has a spi interface, but the driver does not support
3+
* Console driver for LCD2S 4x20 character displays connected through i2c.
4+
* The display also has a SPI interface, but the driver does not support
55
* this yet.
66
*
7-
* This is a driver allowing you to use a LCD2S 4x20 from modtronix
7+
* This is a driver allowing you to use a LCD2S 4x20 from Modtronix
88
* engineering as auxdisplay character device.
99
*
1010
* (C) 2019 by Lemonage Software GmbH
1111
* Author: Lars Pöschel <poeschel@lemonage.de>
1212
* All rights reserved.
1313
*/
1414
#include <linux/kernel.h>
15+
#include <linux/mod_devicetable.h>
1516
#include <linux/module.h>
17+
#include <linux/property.h>
1618
#include <linux/slab.h>
1719
#include <linux/i2c.h>
1820
#include <linux/delay.h>
@@ -104,7 +106,7 @@ static int lcd2s_print(struct charlcd *lcd, int c)
104106
static int lcd2s_gotoxy(struct charlcd *lcd, unsigned int x, unsigned int y)
105107
{
106108
struct lcd2s_data *lcd2s = lcd->drvdata;
107-
u8 buf[] = { LCD2S_CMD_CUR_POS, y + 1, x + 1};
109+
u8 buf[3] = { LCD2S_CMD_CUR_POS, y + 1, x + 1 };
108110

109111
lcd2s_i2c_master_send(lcd2s->i2c, buf, sizeof(buf));
110112

@@ -214,16 +216,15 @@ static int lcd2s_lines(struct charlcd *lcd, enum charlcd_lines lines)
214216
return 0;
215217
}
216218

219+
/*
220+
* Generator: LGcxxxxx...xx; must have <c> between '0' and '7',
221+
* representing the numerical ASCII code of the redefined character,
222+
* and <xx...xx> a sequence of 16 hex digits representing 8 bytes
223+
* for each character. Most LCDs will only use 5 lower bits of
224+
* the 7 first bytes.
225+
*/
217226
static int lcd2s_redefine_char(struct charlcd *lcd, char *esc)
218227
{
219-
/* Generator : LGcxxxxx...xx; must have <c> between '0'
220-
* and '7', representing the numerical ASCII code of the
221-
* redefined character, and <xx...xx> a sequence of 16
222-
* hex digits representing 8 bytes for each character.
223-
* Most LCDs will only use 5 lower bits of the 7 first
224-
* bytes.
225-
*/
226-
227228
struct lcd2s_data *lcd2s = lcd->drvdata;
228229
u8 buf[LCD2S_CHARACTER_SIZE + 2] = { LCD2S_CMD_DEF_CUSTOM_CHAR };
229230
u8 value;
@@ -286,8 +287,7 @@ static const struct charlcd_ops lcd2s_ops = {
286287
.redefine_char = lcd2s_redefine_char,
287288
};
288289

289-
static int lcd2s_i2c_probe(struct i2c_client *i2c,
290-
const struct i2c_device_id *id)
290+
static int lcd2s_i2c_probe(struct i2c_client *i2c)
291291
{
292292
struct charlcd *lcd;
293293
struct lcd2s_data *lcd2s;
@@ -355,43 +355,22 @@ static const struct i2c_device_id lcd2s_i2c_id[] = {
355355
};
356356
MODULE_DEVICE_TABLE(i2c, lcd2s_i2c_id);
357357

358-
#ifdef CONFIG_OF
359358
static const struct of_device_id lcd2s_of_table[] = {
360359
{ .compatible = "modtronix,lcd2s" },
361360
{ }
362361
};
363362
MODULE_DEVICE_TABLE(of, lcd2s_of_table);
364-
#endif
365363

366364
static struct i2c_driver lcd2s_i2c_driver = {
367365
.driver = {
368366
.name = "lcd2s",
369-
#ifdef CONFIG_OF
370-
.of_match_table = of_match_ptr(lcd2s_of_table),
371-
#endif
367+
.of_match_table = lcd2s_of_table,
372368
},
373-
.probe = lcd2s_i2c_probe,
369+
.probe_new = lcd2s_i2c_probe,
374370
.remove = lcd2s_i2c_remove,
375371
.id_table = lcd2s_i2c_id,
376372
};
377-
378-
static int __init lcd2s_modinit(void)
379-
{
380-
int ret = 0;
381-
382-
ret = i2c_add_driver(&lcd2s_i2c_driver);
383-
if (ret != 0)
384-
pr_err("Failed to register lcd2s driver\n");
385-
386-
return ret;
387-
}
388-
module_init(lcd2s_modinit)
389-
390-
static void __exit lcd2s_exit(void)
391-
{
392-
i2c_del_driver(&lcd2s_i2c_driver);
393-
}
394-
module_exit(lcd2s_exit)
373+
module_i2c_driver(lcd2s_i2c_driver);
395374

396375
MODULE_DESCRIPTION("LCD2S character display driver");
397376
MODULE_AUTHOR("Lars Poeschel");

0 commit comments

Comments
 (0)