|
1 | 1 | // SPDX-License-Identifier: GPL-2.0 |
2 | 2 | /* |
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 |
5 | 5 | * this yet. |
6 | 6 | * |
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 |
8 | 8 | * engineering as auxdisplay character device. |
9 | 9 | * |
10 | 10 | * (C) 2019 by Lemonage Software GmbH |
11 | 11 | * Author: Lars Pöschel <poeschel@lemonage.de> |
12 | 12 | * All rights reserved. |
13 | 13 | */ |
14 | 14 | #include <linux/kernel.h> |
| 15 | +#include <linux/mod_devicetable.h> |
15 | 16 | #include <linux/module.h> |
| 17 | +#include <linux/property.h> |
16 | 18 | #include <linux/slab.h> |
17 | 19 | #include <linux/i2c.h> |
18 | 20 | #include <linux/delay.h> |
@@ -104,7 +106,7 @@ static int lcd2s_print(struct charlcd *lcd, int c) |
104 | 106 | static int lcd2s_gotoxy(struct charlcd *lcd, unsigned int x, unsigned int y) |
105 | 107 | { |
106 | 108 | 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 }; |
108 | 110 |
|
109 | 111 | lcd2s_i2c_master_send(lcd2s->i2c, buf, sizeof(buf)); |
110 | 112 |
|
@@ -214,16 +216,15 @@ static int lcd2s_lines(struct charlcd *lcd, enum charlcd_lines lines) |
214 | 216 | return 0; |
215 | 217 | } |
216 | 218 |
|
| 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 | + */ |
217 | 226 | static int lcd2s_redefine_char(struct charlcd *lcd, char *esc) |
218 | 227 | { |
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 | | - |
227 | 228 | struct lcd2s_data *lcd2s = lcd->drvdata; |
228 | 229 | u8 buf[LCD2S_CHARACTER_SIZE + 2] = { LCD2S_CMD_DEF_CUSTOM_CHAR }; |
229 | 230 | u8 value; |
@@ -286,8 +287,7 @@ static const struct charlcd_ops lcd2s_ops = { |
286 | 287 | .redefine_char = lcd2s_redefine_char, |
287 | 288 | }; |
288 | 289 |
|
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) |
291 | 291 | { |
292 | 292 | struct charlcd *lcd; |
293 | 293 | struct lcd2s_data *lcd2s; |
@@ -355,43 +355,22 @@ static const struct i2c_device_id lcd2s_i2c_id[] = { |
355 | 355 | }; |
356 | 356 | MODULE_DEVICE_TABLE(i2c, lcd2s_i2c_id); |
357 | 357 |
|
358 | | -#ifdef CONFIG_OF |
359 | 358 | static const struct of_device_id lcd2s_of_table[] = { |
360 | 359 | { .compatible = "modtronix,lcd2s" }, |
361 | 360 | { } |
362 | 361 | }; |
363 | 362 | MODULE_DEVICE_TABLE(of, lcd2s_of_table); |
364 | | -#endif |
365 | 363 |
|
366 | 364 | static struct i2c_driver lcd2s_i2c_driver = { |
367 | 365 | .driver = { |
368 | 366 | .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, |
372 | 368 | }, |
373 | | - .probe = lcd2s_i2c_probe, |
| 369 | + .probe_new = lcd2s_i2c_probe, |
374 | 370 | .remove = lcd2s_i2c_remove, |
375 | 371 | .id_table = lcd2s_i2c_id, |
376 | 372 | }; |
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); |
395 | 374 |
|
396 | 375 | MODULE_DESCRIPTION("LCD2S character display driver"); |
397 | 376 | MODULE_AUTHOR("Lars Poeschel"); |
|
0 commit comments