Received: by 2002:a05:6358:f14:b0:e5:3b68:ec04 with SMTP id b20csp2264506rwj; Sat, 24 Dec 2022 11:47:00 -0800 (PST) X-Google-Smtp-Source: AMrXdXtdwVhhkHdGNMqOlCSeSZJU4FSBZDUOJDl36f8OM+MvbtXCPVTcaw/IgoRU4TvsIgtMqZdk X-Received: by 2002:a17:907:9b09:b0:849:e96f:521b with SMTP id kn9-20020a1709079b0900b00849e96f521bmr5521857ejc.32.1671911220798; Sat, 24 Dec 2022 11:47:00 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1671911220; cv=none; d=google.com; s=arc-20160816; b=XyWl8zua9uj4YR0nUgzKKbuwKmKottzkOTfnnT/y3sXp78lLZsv+ZWXf+RWON3OaZ4 WVSXoZ7cTwRQlq3IWyxEE615fzUXgHKPEfPSBfrC5hZ2sxCaQy/WfYM25q4DdEJ6vn40 LmVlTTT+/qXvEAvYQZrfE9NNKdYXxhD817iujL0uI8OTpLVRlBu+w4VTgZ4p4RDeRVhb 6dFMRHnPwDHCmYUmdcFC9SQIo4oTddFQmEI3mvOuuP2LX2PovJKVkxJxGrkhK0UY+0sN QygVQS2qM468EWgEgbERpk9Zoi4qCwPpXiIDuu3GFlM6PrmZFzLSp5xSlr6PYa3UZ25p Ipyg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-transfer-encoding :content-disposition:mime-version:references:message-id:subject:cc :to:from:date:dkim-signature; bh=QD23sbwH8r0k8Mg6nLVRzWsdSmM875tPfpoqYqTuCc0=; b=H2PHfxm3Fc9zezILBi/iFzfExVQks9YF86OIGMjWAXdaf2RfOL8CdG5eL4cSZFiZw6 8MSSYo7DuLFT25ow6B5FyI2IuCYurfn3WwrEPyP3LwMDNlI7De9DB4UiocHqkkYZP78J lis5pIFWxUJSDtIMqOFsSMH1o51LTASM1LMJjp7VYpgpl3PGRqgf/c9jwWW3hWHxFgXc l6yu7Mi/FU1CQEXDIJ7P1XbPCccxmrDaR0SqlDSRJeX/rjWC6olGfO2oEDbWT9zA87lt dkjhErwipd04l6toThwBCWBqTxo8+e89e0Pmgo+mwINzXQZqqyo0Fxz8aj+cqgEtYQQZ 2hew== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20210112 header.b="D/ZL92Ok"; 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 xi3-20020a170906dac300b0084c41b233a4si878049ejb.327.2022.12.24.11.46.45; Sat, 24 Dec 2022 11:47:00 -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="D/ZL92Ok"; 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 S229865AbiLXThF (ORCPT + 66 others); Sat, 24 Dec 2022 14:37:05 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:42526 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229445AbiLXThD (ORCPT ); Sat, 24 Dec 2022 14:37:03 -0500 Received: from mail-wr1-x430.google.com (mail-wr1-x430.google.com [IPv6:2a00:1450:4864:20::430]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id C7D0D8FDA for ; Sat, 24 Dec 2022 11:37:01 -0800 (PST) Received: by mail-wr1-x430.google.com with SMTP id h7so7239540wrs.6 for ; Sat, 24 Dec 2022 11:37:01 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=in-reply-to:content-transfer-encoding:content-disposition :mime-version:references:message-id:subject:cc:to:from:date:from:to :cc:subject:date:message-id:reply-to; bh=QD23sbwH8r0k8Mg6nLVRzWsdSmM875tPfpoqYqTuCc0=; b=D/ZL92Ok+p9CEJDf2BZhwcyvi2CpZbNqxS6WyQtG9N8AfUrWKKSNrsdG7VclOKgsce xR/bvHwnChLhNeowok7Z5V+nSQigDNV/b0JOJe5aaNIvPBNx7L057WZYJy7g23jjOFiC EdcAXnl6zXy6OCyHIxzZEPTeB5c5Th4LMzeRAbmzPaq+biwJImd3nCv0nwjekRz6pmNu qi2kL2VLStw2KDKqTpXChp+Thlubo+ICzQ7pgRP5pgzMnwWnsu8sFr8YGI7zkHWn+liv 1Ylw5r9W0nDUPFLZdSD51Tvunj1tHtKVLoB4vqw2rp/b0YqIVoYjrj1FzqVyeAWZ3Fjl yDxQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=in-reply-to:content-transfer-encoding:content-disposition :mime-version:references:message-id:subject:cc:to:from:date :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=QD23sbwH8r0k8Mg6nLVRzWsdSmM875tPfpoqYqTuCc0=; b=NaKSXCSCDV3QVWpFEigtfEV1imjMO2EUP8Tj7+znN/Ue/fnMt9zOZ7gPmxC1fmoBJJ ISBIRRm8aO4owhlSUf3mvmBQ9eGLTeYufxAEQM1EnPd51wp4VE+5m6lqNKK3xRvU/SWf 3KYuLHp3Hhme35k7tuWPB+JfOFlhXgEy6eby15K26nELBQ6a7s0YfCgrIsoAMSRfayDx lufQAroEDg+asdqxDeT50GK8j5X8INHt8j1UXmUbU9Mf0HfQFRREWIhQiV7MxqYAv5wp ESGPd3RnTQ6677sXMxu8zTH++7YIn6g5fTf5hmtA4HkAvNmy8wZ04DCBN3I72epAaMyS Ds/A== X-Gm-Message-State: AFqh2kr/ocvdXkTdaHgdErnYPo7850dGIBrQAj4LK8F8bUigJ2enDeNi t9hlGqKPPKNzDhLzbBo3Azk= X-Received: by 2002:adf:9b99:0:b0:241:fa2d:dea0 with SMTP id d25-20020adf9b99000000b00241fa2ddea0mr8806061wrc.3.1671910620379; Sat, 24 Dec 2022 11:37:00 -0800 (PST) Received: from localhost ([102.36.222.112]) by smtp.gmail.com with ESMTPSA id l7-20020adfc787000000b002238ea5750csm7530886wrg.72.2022.12.24.11.36.59 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 24 Dec 2022 11:37:00 -0800 (PST) Date: Sat, 24 Dec 2022 22:36:55 +0300 From: Dan Carpenter To: Andy Shevchenko Cc: oe-kbuild@lists.linux.dev, Qingtao Cao , lkp@intel.com, oe-kbuild-all@lists.linux.dev, linux-kernel@vger.kernel.org, Bartosz Golaszewski Subject: Re: drivers/gpio/gpio-exar.c:52 exar_offset_to_sel_addr() warn: replace divide condition 'pin / 8' with 'pin >= 8' Message-ID: References: <202212181140.EAWl7FKx-lkp@intel.com> <3D147284-AF8C-4414-9BE1-C83032B6C15D@gmail.com> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: X-Spam-Status: No, score=-1.8 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,FREEMAIL_ENVFROM_END_DIGIT, 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 Sat, Dec 24, 2022 at 10:30:39PM +0300, Dan Carpenter wrote: > On Sat, Dec 24, 2022 at 05:19:27PM +0100, Andy Shevchenko wrote: > > > > > > Lähetetty iPhonesta > > > > > Dan Carpenter kirjoitti 23.12.2022 kello 11.54: > > > > > > tree: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git master > > > head: f9ff5644bcc04221bae56f922122f2b7f5d24d62 > > > commit: 5134272f9f3f71d4e1f3aa15cb09321af49b3646 gpio: exar: access MPIO registers on cascaded chips > > > config: ia64-randconfig-m031-20221218 > > > compiler: ia64-linux-gcc (GCC) 12.1.0 > > > > > > If you fix the issue, kindly add following tag where applicable > > > | Reported-by: kernel test robot > > > | Reported-by: Dan Carpenter > > > > > > smatch warnings: > > > drivers/gpio/gpio-exar.c:52 exar_offset_to_sel_addr() warn: replace divide condition 'pin / 8' with 'pin >= 8' > > > drivers/gpio/gpio-exar.c:62 exar_offset_to_lvl_addr() warn: replace divide condition 'pin / 8' with 'pin >= 8' > > > > > > > > > > > I don’t think this is a good advice. If we want to limit that, we need > > to check also upper limit. But. The GPIO framework does that. So, > > changing / to >= is bogus. > > > How is checking pin / 8 not mathematically equivalent to pin >= 8? > > I don't understand this code at all. The divide is inscrutable Is it > storing something in in the lower 3 bits and something in bit 4? In > that case it might be nicer to just check (pin & BIT(4)). > Or a macro which does: #define GET_UPPER_BIT_THING(pin) ((pin >> 8) & 0xMASK) regards, dan carpenter