A few auxdisplay's lcd2s improvements from Andy Shevchenko.

-----BEGIN PGP SIGNATURE-----
 
 iQIzBAABCgAdFiEEPjU5OPd5QIZ9jqqOGXyLc2htIW0FAmJF0h0ACgkQGXyLc2ht
 IW2MgRAAu3FmAP1bAlnQv0HW17vOOj7HQz8JssF0l6cZhFy6F07AN3wjHXudD87k
 lHX7Pyik4WgT1ecFhkE5il/9ZYghVR0fRNTIBCECayFOjGBgKF2gvbmeCxGwqgj1
 JPo58lVKWHpkZ0rqsWob8qGAupfBafnD1Hvq3KFgcMJlggSzrNmYIiZRGPlf2Cyz
 yAPmnphAXmxEAg0FqaTwTfMwybqvCzh9CXwVvtE8KCOtFW2ptx7syG89lKeBEkSm
 bFA9evpDNnSYttTvWPLY+Ee9IFRBWf/fbwa/IjVosqtNS4U2P1Uaxa0RK8mPTSaw
 O5EbmGy/OUAapTvpshfAPenjbomZ462+9Jp6o4cxSlkwkiNB4Ozv68JhKu+gBvRm
 S0V3YgfjSEIt6XIsZK5Y/1yOKk+6wmAeP0u/YXFUz5MdgO004UA52bU4qpZx8o0t
 GfVm4+W9cR5GYUXNfHDDFhC25n4N6eIJ5N29aivFefld1167B0noRA4SZ+wt/WoJ
 cmKUgcHxQW1R0N8ShyyDSgAFcvfGlcmI0WfaKI22jrPjyIn5a0GICtQGGY8Yy2WJ
 ndRfzjDoHFy4xkdFfoG+0kIC+GEZdVCObAgpug6FOY45WUDp2ZDdT8AMnY7KpcfU
 fxgHjC1Kt3B30pO2F6k1a/s0WRVR6UPmseJdfXjSoqm3oM7JeVU=
 =CAEy
 -----END PGP SIGNATURE-----

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
This commit is contained in:
Linus Torvalds 2022-03-31 14:05:05 -07:00
Родитель f4f5d7cfb2 13de23494f
Коммит d4f1db7715
1 изменённых файлов: 17 добавлений и 38 удалений

Просмотреть файл

@ -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
@ -12,7 +12,9 @@
* All rights reserved.
*/
#include <linux/kernel.h>
#include <linux/mod_devicetable.h>
#include <linux/module.h>
#include <linux/property.h>
#include <linux/slab.h>
#include <linux/i2c.h>
#include <linux/delay.h>
@ -104,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));
@ -214,16 +216,15 @@ static int lcd2s_lines(struct charlcd *lcd, enum charlcd_lines lines)
return 0;
}
/*
* Generator: LGcxxxxx...xx; must have <c> between '0' and '7',
* representing the numerical ASCII code of the redefined character,
* and <xx...xx> 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 <c> between '0'
* and '7', representing the numerical ASCII code of the
* redefined character, and <xx...xx> 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;
@ -286,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;
@ -355,43 +355,22 @@ 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,
.probe_new = lcd2s_i2c_probe,
.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");