From patchwork Mon Nov 21 15:43:14 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Geert Uytterhoeven X-Patchwork-Id: 23924 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:adf:f944:0:0:0:0:0 with SMTP id q4csp1670854wrr; Mon, 21 Nov 2022 07:54:52 -0800 (PST) X-Google-Smtp-Source: AA0mqf54amNdjtfMQYlKigG6DURz4ZCw9GkGdTTOtVO1nFV+ETkzh3/uOLly7NCyC8EZXlquphZo X-Received: by 2002:a17:906:80da:b0:7ae:5473:3c76 with SMTP id a26-20020a17090680da00b007ae54733c76mr314141ejx.752.1669046091780; Mon, 21 Nov 2022 07:54:51 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1669046091; cv=none; d=google.com; s=arc-20160816; b=Bsyjv6d42fhpuXrIu2FKizwquJoGmQ018K5hSkpscqemT+msaZPJneYPInkAq6toYK kgqRv1/ZPxcoZmJgygDSpJYRHKIE8PGx0jxF4a7rXKnlVCz/Pu4nyI4/YgwU0YpYhLNJ Sk3zU9AEvxXvnGEqUGR27f/YpYSxiC1Fgqn8fNquCjbyYRqoss6bNWnrwZgz8i/D8VNZ EVwZixvP9JBSoiDyOqhMGqbPvps81h9PHo2jHRyPahChFOgWGE8/VVElKhIPINqRqMzJ BQLuAJKYBRG0zMKonaKV61AWnxLRVUEddt18MY1hF/c0i6JLq3bnnfD9HoGx1CdVcj48 sBWA== 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; bh=IhEb1PgX4thAk4W281yAm1mc+9lCxzzZiRX+rL1bfVk=; b=o9++cZmd3lXVzQIoNOQkDDuRXNmE/5vwjoajP9TSs+TdcNksh8jrZAMj7xv6DpESgp 0ix1v+RWlNSQygYCNpo2/f8HkUXTAqSJiIhy/Z29Nryay/IplRClSBoemlbyFV/rNvUi Dxx5r/PcFZZ8P6QFslJN8Bomb8xwA4L7d2ACKMsRMbrNxJSCBsMzA5/Sj//Mz+evjQF5 ROrUEXDoBfEJp407ZoeCoTAsw2gmGFZPQwPPTH450SMBpU6a0BMK/Af8GVKclegCzG00 V43ZY4WNPCwf1cr9f4WRHbUVA7Pi+LcxYVhwo8MOtDzap5EaojicuBarxUH66RyA4+fx vheg== 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 Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id w16-20020a056402269000b0045d0660a039si10843158edd.316.2022.11.21.07.54.28; Mon, 21 Nov 2022 07:54:51 -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; 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 S232419AbiKUPoH (ORCPT + 99 others); Mon, 21 Nov 2022 10:44:07 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:45674 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231650AbiKUPne (ORCPT ); Mon, 21 Nov 2022 10:43:34 -0500 Received: from laurent.telenet-ops.be (laurent.telenet-ops.be [IPv6:2a02:1800:110:4::f00:19]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 87030E0EC for ; Mon, 21 Nov 2022 07:43:18 -0800 (PST) Received: from ramsan.of.borg ([IPv6:2a02:1810:ac12:ed10:4821:1ba5:2638:5c3a]) by laurent.telenet-ops.be with bizsmtp id n3jG2800Y5WXlCv013jGTk; Mon, 21 Nov 2022 16:43:17 +0100 Received: from rox.of.borg ([192.168.97.57]) by ramsan.of.borg with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.93) (envelope-from ) id 1ox8x2-0019F9-Al; Mon, 21 Nov 2022 16:43:16 +0100 Received: from geert by rox.of.borg with local (Exim 4.93) (envelope-from ) id 1ox8x1-00BQNV-MS; Mon, 21 Nov 2022 16:43:15 +0100 From: Geert Uytterhoeven To: Russell King , David Airlie , Daniel Vetter Cc: dri-devel@lists.freedesktop.org, linux-kernel@vger.kernel.org, Geert Uytterhoeven Subject: [PATCH resend] drm/armada: Fix off-by-one error in armada_overlay_get_property() Date: Mon, 21 Nov 2022 16:43:14 +0100 Message-Id: <788e97ac9b2aeee1941f274bf7b279b68c7592b6.1669045360.git.geert+renesas@glider.be> X-Mailer: git-send-email 2.25.1 MIME-Version: 1.0 X-Spam-Status: No, score=-2.3 required=5.0 tests=BAYES_00, HEADER_FROM_DIFFERENT_DOMAINS,RCVD_IN_DNSWL_LOW,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?1750121674642475631?= X-GMAIL-MSGID: =?utf-8?q?1750121674642475631?= As ffs() returns one more than the index of the first bit set (zero means no bits set), the color key mode value is shifted one position too much. Fix this by using FIELD_GET() instead. Fixes: c96103b6c49ff9a8 ("drm/armada: move colorkey properties into overlay plane state") Signed-off-by: Geert Uytterhoeven Reviewed-by: Russell King (Oracle) --- Compile-tested only. --- drivers/gpu/drm/armada/armada_overlay.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/drivers/gpu/drm/armada/armada_overlay.c b/drivers/gpu/drm/armada/armada_overlay.c index f21eb8fb76d87285..3b9bd8ecda137f6d 100644 --- a/drivers/gpu/drm/armada/armada_overlay.c +++ b/drivers/gpu/drm/armada/armada_overlay.c @@ -4,6 +4,8 @@ * Rewritten from the dovefb driver, and Armada510 manuals. */ +#include + #include #include #include @@ -445,8 +447,8 @@ static int armada_overlay_get_property(struct drm_plane *plane, drm_to_overlay_state(state)->colorkey_ug, drm_to_overlay_state(state)->colorkey_vb, 0); } else if (property == priv->colorkey_mode_prop) { - *val = (drm_to_overlay_state(state)->colorkey_mode & - CFG_CKMODE_MASK) >> ffs(CFG_CKMODE_MASK); + *val = FIELD_GET(CFG_CKMODE_MASK, + drm_to_overlay_state(state)->colorkey_mode); } else if (property == priv->brightness_prop) { *val = drm_to_overlay_state(state)->brightness + 256; } else if (property == priv->contrast_prop) {