From patchwork Sat Jan 21 19:09:30 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Javier Martinez Canillas X-Patchwork-Id: 46870 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:adf:eb09:0:0:0:0:0 with SMTP id s9csp852074wrn; Sat, 21 Jan 2023 11:24:03 -0800 (PST) X-Google-Smtp-Source: AMrXdXsD55sW+UodUWSjAi+gq+zG0/MjcHycLr0+SMfic9rr5lUKXClsypWAe3SRJNXO+RtIsA4u X-Received: by 2002:a05:6a20:438a:b0:b8:6583:b654 with SMTP id i10-20020a056a20438a00b000b86583b654mr22678303pzl.28.1674329043497; Sat, 21 Jan 2023 11:24:03 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1674329043; cv=none; d=google.com; s=arc-20160816; b=bEsOTI6XI1iNLD7CKXAKOHljjBwlNPd+GtJ7QqIhE6hwhl+OkeZWIs6lSMPC0f7TPs ddtRRLusk8kZRPMsfKxUm+7r0ovAVkzlqYPcm4FiFgvqwVyDztVISI3utaUj08b0FZ2c ZMKEQeO+g24OReLwGhDBd27IBrF/oYm8w7pkTv93zBzNho9ESx28IF5rKMUI+3XBuvVB pSinQ/KQGDncPt7FfAP4Icl340ot6Jja+myyIW6DVBRpWFR/vlu5B5vFMeJfI7bK8v32 tAyiToNJuK63FWRu8lO/EAQuIOop+Ye2JUD69PiNnDQgiHmEl7E/YjOZRLQQfMtZ+lUH uIcw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :message-id:date:subject:cc:to:from:dkim-signature; bh=NPIxC6UFVdw/MjrtfcvzuLHufLGHSjfY7C1EvrBunNo=; b=njvb3wDXM4K/FSzIjJovqKtQqEtW7QZ0kIFikIb/hSQQpclmNyG9I6WYxoHEKdOCc2 AfXPcn9lKkWM4kIu5T0NqZZzXPcdKAbcYSQwR0rU1Cqvcx0/Gze3uescrOyYShzh193P ojgFvlryzk7BdyFy4fJvrm5eaqs2D3OJihu/H151+zSaxZ2BJyguIdCKTZSYSM3iLhqh 9MpULTAWlsxQFDRpO5seWCb0d9yahICGyv4r3gkR5PmBM73cD9boYuxmkSzW6wxuCL8C NHU6FzEP94tGBRv4veQWyc1wnLvZWwilC9SsdkvfLBLmhYCUb6JJ7dlcTjfdGIGt/QkJ ABXA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=K5Zqt0VS; 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=NONE dis=NONE) header.from=redhat.com Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id l6-20020a654486000000b004961fc52367si48292819pgq.59.2023.01.21.11.23.51; Sat, 21 Jan 2023 11:24:03 -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=@redhat.com header.s=mimecast20190719 header.b=K5Zqt0VS; 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=NONE dis=NONE) header.from=redhat.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229799AbjAUTKW (ORCPT + 99 others); Sat, 21 Jan 2023 14:10:22 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:51648 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229675AbjAUTKV (ORCPT ); Sat, 21 Jan 2023 14:10:21 -0500 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 6F7E246B9 for ; Sat, 21 Jan 2023 11:09:39 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1674328178; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding; bh=NPIxC6UFVdw/MjrtfcvzuLHufLGHSjfY7C1EvrBunNo=; b=K5Zqt0VSIac18zslftA3/mLwz4M9LH+6BblFAXh/0jfoMbBx0DufS4bMgXlOJppDQ2kYAt T+X1wsPgzUSe7QSOWFW0noZ+xBJRYCer421ywjHKxJ1s++B/4OfM5hywoa78VqFCUJE5g0 0nyRYsQFLPS7At9s+bTY0zDnxJ21kSc= Received: from mail-wm1-f72.google.com (mail-wm1-f72.google.com [209.85.128.72]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_128_GCM_SHA256) id us-mta-396-BcgOs6STOOW9pVO0nN0cCQ-1; Sat, 21 Jan 2023 14:09:37 -0500 X-MC-Unique: BcgOs6STOOW9pVO0nN0cCQ-1 Received: by mail-wm1-f72.google.com with SMTP id k34-20020a05600c1ca200b003db30c3ed63so3128877wms.2 for ; Sat, 21 Jan 2023 11:09:37 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=NPIxC6UFVdw/MjrtfcvzuLHufLGHSjfY7C1EvrBunNo=; b=7MT55+Qk+Puff5Zk/EWpteOr0I1yD7dt2xsZlAyW52iivokd4B77krYyYQvpzfnN93 0Lsmz0bb9W1P7VYWZRtVtt0ZrN9zMsvFzHckZpMxtPRgQjzoThuwwlflDOsW7i7gF5up qPd5hDeyj7ZJNxO+OdMQNzFThJ7hjYe+5SNK+g6kicTEkaA59X9zT19aJkEuisDmrQbB Ik4oMJCh8NyQng0V1dO7WsAhYtEXpS3W/ti8cnEvrTF3Jw1nKacjsBBc3V+cd3zO8Rx7 9an0OzusMr674tZxf0/A1fjz2g4g5VX1Cvyt6nXfq34TbeMsmJ/MAQ9tb02wKk4kd9pJ lAiA== X-Gm-Message-State: AFqh2kqmUqKUZ6nGt01MoL/x8QATK20vHZFZFUr6jDYtt4WaU+KZhabl ZMwrzvU4MAmfjklFwIP+kS/OyDXVrONQAR0YSDdtY3y9vTggcjLZKDA/ksCJzZWUxwrHsM7WIou L8VfWcam5Q503FpaNysE7Aw7IIMITpJVmo4scsSCyshuUZFFgVNfciizPh/dDaC/twoDP6eQbSE s= X-Received: by 2002:a05:6000:79d:b0:2bf:95cc:7447 with SMTP id bu29-20020a056000079d00b002bf95cc7447mr4039186wrb.32.1674328175960; Sat, 21 Jan 2023 11:09:35 -0800 (PST) X-Received: by 2002:a05:6000:79d:b0:2bf:95cc:7447 with SMTP id bu29-20020a056000079d00b002bf95cc7447mr4039169wrb.32.1674328175669; Sat, 21 Jan 2023 11:09:35 -0800 (PST) Received: from minerva.home (205.pool92-176-231.dynamic.orange.es. [92.176.231.205]) by smtp.gmail.com with ESMTPSA id k5-20020adfd845000000b002bdd96d88b4sm23716899wrl.75.2023.01.21.11.09.34 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 21 Jan 2023 11:09:35 -0800 (PST) From: Javier Martinez Canillas To: linux-kernel@vger.kernel.org Cc: Javier Martinez Canillas , Thomas Zimmermann , Daniel Vetter , David Airlie , dri-devel@lists.freedesktop.org Subject: [PATCH] drm/ssd130x: Silence a `dubious: x & !y` warning Date: Sat, 21 Jan 2023 20:09:30 +0100 Message-Id: <20230121190930.2804224-1-javierm@redhat.com> X-Mailer: git-send-email 2.39.0 MIME-Version: 1.0 X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H2,SPF_HELO_NONE,SPF_NONE 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 X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1755661251090170693?= X-GMAIL-MSGID: =?utf-8?q?1755661251090170693?= The sparse tool complains with the following warning: $ make M=drivers/gpu/drm/solomon/ C=2 CC [M] drivers/gpu/drm/solomon/ssd130x.o CHECK drivers/gpu/drm/solomon/ssd130x.c drivers/gpu/drm/solomon/ssd130x.c:363:21: warning: dubious: x & !y This seems to be a false positive in my opinion but still we can silence the tool while making the code easier to read. Let's also add a comment, to explain why the "com_seq" logical not is used rather than its value. Reported-by: Thomas Zimmermann Signed-off-by: Javier Martinez Canillas Reviewed-by: Thomas Zimmermann --- drivers/gpu/drm/solomon/ssd130x.c | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/drivers/gpu/drm/solomon/ssd130x.c b/drivers/gpu/drm/solomon/ssd130x.c index c3bf3a18302e..b16330a8b624 100644 --- a/drivers/gpu/drm/solomon/ssd130x.c +++ b/drivers/gpu/drm/solomon/ssd130x.c @@ -81,7 +81,7 @@ #define SSD130X_SET_PRECHARGE_PERIOD2_MASK GENMASK(7, 4) #define SSD130X_SET_PRECHARGE_PERIOD2_SET(val) FIELD_PREP(SSD130X_SET_PRECHARGE_PERIOD2_MASK, (val)) #define SSD130X_SET_COM_PINS_CONFIG1_MASK GENMASK(4, 4) -#define SSD130X_SET_COM_PINS_CONFIG1_SET(val) FIELD_PREP(SSD130X_SET_COM_PINS_CONFIG1_MASK, !(val)) +#define SSD130X_SET_COM_PINS_CONFIG1_SET(val) FIELD_PREP(SSD130X_SET_COM_PINS_CONFIG1_MASK, (val)) #define SSD130X_SET_COM_PINS_CONFIG2_MASK GENMASK(5, 5) #define SSD130X_SET_COM_PINS_CONFIG2_SET(val) FIELD_PREP(SSD130X_SET_COM_PINS_CONFIG2_MASK, (val)) @@ -298,6 +298,7 @@ static void ssd130x_power_off(struct ssd130x_device *ssd130x) static int ssd130x_init(struct ssd130x_device *ssd130x) { u32 precharge, dclk, com_invdir, compins, chargepump, seg_remap; + bool scan_mode; int ret; /* Set initial contrast */ @@ -360,7 +361,13 @@ static int ssd130x_init(struct ssd130x_device *ssd130x) /* Set COM pins configuration */ compins = BIT(1); - compins |= (SSD130X_SET_COM_PINS_CONFIG1_SET(ssd130x->com_seq) | + /* + * The COM scan mode field values are the inverse of the boolean DT + * property "solomon,com-seq". The value 0b means scan from COM0 to + * COM[N - 1] while 1b means scan from COM[N - 1] to COM0. + */ + scan_mode = !ssd130x->com_seq; + compins |= (SSD130X_SET_COM_PINS_CONFIG1_SET(scan_mode) | SSD130X_SET_COM_PINS_CONFIG2_SET(ssd130x->com_lrremap)); ret = ssd130x_write_cmd(ssd130x, 2, SSD130X_SET_COM_PINS_CONFIG, compins); if (ret < 0)