Thread (5 messages) 5 messages, 3 authors, 2012-11-22

Re: [PATCH] video console: add a driver for lcd2s character display

flat view

From: Lars Poeschel <hidden>
Date: 2012-11-20 14:21:07
Also in: lkml

On Tuesday 20 November 2012 at 14:25:57, Arnd Bergmann wrote:
On Tuesday 20 November 2012, Lars Poeschel wrote:
quoted
From: Lars Poeschel <redacted>

This driver allows to use a lcd2s 20x4 character display as
a linux console output device.

Signed-off-by: Lars Poeschel <redacted>
The driver looks nice overall, but I found two style issues:
Thank you for your feedback.
quoted
+static int __devinit lcd2s_i2c_probe(struct i2c_client *i2c,
+				const struct i2c_device_id *id)
+{
+	struct lcd2s_data *data;
+
+	if (!i2c_check_functionality(i2c->adapter,
+			I2C_FUNC_SMBUS_BYTE_DATA | I2C_FUNC_SMBUS_WORD_DATA))
+		return -EIO;
+	data = devm_kzalloc(&i2c->dev, sizeof(struct lcd2s_data), 
GFP_KERNEL);
quoted
+	if (!data)
+		return -ENOMEM;
+
+	data->i2c = i2c;
+	data->consw.owner		= THIS_MODULE;
+	data->consw.con_startup		= lcd2s_startup;
+	data->consw.con_init		= lcd2s_init;
+	data->consw.con_deinit		= lcd2s_deinit;
+	data->consw.con_clear		= lcd2s_clear;
+	data->consw.con_putc		= lcd2s_putc;
+	data->consw.con_putcs		= lcd2s_putcs;
+	data->consw.con_cursor		= lcd2s_cursor;
+	data->consw.con_scroll		= lcd2s_scroll;
+	data->consw.con_bmove		= lcd2s_bmove;
+	data->consw.con_switch		= lcd2s_switch;
+	data->consw.con_blank		= lcd2s_blank;
+	data->consw.con_set_palette	= lcd2s_set_palette;
+	data->consw.con_scrolldelta	= lcd2s_scrolldelta;
+
+	i2c_set_clientdata(i2c, data);
+
+	take_over_console(&data->consw, LCD2S_FIRST, LCD2S_LAST, 1);
+
+	return 0;
+}
It's better to define the struct consw as a preinitialized
'static const' object, rather than dynamically setting each
member.
I could not find a place to store the drivers private data inside the struct 
vc_data. I wanted to have the struct consw inside the drivers private data 
(struct lcd2s_data) to be able to container_of to the drivers private data in 
the consw.con_* functions. This makes it possible to use more than one actual 
lcd2s display with the same driver. Otherwise I have to store the struct 
i2c_client somewhere statically and the driver can control only one display 
and has to forbid to be probed a second time. Or am I wrong somewhere ?

Lars
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help