Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from phobos.denx.de (phobos.denx.de [85.214.62.61]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 93088C001DB for ; Sat, 12 Aug 2023 10:46:23 +0000 (UTC) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id B1F838696C; Sat, 12 Aug 2023 12:46:14 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=u-boot-bounces@lists.denx.de Authentication-Results: phobos.denx.de; dkim=pass (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.b="Z/v8bJfS"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 8C3F48696B; Sat, 12 Aug 2023 12:46:13 +0200 (CEST) Received: from mail-ej1-x631.google.com (mail-ej1-x631.google.com [IPv6:2a00:1450:4864:20::631]) (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits)) (No client certificate requested) by phobos.denx.de (Postfix) with ESMTPS id B558F86918 for ; Sat, 12 Aug 2023 12:46:11 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=clamor95@gmail.com Received: by mail-ej1-x631.google.com with SMTP id a640c23a62f3a-99bf8e5ab39so386751266b.2 for ; Sat, 12 Aug 2023 03:46:11 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20221208; t=1691837171; x=1692441971; 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=RygY+z6+rekuzyU6EDD/kgZxDPkxD9vBEx15RbL1ejU=; b=Z/v8bJfSmC8f168LbZ21UKFodTI+G/39n6M2neH5vTxo5KnIiL07DuwjFelU9H1sxS 9g0mi87rpKlQBA0jPVJYCGtpHGG9bAeoSu7zxYmSLrl3ZqvvKtRwFg+z+ctw54iCJCGL mgPJgI+V9HPjkchNu5NawRR18KQEVCCgLvIoiefzcZCTGKudWptbdCcPn1SqNimPnLer I4NN+1MmfTIro8n0jCqCruKrYRLH8L5jsEJdqdOuZMmhN3xET4R8WIR4TkCekGAH/9kU 8Fya0Us4YFv4ESKtOpc2ooXmH5BOF5dopuOyAoEj5XviCn864+U8X3Zkk5g08kNrm6CA EN2Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1691837171; x=1692441971; 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=RygY+z6+rekuzyU6EDD/kgZxDPkxD9vBEx15RbL1ejU=; b=bnAjrgWEVtkMKST4giNavE8TVrKwsJuZd0uDGjVOfe9pr5YOjkyPtZ8KlLO4+t/Q0F goemdppwaSwfYgLxg32BLCB/xz4IxakZR6fn4kqkq+s+NULDn/LI1ZbZyEuVZzy2sDnP I5Wc3WZ4RQCIHqJigsxy/R4eARIC0kSS5uSdnCWql0cJPIhXOUPjIRd394wn6fYEFYkW 0WpMkmsGDFfzdRpvbUJfgdAEdRsugjUnb7IAMG4yHJJ8ZvDskT6K0jQ9npIerPKYW+pt ndDM/+4BSVXgdVDzyq6h0ZAA43/mf9BmoqHbkbtJMFCP9CobuirL4IhBnRsoGqPt0ikq US4A== X-Gm-Message-State: AOJu0Yyn3ss9CXTMAsM1rXQR9Wf41NfTm7ucjUya+oTbp6KSNutbJkWP VzOTtGMvWXbClGS+kh+3IPo= X-Google-Smtp-Source: AGHT+IFWcDp3prIodgfzKttiJFd5uy6vjqLjWdW8ZVqXl3U8MMCgWQnWoNJHkDJ1S3Wvk5/JJQP6Zw== X-Received: by 2002:a17:907:270e:b0:99b:dd1d:64ba with SMTP id w14-20020a170907270e00b0099bdd1d64bamr4046001ejk.50.1691837171194; Sat, 12 Aug 2023 03:46:11 -0700 (PDT) Received: from xeon.. ([188.163.112.48]) by smtp.gmail.com with ESMTPSA id kd28-20020a17090798dc00b009937e7c4e54sm3342484ejc.39.2023.08.12.03.46.09 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 12 Aug 2023 03:46:09 -0700 (PDT) From: Svyatoslav Ryhel To: Anatolij Gustschin , Simon Glass , Jonas Karlman , Svyatoslav Ryhel Cc: u-boot@lists.denx.de Subject: [PATCH v2 1/3] video: pwm_backlight: use regulator_set_enable_if_allowed Date: Sat, 12 Aug 2023 13:45:50 +0300 Message-Id: <20230812104552.32043-2-clamor95@gmail.com> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20230812104552.32043-1-clamor95@gmail.com> References: <20230812104552.32043-1-clamor95@gmail.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.39 Precedence: list List-Id: U-Boot discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: u-boot-bounces@lists.denx.de Sender: "U-Boot" X-Virus-Scanned: clamav-milter 0.103.8 at phobos.denx.de X-Virus-Status: Clean With the commit 4fcba5d556b4 ("regulator: implement basic reference counter") the return value of regulator_set_enable may be EALREADY or EBUSY for fixed/gpio regulators and may be further expanded on all regulators. Change to use the more relaxed regulator_set_enable_if_allowed to continue if regulator already was enabled or disabled. Signed-off-by: Svyatoslav Ryhel --- drivers/video/pwm_backlight.c | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) diff --git a/drivers/video/pwm_backlight.c b/drivers/video/pwm_backlight.c index 46c16a8f44..31160d352e 100644 --- a/drivers/video/pwm_backlight.c +++ b/drivers/video/pwm_backlight.c @@ -97,8 +97,8 @@ static int enable_sequence(struct udevice *dev, int seq) plat = dev_get_uclass_plat(priv->reg); log_debug("Enable '%s', regulator '%s'/'%s'\n", dev->name, priv->reg->name, plat->name); - ret = regulator_set_enable(priv->reg, true); - if (ret) { + ret = regulator_set_enable_if_allowed(priv->reg, true); + if (ret && ret != -ENOSYS) { log_debug("Cannot enable regulator for PWM '%s'\n", dev->name); return log_ret(ret); @@ -178,11 +178,10 @@ static int pwm_backlight_set_brightness(struct udevice *dev, int percent) } if (disable) { dm_gpio_set_value(&priv->enable, 0); - if (priv->reg) { - ret = regulator_set_enable(priv->reg, false); - if (ret) - return log_ret(ret); - } + ret = regulator_set_enable_if_allowed(priv->reg, false); + if (ret && ret != -ENOSYS) + return log_ret(ret); + priv->enabled = false; } -- 2.39.2