From: Eli Billauer <eli.billauer@gmail.com>
To: gregkh@linuxfoundation.org
Cc: arnd@arndb.de, linux-kernel@vger.kernel.org, corbet@lwn.net,
Eli Billauer <eli.billauer@gmail.com>
Subject: [PATCH v5 5/7] char: xillybus: Integer arithmetic improvements
Date: Wed, 5 Aug 2026 13:13:35 +0200 [thread overview]
Message-ID: <20260805111337.69178-6-eli.billauer@gmail.com> (raw)
In-Reply-To: <20260805111337.69178-1-eli.billauer@gmail.com>
Choose unsigned integers instead of signed where natural and required to
ensure defined overflow behavoir.
Simplify an arithmetic expression too.
No functional change is expected, as the relevant variables normally never
reach values where this transition matters.
Assisted-by: Deepseek:v4-pro Kimi:K2.6 ChatGPT:GPT-5.5 Claude:Sonnet-4.6
Assisted-by: Sashiko-0.2.5:gemini-3.1-pro-preview
Signed-off-by: Eli Billauer <eli.billauer@gmail.com>
---
Notes:
Changelog:
=========
Changes v4->v5:
-- Use unsigned literal ("1U") instead of signed to ensure defined
behavior when left-shifted (in response to Sashiko's remark)
No change on v3->v4.
Changes v2->v3:
-- Add Assisted-by tag to description
No change on v1->v2.
drivers/char/xillybus/xillybus_core.c | 14 +++++++-------
1 file changed, 7 insertions(+), 7 deletions(-)
diff --git a/drivers/char/xillybus/xillybus_core.c b/drivers/char/xillybus/xillybus_core.c
index 7acebc1e6050..3ae95e6b17e9 100644
--- a/drivers/char/xillybus/xillybus_core.c
+++ b/drivers/char/xillybus/xillybus_core.c
@@ -343,7 +343,8 @@ static int xilly_map_single(struct xilly_endpoint *ep,
static int xilly_get_dma_buffers(struct xilly_endpoint *ep,
struct xilly_alloc_state *s,
struct xilly_buffer **buffers,
- int bufnum, int bytebufsize)
+ unsigned int bufnum,
+ unsigned int bytebufsize)
{
int i, rc;
dma_addr_t dma_addr;
@@ -431,8 +432,8 @@ static int xilly_setupchannels(struct xilly_endpoint *ep,
struct device *dev = ep->dev;
int i, entry, rc;
struct xilly_channel *channel;
- int channelnum, bufnum, bufsize, format, is_writebuf;
- int bytebufsize;
+ unsigned int channelnum, bufnum, bufsize, format, is_writebuf;
+ unsigned int bytebufsize;
int synchronous, allowpartial, exclusive_open, seekable;
int supports_nonempty;
int msg_buf_done = 0;
@@ -512,7 +513,7 @@ static int xilly_setupchannels(struct xilly_endpoint *ep,
format = (chandesc[1] >> 4) & 0x03;
allowpartial = (chandesc[1] >> 6) & 0x01;
synchronous = (chandesc[1] >> 7) & 0x01;
- bufsize = 1 << (chandesc[2] & 0x1f);
+ bufsize = 1U << (chandesc[2] & 0x1f);
bufnum = 1 << (chandesc[3] & 0x0f);
exclusive_open = (chandesc[2] >> 7) & 0x01;
seekable = (chandesc[2] >> 6) & 0x01;
@@ -531,8 +532,7 @@ static int xilly_setupchannels(struct xilly_endpoint *ep,
channel->log2_element_size = ((format > 2) ?
2 : format);
- bytebufsize = bufsize *
- (1 << channel->log2_element_size);
+ bytebufsize = bufsize << channel->log2_element_size;
buffers = devm_kcalloc(dev, bufnum,
sizeof(struct xilly_buffer *),
@@ -589,7 +589,7 @@ static int xilly_setupchannels(struct xilly_endpoint *ep,
static int xilly_scan_idt(struct xilly_endpoint *endpoint,
struct xilly_idt_handle *idt_handle)
{
- int count = 0;
+ unsigned int count = 0;
unsigned char *idt = endpoint->channels[1]->wr_buffers[0]->addr;
unsigned char *end_of_idt = idt + endpoint->idtlen - 4;
unsigned char *scan;
--
2.34.1
next prev parent reply other threads:[~2026-08-05 11:14 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-08-05 11:13 [PATCH v5 0/7] char: xillybus: Harden driver and improve code quality Eli Billauer
2026-08-05 11:13 ` [PATCH v5 1/7] char: xillybus: Improve control of execution flow with mutexes Eli Billauer
2026-08-05 11:13 ` [PATCH v5 2/7] char: xillybus: Remove duplicate error path code Eli Billauer
2026-08-05 11:13 ` [PATCH v5 3/7] char: xillybus: Avoid possible bandwidth inefficiency Eli Billauer
2026-08-05 11:13 ` [PATCH v5 4/7] char: xillybus: Use unsigned arithmetic for jiffies differences Eli Billauer
2026-08-05 11:13 ` Eli Billauer [this message]
2026-08-05 11:13 ` [PATCH v5 6/7] char: xillybus: Add defensive sanity checks Eli Billauer
2026-08-05 11:13 ` [PATCH v5 7/7] char: xillybus: Ignore and report unsolicited interrupts Eli Billauer
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=20260805111337.69178-6-eli.billauer@gmail.com \
--to=eli.billauer@gmail.com \
--cc=arnd@arndb.de \
--cc=corbet@lwn.net \
--cc=gregkh@linuxfoundation.org \
--cc=linux-kernel@vger.kernel.org \
/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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.