From patchwork Fri Aug 5 15:49:05 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andy Shevchenko X-Patchwork-Id: 12937486 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 bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 25D17C00140 for ; Fri, 5 Aug 2022 15:54:29 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: Message-Id:Date:Subject:Cc:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=X9lvGXh6qBBecSSBXqhL5VfO3PWrMwtZ7WYZwnzYNfI=; b=LtJaFROb15jwZP j/GnP5B+wDeVmTZAaLMBTfVt+VRJYxwGoAP+SX9lfFjKBTwc1KeDMdynXFZStbWPG2rIMW2zK5+oW 8v0v/8xz+L/kxn9OWXNAq5A/qolfUJ6XBEQH42Z06Wu/QhJUPxKGWKE0uohtY+MtA5Ixp7FtbMRZl hvqvTWSZsVCneHfxUtkzplQLfLC1de3AzX+7IHfXEKC0mz1sUSmKLwaQWzAh6APm/D6fRCJIq7Noz C4u+VLy755Jy4nYOgQSEDYuoHrh1k2xcc44+/RzbmU/LuS9GkU6Qu6rPlzTveIw8Zz56AZL3tU2G+ kWF846ifJs9SVCHiVUCA==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1oJzdU-00GSug-CA; Fri, 05 Aug 2022 15:53:17 +0000 Received: from mga17.intel.com ([192.55.52.151]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1oJzZh-00GQFY-Bf; Fri, 05 Aug 2022 15:49:22 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1659714561; x=1691250561; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=hvI26OhQ+1E3Y1b+RrDqvUOiyVnslqAALa2RhHdwGbY=; b=DuWkIRW3UDVWzm6NeKTV02z9zDH2zkX8NR5NeOt3ggZWUOuoFtHl1dCY YxJv2+34tTz1RjEvRjkLQaIhXr8JJ5ehDbPeOR6+zavC/3YzJwEXvDRkW lJQ5bUky2aLBmO5OvQ0duxkUJXdfs0rC9NCaNktNWQJX002YF8WDJ2TW4 uJ+MXcZl/zTtpHcoeddOg2Zl3Wxd2q12PUZrpqgrSijakbb9YtG2wo73O fwC2QnmjWvC1SHSidB0RJHRlEJ7nhn05XrXD2ZH8JMsbhjz44Ra4K8Ksr icuumvi5pQvnj1kp/txx+zsYjiZaJj/GwS89+x7lAeq5h0/V9d7Tvvphf g==; X-IronPort-AV: E=McAfee;i="6400,9594,10430"; a="270608788" X-IronPort-AV: E=Sophos;i="5.93,216,1654585200"; d="scan'208";a="270608788" Received: from orsmga007.jf.intel.com ([10.7.209.58]) by fmsmga107.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 05 Aug 2022 08:49:16 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.93,216,1654585200"; d="scan'208";a="600399033" Received: from black.fi.intel.com ([10.237.72.28]) by orsmga007.jf.intel.com with ESMTP; 05 Aug 2022 08:49:11 -0700 Received: by black.fi.intel.com (Postfix, from userid 1003) id ECFC1450; Fri, 5 Aug 2022 18:49:16 +0300 (EEST) From: Andy Shevchenko To: Gene Chen , Andy Shevchenko , Pavel Machek , Eddie James , Denis Osterland-Heim , 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: Matthias Brugger , Sean Wang , Kurt Kanzenbach , Andrew Lunn , Vivien Didelot , Florian Fainelli , Vladimir Oltean , "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni Subject: [PATCH v2 09/11] leds: pm8058: Get rid of custom led_init_default_state_get() Date: Fri, 5 Aug 2022 18:49:05 +0300 Message-Id: <20220805154907.32263-10-andriy.shevchenko@linux.intel.com> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220805154907.32263-1-andriy.shevchenko@linux.intel.com> References: <20220805154907.32263-1-andriy.shevchenko@linux.intel.com> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20220805_084921_455961_E03210AD X-CRM114-Status: GOOD ( 13.21 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.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);