Received: by 2002:ab2:6f44:0:b0:1fd:c486:4f03 with SMTP id l4csp229225lqq; Thu, 13 Jun 2024 00:59:27 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCXOfzqcHXapqUDk4yZXye9mKd0giUdi69SBl1v/3+MaMjaNcYdX43DebBGxi+3nBJAg3r07gdMTA01yAO1qE8xTcq8qkBuY4/Qg8i+SbA== X-Google-Smtp-Source: AGHT+IHQdLFZXkw4+SZo8w9tfLPjOm/BHywP5/qyLRJ3AksT7R/NmFRWqTsdySlC++3nQO8eFXgt X-Received: by 2002:ac8:5d03:0:b0:440:c291:9c66 with SMTP id d75a77b69052e-4415ac6135dmr50332251cf.51.1718265567408; Thu, 13 Jun 2024 00:59:27 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1718265567; cv=pass; d=google.com; s=arc-20160816; b=BDh/geNCNu7mReTbfZAEW7OWUQYJXdQpgpMGB4ddOKr1rNE6zwkTUbHFURDoFV85oV VsPpUUbMbv6o4ewbTgLunI3liRL3+xEhbYYe6/b8kGTpwnuDTiPkVry3VykT9t6ceyi2 7LU6Raix247jt5j71gNhHRFTtJQHdyV9f60OWcu9L80RDUE7fyh/0vkNO+AQ0biD+ZcH 6F4FXv6X72AILEzIeRRRRrFLm4RfY+x24qpOkwejfNzX9FiH7VDQRP7spxovfrpP7R1b kVXhwWS+WY059SE5EvPPfz7IVW5wQejH6nhyqAvxP0EeOc6lRB9EqJ8P8JMmNpGyR3Wk e5JQ== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:message-id:date:subject:cc:to :from:dkim-signature; bh=BDB+Qx+e/UMSgsd26SmkQypreZPHCIA5QvdNyPC8ML8=; fh=uVXpX78Au+Fs3z1cULDkRfzNvy16VqZen6I0CdDLkcI=; b=oWT/UFy21USCT6OReqaNV8ntgoGmqymQJDAmI5IhydMrn37TF5mRcoSu3rjLyx2yjF zj9hzb82LlPR5NSqJFtHAW1lYI1yOMB/AsfverUfwLcWvQNLCoyRIjczfDM3em2jivS/ dNTGBt61f75e4wU/TuXTHjGBOL8ksozfTd/WlmMJoSrIWJC+T0uJClug+alsdpuGWnMA a931kZdNL5Fg5mRQ7Ab7le22thsPig5u6rUXfbuoQP5M2GBYMEXEmYKX5ktcQB128Pu5 umACnzlOYEgG6d3aLezUO+1PmUtolRb0TG5XJBcXMr2nFQhnoDFu7QKU2DCdJfElp4Oh X++Q==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=p9vskcV0; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-212766-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) smtp.mailfrom="linux-kernel+bounces-212766-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from ny.mirrors.kernel.org (ny.mirrors.kernel.org. [147.75.199.223]) by mx.google.com with ESMTPS id d75a77b69052e-441ef3bd2f4si9331681cf.136.2024.06.13.00.59.27 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 13 Jun 2024 00:59:27 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-212766-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) client-ip=147.75.199.223; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=p9vskcV0; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-212766-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) smtp.mailfrom="linux-kernel+bounces-212766-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ny.mirrors.kernel.org (Postfix) with ESMTPS id 14D601C215CD for ; Thu, 13 Jun 2024 07:59:27 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id B59C813CF9A; Thu, 13 Jun 2024 07:57:22 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="p9vskcV0" Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id E1A1C13D285; Thu, 13 Jun 2024 07:57:21 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1718265442; cv=none; b=LtTT/9UvVYnG4nobAUxFUKZlJqZHY0Ti9Eoqw2DGsLNqlpc3ADAFOMsIoh2imvndNm8KG5Dh+4N+N7uxzvoUGXh+XNuVch5sK8oUgI5D+/1J/gVUqrUgiWJL851n14v8l1eAsqxWHILkkGSudCw9rad0TOAagP1S1ktdV7wYofY= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1718265442; c=relaxed/simple; bh=OCtOhYu837Sd/8HvLhR6dWGgEllOhuY4C03+r2+NBgA=; h=From:To:Cc:Subject:Date:Message-ID:MIME-Version; b=GLUm89tVXpOB5kpMmlDLSIST751zvBK+3dItNMSkIVFHGOVk+pkQtVOnK5F6MOqg/q/mxII/baobuvj3wgeWDpO8v9XXm1GIUdjBTQg1fLu/dmF3DfdUs9onQP4X1Kv/znKoUZhq37Oo3Gl5EUlnM8YTRS8oBY6/kVQDSNuPd5k= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=p9vskcV0; arc=none smtp.client-ip=10.30.226.201 Received: by smtp.kernel.org (Postfix) with ESMTPSA id 868EBC3277B; Thu, 13 Jun 2024 07:57:20 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1718265441; bh=OCtOhYu837Sd/8HvLhR6dWGgEllOhuY4C03+r2+NBgA=; h=From:To:Cc:Subject:Date:From; b=p9vskcV0vyail7cHf+/fmUO0erG6vuNWyLfmjRjk4LM6OIoPAiynBFddj5BStR2xm BdB6vizMAMHuus1sAZGaq0bb39PRkVdFTfkUZ5I6x2v5p6RbAjngD717JNNZRuof4n Sh0I7qKvRM7onR1M6FUTMmqlbY76frVWWtPTIBZbSKrYo13wJ/WmjCphcJ5Qmeu0tC Lfx4Tc90QDDnmqwfA5J29XUbQUX6mfeurq7jMFFiAHh0b/52jSelp75R3jkbhDAufi 5umZcQ/LhIKFvRsn34zphv6l4fkgIafiEbiAIrMiPol8giwCr0N/mE87wUjWihRpNl uE2nv2myztqXA== From: Lee Jones To: lee@kernel.org Cc: linux-kernel@vger.kernel.org, Pavel Machek , linux-leds@vger.kernel.org, Heiner Kallweit Subject: [PATCH 1/1] leds: core: Omit set_brightness error message for a LED supporting hw trigger only Date: Thu, 13 Jun 2024 08:57:12 +0100 Message-ID: <20240613075712.2479669-1-lee@kernel.org> X-Mailer: git-send-email 2.45.2.505.gda0bf45e8d-goog Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit If both set_brightness functions return -ENOTSUPP, then the LED doesn't support setting a fixed brightness value, and the error message isn't helpful. This can be the case e.g. for LEDs supporting a specific hw trigger only. Pinched the subject line and commit message from Heiner: Link: https://lore.kernel.org/all/44177e37-9512-4044-8991-bb23b184bf37@gmail.com/ Reworked the function to provide Heiner's required semantics whilst simultaneously increasing readability and flow. Cc: Pavel Machek Cc: linux-leds@vger.kernel.org Suggested-by: Heiner Kallweit Signed-off-by: Lee Jones --- drivers/leds/led-core.c | 19 +++++++++++++------ 1 file changed, 13 insertions(+), 6 deletions(-) diff --git a/drivers/leds/led-core.c b/drivers/leds/led-core.c index ef7d1c6767ca..3b4db39f2326 100644 --- a/drivers/leds/led-core.c +++ b/drivers/leds/led-core.c @@ -123,15 +123,22 @@ static void led_timer_function(struct timer_list *t) static void set_brightness_delayed_set_brightness(struct led_classdev *led_cdev, unsigned int value) { - int ret = 0; + int ret; ret = __led_set_brightness(led_cdev, value); - if (ret == -ENOTSUPP) + if (ret == -ENOTSUPP) { ret = __led_set_brightness_blocking(led_cdev, value); - if (ret < 0 && - /* LED HW might have been unplugged, therefore don't warn */ - !(ret == -ENODEV && (led_cdev->flags & LED_UNREGISTERING) && - (led_cdev->flags & LED_HW_PLUGGABLE))) + if (ret == -ENOTSUPP) + /* No back-end support to set a fixed brightness value */ + return; + } + + /* LED HW might have been unplugged, therefore don't warn */ + if (ret == -ENODEV && led_cdev->flags & LED_UNREGISTERING && + led_cdev->flags & LED_HW_PLUGGABLE) + return; + + if (ret < 0) dev_err(led_cdev->dev, "Setting an LED's brightness failed (%d)\n", ret); } -- 2.45.2.505.gda0bf45e8d-goog