Received: by 2002:a05:6358:3188:b0:123:57c1:9b43 with SMTP id q8csp964334rwd; Tue, 13 Jun 2023 02:56:04 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ4/HB5+u4+9kSl785Q42qiYAmDOvkZUG7W3goAP8UIUewGhgw7vW+stiOsdiNCRj77x8ecE X-Received: by 2002:a17:907:320a:b0:974:52e6:93cb with SMTP id xg10-20020a170907320a00b0097452e693cbmr12890558ejb.50.1686650164655; Tue, 13 Jun 2023 02:56:04 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1686650164; cv=none; d=google.com; s=arc-20160816; b=RtVg2yj59I4B3b1l/F4ZLat7GTG58fkZXuamm7QjoOIIUI52/6NmBC1FxaFhCdULVV slac3redFEpWfm1Ef833lmZKxm5F0y1MjtCeqJexj1k/S7pTz35VhX9n0KacTjiHRyv5 QyLB54JZDbr8m6g7rozmWAXpAtp54qB8qAZjwlnab6NP+8BLKQGkgjuDzePjGTJfAR6Y Q4rZQl55MVpfxhkdnaQ1aLDic8Umv8CwiV3Igwfxlt9mJUUzl4SKFD7lJJkwM269OgrF itWdNjw2thcr/kRXYh1zY0Pv1akHYNO6zT1Lcg5OCl7C2HbVVlXrVHrTE1ujRLtzJibg jp7Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:in-reply-to:from :references:cc:to:content-language:subject:user-agent:mime-version :date:message-id; bh=6uUNLwv/ZAfXqkJ1yWJ7bTeRAZe/i/31wtqpYT7yTlk=; b=NUoma7gDl2edZFaqVyhlmfMJVzw6qAD/hwxLp3CWZDCGt2GxzLyZfCoMfU8ZRuDcom 6FV5PH7YtBqB1kBWlADLTvDff2ET2ANNzWgEsVc7UvNXhblKPq4/bgb6qeg38KGKd5YW mySMMzZ/drZZHvAA4j3908uq05hO80YtsSfvDwEc34VSXo55wc4B2VePLOLmcsW87D3x tV5uLH9+7tV7Hi5nvoQGLr4q1H03Kaf6yMgarlEhtD9D4x5SSEBkAvOQzvh7j9JrB2zW H55B3e5fzbkr6a/HQIVfRaAyuRe5Sk6mjXK+u6BQOXsWlDtbMJWaE39NAWf/b52VNwBa btwQ== ARC-Authentication-Results: i=1; mx.google.com; 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 Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id s6-20020a1709064d8600b00969c8607ef5si6850513eju.1038.2023.06.13.02.55.37; Tue, 13 Jun 2023 02:56:04 -0700 (PDT) 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; 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S240545AbjFMJpl (ORCPT + 99 others); Tue, 13 Jun 2023 05:45:41 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:58808 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S240448AbjFMJph (ORCPT ); Tue, 13 Jun 2023 05:45:37 -0400 Received: from dggsgout11.his.huawei.com (dggsgout11.his.huawei.com [45.249.212.51]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 23AE1173C; Tue, 13 Jun 2023 02:45:33 -0700 (PDT) Received: from mail02.huawei.com (unknown [172.30.67.153]) by dggsgout11.his.huawei.com (SkyGuard) with ESMTP id 4QgNvs0klWz4f3wRQ; Tue, 13 Jun 2023 17:45:29 +0800 (CST) Received: from [10.67.110.48] (unknown [10.67.110.48]) by APP1 (Coremail) with SMTP id cCh0CgDHIBu4OohkevjXKw--.29140S2; Tue, 13 Jun 2023 17:45:29 +0800 (CST) Message-ID: <4a501c9f-245f-5ecd-46e9-dc0e71abf8a5@huaweicloud.com> Date: Tue, 13 Jun 2023 17:45:28 +0800 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:102.0) Gecko/20100101 Thunderbird/102.11.0 Subject: Re: [PATCH] pinctrl: renesas: remove checker warnings: x | !y Content-Language: en-US To: Geert Uytterhoeven Cc: Linus Walleij , linux-renesas-soc@vger.kernel.org, linux-gpio@vger.kernel.org, linux-kernel@vger.kernel.org, gongruiqi1@huawei.com, linux-sparse@vger.kernel.org, Dan Carpenter References: <20230613021643.3330661-1-gongruiqi@huaweicloud.com> From: "GONG, Ruiqi" In-Reply-To: Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-CM-TRANSID: cCh0CgDHIBu4OohkevjXKw--.29140S2 X-Coremail-Antispam: 1UD129KBjvJXoW7Cry8Xr4fWw1xtF4kWw18uFg_yoW8Zr4UpF 47ta4UtFsYyF4UZFZ8t3yxWrWYyan2krWDG3WDKa4UZFZ8ZF1kt3WSgw4FvF4Durs7Aw1q qF4UKa4fG3W3A3JanT9S1TB71UUUUUUqnTZGkaVYY2UrUUUUjbIjqfuFe4nvWSU5nxnvy2 9KBjDU0xBIdaVrnRJUUUkjb4IE77IF4wAFF20E14v26r4j6ryUM7CY07I20VC2zVCF04k2 6cxKx2IYs7xG6r1S6rWUM7CIcVAFz4kK6r1j6r18M28lY4IEw2IIxxk0rwA2F7IY1VAKz4 vEj48ve4kI8wA2z4x0Y4vE2Ix0cI8IcVAFwI0_tr0E3s1l84ACjcxK6xIIjxv20xvEc7Cj xVAFwI0_Gr1j6F4UJwA2z4x0Y4vEx4A2jsIE14v26rxl6s0DM28EF7xvwVC2z280aVCY1x 0267AKxVW0oVCq3wAS0I0E0xvYzxvE52x082IY62kv0487Mc02F40EFcxC0VAKzVAqx4xG 6I80ewAv7VC0I7IYx2IY67AKxVWUJVWUGwAv7VC2z280aVAFwI0_Jr0_Gr1lOx8S6xCaFV Cjc4AY6r1j6r4UM4x0Y48IcVAKI48JMxk0xIA0c2IEe2xFo4CEbIxvr21l42xK82IYc2Ij 64vIr41l4I8I3I0E4IkC6x0Yz7v_Jr0_Gr1lx2IqxVAqx4xG67AKxVWUJVWUGwC20s026x 8GjcxK67AKxVWUGVWUWwC2zVAF1VAY17CE14v26r1q6r43MIIYrxkI7VAKI48JMIIF0xvE 2Ix0cI8IcVAFwI0_Jr0_JF4lIxAIcVC0I7IYx2IY6xkF7I0E14v26r1j6r4UMIIF0xvE42 xK8VAvwI8IcIk0rVWrZr1j6s0DMIIF0xvEx4A2jsIE14v26r1j6r4UMIIF0xvEx4A2jsIE c7CjxVAFwI0_Gr0_Gr1UYxBIdaVFxhVjvjDU0xZFpf9x07UWE__UUUUU= X-CM-SenderInfo: pjrqw2pxltxq5kxd4v5lfo033gof0z/ X-CFilter-Loop: Reflected X-Spam-Status: No, score=-2.0 required=5.0 tests=BAYES_00,NICE_REPLY_A, SPF_HELO_NONE,SPF_NONE,T_SCC_BODY_TEXT_LINE 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 Hi Geert, On 2023/06/13 15:38, Geert Uytterhoeven wrote: > Hi Gong, > > On Tue, Jun 13, 2023 at 4:13 AM GONG, Ruiqi wrote: >> Eliminate the following Sparse reports when building with C=1: >> >> drivers/pinctrl/renesas/pinctrl-rzn1.c:187:52: warning: dubious: x | !y >> drivers/pinctrl/renesas/pinctrl-rzn1.c:193:52: warning: dubious: x | !y >> >> Signed-off-by: GONG, Ruiqi > > Thanks for your patch! > > Looks like sparse needs to be taught the "|" is not used in a boolean > context here? Okay after reading the source code of Sparse I think what this kind of warnings actually means is to hint us a possible misuse of "|" instead of "||" (i.e. misusing a binary operator in a conditional context). Here the code is doing binary operation (i.e. to flip a bit or two), so in this sense the warnings should be just false alarms. However, the original code is a bit weird for me because of the sudden appearance of a boolean operator (i.e. "!") in the middle of a binary calculation. And I think it looks better after this change, since it makes the expression look more "binary". So maybe we can still consider apply this change ;) Greetings, Ruiqi > >> --- a/drivers/pinctrl/renesas/pinctrl-rzn1.c >> +++ b/drivers/pinctrl/renesas/pinctrl-rzn1.c >> @@ -184,13 +184,15 @@ static void rzn1_hw_set_lock(struct rzn1_pinctrl *ipctl, u8 lock, u8 value) >> * address | 1. >> */ >> if (lock & LOCK_LEVEL1) { >> - u32 val = ipctl->lev1_protect_phys | !(value & LOCK_LEVEL1); >> + u32 val = ipctl->lev1_protect_phys | >> + (value & LOCK_LEVEL1 ? 0 : 1); >> >> writel(val, &ipctl->lev1->status_protect); >> } >> >> if (lock & LOCK_LEVEL2) { >> - u32 val = ipctl->lev2_protect_phys | !(value & LOCK_LEVEL2); >> + u32 val = ipctl->lev2_protect_phys | >> + (value & LOCK_LEVEL2 ? 0 : 1); >> >> writel(val, &ipctl->lev2->status_protect); >> } > > Gr{oetje,eeting}s, > > Geert >