From: Nikita Kiryushin <kiryushin@ancud.ru>
To: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Cc: "Nikita Kiryushin" <kiryushin@ancud.ru>,
"Jiri Slaby" <jirislaby@kernel.org>,
"Tony Lindgren" <tony@atomide.com>,
"Ilpo Järvinen" <ilpo.jarvinen@linux.intel.com>,
"Lino Sanfilippo" <l.sanfilippo@kunbus.com>,
"John Ogness" <john.ogness@linutronix.de>,
"Thomas Gleixner" <tglx@linutronix.de>,
"Andy Shevchenko" <andriy.shevchenko@linux.intel.com>,
linux-kernel@vger.kernel.org, linux-serial@vger.kernel.org,
lvc-project@linuxtesting.org
Subject: [PATCH] serial: core: use sysfs_emit() in sysfs show handlers
Date: Fri, 29 Mar 2024 21:06:34 +0300 [thread overview]
Message-ID: <20240329180634.1037706-1-kiryushin@ancud.ru> (raw)
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
next reply other threads:[~2024-03-29 18:07 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-03-29 18:06 Nikita Kiryushin [this message]
2024-04-02 12:05 ` [PATCH] serial: core: use sysfs_emit() in sysfs show handlers Ilpo Järvinen
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=20240329180634.1037706-1-kiryushin@ancud.ru \
--to=kiryushin@ancud.ru \
--cc=andriy.shevchenko@linux.intel.com \
--cc=gregkh@linuxfoundation.org \
--cc=ilpo.jarvinen@linux.intel.com \
--cc=jirislaby@kernel.org \
--cc=john.ogness@linutronix.de \
--cc=l.sanfilippo@kunbus.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-serial@vger.kernel.org \
--cc=lvc-project@linuxtesting.org \
--cc=tglx@linutronix.de \
--cc=tony@atomide.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;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).