Received: by 2002:a05:6358:16cc:b0:ea:6187:17c9 with SMTP id r12csp11828696rwl; Tue, 3 Jan 2023 05:27:19 -0800 (PST) X-Google-Smtp-Source: AMrXdXuCo0CPNTAKiIRirdg0Nii31yv/j5ovmJxSZh5T6SmBBACFIKWTfqwj16K7WAqVoJBEg771 X-Received: by 2002:a05:6a21:3990:b0:a7:787:80ed with SMTP id ad16-20020a056a21399000b000a7078780edmr50663286pzc.17.1672752439420; Tue, 03 Jan 2023 05:27:19 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1672752439; cv=none; d=google.com; s=arc-20160816; b=G9sD+ht4E7FsfeEGwt7O+ol74jc3A/GZha4SF+jhw4awusOgZBf2uKB7xKU8+1Xo1o NecelWlpCyWE4KpKkHqrUT8OM9AhZ0ws6kk9ECSTY0JRoHYgu6aKe53S350IBtL0f82U DJq5CGF+kAgcye/y3lg6c97EAMKInixRj0w1YBQqByUELgQFk4Uq8mzocXmoN6foOa7C jyAUoVFLuU+qMc5qRM70pXicDBMBmInDtN/ucfAph6t6Wr94Q4C+zCPjbLQ6+HKpKXkD OSSH9aK6tyD0qiczozRR69HGYltu5gE+9Zt9IPepOpyU1yN1QFBYN4SNbgCIE8czLBNv uzOQ== 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=e7w6baOKr4KB2PiuqgQdQHmUSuRlMcuXittrTw63Bx0=; b=U+I5ssfbatTEKNnNhSmvDAgA0RYGbRE3PIBW+eYNKLqN737uc92XcqxXkZMD1WEuhC JjOtszT46RicsRnnnP9v+oRfzyqgnWXXwaVOM+eELqnNpkT2cvTnyS+8B+Et1XGIlvPY YxBOxlf+1NF6a0RvxvYhm31ApNq3uOzWQtYockoPuNmKIW4RFjYcIxS1bc+6S6XKe12w JXwlkv6ZoyzPYXNtlcG85K1PlXmIMq1eYwyZd4XfuLSnHi07AeIjgVmDG+VougeikZXh Q9vvqDyPpPh8iD/xa90p5AaXR5viNSejfoqNlwz/DYXgaL11nN2JAXzNpztIPSPoLMXY HIHA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=m2K9HbaX; 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 u10-20020a63d34a000000b004470e9c2e53si32841478pgi.591.2023.01.03.05.27.12; Tue, 03 Jan 2023 05:27:19 -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=m2K9HbaX; 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 S237728AbjACNNM (ORCPT + 60 others); Tue, 3 Jan 2023 08:13:12 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:52732 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S237676AbjACNMn (ORCPT ); Tue, 3 Jan 2023 08:12:43 -0500 Received: from mga04.intel.com (mga04.intel.com [192.55.52.120]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 1DACD10B70; Tue, 3 Jan 2023 05:12:39 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1672751560; x=1704287560; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=hvI26OhQ+1E3Y1b+RrDqvUOiyVnslqAALa2RhHdwGbY=; b=m2K9HbaXlAohLwUKkPBF8jj3ww+UpveJ7AB21Q5apwPCGrvhNPPqL5FV Zq2lES0nJIYwFPlnNCfoJYoGTzyZnYCwUJxqt3ObNKBy/cDnOvYpVXr5t xUplS96h3LU07X5+gGnSEB8P/fTuy3v0oh36zCFf9B4CDXjprJTe+v79V Nzn+K2eSa6bEI9gA3grxxE9vN7p37GGmGPcLLpdCSWe/hcHu/ZXALoawE 06a+PXvtCOhfaR+y/E68aRdEMvWxWNwBXAIXuhNXIuccP0tMvk+1ibkWU KDRHgCYYXBa4kkrTavlHe8fUnYc5RO9XrofVjuH9bIoxpFVQWCMx2OyIk w==; X-IronPort-AV: E=McAfee;i="6500,9779,10579"; a="320367274" X-IronPort-AV: E=Sophos;i="5.96,297,1665471600"; d="scan'208";a="320367274" Received: from orsmga002.jf.intel.com ([10.7.209.21]) by fmsmga104.fm.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="654781148" X-IronPort-AV: E=Sophos;i="5.96,297,1665471600"; d="scan'208";a="654781148" Received: from black.fi.intel.com ([10.237.72.28]) by orsmga002.jf.intel.com with ESMTP; 03 Jan 2023 05:12:34 -0800 Received: by black.fi.intel.com (Postfix, from userid 1003) id D30BE3FD; 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 09/11] leds: pm8058: Get rid of custom led_init_default_state_get() Date: Tue, 3 Jan 2023 15:12:54 +0200 Message-Id: <20230103131256.33894-10-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,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 --- drivers/leds/leds-pm8058.c | 29 +++++++++++++++-------------- 1 file changed, 15 insertions(+), 14 deletions(-) diff --git a/drivers/leds/leds-pm8058.c b/drivers/leds/leds-pm8058.c index fb2ab72c0c40..b9233f14b646 100644 --- a/drivers/leds/leds-pm8058.c +++ b/drivers/leds/leds-pm8058.c @@ -93,8 +93,8 @@ static int pm8058_led_probe(struct platform_device *pdev) struct device_node *np; int ret; struct regmap *map; - const char *state; enum led_brightness maxbright; + enum led_default_state state; led = devm_kzalloc(dev, sizeof(*led), GFP_KERNEL); if (!led) @@ -125,25 +125,26 @@ static int pm8058_led_probe(struct platform_device *pdev) maxbright = 15; /* 4 bits */ led->cdev.max_brightness = maxbright; - state = of_get_property(np, "default-state", NULL); - if (state) { - if (!strcmp(state, "keep")) { - led->cdev.brightness = pm8058_led_get(&led->cdev); - } else if (!strcmp(state, "on")) { - led->cdev.brightness = maxbright; - pm8058_led_set(&led->cdev, maxbright); - } else { - led->cdev.brightness = LED_OFF; - pm8058_led_set(&led->cdev, LED_OFF); - } + init_data.fwnode = of_fwnode_handle(np); + + state = led_init_default_state_get(init_data.fwnode); + switch (state) { + case LEDS_DEFSTATE_ON: + led->cdev.brightness = maxbright; + pm8058_led_set(&led->cdev, maxbright); + break; + case LEDS_DEFSTATE_KEEP: + led->cdev.brightness = pm8058_led_get(&led->cdev); + break; + default: + led->cdev.brightness = LED_OFF; + pm8058_led_set(&led->cdev, LED_OFF); } if (led->ledtype == PM8058_LED_TYPE_KEYPAD || led->ledtype == PM8058_LED_TYPE_FLASH) led->cdev.flags = LED_CORE_SUSPENDRESUME; - init_data.fwnode = of_fwnode_handle(np); - ret = devm_led_classdev_register_ext(dev, &led->cdev, &init_data); if (ret) dev_err(dev, "Failed to register LED for %pOF\n", np); -- 2.35.1