Skip to content

Commit 68917df

Browse files
committed
auxdisplay: lcd2s: Allocate memory for custom data in charlcd_alloc()
Allocate memory for custom data in charlcd_alloc() instead of doing that explicitly in the driver. Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com> Reviewed-by: Geert Uytterhoeven <geert@linux-m68k.org>
1 parent 09965a1 commit 68917df

File tree

1 file changed

+4
-8
lines changed

1 file changed

+4
-8
lines changed

drivers/auxdisplay/lcd2s.c

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -298,20 +298,18 @@ static int lcd2s_i2c_probe(struct i2c_client *i2c)
298298
I2C_FUNC_SMBUS_WRITE_BLOCK_DATA))
299299
return -EIO;
300300

301-
lcd2s = devm_kzalloc(&i2c->dev, sizeof(*lcd2s), GFP_KERNEL);
302-
if (!lcd2s)
303-
return -ENOMEM;
304-
305301
/* Test, if the display is responding */
306302
err = lcd2s_i2c_smbus_write_byte(i2c, LCD2S_CMD_DISPLAY_OFF);
307303
if (err < 0)
308304
return err;
309305

310-
lcd = charlcd_alloc(0);
306+
lcd = charlcd_alloc(sizeof(*lcd2s));
311307
if (!lcd)
312308
return -ENOMEM;
313309

314-
lcd->drvdata = lcd2s;
310+
lcd->ops = &lcd2s_ops;
311+
312+
lcd2s = lcd->drvdata;
315313
lcd2s->i2c = i2c;
316314
lcd2s->charlcd = lcd;
317315

@@ -326,8 +324,6 @@ static int lcd2s_i2c_probe(struct i2c_client *i2c)
326324
if (err)
327325
goto fail1;
328326

329-
lcd->ops = &lcd2s_ops;
330-
331327
err = charlcd_register(lcd2s->charlcd);
332328
if (err)
333329
goto fail1;

0 commit comments

Comments
 (0)