From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail-lf1-f46.google.com (mail-lf1-f46.google.com [209.85.167.46]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 3BB1D399357 for ; Tue, 30 Jun 2026 09:24:17 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.167.46 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1782811460; cv=none; b=I4YmqHMJsppCGevYwhK0kngjaupLWqwAqGBZXg/Fg9ifPBiMzG6VPURVU3/3cy0rEksjbCFjqSeS0v5bP0oeSLmx0ueTYnnSa0vQVaMnQSt4DJ+RDE+IMr/wecoRr4hgGu2Gy8ZuVrzsAHmUdUBIiN6oa2oGrcZFjQKK3eZMPKU= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1782811460; c=relaxed/simple; bh=TgTbAPF2uJwxseqNg5SEepySI/DEi2UNOH9IkUT36fo=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References; b=ayvVAU30+sFJHz9H8LRY4OyUsEcmrAdZzNU3IVwTO02qy8kyfMHqX1KExABQSyL8GNVzIQmZDbjbmhxCPxz5WiBPMYjAk59JMzbymDifjBDvFvKXjV0D8CJGJtX7P7rM/N7FReMRE+9Dwu6fSRozoPM++W8j3w0CVqGHt2ifmyY= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=Lc4VJdao; arc=none smtp.client-ip=209.85.167.46 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="Lc4VJdao" Received: by mail-lf1-f46.google.com with SMTP id 2adb3069b0e04-5aeb7467a8dso448656e87.1 for ; Tue, 30 Jun 2026 02:24:16 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20251104; t=1782811455; x=1783416255; darn=vger.kernel.org; h=references:in-reply-to:message-id:date:subject:cc:to:from:from:to :cc:subject:date:message-id:reply-to; bh=gnRnRFdGlu30NWH7ftJ3sdxeEm2mUQB2ezQBOTQwhgg=; b=Lc4VJdaoGwlM6XVYRKOWchtd0TBJv1sNb1dUv2jrMrUlrUXP3VnZzUPUxra1QITsqM 19rGFHdBozvuOBCBqeDECr5w3ABMkaCWyxhfZ4PpgK6wNDed/5gHpn1Olw1kR+D9Fk3q Om7jMLL9bQnH6y/bnRoKK71+/lQUS0GYPEq1tNXu+UOe/2hJu+vRmmqeMLwKRlLyLPuV GEWCw0cLKoUxvaNAIk3fvIRc9UH6sz88IlSOxZxEJsiJ+YhJlQ6Q44edBryc4xeErOMQ mFzYdXa47BJJ64Ekr3dnVOPMO5vk2Z7+JBf6Y7nAX0TPyoMkly+H/ojlnHPWR7NV0J8p 7qvQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1782811455; x=1783416255; h=references:in-reply-to:message-id:date:subject:cc:to:from:x-gm-gg :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=gnRnRFdGlu30NWH7ftJ3sdxeEm2mUQB2ezQBOTQwhgg=; b=AaxkSZe/XECFfR3pFU7VfzyGj0IS/+LpsnHM4zUcH+RT0zwvnebBlUsHv1eq7S90AR aO7/Hm7XZk7/zqzccxi5es4mApC9Fct0EeNCUKigNUeeB4EMszadSOBZivIk5IuV4Z52 kgBe6hn8i0qHjMdcAqRaZ850c2LF8N7UgP6/j20TUkWxuSEbLvlMTStNfa2YPceJCYyY cNBT679xJpaoLeQ3tsrv2RZq92sWWaCbHlgJaj9Gfg12W/jQcBkgvtDQfi9/Op55rz+Z 0xD+nPua0tI0dZxOwFTwSLldE8lW22QBLzkHiWRmtvdtfh5gVNcmuTPwsv23FJr5Tx1w 1XVQ== X-Forwarded-Encrypted: i=1; AHgh+RrdfgEnSU6H3LHGPe8zeYBdTcr7SIqPBAldnmzt46YRsS170EZG6E5K/R1RdaD6yWJz7OF/DAuSE/MNwxo=@vger.kernel.org X-Gm-Message-State: AOJu0YxYi4qLgq/yvKbQkWmEMPebP0YyT2Ep5gyVnVG6A9eEFiApPyPe mNrV4726y4vTye+f5VSxUm07Th1wkatmPe4Rhc3ZTxYNtQ5CZ5/c/VEDvbbal4bX X-Gm-Gg: AfdE7cl76rRt+xEFJ3uBCg1KXe13s316mNdDAWuu5KAT5uddLFVQvbCLl+PlMTAJiKA boGiNzt2IFryIB0WxTNegKQdfqEjFXFfoZbP9Wk13PVF55r67q1K8G3yfBod4LwFL5uE02+/dQb 4dWoxMqBKLKkazS+dDgb1grkkONQahdRsgTS3+/GJzeqRw0PmKNB9wPDxSBMOxcp80GwGvE7/rU H39WLK/wIi+c5AqXQdCdcasGEGJMR/SMbCrG702by0kdOGt/Pkd6LR6ZhLhgpxjPTy3iPEJb5u8 d68C3ivijo3Hg/mRWFAt50d647xPHXvA/1dSJ9bdr2aE1XgCOgyKB9PxVkpKTRx0HIzZdhq++/P yDLsQfoPaB6W184+LIyEmsjeWmR61m7UMXLe2OKjqd7Qu+xN0uzU41FtkIGrLcAwznIqxyRaWLu MuRAvYplyF1lYs6JnDlHYggF1YuuG/IhxdsER8DZ2x X-Received: by 2002:a05:6512:4481:b0:5ad:5901:20ab with SMTP id 2adb3069b0e04-5aebf9616e2mr284705e87.6.1782811454965; Tue, 30 Jun 2026 02:24:14 -0700 (PDT) Received: from localhost (c-85-228-45-68.bbcust.telenor.se. [85.228.45.68]) by smtp.gmail.com with ESMTPSA id 2adb3069b0e04-5aebe49863asm424862e87.45.2026.06.30.02.24.13 (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Tue, 30 Jun 2026 02:24:14 -0700 (PDT) From: Eli Billauer To: gregkh@linuxfoundation.org Cc: arnd@arndb.de, linux-kernel@vger.kernel.org, Eli Billauer Subject: [PATCH 4/7] char: xillybus: Use unsigned arithmetic for jiffies differences Date: Tue, 30 Jun 2026 11:23:27 +0200 Message-Id: <20260630092330.43534-5-eli.billauer@gmail.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20260630092330.43534-1-eli.billauer@gmail.com> References: <20260630092330.43534-1-eli.billauer@gmail.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: 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. Signed-off-by: Eli Billauer --- drivers/char/xillybus/xillybus_core.c | 5 +++-- drivers/char/xillybus/xillyusb.c | 17 ++++++++++------- 2 files changed, 13 insertions(+), 9 deletions(-) diff --git a/drivers/char/xillybus/xillybus_core.c b/drivers/char/xillybus/xillybus_core.c index 952ef149aba1..7acebc1e6050 100644 --- a/drivers/char/xillybus/xillybus_core.c +++ b/drivers/char/xillybus/xillybus_core.c @@ -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 diff --git a/drivers/char/xillybus/xillyusb.c b/drivers/char/xillybus/xillyusb.c index 7d2434c02fa7..aa08206a18ef 100644 --- a/drivers/char/xillybus/xillyusb.c +++ b/drivers/char/xillybus/xillyusb.c @@ -1127,12 +1127,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) @@ -1141,7 +1142,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, @@ -1152,7 +1154,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); @@ -1202,7 +1204,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; @@ -1435,7 +1437,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; @@ -1464,7 +1467,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 -- 2.34.1