Received: by 2002:a05:6358:16cc:b0:ea:6187:17c9 with SMTP id r12csp11829894rwl; Tue, 3 Jan 2023 05:28:16 -0800 (PST) X-Google-Smtp-Source: AMrXdXstxrlN3eNjyB69TBJnhKTJvDedui0eSUoGk7z6jsWvkfdeCo716GkK3e/eJy/sQM/2NutX X-Received: by 2002:a17:90a:9304:b0:223:fcc8:d7dd with SMTP id p4-20020a17090a930400b00223fcc8d7ddmr47506058pjo.30.1672752496621; Tue, 03 Jan 2023 05:28:16 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1672752496; cv=none; d=google.com; s=arc-20160816; b=BIdbTpQ/aGefkgo5LU8E/BLdDz/mZehplI2OLbe4NVszE54X7oWRAtVkBdrWZU+xeS xlBMEttZr65JDUsksjJGpCxBgoXusyculJfqBWSgLsySbpaCUsXWSWLENU/mrkDWisez Mv9K36Q/RAal9UMBEBlJPpB3M+j4Se50El/mWIym0HYqrWkB0+BXQ9MEfb5s8d6wy05x 6o6ZcIGo0GsPlRHOOMoibv/zhcGXOnuSqdiPQZJlTKWDWZEn6NsiOGDuSXaQDFMhkhKi F1djmKGH9aDTcNQIqyyLIZSG56yqAq+CZIbutz11v1EvrvMzUD+LBFIsy/DK/ZBgglqi tP4w== 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=uhiFLBFtyTtS9hkNkQi647HtLFPenm1IJPibK3iL+8U=; b=0rmSH++oxF+1awBWPDoBHXfp7XiyOE6JtBKfBTAzu4/W4obBNpsGkS2gvcTtP20rWo 3cZBXq60lBEFmmqsmzfSeyG2bTcRhzuDisx8pE4lYjyu99yPQQoNNiY3Lfmh1EZ4n3DR oS3/9jJkz0TIe8rlvMa+9FSvDm/ka8pilKYXQO45B2OMWNZhguQ2GZS45uMTAABB1iGQ SHjyrZXtqOdIsFEZmPFuVwNxgtffsxCZW0Vy/t8gExSgCmh5Axjr9R3DdwjUYDLJnCYX resPbiscps2OqXDFiDZItIj+4UxAvW2sdTHHAE12CRAhqrhJQD+nASlQvANus2lDiDZv vwPg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=j722cG7A; 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=intel.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id d59-20020a17090a6f4100b0021917840676si8441784pjk.31.2023.01.03.05.28.09; Tue, 03 Jan 2023 05:28:16 -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; dkim=pass header.i=@intel.com header.s=Intel header.b=j722cG7A; 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=intel.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230131AbjACNNr (ORCPT + 60 others); Tue, 3 Jan 2023 08:13:47 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:53436 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S237731AbjACNNM (ORCPT ); Tue, 3 Jan 2023 08:13:12 -0500 Received: from mga09.intel.com (mga09.intel.com [134.134.136.24]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 299E011149; Tue, 3 Jan 2023 05:12:44 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1672751564; x=1704287564; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=7p6zWbQRFO6BWGKdmzxHibs27PU9es81+rcbWbLCG20=; b=j722cG7A2lXzw/ka6jI1UYD83qpkWlRMTyb/+mfQJwHTjYrJiRIt1ngc mB+xPxgwjsgNCrNpXXUcY2kgrXbVG5olZbG2VhkQ8EiUqNR2prKGlkKmI Z21JqNnLBGOys8YQG+4TApLmTOSjlML1vZIOrfcD/Qtf6kB+dSx3oiM8F HJm6L/YUTkc6A6bmEDZg+ivX9aKIFHOJYxsRdzh5YbemjJ6ZxfIgnHzEH Rzqixq7bv9Pm5xxfKPGL1mnmkWM7dfgawQch8EqQlImC33+54tqqCb3o+ VWE/PCRSGjZdRnmfYQsv3ZvcAiJCVMdpjDwOmXDtYl2fvkcgq8GZMDa1a Q==; X-IronPort-AV: E=McAfee;i="6500,9779,10579"; a="322887977" X-IronPort-AV: E=Sophos;i="5.96,297,1665471600"; d="scan'208";a="322887977" Received: from orsmga008.jf.intel.com ([10.7.209.65]) by orsmga102.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 03 Jan 2023 05:12:39 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6500,9779,10579"; a="685397941" X-IronPort-AV: E=Sophos;i="5.96,297,1665471600"; d="scan'208";a="685397941" Received: from black.fi.intel.com ([10.237.72.28]) by orsmga008.jf.intel.com with ESMTP; 03 Jan 2023 05:12:33 -0800 Received: by black.fi.intel.com (Postfix, from userid 1003) id A5E0C2AA; Tue, 3 Jan 2023 15:13:00 +0200 (EET) From: Andy Shevchenko To: Andy Shevchenko , Gene Chen , linux-leds@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-mediatek@lists.infradead.org, linux-kernel@vger.kernel.org, netdev@vger.kernel.org Cc: Pavel Machek , Lee Jones , Matthias Brugger , Sean Wang , Kurt Kanzenbach , Andrew Lunn , Florian Fainelli , Vladimir Oltean , "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni Subject: [PATCH v4 05/11] leds: bcm6358: Get rid of custom led_init_default_state_get() Date: Tue, 3 Jan 2023 15:12:50 +0200 Message-Id: <20230103131256.33894-6-andriy.shevchenko@linux.intel.com> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20230103131256.33894-1-andriy.shevchenko@linux.intel.com> References: <20230103131256.33894-1-andriy.shevchenko@linux.intel.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-4.3 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_EF,RCVD_IN_DNSWL_MED, RCVD_IN_MSPIKE_H3,RCVD_IN_MSPIKE_WL,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 LED core provides a helper to parse default state from firmware node. Use it instead of custom implementation. Signed-off-by: Andy Shevchenko Reviewed-by: Florian Fainelli --- drivers/leds/leds-bcm6358.c | 32 ++++++++++++++++---------------- 1 file changed, 16 insertions(+), 16 deletions(-) diff --git a/drivers/leds/leds-bcm6358.c b/drivers/leds/leds-bcm6358.c index 9d2e487fa08a..86e51d44a5a7 100644 --- a/drivers/leds/leds-bcm6358.c +++ b/drivers/leds/leds-bcm6358.c @@ -96,7 +96,8 @@ static int bcm6358_led(struct device *dev, struct device_node *nc, u32 reg, { struct led_init_data init_data = {}; struct bcm6358_led *led; - const char *state; + enum led_default_state state; + unsigned long val; int rc; led = devm_kzalloc(dev, sizeof(*led), GFP_KERNEL); @@ -110,29 +111,28 @@ static int bcm6358_led(struct device *dev, struct device_node *nc, u32 reg, if (of_property_read_bool(nc, "active-low")) led->active_low = true; - if (!of_property_read_string(nc, "default-state", &state)) { - if (!strcmp(state, "on")) { + init_data.fwnode = of_fwnode_handle(nc); + + state = led_init_default_state_get(init_data.fwnode); + switch (state) { + case LEDS_DEFSTATE_ON: + led->cdev.brightness = LED_FULL; + break; + case LEDS_DEFSTATE_KEEP: + val = bcm6358_led_read(led->mem + BCM6358_REG_MODE); + val &= BIT(led->pin); + if ((led->active_low && !val) || (!led->active_low && val)) led->cdev.brightness = LED_FULL; - } else if (!strcmp(state, "keep")) { - unsigned long val; - val = bcm6358_led_read(led->mem + BCM6358_REG_MODE); - val &= BIT(led->pin); - if ((led->active_low && !val) || - (!led->active_low && val)) - led->cdev.brightness = LED_FULL; - else - led->cdev.brightness = LED_OFF; - } else { + else led->cdev.brightness = LED_OFF; - } - } else { + break; + default: led->cdev.brightness = LED_OFF; } bcm6358_led_set(&led->cdev, led->cdev.brightness); led->cdev.brightness_set = bcm6358_led_set; - init_data.fwnode = of_fwnode_handle(nc); rc = devm_led_classdev_register_ext(dev, &led->cdev, &init_data); if (rc < 0) -- 2.35.1