Received: by 2002:a05:6358:16cc:b0:ea:6187:17c9 with SMTP id r12csp3540349rwl; Tue, 27 Dec 2022 10:40:17 -0800 (PST) X-Google-Smtp-Source: AMrXdXutM0Cp5yO9e+PK0vUXp0JllPVVNIvJnqWrf/yUyIHosNPT1beaG6utdl0NxY3IScOl9xOS X-Received: by 2002:a62:2741:0:b0:577:a0d:b091 with SMTP id n62-20020a622741000000b005770a0db091mr24923385pfn.14.1672166417458; Tue, 27 Dec 2022 10:40:17 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1672166417; cv=none; d=google.com; s=arc-20160816; b=AdWg5qm9fK1hR3K0M22CRvsyvmZO7yGgeQQcMTH14I/7vPKGXQE7pJUlab+A91riu6 TbDvTtNuNsZmTaygW/kBYPwVf4VXisFUacYlnBb+Jr1R8x3/S+Ec9V8MwdRguv+6QRsT hDM54cRFSn+3v51wr3oq6WsLrMLWAY4WpIH4TGPKosZ/Rg4VTpMptsl2fVx9jj5/9Eg9 XeAs//xCRPngfPWEA+2hjPBle+VggvRSDzVYKG/+QZRjxjXCqhNQztFIuRz1pJPxNhEO 4uZ0FZBv9YTk7hmyyqcG9fcQKmad2Qy8snImPeYxXCbYj58NhIJ0Y8ZcIG0eOVW6VuyN 17dw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:cc:to:subject :message-id:date:from:in-reply-to:references:mime-version :dkim-signature; bh=rS71xZ4HPr7MRbcFAzGlUhLBBLnKXHBQUCJ7VI/xMRw=; b=HNAh6AcX5A7cuynNxRGMFK3HBm2oxWVp2d/7FwkwYLzS+Nona7wml4j+Vcndp/ORdY /VP0swFp9m5OtT4zroljtNRkKm9NzFmijBJCxypDwSAwG3LHqlRM9oPzUDnwpw/b6cxj nHTNq+IT9jSmk5zmtGHC8WEThRBwdqPjLSDuRZiMxG0M3baKe8XkEIdTFu1l4xd+6APg Ipf91y/thisNzVsW7jH29aLK7MyyqcW87XcdHdgu2nd+baAOK9Mk2CNdy/yj6vzYmwdG 3+PrtjaCMnzcpnhI2/kRE1/rAZbSEVXyQtIr/X1gfLwkUcyBUt05Pk5fFpDA4q3VX//R l18Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20210112 header.b=UKIYX6sT; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id b5-20020a056a000cc500b00572d3b2ed93si609052pfv.139.2022.12.27.10.40.08; Tue, 27 Dec 2022 10:40:17 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20210112 header.b=UKIYX6sT; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229987AbiL0SbU (ORCPT + 66 others); Tue, 27 Dec 2022 13:31:20 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:60068 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230178AbiL0SbL (ORCPT ); Tue, 27 Dec 2022 13:31:11 -0500 Received: from mail-qv1-xf2c.google.com (mail-qv1-xf2c.google.com [IPv6:2607:f8b0:4864:20::f2c]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 3A6C5BDA for ; Tue, 27 Dec 2022 10:31:11 -0800 (PST) Received: by mail-qv1-xf2c.google.com with SMTP id i12so9600135qvs.2 for ; Tue, 27 Dec 2022 10:31:11 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:from:to:cc:subject:date :message-id:reply-to; bh=rS71xZ4HPr7MRbcFAzGlUhLBBLnKXHBQUCJ7VI/xMRw=; b=UKIYX6sTjIrN2dR+vWZ+y7NHzENQOFsbOk19f8o9VqhnPr75D1CkxnDkX9prANvVLr vsuDFBydsdqoPFxGik/5raljx9gSZ7ZUsrZh1uTBFTtcQYZ9KeebJqHOiJvVBagamsWd F33I7QugA5YQy7of8pFxF0wTToAOw5RYuoR46XPZC4fIZaShsFa+12uaNHOr9CBNXkAr cxMfQdXpmlC5Kx+rNeLhIPb39EA1VKzwSnm6j+LDKFUkLKohb5XufBXJ4oeByM7cA/KL LwwNULmgGk0SmfjMwNZuLorgIRcyjYVhL/kxRTrakngH9HNXNrxEJgWwSPjKl0zf9G9E AgrQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=rS71xZ4HPr7MRbcFAzGlUhLBBLnKXHBQUCJ7VI/xMRw=; b=TyxwRZYVdDUsL3KHa5vmeS1qOWbfVHs0TLhLKgv3KEtWaiYSrfU/PubE6ul3GQBf/k wvjUJyJq/9i5E2iYHMesav8W+iv9sb/nJ0L5a0+YB845T8zceWf6n5WKXcWy5pVau7DJ J4Kjx/t4PvhyiAEhY43+X/gX8a9yLmcPvfOhBImcqv22UH1ho+4MHdG/YAzVzTI/iiKG Gr/YiCatG4gwsVlSgOPih7vUkqRQSg/9zjzrQjCRFnq6vmrmF2oKEylj/n27p1P3Zbfp WT2Jt2V2mYTrOH6YQsLmkacNMDBvxKxbk6lSImZ+JIYgTCcHY6iE56SbME0gmEcQiX8v 9qWQ== X-Gm-Message-State: AFqh2kpyskb7AUVk64lVh5M82gUl+Hvgw0SyxDUD4Ot7bSP+LQLB61fM JiDr8LsswNOB6oRp/l7WZ4kDcBmPMAy/Tpbf+oVYhU99Bog= X-Received: by 2002:a05:6214:3906:b0:4c7:1ebf:719f with SMTP id nh6-20020a056214390600b004c71ebf719fmr914966qvb.64.1672165870312; Tue, 27 Dec 2022 10:31:10 -0800 (PST) MIME-Version: 1.0 References: <202212181140.EAWl7FKx-lkp@intel.com> <3D147284-AF8C-4414-9BE1-C83032B6C15D@gmail.com> In-Reply-To: From: Andy Shevchenko Date: Tue, 27 Dec 2022 20:30:33 +0200 Message-ID: Subject: Re: drivers/gpio/gpio-exar.c:52 exar_offset_to_sel_addr() warn: replace divide condition 'pin / 8' with 'pin >= 8' To: Dan Carpenter Cc: oe-kbuild@lists.linux.dev, Qingtao Cao , lkp@intel.com, oe-kbuild-all@lists.linux.dev, linux-kernel@vger.kernel.org, Bartosz Golaszewski Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,FREEMAIL_FROM, RCVD_IN_DNSWL_NONE,SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Tue, Dec 27, 2022 at 7:46 PM Dan Carpenter wrote: > On Sun, Dec 25, 2022 at 12:50:46PM +0100, Andy Shevchenko wrote: > > > Andy Shevchenko kirjoitti 25.12.2022 kell= o 12.45: > > >>> Dan Carpenter kirjoitti 24.12.2022 kello 20.30: > > >>> On Sat, Dec 24, 2022 at 05:19:27PM +0100, Andy Shevchenko wrote: > > >>>> Dan Carpenter kirjoitti 23.12.2022 kello 11.54= : ... > > >>>> smatch warnings: > > >>>> drivers/gpio/gpio-exar.c:52 exar_offset_to_sel_addr() warn: replac= e divide condition 'pin / 8' with 'pin >=3D 8' > > >>>> drivers/gpio/gpio-exar.c:62 exar_offset_to_lvl_addr() warn: replac= e divide condition 'pin / 8' with 'pin >=3D 8' > > >>> > > >>> I don=E2=80=99t think this is a good advice. If we want to limit th= at, we need > > >>> to check also upper limit. But. The GPIO framework does that. So, > > >>> changing / to >=3D is bogus. > > >> > > >> How is checking pin / 8 not mathematically equivalent to pin >=3D 8? > > > > > > The point is that semantically the / is better in case this code will= ever support more than two banks of pins. > > > > On top of that it=E2=80=99s paired with pin % 8. > > I noticed that, but it's a common bug though that a lot of people > accidentally write if (pin / 8) when if ((pin % 8) =3D=3D 0) is intended. Probably. Here the pin/8 is the correct approach, it shows the bank number, where each bank is out of 8 pins. > For example: Thanks, but it's unrelated to this case. --=20 With Best Regards, Andy Shevchenko