Received: by 2002:a05:6359:6284:b0:131:369:b2a3 with SMTP id se4csp420996rwb; Fri, 4 Aug 2023 15:17:06 -0700 (PDT) X-Google-Smtp-Source: AGHT+IGEULr6q+oCiJOd4gVUnnH3WGGEVKRzYQ2dXKdBgcP2iuFtU3Gh3QAuHoATUcEQX9FfhyU6 X-Received: by 2002:a05:6a00:841:b0:666:a25b:3788 with SMTP id q1-20020a056a00084100b00666a25b3788mr3187316pfk.34.1691187425851; Fri, 04 Aug 2023 15:17:05 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1691187425; cv=none; d=google.com; s=arc-20160816; b=Os3r3CtfuG47Xyleagb9F8DOaHNSWZWfgf5N0cP+gX2kTmTSlcmU2Xy07titwtf/Ql u/a2PY9QHbxbocOva35LniavF7Tvl2lMcapYKHIqt9yOm6vv9k15MfGUU3NATbkDIidG 1YC3PcymxJr1iCx++2zYcC/waFSq4skZTqO86vVGWO2mtS/9qQWyAVw28Rjc0EKY/t3P 8j3rgPYtNCctimPg5NPsFf19SULd0aJgv4Y/t9d880LFPEjjZ2BeLpzUmIs0djVhxVUk HabH0RxZ8ZtaerRNkjpBfyxk/jZDNWfceKeENfroOWhXp71is9ER7hRENnxxJSahEdie A/Cw== 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 :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=SrsSjqZ7OVl1AWfIXsg4vL7ZkYMxPl18iDNJrqzoz4k=; fh=bZAZJM/HZrsuI+Vu//SdQoRwN6TqI5f//Q2p0i3uDNg=; b=RBuauzyxIG84dRLKsp6MPWLuBxnhtATQKv/Jl3wzptQ14tJ3aLB8GTZnPX4lvRMHKp sfPYerkrZHhTO+NWNGPDDuDYBiluogPUSmlfFSRValhLdSRSoaG58A71RWPMxwS9LG7r IACrcCMw/vkpiAt8d9wbg6Nm8jNDWPbMg4pf9CPPtNjKDbmPGyBQyjyqt8KA4BJ7W1L1 pTCyfjlGHgmFhprW3tqFUIyP0qwZjf6lbBVB3RsGZVyCSm5KnVZIxvwvftXOV+Kgzlzn KaM4Dt4oRPY4qcahWZ6g/YJAipXMzMfUZWG+OZ9C4zz4XCo9z3hC+fKu0OqnUN2USRR0 rPAA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@chromium.org header.s=google header.b=igZkBXcH; 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=chromium.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id x63-20020a638642000000b005633d4ca6dcsi2253665pgd.849.2023.08.04.15.16.53; Fri, 04 Aug 2023 15:17:05 -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; dkim=pass header.i=@chromium.org header.s=google header.b=igZkBXcH; 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=chromium.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231128AbjHDVIz (ORCPT + 99 others); Fri, 4 Aug 2023 17:08:55 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:35694 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230479AbjHDVIg (ORCPT ); Fri, 4 Aug 2023 17:08:36 -0400 Received: from mail-pf1-x433.google.com (mail-pf1-x433.google.com [IPv6:2607:f8b0:4864:20::433]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 2E4784EDD for ; Fri, 4 Aug 2023 14:07:31 -0700 (PDT) Received: by mail-pf1-x433.google.com with SMTP id d2e1a72fcca58-686fc0d3c92so1904061b3a.0 for ; Fri, 04 Aug 2023 14:07:31 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; t=1691183248; x=1691788048; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=SrsSjqZ7OVl1AWfIXsg4vL7ZkYMxPl18iDNJrqzoz4k=; b=igZkBXcHHS/NmtYnn82Gu31zizwN7sk/X1c4RXzpaeTXixkHYqPgzx5DzIgAZExffK mICfP6MOntNN+49lbOrNo9rMHa67le2kkx350dw0aTzJ/t0z66RTi8tWKsQ5xvmOt7Cb aT3W7ufFoCZ/s9dfIdRqpOo6DBhQXgaZ5Be9c= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1691183248; x=1691788048; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=SrsSjqZ7OVl1AWfIXsg4vL7ZkYMxPl18iDNJrqzoz4k=; b=TkkD73Haki/3DMTK0FTYJ33ydyNZQOUSOCMzK215ROy+fUk1cd9r2yKBtzLtkr7qCw 53yMfB0e6+5R3/ftsYDVPQgOBt5MpAZ4BCLONbcX9XuqC44Uzb1+wCX3cCkSgIK8CJCi L03OTzXd9OyS81RpJHKpspk7dG6rXdJZqkpNwvAyqOty4Sur2AyFHYqyfU+6etK1FPIV /cTqIp0GN19zrNuUZQGaoa3nlxSlfFm1qpxvJmOV/J8Pj8/yaq6Gy7Tgq3wvboucupwT hx+p8I/bkVjkyMdargEkYgPUCeRN6j+8DFTTKIJGk6P+N/AioesnkoSvCwFdlK/hDbKE Gmcw== X-Gm-Message-State: AOJu0YzxeJWh4dDI6PJ6sA7KtRMCjZcV6vvFu4oloic5EfkritY1aHX3 sZMgkUW8V9MFxFWZ5rpNtVpDEQ== X-Received: by 2002:a05:6a00:1798:b0:666:b254:1c9c with SMTP id s24-20020a056a00179800b00666b2541c9cmr3339506pfg.27.1691183248705; Fri, 04 Aug 2023 14:07:28 -0700 (PDT) Received: from tictac2.mtv.corp.google.com ([2620:15c:9d:2:e186:e5d2:e60:bad3]) by smtp.gmail.com with ESMTPSA id n22-20020aa78a56000000b0068664ace38asm2037584pfa.19.2023.08.04.14.07.25 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 04 Aug 2023 14:07:27 -0700 (PDT) From: Douglas Anderson To: dri-devel@lists.freedesktop.org, Maxime Ripard Cc: Linus Walleij , Douglas Anderson , Daniel Vetter , David Airlie , =?UTF-8?q?Guido=20G=C3=BCnther?= , Neil Armstrong , Ondrej Jirman , Purism Kernel Team , Sam Ravnborg , linux-kernel@vger.kernel.org Subject: [RFC PATCH 07/10] drm/panel: st7703: Don't store+check prepared Date: Fri, 4 Aug 2023 14:06:10 -0700 Message-ID: <20230804140605.RFC.7.Ifc436b262d72f1a33ddef10adfd7578d4acb60d8@changeid> X-Mailer: git-send-email 2.41.0.585.gd2178a4bd4-goog In-Reply-To: <20230804210644.1862287-1-dianders@chromium.org> References: <20230804210644.1862287-1-dianders@chromium.org> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit 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_BLOCKED,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED 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 As talked about in commit d2aacaf07395 ("drm/panel: Check for already prepared/enabled in drm_panel"), we want to remove needless code from panel drivers that was storing and double-checking the prepared/enabled state. Even if someone was relying on the double-check before, that double-check is now in the core and not needed in individual drivers. For the st7703 panel driver this is fairly straightforward. Like with many other panels, we need to use the new drm_panel_helper_shutdown() function to make sure that remove() and shutdown() don't try to disable/unprepare a panel that hasn't been prepared/enabled. One thing that is a little different for st7703 is that it has a special "allpixelson" debugfs file. When this file is written the driver hacks a disable/unprepare and then a prepare/enable to try to reset the panel. This debugfs file didn't appear to be particularly safe to use even before this patch since it would cause a disabled/unprepared panel to become prepared/enabled. It is nominally even less safe after this patch since calling it on a panel that wasn't prepared/enabled will now likely cause a regulator underflow message. If this matters to anyone, it could be fixed in a future patch. Signed-off-by: Douglas Anderson --- drivers/gpu/drm/panel/panel-sitronix-st7703.c | 20 ++----------------- 1 file changed, 2 insertions(+), 18 deletions(-) diff --git a/drivers/gpu/drm/panel/panel-sitronix-st7703.c b/drivers/gpu/drm/panel/panel-sitronix-st7703.c index 6a3945639535..dde903e803d1 100644 --- a/drivers/gpu/drm/panel/panel-sitronix-st7703.c +++ b/drivers/gpu/drm/panel/panel-sitronix-st7703.c @@ -22,6 +22,7 @@ #include #include #include +#include #define DRV_NAME "panel-sitronix-st7703" @@ -58,7 +59,6 @@ struct st7703 { struct gpio_desc *reset_gpio; struct regulator *vcc; struct regulator *iovcc; - bool prepared; struct dentry *debugfs; const struct st7703_panel_desc *desc; @@ -486,13 +486,9 @@ static int st7703_unprepare(struct drm_panel *panel) { struct st7703 *ctx = panel_to_st7703(panel); - if (!ctx->prepared) - return 0; - gpiod_set_value_cansleep(ctx->reset_gpio, 1); regulator_disable(ctx->iovcc); regulator_disable(ctx->vcc); - ctx->prepared = false; return 0; } @@ -502,9 +498,6 @@ static int st7703_prepare(struct drm_panel *panel) struct st7703 *ctx = panel_to_st7703(panel); int ret; - if (ctx->prepared) - return 0; - dev_dbg(ctx->dev, "Resetting the panel\n"); ret = regulator_enable(ctx->vcc); if (ret < 0) { @@ -522,8 +515,6 @@ static int st7703_prepare(struct drm_panel *panel) gpiod_set_value_cansleep(ctx->reset_gpio, 0); msleep(20); - ctx->prepared = true; - return 0; disable_vcc: @@ -665,15 +656,8 @@ static int st7703_probe(struct mipi_dsi_device *dsi) static void st7703_shutdown(struct mipi_dsi_device *dsi) { struct st7703 *ctx = mipi_dsi_get_drvdata(dsi); - int ret; - ret = drm_panel_unprepare(&ctx->panel); - if (ret < 0) - dev_err(&dsi->dev, "Failed to unprepare panel: %d\n", ret); - - ret = drm_panel_disable(&ctx->panel); - if (ret < 0) - dev_err(&dsi->dev, "Failed to disable panel: %d\n", ret); + drm_panel_helper_shutdown(&ctx->panel); } static void st7703_remove(struct mipi_dsi_device *dsi) -- 2.41.0.585.gd2178a4bd4-goog