spi: rspi: Use devm_kasprintf()
authorGeert Uytterhoeven <geert+renesas@glider.be>
Wed, 6 Aug 2014 12:59:00 +0000 (14:59 +0200)
committerMark Brown <broonie@linaro.org>
Sat, 16 Aug 2014 22:14:09 +0000 (17:14 -0500)
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>
Signed-off-by: Mark Brown <broonie@linaro.org>
drivers/spi/spi-rspi.c

index a4d8d3cf291283b941dcba07ea37ac5d08900918..aa1c6a893570d441b8867161f7092511b716dd8d 100644 (file)
@@ -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);
 }