* [PATCH] serial: core: use sysfs_emit() in sysfs show handlers
@ 2024-03-29 18:06 Nikita Kiryushin
2024-04-02 12:05 ` Ilpo Järvinen
0 siblings, 1 reply; 2+ messages in thread
From: Nikita Kiryushin @ 2024-03-29 18:06 UTC (permalink / raw)
To: Greg Kroah-Hartman
Cc: Nikita Kiryushin, Jiri Slaby, Tony Lindgren, Ilpo Järvinen,
Lino Sanfilippo, John Ogness, Thomas Gleixner, Andy Shevchenko,
linux-kernel, linux-serial, lvc-project
Change sprintf() in sysfs show() handlers to sysfs_emit(),
as recommended by sysfs documentation.
Found by Linux Verification Center (linuxtesting.org) with SVACE.
Signed-off-by: Nikita Kiryushin <kiryushin@ancud.ru>
---
drivers/tty/serial/serial_core.c | 28 ++++++++++++++--------------
1 file changed, 14 insertions(+), 14 deletions(-)
diff --git a/drivers/tty/serial/serial_core.c b/drivers/tty/serial/serial_core.c
index ff85ebd3a007..a80b6aab2d98 100644
--- a/drivers/tty/serial/serial_core.c
+++ b/drivers/tty/serial/serial_core.c
@@ -2903,7 +2903,7 @@ static ssize_t uartclk_show(struct device *dev,
struct tty_port *port = dev_get_drvdata(dev);
uart_get_info(port, &tmp);
- return sprintf(buf, "%d\n", tmp.baud_base * 16);
+ return sysfs_emit(buf, "%d\n", tmp.baud_base * 16);
}
static ssize_t type_show(struct device *dev,
@@ -2913,7 +2913,7 @@ static ssize_t type_show(struct device *dev,
struct tty_port *port = dev_get_drvdata(dev);
uart_get_info(port, &tmp);
- return sprintf(buf, "%d\n", tmp.type);
+ return sysfs_emit(buf, "%d\n", tmp.type);
}
static ssize_t line_show(struct device *dev,
@@ -2923,7 +2923,7 @@ static ssize_t line_show(struct device *dev,
struct tty_port *port = dev_get_drvdata(dev);
uart_get_info(port, &tmp);
- return sprintf(buf, "%d\n", tmp.line);
+ return sysfs_emit(buf, "%d\n", tmp.line);
}
static ssize_t port_show(struct device *dev,
@@ -2937,7 +2937,7 @@ static ssize_t port_show(struct device *dev,
ioaddr = tmp.port;
if (HIGH_BITS_OFFSET)
ioaddr |= (unsigned long)tmp.port_high << HIGH_BITS_OFFSET;
- return sprintf(buf, "0x%lX\n", ioaddr);
+ return sysfs_emit(buf, "0x%lX\n", ioaddr);
}
static ssize_t irq_show(struct device *dev,
@@ -2947,7 +2947,7 @@ static ssize_t irq_show(struct device *dev,
struct tty_port *port = dev_get_drvdata(dev);
uart_get_info(port, &tmp);
- return sprintf(buf, "%d\n", tmp.irq);
+ return sysfs_emit(buf, "%d\n", tmp.irq);
}
static ssize_t flags_show(struct device *dev,
@@ -2957,7 +2957,7 @@ static ssize_t flags_show(struct device *dev,
struct tty_port *port = dev_get_drvdata(dev);
uart_get_info(port, &tmp);
- return sprintf(buf, "0x%X\n", tmp.flags);
+ return sysfs_emit(buf, "0x%X\n", tmp.flags);
}
static ssize_t xmit_fifo_size_show(struct device *dev,
@@ -2967,7 +2967,7 @@ static ssize_t xmit_fifo_size_show(struct device *dev,
struct tty_port *port = dev_get_drvdata(dev);
uart_get_info(port, &tmp);
- return sprintf(buf, "%d\n", tmp.xmit_fifo_size);
+ return sysfs_emit(buf, "%d\n", tmp.xmit_fifo_size);
}
static ssize_t close_delay_show(struct device *dev,
@@ -2977,7 +2977,7 @@ static ssize_t close_delay_show(struct device *dev,
struct tty_port *port = dev_get_drvdata(dev);
uart_get_info(port, &tmp);
- return sprintf(buf, "%d\n", tmp.close_delay);
+ return sysfs_emit(buf, "%d\n", tmp.close_delay);
}
static ssize_t closing_wait_show(struct device *dev,
@@ -2987,7 +2987,7 @@ static ssize_t closing_wait_show(struct device *dev,
struct tty_port *port = dev_get_drvdata(dev);
uart_get_info(port, &tmp);
- return sprintf(buf, "%d\n", tmp.closing_wait);
+ return sysfs_emit(buf, "%d\n", tmp.closing_wait);
}
static ssize_t custom_divisor_show(struct device *dev,
@@ -2997,7 +2997,7 @@ static ssize_t custom_divisor_show(struct device *dev,
struct tty_port *port = dev_get_drvdata(dev);
uart_get_info(port, &tmp);
- return sprintf(buf, "%d\n", tmp.custom_divisor);
+ return sysfs_emit(buf, "%d\n", tmp.custom_divisor);
}
static ssize_t io_type_show(struct device *dev,
@@ -3007,7 +3007,7 @@ static ssize_t io_type_show(struct device *dev,
struct tty_port *port = dev_get_drvdata(dev);
uart_get_info(port, &tmp);
- return sprintf(buf, "%d\n", tmp.io_type);
+ return sysfs_emit(buf, "%d\n", tmp.io_type);
}
static ssize_t iomem_base_show(struct device *dev,
@@ -3017,7 +3017,7 @@ static ssize_t iomem_base_show(struct device *dev,
struct tty_port *port = dev_get_drvdata(dev);
uart_get_info(port, &tmp);
- return sprintf(buf, "0x%lX\n", (unsigned long)tmp.iomem_base);
+ return sysfs_emit(buf, "0x%lX\n", (unsigned long)tmp.iomem_base);
}
static ssize_t iomem_reg_shift_show(struct device *dev,
@@ -3027,7 +3027,7 @@ static ssize_t iomem_reg_shift_show(struct device *dev,
struct tty_port *port = dev_get_drvdata(dev);
uart_get_info(port, &tmp);
- return sprintf(buf, "%d\n", tmp.iomem_reg_shift);
+ return sysfs_emit(buf, "%d\n", tmp.iomem_reg_shift);
}
static ssize_t console_show(struct device *dev,
@@ -3044,7 +3044,7 @@ static ssize_t console_show(struct device *dev,
console = uart_console_registered(uport);
mutex_unlock(&port->mutex);
- return sprintf(buf, "%c\n", console ? 'Y' : 'N');
+ return sysfs_emit(buf, "%c\n", console ? 'Y' : 'N');
}
static ssize_t console_store(struct device *dev,
--
2.34.1
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [PATCH] serial: core: use sysfs_emit() in sysfs show handlers
2024-03-29 18:06 [PATCH] serial: core: use sysfs_emit() in sysfs show handlers Nikita Kiryushin
@ 2024-04-02 12:05 ` Ilpo Järvinen
0 siblings, 0 replies; 2+ messages in thread
From: Ilpo Järvinen @ 2024-04-02 12:05 UTC (permalink / raw)
To: Nikita Kiryushin
Cc: Greg Kroah-Hartman, Jiri Slaby, Tony Lindgren, Lino Sanfilippo,
John Ogness, Thomas Gleixner, Andy Shevchenko, LKML, linux-serial,
lvc-project
[-- Attachment #1: Type: text/plain, Size: 359 bytes --]
On Fri, 29 Mar 2024, Nikita Kiryushin wrote:
> Change sprintf() in sysfs show() handlers to sysfs_emit(),
> as recommended by sysfs documentation.
>
> Found by Linux Verification Center (linuxtesting.org) with SVACE.
>
> Signed-off-by: Nikita Kiryushin <kiryushin@ancud.ru>
Reviewed-by: Ilpo Järvinen <ilpo.jarvinen@linux.intel.com>
--
i.
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2024-04-02 12:05 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-03-29 18:06 [PATCH] serial: core: use sysfs_emit() in sysfs show handlers Nikita Kiryushin
2024-04-02 12:05 ` Ilpo Järvinen
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox