From nobody Sat Nov 30 07:25:47 2024 Received: from galois.linutronix.de (Galois.linutronix.de [193.142.43.55]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 31C387E583 for ; Wed, 11 Sep 2024 05:13:56 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=193.142.43.55 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1726031637; cv=none; b=UQpiJd8R5o1TJU/PQi74YyBb1P0Np4s9pdWuKHWia571lz5Gk0yNWlxNmW2rbS0T1lqqMPemUXQvX/TqMPIg/prr65pOunvUR1ZDgqMKJeww/UarFL/8Q8LwcpqEjex84/rx7UZcrjrlNfwA91PDf7ROritbzTxj1RtZ2pX4afc= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1726031637; c=relaxed/simple; bh=8rAJHPbtbN9E6pLkIP1/MlsY+gRBYnFfgvI+DhXdP5E=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=ZoRF4MHkekVk5AcH12jMqPGPh/919cIW4vGzLXqoUZCNik0dulsNHTJGaTv0QlCACfjUFK5T5voZQomeMblBMHM6I3P3l8pY6kUcFH00qUtIkxdr00IXXHeaX08n78/s1kHzR2whNdg/HbgZiKyl2bxAOwnod8/x06a8u3qhPS4= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linutronix.de; spf=pass smtp.mailfrom=linutronix.de; dkim=pass (2048-bit key) header.d=linutronix.de header.i=@linutronix.de header.b=kMI2G0OR; dkim=permerror (0-bit key) header.d=linutronix.de header.i=@linutronix.de header.b=PyMbHoX/; arc=none smtp.client-ip=193.142.43.55 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linutronix.de Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=linutronix.de Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=linutronix.de header.i=@linutronix.de header.b="kMI2G0OR"; dkim=permerror (0-bit key) header.d=linutronix.de header.i=@linutronix.de header.b="PyMbHoX/" From: Anna-Maria Behnsen DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020; t=1726031633; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=R0M7Wr68xib3pXvNOYvULR95dTa0mXvdGPVRKK8CDzw=; b=kMI2G0OR020zrfLLC+7RLo1wjK5nPAymaW9S9UhIe3O0PRPfF9A0Olb5w+dMBA2iEwu7ZF bPgvvB5DgN7D3GLbskm9Y9zZyIAeSlB+U9QqoDbU+Rltbw24/abgbRa1i/ioXbVXQav0oB DSI0DbVvRQwImEtBGJnCACcCMuG4pjFV6Kz3jTVyBoM1dRN1iDygifRbwSWGsIFyvFkfiC FBjaKa3oO/fTc51OhNrOOUlj9gUQgI75zJlybF1oqtiMxYCqksNBYJiO+RmPu+iApE3hO/ OWmY7TOUrgA8l2EucQbFlSZgDtQ6sf0mgAL7cO8CY0kNfbPViKERPYbkctxyFA== DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020e; t=1726031633; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=R0M7Wr68xib3pXvNOYvULR95dTa0mXvdGPVRKK8CDzw=; b=PyMbHoX/CGUwfDsyNiJThDTbY53xMotqdV2BKxE7uZmZ/4QLSm9wGCi6AdszqpwQMOLZiy eVsFkGKqbLYD6jAw== Date: Wed, 11 Sep 2024 07:13:35 +0200 Subject: [PATCH v2 09/15] timers: Add a warning to usleep_range_state() for wrong order of arguments Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Message-Id: <20240911-devel-anna-maria-b4-timers-flseep-v2-9-b0d3f33ccfe0@linutronix.de> References: <20240911-devel-anna-maria-b4-timers-flseep-v2-0-b0d3f33ccfe0@linutronix.de> In-Reply-To: <20240911-devel-anna-maria-b4-timers-flseep-v2-0-b0d3f33ccfe0@linutronix.de> To: Frederic Weisbecker , Thomas Gleixner , Jonathan Corbet Cc: linux-kernel@vger.kernel.org, Len Brown , "Rafael J. Wysocki" , Anna-Maria Behnsen , Andy Whitcroft , Joe Perches There is a warning in checkpatch script that triggers, when min and max arguments of usleep_range_state() are in reverse order. This check does only cover callsites which uses constants. Move this check into the code as a WARN_ON_ONCE() to also cover callsites not using constants and get rid of it in checkpatch. Cc: Andy Whitcroft Cc: Joe Perches Signed-off-by: Anna-Maria Behnsen --- kernel/time/sleep_timeout.c | 2 ++ scripts/checkpatch.pl | 4 ---- 2 files changed, 2 insertions(+), 4 deletions(-) diff --git a/kernel/time/sleep_timeout.c b/kernel/time/sleep_timeout.c index 21f412350b15..4b805d7e1903 100644 --- a/kernel/time/sleep_timeout.c +++ b/kernel/time/sleep_timeout.c @@ -364,6 +364,8 @@ void __sched usleep_range_state(unsigned long min, unsi= gned long max, unsigned i ktime_t exp =3D ktime_add_us(ktime_get(), min); u64 delta =3D (u64)(max - min) * NSEC_PER_USEC; =20 + WARN_ON_ONCE(max < min); + for (;;) { __set_current_state(state); /* Do not return before the requested sleep time has elapsed */ diff --git a/scripts/checkpatch.pl b/scripts/checkpatch.pl index 39032224d504..ba3359bdd1fa 100755 --- a/scripts/checkpatch.pl +++ b/scripts/checkpatch.pl @@ -7088,10 +7088,6 @@ sub process { if ($min eq $max) { WARN("USLEEP_RANGE", "usleep_range should not use min =3D=3D max args; see Documentati= on/timers/timers-howto.rst\n" . "$here\n$stat\n"); - } elsif ($min =3D~ /^\d+$/ && $max =3D~ /^\d+$/ && - $min > $max) { - WARN("USLEEP_RANGE", - "usleep_range args reversed, use min then max; see Documentation/= timers/timers-howto.rst\n" . "$here\n$stat\n"); } } =20 --=20 2.39.2