diff options
Diffstat (limited to 'drivers/auxdisplay/hd44780.c')
-rw-r--r-- | drivers/auxdisplay/hd44780.c | 24 |
1 files changed, 8 insertions, 16 deletions
diff --git a/drivers/auxdisplay/hd44780.c b/drivers/auxdisplay/hd44780.c index d56a5d508ccd..cef42656c4b0 100644 --- a/drivers/auxdisplay/hd44780.c +++ b/drivers/auxdisplay/hd44780.c @@ -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(struct hd44780), GFP_KERNEL); + 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,23 +310,18 @@ static int hd44780_probe(struct platform_device *pdev) fail3: kfree(hd); fail2: - kfree(lcd); -fail1: - kfree(hdc); + hd44780_common_free(lcd); return ret; } -static int hd44780_remove(struct platform_device *pdev) +static void hd44780_remove(struct platform_device *pdev) { struct charlcd *lcd = platform_get_drvdata(pdev); struct hd44780_common *hdc = lcd->drvdata; charlcd_unregister(lcd); kfree(hdc->hd44780); - kfree(lcd->drvdata); - - kfree(lcd); - return 0; + hd44780_common_free(lcd); } static const struct of_device_id hd44780_of_match[] = { |