diff mbox

[03/12] spi: rspi: Use devm_kasprintf()

Message ID 1407329949-5695-4-git-send-email-geert+renesas@glider.be (mailing list archive)
State Accepted
Commit 43937455c9bf294cffc2f25c4a4d0a1b9bbd88e6
Headers show

Commit Message

Geert Uytterhoeven Aug. 6, 2014, 12:59 p.m. UTC
Use the devm_kasprintf() helper function instead of open coding
error-prone buffer handling and string formatting.

Signed-off-by: Geert Uytterhoeven <geert+renesas@glider.be>
---
devm_kasprintf() was included in upstream, and will be available as of
release v3.17-rc1.
---
 drivers/spi/spi-rspi.c | 7 +++----
 1 file changed, 3 insertions(+), 4 deletions(-)

Comments

Mark Brown Aug. 6, 2014, 8:26 p.m. UTC | #1
On Wed, Aug 06, 2014 at 02:59:00PM +0200, Geert Uytterhoeven wrote:
> Use the devm_kasprintf() helper function instead of open coding
> error-prone buffer handling and string formatting.

Applied, thanks.
diff mbox

Patch

diff --git a/drivers/spi/spi-rspi.c b/drivers/spi/spi-rspi.c
index a4d8d3cf2912..aa1c6a893570 100644
--- a/drivers/spi/spi-rspi.c
+++ b/drivers/spi/spi-rspi.c
@@ -1046,12 +1046,11 @@  static int rspi_request_irq(struct device *dev, unsigned int irq,
 			    irq_handler_t handler, const char *suffix,
 			    void *dev_id)
 {
-	const char *base = dev_name(dev);
-	size_t len = strlen(base) + strlen(suffix) + 2;
-	char *name = devm_kzalloc(dev, len, GFP_KERNEL);
+	const char *name = devm_kasprintf(dev, GFP_KERNEL, "%s:%s",
+					  dev_name(dev), suffix);
 	if (!name)
 		return -ENOMEM;
-	snprintf(name, len, "%s:%s", base, suffix);
+
 	return devm_request_irq(dev, irq, handler, 0, name, dev_id);
 }