auxdisplay for v6.15-1

* Refactor a couple of APIs to reduce amount of calls to memory allocator
 * Miscellaneous small fixes and improvements
 
 The following is an automated git shortlog grouped by driver:
 
 charlcd:
  -  Partially revert "Move hwidth and bwidth to struct hd44780_common"
 
 gpiolib:
  -  add gpiod_multi_set_value_cansleep()
 
 hd44780:
  -  Rename hd to hdc in hd44780_common_alloc()
  -  Call charlcd_alloc() from hd44780_common_alloc()
  -  Make use of hd44780_common_free()
  -  Introduce hd44780_common_free()
  -  Fix an API misuse in hd44780.c
 
 lcd2s:
  -  Allocate memory for custom data in charlcd_alloc()
 
 MAX6959 should select BITREVERSE:
  - MAX6959 should select BITREVERSE
 
 panel:
  -  Make use of hd44780_common_free()
  -  Fix an API misuse in panel.c
 
 seg-led-gpio:
  -  use gpiod_multi_set_value_cansleep
 -----BEGIN PGP SIGNATURE-----
 
 iQIzBAABCgAdFiEEqaflIX74DDDzMJJtb7wzTHR8rCgFAmfizF8ACgkQb7wzTHR8
 rCgJQw/+Mdwx/5mFZ6GFLzVVEtDnqJx8SHs2wwBiQuA/l8vd587bbC8TtqnNZuc2
 kDucQxVdXXW4Fi5Szd+aPtCuYEKFOauLHMkn8JPLvvd/Z862k3rrYME2oDj7a7I2
 MLujywMWhlGiceNIL9lU5CnuVPW+IsUhunsahvVS98SlSoc8/aNZ3ezowUCaMTTs
 xfTAbByvf5BM8bfsZtlCldiKDxhr6VCgJCastZTwhpjtJ0GT4BpvYaz2NqbTLfpT
 6aNjCdUdNNWyzlY44MlCOQgxx+5GyyDmelNLnYnAN2/FqRWoVc1Wa9PQf+sGUSIz
 PSbkA/FIRDPZGWPmyPvEGIj9PFXlb5DCIpl1UlX+o1UuiOXuzBGK7xzs6ypRxHui
 rs14qLrtayIwklejwPBBPdYZ9MHAfL1H5DmgeBEz0yx5LXGtrYSnL3G1gtoc/BDL
 BqbV5kKaBlg/BOcsyCNcfNO0E9LaxEn9SpGchISXB28gOY6NmGcZTgrIiQdzKf5G
 PKpZ23VIKT6MtCimKSNLHIzq2aMlaIk2iXBKceqPGZ/MZeQL/CU1dWJUEL+mlnuf
 e1q3fAO1atiTDNdWR5fPxMibOpaH1VfvY29O8Tw6giaY69E2lMV5tTbK7K8a+kr/
 S6rsXCsaJvYxtarW2V4dcRyN9ihFr4KMcq4o1Dpqrh+T2fZqcDA=
 =rwYl
 -----END PGP SIGNATURE-----

Merge tag 'auxdisplay-v6.15-1' of git://git.kernel.org/pub/scm/linux/kernel/git/andy/linux-auxdisplay

Pull auxdisplay updates from Andy Shevchenko:

 - Refactor a couple of APIs to reduce amount of calls to memory
   allocator

 - Miscellaneous small fixes and improvements

* tag 'auxdisplay-v6.15-1' of git://git.kernel.org/pub/scm/linux/kernel/git/andy/linux-auxdisplay:
  auxdisplay: hd44780: Rename hd to hdc in hd44780_common_alloc()
  auxdisplay: hd44780: Call charlcd_alloc() from hd44780_common_alloc()
  auxdisplay: panel: Make use of hd44780_common_free()
  auxdisplay: hd44780: Make use of hd44780_common_free()
  auxdisplay: hd44780: Introduce hd44780_common_free()
  auxdisplay: lcd2s: Allocate memory for custom data in charlcd_alloc()
  auxdisplay: charlcd: Partially revert "Move hwidth and bwidth to struct hd44780_common"
  auxdisplay: panel: Fix an API misuse in panel.c
  auxdisplay: hd44780: Fix an API misuse in hd44780.c
  auxdisplay: MAX6959 should select BITREVERSE
  auxdisplay: seg-led-gpio: use gpiod_multi_set_value_cansleep
This commit is contained in:
Linus Torvalds 2025-03-25 20:54:28 -07:00
commit c84907a145
9 changed files with 42 additions and 48 deletions

View File

@ -503,6 +503,7 @@ config HT16K33
config MAX6959
tristate "Maxim MAX6958/6959 7-segment LED controller"
depends on I2C
select BITREVERSE
select REGMAP_I2C
select LINEDISP
help

View File

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

View File

@ -51,7 +51,7 @@ struct charlcd {
unsigned long y;
} addr;
void *drvdata;
void *drvdata; /* Set by charlcd_alloc() */
};
/**
@ -95,7 +95,8 @@ struct charlcd_ops {
};
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);
int charlcd_register(struct charlcd *lcd);

View File

@ -222,20 +222,17 @@ static int hd44780_probe(struct platform_device *pdev)
return -EINVAL;
}
hdc = hd44780_common_alloc();
if (!hdc)
return -ENOMEM;
lcd = charlcd_alloc();
lcd = hd44780_common_alloc();
if (!lcd)
goto fail1;
return -ENOMEM;
hd = kzalloc(sizeof(*hd), GFP_KERNEL);
if (!hd)
goto fail2;
hdc = lcd->drvdata;
hdc->hd44780 = hd;
lcd->drvdata = hdc;
for (i = 0; i < ifwidth; i++) {
hd->pins[base + i] = devm_gpiod_get_index(dev, "data", i,
GPIOD_OUT_LOW);
@ -313,9 +310,7 @@ static int hd44780_probe(struct platform_device *pdev)
fail3:
kfree(hd);
fail2:
kfree(lcd);
fail1:
kfree(hdc);
hd44780_common_free(lcd);
return ret;
}
@ -326,9 +321,7 @@ static void hd44780_remove(struct platform_device *pdev)
charlcd_unregister(lcd);
kfree(hdc->hd44780);
kfree(lcd->drvdata);
kfree(lcd);
hd44780_common_free(lcd);
}
static const struct of_device_id hd44780_of_match[] = {

View File

@ -351,20 +351,28 @@ int hd44780_common_redefine_char(struct charlcd *lcd, char *esc)
}
EXPORT_SYMBOL_GPL(hd44780_common_redefine_char);
struct hd44780_common *hd44780_common_alloc(void)
struct charlcd *hd44780_common_alloc(void)
{
struct hd44780_common *hd;
struct hd44780_common *hdc;
struct charlcd *lcd;
hd = kzalloc(sizeof(*hd), GFP_KERNEL);
if (!hd)
lcd = charlcd_alloc(sizeof(*hdc));
if (!lcd)
return NULL;
hd->ifwidth = 8;
hd->bwidth = DEFAULT_LCD_BWIDTH;
hd->hwidth = DEFAULT_LCD_HWIDTH;
return hd;
hdc = lcd->drvdata;
hdc->ifwidth = 8;
hdc->bwidth = DEFAULT_LCD_BWIDTH;
hdc->hwidth = DEFAULT_LCD_HWIDTH;
return lcd;
}
EXPORT_SYMBOL_GPL(hd44780_common_alloc);
void hd44780_common_free(struct charlcd *lcd)
{
charlcd_free(lcd);
}
EXPORT_SYMBOL_GPL(hd44780_common_free);
MODULE_DESCRIPTION("Common functions for HD44780 (and compatibles) LCD displays");
MODULE_LICENSE("GPL");

View File

@ -30,4 +30,6 @@ int hd44780_common_blink(struct charlcd *lcd, enum charlcd_onoff on);
int hd44780_common_fontsize(struct charlcd *lcd, enum charlcd_fontsize size);
int hd44780_common_lines(struct charlcd *lcd, enum charlcd_lines lines);
int hd44780_common_redefine_char(struct charlcd *lcd, char *esc);
struct hd44780_common *hd44780_common_alloc(void);
struct charlcd *hd44780_common_alloc(void);
void hd44780_common_free(struct charlcd *lcd);

View File

@ -298,20 +298,18 @@ static int lcd2s_i2c_probe(struct i2c_client *i2c)
I2C_FUNC_SMBUS_WRITE_BLOCK_DATA))
return -EIO;
lcd2s = devm_kzalloc(&i2c->dev, sizeof(*lcd2s), GFP_KERNEL);
if (!lcd2s)
return -ENOMEM;
/* Test, if the display is responding */
err = lcd2s_i2c_smbus_write_byte(i2c, LCD2S_CMD_DISPLAY_OFF);
if (err < 0)
return err;
lcd = charlcd_alloc();
lcd = charlcd_alloc(sizeof(*lcd2s));
if (!lcd)
return -ENOMEM;
lcd->drvdata = lcd2s;
lcd->ops = &lcd2s_ops;
lcd2s = lcd->drvdata;
lcd2s->i2c = i2c;
lcd2s->charlcd = lcd;
@ -326,8 +324,6 @@ static int lcd2s_i2c_probe(struct i2c_client *i2c)
if (err)
goto fail1;
lcd->ops = &lcd2s_ops;
err = charlcd_register(lcd2s->charlcd);
if (err)
goto fail1;

View File

@ -831,18 +831,12 @@ static void lcd_init(void)
struct charlcd *charlcd;
struct hd44780_common *hdc;
hdc = hd44780_common_alloc();
if (!hdc)
charlcd = hd44780_common_alloc();
if (!charlcd)
return;
charlcd = charlcd_alloc();
if (!charlcd) {
kfree(hdc);
return;
}
hdc = charlcd->drvdata;
hdc->hd44780 = &lcd;
charlcd->drvdata = hdc;
/*
* Init lcd struct with load-time values to preserve exact
@ -1664,7 +1658,7 @@ static void panel_attach(struct parport *port)
if (lcd.enabled)
charlcd_unregister(lcd.charlcd);
err_unreg_device:
kfree(lcd.charlcd);
hd44780_common_free(lcd.charlcd);
lcd.charlcd = NULL;
parport_unregister_device(pprt);
pprt = NULL;
@ -1691,8 +1685,7 @@ static void panel_detach(struct parport *port)
if (lcd.enabled) {
charlcd_unregister(lcd.charlcd);
lcd.initialized = false;
kfree(lcd.charlcd->drvdata);
kfree(lcd.charlcd);
hd44780_common_free(lcd.charlcd);
lcd.charlcd = NULL;
}

View File

@ -36,8 +36,7 @@ static void seg_led_update(struct work_struct *work)
bitmap_set_value8(values, map_to_seg7(&map->map.seg7, linedisp->buf[0]), 0);
gpiod_set_array_value_cansleep(priv->segment_gpios->ndescs, priv->segment_gpios->desc,
priv->segment_gpios->info, values);
gpiod_multi_set_value_cansleep(priv->segment_gpios, values);
}
static int seg_led_linedisp_get_map_type(struct linedisp *linedisp)