mirror of
https://github.com/torvalds/linux.git
synced 2026-11-06 21:58:01 +01:00
char: xillybus: Use unsigned arithmetic for jiffies differences
Change the type of jiffies-related deadline variables from long to unsigned long, and remove unnecessary casts when computing time remaining as deadline - jiffies. No functional change is expected: although signed overflow is undefined in the C standard, processors perform the calculation correctly in practice. Using unsigned arithmetic is nevertheless the proper way to handle jiffies differences. Assisted-by: Deepseek:v4-pro Kimi:K2.6 ChatGPT:GPT-5.5 Claude:Sonnet-4.6 Signed-off-by: Eli Billauer <eli.billauer@gmail.com> Link: https://patch.msgid.link/20261009074557.19996-5-eli.billauer@gmail.com Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
This commit is contained in:
parent
9db7ade8f8
commit
f82830f560
|
|
@ -694,7 +694,8 @@ static ssize_t xillybus_read(struct file *filp, char __user *userbuf,
|
|||
unsigned long flags;
|
||||
int bytes_done = 0;
|
||||
int no_time_left = 0;
|
||||
long deadline, left_to_sleep;
|
||||
unsigned long deadline;
|
||||
long left_to_sleep;
|
||||
struct xilly_channel *channel = filp->private_data;
|
||||
|
||||
int empty, reached_eof, exhausted, ready;
|
||||
|
|
@ -938,7 +939,7 @@ static ssize_t xillybus_read(struct file *filp, char __user *userbuf,
|
|||
return -EINTR;
|
||||
}
|
||||
|
||||
left_to_sleep = deadline - ((long) jiffies);
|
||||
left_to_sleep = deadline - jiffies;
|
||||
|
||||
/*
|
||||
* If our time is out, skip the waiting. We may miss wr_sleepy
|
||||
|
|
|
|||
|
|
@ -1121,12 +1121,13 @@ static int xillyusb_send_opcode(struct xillyusb_dev *xdev,
|
|||
*/
|
||||
|
||||
static int flush_downstream(struct xillyusb_channel *chan,
|
||||
long timeout,
|
||||
unsigned long timeout,
|
||||
bool interruptible)
|
||||
{
|
||||
struct xillyusb_dev *xdev = chan->xdev;
|
||||
int chan_num = chan->chan_idx << 1;
|
||||
long deadline, left_to_sleep;
|
||||
unsigned long deadline;
|
||||
long left_to_sleep;
|
||||
int rc;
|
||||
|
||||
if (chan->flushed)
|
||||
|
|
@ -1135,7 +1136,8 @@ static int flush_downstream(struct xillyusb_channel *chan,
|
|||
deadline = jiffies + 1 + timeout;
|
||||
|
||||
if (chan->flushing) {
|
||||
long cancel_deadline = jiffies + 1 + XILLY_RESPONSE_TIMEOUT;
|
||||
unsigned long cancel_deadline =
|
||||
jiffies + 1 + XILLY_RESPONSE_TIMEOUT;
|
||||
|
||||
chan->canceled = 0;
|
||||
rc = xillyusb_send_opcode(xdev, chan_num,
|
||||
|
|
@ -1146,7 +1148,7 @@ static int flush_downstream(struct xillyusb_channel *chan,
|
|||
|
||||
/* Ignoring interrupts. Cancellation must be handled */
|
||||
while (!chan->canceled) {
|
||||
left_to_sleep = cancel_deadline - ((long)jiffies);
|
||||
left_to_sleep = cancel_deadline - jiffies;
|
||||
|
||||
if (left_to_sleep <= 0) {
|
||||
report_io_error(xdev, -EIO);
|
||||
|
|
@ -1196,7 +1198,7 @@ static int flush_downstream(struct xillyusb_channel *chan,
|
|||
}
|
||||
|
||||
while (chan->flushing) {
|
||||
left_to_sleep = deadline - ((long)jiffies);
|
||||
left_to_sleep = deadline - jiffies;
|
||||
|
||||
if (left_to_sleep <= 0)
|
||||
return -ETIMEDOUT;
|
||||
|
|
@ -1429,7 +1431,8 @@ static ssize_t xillyusb_read(struct file *filp, char __user *userbuf,
|
|||
struct xillyfifo *fifo = chan->in_fifo;
|
||||
int chan_num = (chan->chan_idx << 1) | 1;
|
||||
|
||||
long deadline, left_to_sleep;
|
||||
unsigned long deadline;
|
||||
long left_to_sleep;
|
||||
int bytes_done = 0;
|
||||
bool sent_set_push = false;
|
||||
int rc;
|
||||
|
|
@ -1458,7 +1461,7 @@ static ssize_t xillyusb_read(struct file *filp, char __user *userbuf,
|
|||
bytes_done += rc;
|
||||
chan->in_consumed_bytes += rc;
|
||||
|
||||
left_to_sleep = deadline - ((long)jiffies);
|
||||
left_to_sleep = deadline - jiffies;
|
||||
|
||||
/*
|
||||
* Some 32-bit arithmetic that may wrap. Note that
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user