]> git.ipfire.org Git - thirdparty/u-boot.git/commitdiff
pinctrl: mediatek: use scnprintf() instead of snprintf()
authorDavid Lechner <dlechner@baylibre.com>
Wed, 6 May 2026 23:05:31 +0000 (18:05 -0500)
committerDavid Lechner <dlechner@baylibre.com>
Wed, 10 Jun 2026 20:31:42 +0000 (15:31 -0500)
Replace snprintf() with scnprintf() in the MediaTek pinctrl driver.

snprintf() returns the number of characters that _would_ have been
written if the buffer were large enough, while scnprintf() returns the
number of characters actually written to the buffer. Since we use the
return value to advance the buffer pointer, we need to use scnprintf()
to have the correct pointer arithmetic.

Fixes: 76da7482cf39 ("pinctrl: mediatek: print bias info along with pinmux")
Reviewed-by: Julien Stephan <jstephan@baylibre.com>
Link: https://patch.msgid.link/20260506-mtk-pinctrl-fix-scnprintf-v1-1-56b99d5809db@baylibre.com
Signed-off-by: David Lechner <dlechner@baylibre.com>
drivers/pinctrl/mediatek/pinctrl-mtk-common.c

index cfffbaeef84cda67cae74c42f0b033b1f05454ba..01f67f09407a67d16c5d067b5df0f0ff88ca0293 100644 (file)
@@ -251,7 +251,7 @@ static int mtk_pinconf_get(struct udevice *dev, u32 pin, char *buf, size_t size)
        if (mtk_get_pin_io_type(dev, pin, &io_type))
                return 0;
 
-       pos = snprintf(buf, size, " (%s)", io_type.name);
+       pos = scnprintf(buf, size, " (%s)", io_type.name);
        if (pos >= size)
                return pos;
 
@@ -306,7 +306,7 @@ static int mtk_get_pin_muxing(struct udevice *dev, unsigned int selector,
        if (err)
                return err;
 
-       pos = snprintf(buf, size, "Aux Func.%d", val);
+       pos = scnprintf(buf, size, "Aux Func.%d", val);
        if (pos >= size)
                return 0;
 
@@ -721,7 +721,7 @@ int mtk_pinconf_get_pu_pd(struct udevice *dev, u32 pin, char *buf, size_t size)
        if (err)
                return err;
 
-       return snprintf(buf, size, " PU:%d PD:%d", pu, pd);
+       return scnprintf(buf, size, " PU:%d PD:%d", pu, pd);
 }
 
 int mtk_pinconf_get_pupd_r1_r0(struct udevice *dev, u32 pin, char *buf, size_t size)
@@ -740,7 +740,7 @@ int mtk_pinconf_get_pupd_r1_r0(struct udevice *dev, u32 pin, char *buf, size_t s
        if (err)
                return err;
 
-       return snprintf(buf, size, " PUPD:%d R1:%d R0:%d", pupd, r1, r0);
+       return scnprintf(buf, size, " PUPD:%d R1:%d R0:%d", pupd, r1, r0);
 }
 
 int mtk_pinconf_get_pu_pd_rsel(struct udevice *dev, u32 pin, char *buf, size_t size)
@@ -755,7 +755,7 @@ int mtk_pinconf_get_pu_pd_rsel(struct udevice *dev, u32 pin, char *buf, size_t s
        if (err)
                return err;
 
-       return pos + snprintf(buf + pos, size - pos, " RSEL:%d", rsel);
+       return pos + scnprintf(buf + pos, size - pos, " RSEL:%d", rsel);
 }
 #endif