From: Sasha Levin <sashal@kernel.org>
To: linux-kernel@vger.kernel.org, stable@vger.kernel.org
Cc: Khadija Kamran <kamrankhadijadj@gmail.com>,
"Fabio M . De Francesco" <fmdefrancesco@gmail.com>,
Greg Kroah-Hartman <gregkh@linuxfoundation.org>,
Sasha Levin <sashal@kernel.org>,
u.kleine-koenig@pengutronix.de, linux-staging@lists.linux.dev
Subject: [PATCH AUTOSEL 6.2 05/20] staging: axis-fifo: initialize timeouts in init only
Date: Sat, 6 May 2023 20:32:20 -0400 [thread overview]
Message-ID: <20230507003237.4074305-5-sashal@kernel.org> (raw)
In-Reply-To: <20230507003237.4074305-1-sashal@kernel.org>
From: Khadija Kamran <kamrankhadijadj@gmail.com>
[ Upstream commit 752cbd8f191678e86aa754f795546b7f06b7f171 ]
Initialize the module parameters, read_timeout and write_timeout once in
init().
Module parameters can only be set once and cannot be modified later, so we
don't need to evaluate them again when passing the parameters to
wait_event_interruptible_timeout().
Convert datatype of {read,write}_timeout from 'int' to 'long int' because
implicit conversion of 'long int' to 'int' in statement
'{read,write}_timeout = MAX_SCHEDULE_TIMEOUT' results in an overflow.
Change format specifier for {read,write}_timeout from %i to %li.
Reviewed-by: Fabio M. De Francesco <fmdefrancesco@gmail.com>
Suggested-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Signed-off-by: Khadija Kamran <kamrankhadijadj@gmail.com>
Link: https://lore.kernel.org/r/ZBN3XAsItCiTk7CV@khadija-virtual-machine
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Signed-off-by: Sasha Levin <sashal@kernel.org>
---
drivers/staging/axis-fifo/axis-fifo.c | 28 ++++++++++++++++-----------
1 file changed, 17 insertions(+), 11 deletions(-)
diff --git a/drivers/staging/axis-fifo/axis-fifo.c b/drivers/staging/axis-fifo/axis-fifo.c
index dfd2b357f484b..0a85ea667a1b5 100644
--- a/drivers/staging/axis-fifo/axis-fifo.c
+++ b/drivers/staging/axis-fifo/axis-fifo.c
@@ -103,17 +103,17 @@
* globals
* ----------------------------
*/
-static int read_timeout = 1000; /* ms to wait before read() times out */
-static int write_timeout = 1000; /* ms to wait before write() times out */
+static long read_timeout = 1000; /* ms to wait before read() times out */
+static long write_timeout = 1000; /* ms to wait before write() times out */
/* ----------------------------
* module command-line arguments
* ----------------------------
*/
-module_param(read_timeout, int, 0444);
+module_param(read_timeout, long, 0444);
MODULE_PARM_DESC(read_timeout, "ms to wait before blocking read() timing out; set to -1 for no timeout");
-module_param(write_timeout, int, 0444);
+module_param(write_timeout, long, 0444);
MODULE_PARM_DESC(write_timeout, "ms to wait before blocking write() timing out; set to -1 for no timeout");
/* ----------------------------
@@ -384,9 +384,7 @@ static ssize_t axis_fifo_read(struct file *f, char __user *buf,
mutex_lock(&fifo->read_lock);
ret = wait_event_interruptible_timeout(fifo->read_queue,
ioread32(fifo->base_addr + XLLF_RDFO_OFFSET),
- (read_timeout >= 0) ?
- msecs_to_jiffies(read_timeout) :
- MAX_SCHEDULE_TIMEOUT);
+ read_timeout);
if (ret <= 0) {
if (ret == 0) {
@@ -528,9 +526,7 @@ static ssize_t axis_fifo_write(struct file *f, const char __user *buf,
ret = wait_event_interruptible_timeout(fifo->write_queue,
ioread32(fifo->base_addr + XLLF_TDFV_OFFSET)
>= words_to_write,
- (write_timeout >= 0) ?
- msecs_to_jiffies(write_timeout) :
- MAX_SCHEDULE_TIMEOUT);
+ write_timeout);
if (ret <= 0) {
if (ret == 0) {
@@ -948,7 +944,17 @@ static struct platform_driver axis_fifo_driver = {
static int __init axis_fifo_init(void)
{
- pr_info("axis-fifo driver loaded with parameters read_timeout = %i, write_timeout = %i\n",
+ if (read_timeout >= 0)
+ read_timeout = msecs_to_jiffies(read_timeout);
+ else
+ read_timeout = MAX_SCHEDULE_TIMEOUT;
+
+ if (write_timeout >= 0)
+ write_timeout = msecs_to_jiffies(write_timeout);
+ else
+ write_timeout = MAX_SCHEDULE_TIMEOUT;
+
+ pr_info("axis-fifo driver loaded with parameters read_timeout = %li, write_timeout = %li\n",
read_timeout, write_timeout);
return platform_driver_register(&axis_fifo_driver);
}
--
2.39.2
next prev parent reply other threads:[~2023-05-07 0:35 UTC|newest]
Thread overview: 20+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-05-07 0:32 [PATCH AUTOSEL 6.2 01/20] ASoC: jack: allow multiple interrupt per gpio Sasha Levin
2023-05-07 0:32 ` [PATCH AUTOSEL 6.2 02/20] staging: rtl8192e: Replace macro RTL_PCI_DEVICE with PCI_DEVICE Sasha Levin
2023-05-07 0:32 ` [PATCH AUTOSEL 6.2 03/20] HID: apple: Set the tilde quirk flag on the Geyser 4 and later Sasha Levin
2023-05-07 0:32 ` [PATCH AUTOSEL 6.2 04/20] iio: imu: st_lsm6dsx: discard samples during filters settling time Sasha Levin
2023-05-07 0:32 ` Sasha Levin [this message]
2023-05-07 0:32 ` [PATCH AUTOSEL 6.2 06/20] ASoC: tegra: Support coupled mic-hp detection Sasha Levin
2023-05-07 0:32 ` [PATCH AUTOSEL 6.2 07/20] ASoC: amd: yc: Add DMI entries to support HP OMEN 16-n0xxx (8A42) Sasha Levin
2023-05-07 0:32 ` [PATCH AUTOSEL 6.2 08/20] HID: logitech-hidpp: Don't use the USB serial for USB devices Sasha Levin
2023-05-07 0:32 ` [PATCH AUTOSEL 6.2 09/20] HID: logitech-hidpp: Reconcile USB and Unifying serials Sasha Levin
2023-05-07 0:32 ` [PATCH AUTOSEL 6.2 10/20] spi: spi-imx: fix MX51_ECSPI_* macros when cs > 3 Sasha Levin
2023-05-07 0:32 ` [PATCH AUTOSEL 6.2 11/20] usb: typec: ucsi: acpi: add quirk for ASUS Zenbook UM325 Sasha Levin
2023-05-07 0:32 ` [PATCH AUTOSEL 6.2 12/20] ALSA: hda: LNL: add HD Audio PCI ID Sasha Levin
2023-05-07 0:32 ` [PATCH AUTOSEL 6.2 13/20] ASoC: amd: Add Dell G15 5525 to quirks list Sasha Levin
2023-05-07 0:32 ` [PATCH AUTOSEL 6.2 14/20] ASoC: amd: yc: Add ThinkBook 14 G5+ ARP to quirks list for acp6x Sasha Levin
2023-05-07 0:32 ` [PATCH AUTOSEL 6.2 15/20] HID: apple: Set the tilde quirk flag on the Geyser 3 Sasha Levin
2023-05-07 0:32 ` [PATCH AUTOSEL 6.2 16/20] HID: Ignore battery for ELAN touchscreen on ROG Flow X13 GV301RA Sasha Levin
2023-05-07 0:32 ` [PATCH AUTOSEL 6.2 17/20] HID: wacom: generic: Set battery quirk only when we see battery data Sasha Levin
2023-05-07 0:32 ` [PATCH AUTOSEL 6.2 18/20] usb: typec: tcpm: fix multiple times discover svids error Sasha Levin
2023-05-07 0:32 ` [PATCH AUTOSEL 6.2 19/20] serial: 8250: Reinit port->pm on port specific driver unbind Sasha Levin
2023-05-07 0:32 ` [PATCH AUTOSEL 6.2 20/20] mcb-pci: Reallocate memory region to avoid memory overlapping Sasha Levin
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=20230507003237.4074305-5-sashal@kernel.org \
--to=sashal@kernel.org \
--cc=fmdefrancesco@gmail.com \
--cc=gregkh@linuxfoundation.org \
--cc=kamrankhadijadj@gmail.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-staging@lists.linux.dev \
--cc=stable@vger.kernel.org \
--cc=u.kleine-koenig@pengutronix.de \
/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