public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
To: Andy Shevchenko <andriy.shevchenko@linux.intel.com>,
	linux-kernel@vger.kernel.org
Cc: Andy Shevchenko <andy@kernel.org>,
	Geert Uytterhoeven <geert@linux-m68k.org>,
	Willy Tarreau <willy@haproxy.com>,
	Ksenija Stanojevic <ksenija.stanojevic@gmail.com>
Subject: [PATCH v1 2/7] auxdisplay: lcd2s: Allocate memory for custom data in charlcd_alloc()
Date: Mon, 24 Feb 2025 19:27:39 +0200	[thread overview]
Message-ID: <20250224173010.219024-3-andriy.shevchenko@linux.intel.com> (raw)
In-Reply-To: <20250224173010.219024-1-andriy.shevchenko@linux.intel.com>

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>
---
 drivers/auxdisplay/lcd2s.c | 12 ++++--------
 1 file changed, 4 insertions(+), 8 deletions(-)

diff --git a/drivers/auxdisplay/lcd2s.c b/drivers/auxdisplay/lcd2s.c
index d573d36e3067..d18735665706 100644
--- a/drivers/auxdisplay/lcd2s.c
+++ b/drivers/auxdisplay/lcd2s.c
@@ -301,20 +301,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(0);
+	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;
 
@@ -329,8 +327,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;
-- 
2.45.1.3035.g276e886db78b


  parent reply	other threads:[~2025-02-24 17:30 UTC|newest]

Thread overview: 32+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-02-24 17:27 [PATCH v1 0/7] auxdisplay: charlcd: Refactor memory allocation Andy Shevchenko
2025-02-24 17:27 ` [PATCH v1 1/7] auxdisplay: charlcd: Partially revert "Move hwidth and bwidth to struct hd44780_common" Andy Shevchenko
2025-03-07  9:03   ` Geert Uytterhoeven
2025-03-07 16:57     ` Andy Shevchenko
2025-03-07 18:14       ` Geert Uytterhoeven
2025-03-07 18:57         ` Andy Shevchenko
2025-03-07 19:05           ` Geert Uytterhoeven
2025-03-10  8:12             ` Andy Shevchenko
2025-03-10  9:39               ` Geert Uytterhoeven
2025-03-10 10:53                 ` Andy Shevchenko
2025-03-10 15:15                 ` Andy Shevchenko
2025-02-24 17:27 ` Andy Shevchenko [this message]
2025-03-07  9:03   ` [PATCH v1 2/7] auxdisplay: lcd2s: Allocate memory for custom data in charlcd_alloc() Geert Uytterhoeven
2025-02-24 17:27 ` [PATCH v1 3/7] auxdisplay: hd44780: Introduce hd44780_common_free() Andy Shevchenko
2025-03-07  9:04   ` Geert Uytterhoeven
2025-02-24 17:27 ` [PATCH v1 4/7] auxdisplay: hd44780: Make use of hd44780_common_free() Andy Shevchenko
2025-03-07  9:05   ` Geert Uytterhoeven
2025-03-07 17:00     ` Andy Shevchenko
2025-02-24 17:27 ` [PATCH v1 5/7] auxdisplay: panel: " Andy Shevchenko
2025-03-07  9:05   ` Geert Uytterhoeven
2025-03-07 17:02     ` Andy Shevchenko
2025-03-07 18:14       ` Geert Uytterhoeven
2025-02-24 17:27 ` [PATCH v1 6/7] auxdisplay: hd44780: Call charlcd_alloc() from hd44780_common_alloc() Andy Shevchenko
2025-03-07  9:14   ` Geert Uytterhoeven
2025-03-07 17:08     ` Andy Shevchenko
2025-03-07 18:19       ` Geert Uytterhoeven
2025-03-07 19:01         ` Andy Shevchenko
2025-03-07 19:06           ` Geert Uytterhoeven
2025-03-10  8:14             ` Andy Shevchenko
2025-02-24 17:27 ` [PATCH v1 7/7] auxdisplay: hd44780: Rename hd to hdc in hd44780_common_alloc() Andy Shevchenko
2025-03-03 10:30 ` [PATCH v1 0/7] auxdisplay: charlcd: Refactor memory allocation Andy Shevchenko
2025-03-04 14:29   ` Andy Shevchenko

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20250224173010.219024-3-andriy.shevchenko@linux.intel.com \
    --to=andriy.shevchenko@linux.intel.com \
    --cc=andy@kernel.org \
    --cc=geert@linux-m68k.org \
    --cc=ksenija.stanojevic@gmail.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=willy@haproxy.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox