Received: by 2002:ad5:4acb:0:0:0:0:0 with SMTP id n11csp2412345imw; Wed, 6 Jul 2022 05:37:22 -0700 (PDT) X-Google-Smtp-Source: AGRyM1s7Zp+l7Kb++DHeneQetMCc/qO6cKA+MT237qYkyhsc3PCblwQdiRNH6DvCMKHo63MpZJ6Q X-Received: by 2002:a17:907:a427:b0:71b:6f0b:8beb with SMTP id sg39-20020a170907a42700b0071b6f0b8bebmr38711287ejc.496.1657111042540; Wed, 06 Jul 2022 05:37:22 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1657111042; cv=none; d=google.com; s=arc-20160816; b=R1bLxZJzxwoRAzN/gmc8V3ezzCgJcRSHzofit1obavxdcyrk5PKwECy0FGqvrtH9N2 90b4Oi/SUQ8SBR+e2n1eeJmErUrBsWEFOtj5vMUPO+lGou/rBdmj41Ds9mIrhL82ctb2 whYBd+pjdU/U5oGuiK5qs6U26RftCoDDsQFYBu0ZC1IO5y/LFKVkOifpH9yRF1LJfM+2 W6mF220R05fTamJWsGF98oCIq6xVLlum6Ja+II4q57yhElBBR1wCCb337lBEflTefqlC 3UMhr2/ItlKBWlb+nNgzus1G14kqrnUeR73gX36LrfdcfD7sxyfLzkRamX5qdRhHF+iI 7juQ== 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=HaMiTPVbUpJlrlMXLTXFFIMbxl/Cpi8Ss1Z2475xygg=; b=xveMN4HSKpvEzv86NitttfxQRR2RdPZ4V49BHVcoli8h76MhKfk9Wopl/+gTIpwc9y l2h4jh/Yu+Kdo11U86db9ACYRYul78/VXf6fgba6THJGRXXj5XrjrWm4sF8uI9aAbh3D ShPkKjZss/bYBrC2wUFnQa70bMXwtlQ1Lmt4OEVujDr71SZ7YSpyhiJGTvmixokz6UxM Tul/a/eoScKdlwK/3sJFLe877jiRCjaFW6jFPk32y33piovKILI/+2NzghKNx8jr0Tf8 2Fiv7EuGN3dW2npj4KsYf+MZilkJInULQeZ3F3wV8wv2zN/094BfqiMkVN/cuG6igeTx sMyA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=ZbCf7YAm; 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=kernel.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id gb34-20020a170907962200b007121b9fc6fbsi19742083ejc.956.2022.07.06.05.36.56; Wed, 06 Jul 2022 05:37:22 -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=@kernel.org header.s=k20201202 header.b=ZbCf7YAm; 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=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232336AbiGFL3O (ORCPT + 99 others); Wed, 6 Jul 2022 07:29:14 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:33190 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229984AbiGFL3M (ORCPT ); Wed, 6 Jul 2022 07:29:12 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 8A8FD25C49; Wed, 6 Jul 2022 04:29:11 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id 2590561E72; Wed, 6 Jul 2022 11:29:11 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 5C32EC341C0; Wed, 6 Jul 2022 11:29:10 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1657106950; bh=4ASXZQVP9AzJtJ0hy++BPz1LtZi0DXsVgS0qlgbwSbA=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=ZbCf7YAm60jIpENUSEoVes5cgy39ZTGG4d0Nlncn6DWpQHhL4pyJyJzhqiDW45j6v W+dDhR1R5dKHCCugt0BGOYP29VX/ruqj3uiGC419sEYRLPAWyPmanSOrTmWl1g04Fn d/SrR/g8458dK3JjC78mBMMCfFUt9wADGcXUGpcdNlGWEf8fVSjDbC6SNRbsUfJpPT wR/Egc5HIgPhDlGKPg0/1B7qeyPhoZUwCeHRoTpF+jQhVZYJrc4XCGlpu0orv0j5OK Va+5eXFgtNW0cQudJXHg5TXao3RtGIXOaIn9OZKeJr/bR+JenjDzrAaurMan82yp/F NCoTRY3YQWsow== Received: by pali.im (Postfix) id C51F87F1; Wed, 6 Jul 2022 13:29:07 +0200 (CEST) From: =?UTF-8?q?Pali=20Roh=C3=A1r?= To: Pavel Machek , Rob Herring , Krzysztof Kozlowski , Linus Walleij , =?UTF-8?q?Marek=20Beh=C3=BAn?= Cc: linux-leds@vger.kernel.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH 2/2] leds: syscon: Implement support for value property Date: Wed, 6 Jul 2022 13:28:28 +0200 Message-Id: <20220706112828.27278-2-pali@kernel.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20220706112828.27278-1-pali@kernel.org> References: <20220706112828.27278-1-pali@kernel.org> MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-7.8 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_HI, SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE 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 This new value property specify when is LED enabled. By default its value is from the mask and therefore LED is enabled when bit is set. This change allows to define inverted logic (0 - enable LED, 1 - disable LED) by setting value property to zero. Signed-off-by: Pali Rohár --- drivers/leds/leds-syscon.c | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/drivers/leds/leds-syscon.c b/drivers/leds/leds-syscon.c index 7eddb8ecb44e..337a0bada967 100644 --- a/drivers/leds/leds-syscon.c +++ b/drivers/leds/leds-syscon.c @@ -29,6 +29,7 @@ struct syscon_led { struct regmap *map; u32 offset; u32 mask; + u32 value; bool state; }; @@ -41,10 +42,10 @@ static void syscon_led_set(struct led_classdev *led_cdev, int ret; if (value == LED_OFF) { - val = 0; + val = ~sled->value; sled->state = false; } else { - val = sled->mask; + val = sled->value; sled->state = true; } @@ -85,6 +86,8 @@ static int syscon_led_probe(struct platform_device *pdev) return -EINVAL; if (of_property_read_u32(np, "mask", &sled->mask)) return -EINVAL; + if (of_property_read_u32(np, "value", &sled->value)) + sled->value = sled->mask; state = of_get_property(np, "default-state", NULL); if (state) { @@ -94,18 +97,19 @@ static int syscon_led_probe(struct platform_device *pdev) ret = regmap_read(map, sled->offset, &val); if (ret < 0) return ret; - sled->state = !!(val & sled->mask); + sled->state = (val & sled->mask) == sled->value; } else if (!strcmp(state, "on")) { sled->state = true; ret = regmap_update_bits(map, sled->offset, sled->mask, - sled->mask); + sled->value); if (ret < 0) return ret; } else { sled->state = false; ret = regmap_update_bits(map, sled->offset, - sled->mask, 0); + sled->mask, + ~sled->value); if (ret < 0) return ret; } -- 2.20.1