auxdisplay: charlcd: Partially revert "Move hwidth and bwidth to struct hd44780_common"

[ Upstream commit 09965a142078080fe7807bab0f6f1890cb5987a4 ]

Commit 2545c1c948 ("auxdisplay: Move hwidth and bwidth to struct
hd44780_common") makes charlcd_alloc() argument-less effectively dropping
the single allocation for the struct charlcd_priv object along with
the driver specific one. Restore that behaviour here.

Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Reviewed-by: Geert Uytterhoeven <geert@linux-m68k.org>
Signed-off-by: Sasha Levin <sashal@kernel.org>
This commit is contained in:
Andy Shevchenko
2025-02-24 19:27:38 +02:00
committed by Greg Kroah-Hartman
parent 769d1bccd1
commit 5b518c452f
5 changed files with 9 additions and 7 deletions

View File

@@ -594,18 +594,19 @@ static int charlcd_init(struct charlcd *lcd)
return 0; return 0;
} }
struct charlcd *charlcd_alloc(void) struct charlcd *charlcd_alloc(unsigned int drvdata_size)
{ {
struct charlcd_priv *priv; struct charlcd_priv *priv;
struct charlcd *lcd; struct charlcd *lcd;
priv = kzalloc(sizeof(*priv), GFP_KERNEL); priv = kzalloc(sizeof(*priv) + drvdata_size, GFP_KERNEL);
if (!priv) if (!priv)
return NULL; return NULL;
priv->esc_seq.len = -1; priv->esc_seq.len = -1;
lcd = &priv->lcd; lcd = &priv->lcd;
lcd->drvdata = priv->drvdata;
return lcd; return lcd;
} }

View File

@@ -49,7 +49,7 @@ struct charlcd {
unsigned long y; unsigned long y;
} addr; } addr;
void *drvdata; void *drvdata; /* Set by charlcd_alloc() */
}; };
/** /**
@@ -93,7 +93,8 @@ struct charlcd_ops {
}; };
void charlcd_backlight(struct charlcd *lcd, enum charlcd_onoff on); void charlcd_backlight(struct charlcd *lcd, enum charlcd_onoff on);
struct charlcd *charlcd_alloc(void);
struct charlcd *charlcd_alloc(unsigned int drvdata_size);
void charlcd_free(struct charlcd *lcd); void charlcd_free(struct charlcd *lcd);
int charlcd_register(struct charlcd *lcd); int charlcd_register(struct charlcd *lcd);

View File

@@ -226,7 +226,7 @@ static int hd44780_probe(struct platform_device *pdev)
if (!hdc) if (!hdc)
return -ENOMEM; return -ENOMEM;
lcd = charlcd_alloc(); lcd = charlcd_alloc(0);
if (!lcd) if (!lcd)
goto fail1; goto fail1;

View File

@@ -307,7 +307,7 @@ static int lcd2s_i2c_probe(struct i2c_client *i2c)
if (err < 0) if (err < 0)
return err; return err;
lcd = charlcd_alloc(); lcd = charlcd_alloc(0);
if (!lcd) if (!lcd)
return -ENOMEM; return -ENOMEM;

View File

@@ -835,7 +835,7 @@ static void lcd_init(void)
if (!hdc) if (!hdc)
return; return;
charlcd = charlcd_alloc(); charlcd = charlcd_alloc(0);
if (!charlcd) { if (!charlcd) {
kfree(hdc); kfree(hdc);
return; return;