From patchwork Tue Sep 6 13:49:54 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andy Shevchenko X-Patchwork-Id: 12967569 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 169B0C6FA83 for ; Tue, 6 Sep 2022 14:08:16 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender:List-Subscribe:List-Help :List-Post:List-Archive:List-Unsubscribe:List-Id:Content-Transfer-Encoding: MIME-Version:References:In-Reply-To:Message-Id:Date:Subject:Cc:To:From: Reply-To:Content-Type:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner; bh=D5tHmAq8XEUna0E5RSbSOZ4xapHQ0h6yyTb36gWfi4Y=; b=JFnMNYsmDpxXLeb8GK3s2lyKVy oJPyJ/GX4C2flO4zdDH45rZ8yaTVdD8pOoFVvlDqOg6zOa63MrqGd7njcDYy+F/iF+9glCMCtDzxP 6CoqxAp/ShSaNVEi9x4oq4xUQlbP3EMiQnvXuDnqDaTTbFIK1Y6LaAHZ+J8pD6fbTIctCuaRsuZuM EZTRQocUG+h4F2RVxL7LwX9qpofKMKeoMXthN+O+NGH2xaRfSIMZ1PqWVUbVmM4JrmBvl8AmGrm03 aAyjUZmDdrgaXfwpCsUWR+4n6vottHrn3+fnn23qm5lrUdMWRxo77zjaQ9S1VVnR1aJTwhcycv9q7 gqlN2Mgw==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1oVZFH-00E9Wq-Ro; Tue, 06 Sep 2022 14:08:07 +0000 Received: from mga01.intel.com ([192.55.52.88]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1oVYxl-00Dzmz-50; Tue, 06 Sep 2022 13:50:03 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1662472201; x=1694008201; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=b85nclneF9BX61RtcZxdbpTMJV7DSQfjZ+m4p4X2wC0=; b=k7+zBNLN9DNJmQ1oavKZvswx/BN+WKryBrJn67S6KqDYuIdRCRSdyFCh phtDeeiq6aHwSL3WIUM1HTc3UzklOOYif+Fu1hr3FTt0Ljpj9yDwYl+2T DneM8tHgoA59oQKxb1Y92sybgoxWYi0bzpLcgcsCJleSSOIOupL2HkHWn vvkpMENKddo6wd/Ssy5hdK2NW6eVB41rCyVlig9z+niDB9kGf6VHkquCB 7vh2Zdut050xNI/2ZhnJftXhqWe8z/RnKCLrRDGkZyhQOdB7nIC8oW8X+ S0fI0Skg7JO1MJVDAI4jge/yKiqhH18sfJmV/EJXTWMVGM0bMDAec3++D w==; X-IronPort-AV: E=McAfee;i="6500,9779,10462"; a="322771118" X-IronPort-AV: E=Sophos;i="5.93,294,1654585200"; d="scan'208";a="322771118" Received: from fmsmga001.fm.intel.com ([10.253.24.23]) by fmsmga101.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 06 Sep 2022 06:49:59 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.93,294,1654585200"; d="scan'208";a="756372522" Received: from black.fi.intel.com ([10.237.72.28]) by fmsmga001.fm.intel.com with ESMTP; 06 Sep 2022 06:49:54 -0700 Received: by black.fi.intel.com (Postfix, from userid 1003) id 5469186; Tue, 6 Sep 2022 16:50:10 +0300 (EEST) From: Andy Shevchenko To: Gene Chen , Andy Shevchenko , Andrew Jeffery , 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 , Matthias Brugger , Sean Wang , Kurt Kanzenbach , Andrew Lunn , Vivien Didelot , Florian Fainelli , Vladimir Oltean , "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , Lee Jones Subject: [PATCH v3 01/11] leds: add missing includes and forward declarations in leds.h Date: Tue, 6 Sep 2022 16:49:54 +0300 Message-Id: <20220906135004.14885-2-andriy.shevchenko@linux.intel.com> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220906135004.14885-1-andriy.shevchenko@linux.intel.com> References: <20220906135004.14885-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-20220906_065001_315167_D10EF4EC X-CRM114-Status: GOOD ( 14.67 ) X-BeenThere: linux-mediatek@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-mediatek" Errors-To: linux-mediatek-bounces+linux-mediatek=archiver.kernel.org@lists.infradead.org Add missing includes and forward declarations to leds.h. While at it, replace headers by forward declarations and vise versa. Signed-off-by: Andy Shevchenko --- include/linux/leds.h | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/include/linux/leds.h b/include/linux/leds.h index ba4861ec73d3..499aea1e59b9 100644 --- a/include/linux/leds.h +++ b/include/linux/leds.h @@ -10,17 +10,21 @@ #include #include -#include -#include #include #include #include #include +#include #include -struct device; -struct led_pattern; +struct attribute_group; struct device_node; +struct fwnode_handle; +struct gpio_desc; +struct kernfs_node; +struct led_pattern; +struct platform_device; + /* * LED Core */ @@ -508,7 +512,6 @@ struct led_properties { const char *label; }; -struct gpio_desc; typedef int (*gpio_blink_set_t)(struct gpio_desc *desc, int state, unsigned long *delay_on, unsigned long *delay_off); From patchwork Tue Sep 6 13:49:55 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andy Shevchenko X-Patchwork-Id: 12967576 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 B3B42ECAAD5 for ; Tue, 6 Sep 2022 14:14:48 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender:List-Subscribe:List-Help :List-Post:List-Archive:List-Unsubscribe:List-Id:Content-Transfer-Encoding: MIME-Version:References:In-Reply-To:Message-Id:Date:Subject:Cc:To:From: Reply-To:Content-Type:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner; bh=oVArDv0lIfvc7Grsn0zO3GkVHpa3SVAzDsMkv50A9yY=; b=DXI5PxeQuRGbLWE1U4qiMALrJg 7jW6NqP8TuZV7R1hD1fW/TTgiI6MDk5Um3YYvl3gimEWTFGYyYZQphuTCm5y5e4M7jWWcIP16F2Mg +20Ar6NmuFr5fs4p27+yXhvZUXNcbvvLggwqlJ7K763hGgq5Z8MTUID9zG6ko83jmHWxySiEtpWxh QlxDS9hTeEKjckp8HB6ESBTX57GxsGTn5BaufKMJlgjq4ADOX1aO2ZT1JKXee10yWxF4Vg0BnEOOL BQt5IgKzV7ZEI0k75ayYIK0PXcJHcy/sPVTV1CLt4W/EZWzDNnrml/Hzou6gAwF6AcrDODtlnOZ22 z/W280+Q==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1oVZLd-00ECCc-BC; Tue, 06 Sep 2022 14:14:41 +0000 Received: from mga11.intel.com ([192.55.52.93]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1oVYxo-00Dzog-2G; Tue, 06 Sep 2022 13:50:08 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1662472204; x=1694008204; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=NEeFuL7s2HGlJGPjMrfp/6jwPjBk7uYpbdHP2kx39AA=; b=eg9yVAPNTw+NPDQDSnTK6uHaInsCh/nlQrf275Cul0QOSdf8ZFZUijL6 Qs/IPG05tQNyPM5sRRMWw8R3hUf3kHTF+GHy7KP3RTTr824Mg7HuszePL EbNdAe2ApRXvlHEKiPF8Fk/fO7oIhpZPu1mhQVTe8wx4z4O3cxIZ1rFvv Zt9Pxh6O8j1ekHKzi9e6Qn+DKKBfxoMzm1hJepxc05RAcNmGvXfsg5Jhb XmuaQ1IeM9yoWO7eTThEYg1kCwkgtKhw8bgsjOwKnnuZFOJsxTUS/hHcG UPNyNdMRoPZ0J9GJX6h2lUdYS2gm+3QO/+G4Ur4Morh7M7F9fq7tc531v g==; X-IronPort-AV: E=McAfee;i="6500,9779,10462"; a="294181881" X-IronPort-AV: E=Sophos;i="5.93,294,1654585200"; d="scan'208";a="294181881" Received: from fmsmga007.fm.intel.com ([10.253.24.52]) by fmsmga102.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 06 Sep 2022 06:50:02 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.93,294,1654585200"; d="scan'208";a="616712869" Received: from black.fi.intel.com ([10.237.72.28]) by fmsmga007.fm.intel.com with ESMTP; 06 Sep 2022 06:49:54 -0700 Received: by black.fi.intel.com (Postfix, from userid 1003) id 6404F363; Tue, 6 Sep 2022 16:50:10 +0300 (EEST) From: Andy Shevchenko To: Gene Chen , Andy Shevchenko , Andrew Jeffery , 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 , Matthias Brugger , Sean Wang , Kurt Kanzenbach , Andrew Lunn , Vivien Didelot , Florian Fainelli , Vladimir Oltean , "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , Lee Jones Subject: [PATCH v3 02/11] leds: Move led_init_default_state_get() to the global header Date: Tue, 6 Sep 2022 16:49:55 +0300 Message-Id: <20220906135004.14885-3-andriy.shevchenko@linux.intel.com> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220906135004.14885-1-andriy.shevchenko@linux.intel.com> References: <20220906135004.14885-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-20220906_065004_166834_0596EB06 X-CRM114-Status: GOOD ( 14.07 ) X-BeenThere: linux-mediatek@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-mediatek" Errors-To: linux-mediatek-bounces+linux-mediatek=archiver.kernel.org@lists.infradead.org There are users inside and outside LED framework that have implemented a local copy of led_init_default_state_get(). In order to deduplicate that, as the first step move the declaration from LED header to the global one. Signed-off-by: Andy Shevchenko --- drivers/leds/leds.h | 1 - include/linux/leds.h | 2 ++ 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/drivers/leds/leds.h b/drivers/leds/leds.h index aa64757a4d89..345062ccabda 100644 --- a/drivers/leds/leds.h +++ b/drivers/leds/leds.h @@ -27,7 +27,6 @@ ssize_t led_trigger_read(struct file *filp, struct kobject *kobj, ssize_t led_trigger_write(struct file *filp, struct kobject *kobj, struct bin_attribute *bin_attr, char *buf, loff_t pos, size_t count); -enum led_default_state led_init_default_state_get(struct fwnode_handle *fwnode); extern struct rw_semaphore leds_list_lock; extern struct list_head leds_list; diff --git a/include/linux/leds.h b/include/linux/leds.h index 499aea1e59b9..b96feacc73f8 100644 --- a/include/linux/leds.h +++ b/include/linux/leds.h @@ -67,6 +67,8 @@ struct led_init_data { bool devname_mandatory; }; +enum led_default_state led_init_default_state_get(struct fwnode_handle *fwnode); + struct led_hw_trigger_type { int dummy; }; From patchwork Tue Sep 6 13:49:56 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andy Shevchenko X-Patchwork-Id: 12967574 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 62A56C6FA8E for ; Tue, 6 Sep 2022 14:14:36 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender:List-Subscribe:List-Help :List-Post:List-Archive:List-Unsubscribe:List-Id:Content-Transfer-Encoding: MIME-Version:References:In-Reply-To:Message-Id:Date:Subject:Cc:To:From: Reply-To:Content-Type:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner; bh=whtg+X8APOE7axzskbilEU6qOgpVAHq4XkJqOAxAWVA=; b=bVWnjBKuCczsLYOjSrh/+D0rbB BUK/PIO1TCfLuVV6jX8r7vnOwA5RAu9NxEW9JRR/GhoG5XzKNTLAopw4rHCBnJoaeYeo9M0n5TY0t MDWOIE+OhVuS7p2/Q2laJ6hnbyodgi3h26zv2oqpRn4Dnm7Yob+K1bknmUvh79gmwVSROdJROIzg5 EgzOFpPL6DU6lD77R98eTPxPlmP+ZDD6mPVfMoJAGsJW6r4dO+gsvbHoPEDWNPgyTwxogEkKlF+1q 5/5JwReBiMNole8QKTabwEgTWVJkBEgyBxMTUqyah2kRUp+fWeLVNkdfzTpfGkH5mXfDF1L2cZwsc Ckr5tTPA==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1oVZLQ-00EC7N-LX; Tue, 06 Sep 2022 14:14:28 +0000 Received: from mga01.intel.com ([192.55.52.88]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1oVYxn-00Dzmz-9E; Tue, 06 Sep 2022 13:50:07 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1662472203; x=1694008203; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=2vu7l/6K0nvkzNmUjyptRlngyguT+RoN4sYZnyNxAgU=; b=g8F6IIpfhCpcrGsrjNPqxntDoJ3rsmbfW+N548CpBHgHzaGmyva1nMF8 QD4f62KGH9EiunHzCTx3xVM4zG3aydEV3Q+e9HEmC9Ub0gasuSuMLUVPb Q24//Yw8gvAFf8yOekfRXGaucYeeCbfGMTy9Q5Ho5QNvtC+Bm3VeNl+Gj mi5iKzAfCuJe3FAmsg3fqi/MgSDbi5EVSVBJ9v8FlHXR3jXog91TXah9C 7ioqGUqQloXHyIQUGchmuUKR8/Lihcc/MgH7C9yozRlWb2P6u9gY/0K8F 2oMkjpmYqXJpuYFQ1ffLfQ4JnUA5EyCwQ7NF0zsfNrdapAxnpzbM3vpx4 g==; X-IronPort-AV: E=McAfee;i="6500,9779,10462"; a="322771122" X-IronPort-AV: E=Sophos;i="5.93,294,1654585200"; d="scan'208";a="322771122" Received: from fmsmga001.fm.intel.com ([10.253.24.23]) by fmsmga101.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 06 Sep 2022 06:49:59 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.93,294,1654585200"; d="scan'208";a="756372523" Received: from black.fi.intel.com ([10.237.72.28]) by fmsmga001.fm.intel.com with ESMTP; 06 Sep 2022 06:49:54 -0700 Received: by black.fi.intel.com (Postfix, from userid 1003) id 6F82145C; Tue, 6 Sep 2022 16:50:10 +0300 (EEST) From: Andy Shevchenko To: Gene Chen , Andy Shevchenko , Andrew Jeffery , 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 , Matthias Brugger , Sean Wang , Kurt Kanzenbach , Andrew Lunn , Vivien Didelot , Florian Fainelli , Vladimir Oltean , "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , Lee Jones Subject: [PATCH v3 03/11] leds: an30259a: Get rid of custom led_init_default_state_get() Date: Tue, 6 Sep 2022 16:49:56 +0300 Message-Id: <20220906135004.14885-4-andriy.shevchenko@linux.intel.com> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220906135004.14885-1-andriy.shevchenko@linux.intel.com> References: <20220906135004.14885-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-20220906_065003_445318_343F76FC X-CRM114-Status: GOOD ( 16.39 ) X-BeenThere: linux-mediatek@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-mediatek" Errors-To: linux-mediatek-bounces+linux-mediatek=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-an30259a.c | 21 ++++----------------- 1 file changed, 4 insertions(+), 17 deletions(-) diff --git a/drivers/leds/leds-an30259a.c b/drivers/leds/leds-an30259a.c index e072ee5409f7..89df267853a9 100644 --- a/drivers/leds/leds-an30259a.c +++ b/drivers/leds/leds-an30259a.c @@ -55,10 +55,6 @@ #define AN30259A_NAME "an30259a" -#define STATE_OFF 0 -#define STATE_KEEP 1 -#define STATE_ON 2 - struct an30259a; struct an30259a_led { @@ -66,7 +62,7 @@ struct an30259a_led { struct fwnode_handle *fwnode; struct led_classdev cdev; u32 num; - u32 default_state; + enum led_default_state default_state; bool sloping; }; @@ -205,7 +201,6 @@ static int an30259a_dt_init(struct i2c_client *client, struct device_node *np = dev_of_node(&client->dev), *child; int count, ret; int i = 0; - const char *str; struct an30259a_led *led; count = of_get_available_child_count(np); @@ -228,15 +223,7 @@ static int an30259a_dt_init(struct i2c_client *client, led->num = source; led->chip = chip; led->fwnode = of_fwnode_handle(child); - - if (!of_property_read_string(child, "default-state", &str)) { - if (!strcmp(str, "on")) - led->default_state = STATE_ON; - else if (!strcmp(str, "keep")) - led->default_state = STATE_KEEP; - else - led->default_state = STATE_OFF; - } + led->default_state = led_init_default_state_get(led->fwnode); i++; } @@ -261,10 +248,10 @@ static void an30259a_init_default_state(struct an30259a_led *led) int led_on, err; switch (led->default_state) { - case STATE_ON: + case LEDS_DEFSTATE_ON: led->cdev.brightness = LED_FULL; break; - case STATE_KEEP: + case LEDS_DEFSTATE_KEEP: err = regmap_read(chip->regmap, AN30259A_REG_LED_ON, &led_on); if (err) break; From patchwork Tue Sep 6 13:49:57 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andy Shevchenko X-Patchwork-Id: 12967609 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 AF4E4ECAAA1 for ; Tue, 6 Sep 2022 14:26:10 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender:List-Subscribe:List-Help :List-Post:List-Archive:List-Unsubscribe:List-Id:Content-Transfer-Encoding: MIME-Version:References:In-Reply-To:Message-Id:Date:Subject:Cc:To:From: Reply-To:Content-Type:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner; bh=3XGRNK6g52C7X/515WzTohcGM8UPH7GUkkMWKZ/Lbck=; b=Q6cc6iY42X7rrKaVHlgaU421zj T4m13nDad7u5OOWn343JIOR8O4R4WNWpPrQxsBnL775/q+KEw193jSylabnJqiyGWBriRkHwW60DK MqmzV8VlFCA/i80besxuJo/1RIOu5Rf0eO3VotWqlNGrz0ECZS/hMAvQZZ7VmbxybN/GmkrO2bg7I fkyTaeqDGM1f5L2PKIyzZrPk9GBWawZy//cZGR7j5ZWkwdqX8XiLnSR44mmR7Tzic6oA8Mh6KaHgv RSvtnHx3KXplJuU9MmicOQTIInl6b6SLw8hqHB6FH1XQDfwTWAiFWXuOIBlb9aHknq+6ZjFfyxEE2 06MYPajA==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1oVZWW-00EHWP-0j; Tue, 06 Sep 2022 14:25:56 +0000 Received: from mga03.intel.com ([134.134.136.65]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1oVYxq-00DzqO-A2; Tue, 06 Sep 2022 13:50:12 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1662472206; x=1694008206; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=LCJNwKIb2JZh9SO69nCDrOY4AomaNFhl38g2hoPWX0w=; b=biHjL2TnGofxV66Q1huIyBtpdOGMgVLFOmbfc1BztnGPmo1gy7jvgAux 1J1Bn5e/Pchc0XIe4RjYCJ6pAYp1pMcD4zuA2uFFNha0Bio8SI4MLMdDn yoI9EUXYxeF/bS+pUQIGVjTXNV7a29d/byg8wrSiJqP6CvVccHskuJ5f8 Z4lm72HmUEUorPTaMSv8Iu28Yr4SdJROuuHgaSE7dxW3oaOzxPh3626TY 0XQjOcoNxseOWmPbx48JEppJZa3XlQE9H5MP4yjwwCIb+cWnYENC3ps5A kse8vhSApsTHuXJlIM2XWCefswn/KKIDRFEH275N4ozpdb3GQQci470Lb A==; X-IronPort-AV: E=McAfee;i="6500,9779,10462"; a="297908808" X-IronPort-AV: E=Sophos;i="5.93,294,1654585200"; d="scan'208";a="297908808" Received: from fmsmga002.fm.intel.com ([10.253.24.26]) by orsmga103.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 06 Sep 2022 06:50:03 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.93,294,1654585200"; d="scan'208";a="717702899" Received: from black.fi.intel.com ([10.237.72.28]) by fmsmga002.fm.intel.com with ESMTP; 06 Sep 2022 06:49:54 -0700 Received: by black.fi.intel.com (Postfix, from userid 1003) id 7B54750D; Tue, 6 Sep 2022 16:50:10 +0300 (EEST) From: Andy Shevchenko To: Gene Chen , Andy Shevchenko , Andrew Jeffery , 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 , Matthias Brugger , Sean Wang , Kurt Kanzenbach , Andrew Lunn , Vivien Didelot , Florian Fainelli , Vladimir Oltean , "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , Lee Jones Subject: [PATCH v3 04/11] leds: bcm6328: Get rid of custom led_init_default_state_get() Date: Tue, 6 Sep 2022 16:49:57 +0300 Message-Id: <20220906135004.14885-5-andriy.shevchenko@linux.intel.com> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220906135004.14885-1-andriy.shevchenko@linux.intel.com> References: <20220906135004.14885-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-20220906_065006_450991_F9546709 X-CRM114-Status: GOOD ( 16.25 ) X-BeenThere: linux-mediatek@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-mediatek" Errors-To: linux-mediatek-bounces+linux-mediatek=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 Reviewed-by: Florian Fainelli --- drivers/leds/leds-bcm6328.c | 49 ++++++++++++++++++------------------- 1 file changed, 24 insertions(+), 25 deletions(-) diff --git a/drivers/leds/leds-bcm6328.c b/drivers/leds/leds-bcm6328.c index 2d4d87957a30..246f1296ab09 100644 --- a/drivers/leds/leds-bcm6328.c +++ b/drivers/leds/leds-bcm6328.c @@ -330,7 +330,9 @@ static int bcm6328_led(struct device *dev, struct device_node *nc, u32 reg, { struct led_init_data init_data = {}; struct bcm6328_led *led; - const char *state; + enum led_default_state state; + unsigned long val, shift; + void __iomem *mode; int rc; led = devm_kzalloc(dev, sizeof(*led), GFP_KERNEL); @@ -346,31 +348,29 @@ static int bcm6328_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: + shift = bcm6328_pin2shift(led->pin); + if (shift / 16) + mode = mem + BCM6328_REG_MODE_HI; + else + mode = mem + BCM6328_REG_MODE_LO; + + val = bcm6328_led_read(mode) >> BCM6328_LED_SHIFT(shift % 16); + val &= BCM6328_LED_MODE_MASK; + if ((led->active_low && val == BCM6328_LED_MODE_OFF) || + (!led->active_low && val == BCM6328_LED_MODE_ON)) led->cdev.brightness = LED_FULL; - } else if (!strcmp(state, "keep")) { - void __iomem *mode; - unsigned long val, shift; - - shift = bcm6328_pin2shift(led->pin); - if (shift / 16) - mode = mem + BCM6328_REG_MODE_HI; - else - mode = mem + BCM6328_REG_MODE_LO; - - val = bcm6328_led_read(mode) >> - BCM6328_LED_SHIFT(shift % 16); - val &= BCM6328_LED_MODE_MASK; - if ((led->active_low && val == BCM6328_LED_MODE_OFF) || - (!led->active_low && val == BCM6328_LED_MODE_ON)) - 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; } @@ -378,7 +378,6 @@ static int bcm6328_led(struct device *dev, struct device_node *nc, u32 reg, led->cdev.brightness_set = bcm6328_led_set; led->cdev.blink_set = bcm6328_blink_set; - init_data.fwnode = of_fwnode_handle(nc); rc = devm_led_classdev_register_ext(dev, &led->cdev, &init_data); if (rc < 0) From patchwork Tue Sep 6 13:49:58 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andy Shevchenko X-Patchwork-Id: 12967596 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 1A2A9ECAAA1 for ; Tue, 6 Sep 2022 14:18:43 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender:List-Subscribe:List-Help :List-Post:List-Archive:List-Unsubscribe:List-Id:Content-Transfer-Encoding: MIME-Version:References:In-Reply-To:Message-Id:Date:Subject:Cc:To:From: Reply-To:Content-Type:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner; bh=vutZ2JI+mmeMhK8d0OkSP0odDbfftcBz49/LOfKzAIE=; b=djmLqqPLsS8vVVT5o+LLJBS28Z RyPKFMFMbyQmUEyZsXA900jv/RJG1XkwO/Zxzf6cUKM8eoNpPE3/5uwwxjeKBNViBVnaSJWqgX26G BD4PJDQxYcCqVIJ7kbbWeOUsMjeTNpiGYRIyaYFRyHfFqI4UYnhtNe64GSP9qXLieKVsOcuWSR33Y ZjzhTmilwLhh/sQiKoTXZ23XQo/OW2reHsGFlrLf1x1Zf2kI2w/OzDzSnMhxfqEIM6ATcvSLnhmaL Ttq8S9PgH3cQn69vAN3gke1V/J+SYq3fhA7q7YbQaZQYdWBIyJmOHZdROMGlgtXcghHxvxBYr8J4G 35QKsTkA==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1oVZPN-00EE0L-KK; Tue, 06 Sep 2022 14:18:33 +0000 Received: from mga14.intel.com ([192.55.52.115]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1oVYxq-00Dzqn-78; Tue, 06 Sep 2022 13:50:11 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1662472206; x=1694008206; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=1IsTbKM8jNHxj4ziPqVComygZINDozfOXf+AY99bFeg=; b=l87i5e54XjOapp+SKm8HRzmdxtTbxZRz5i/8W19eT2xMOYfjJxSrrKoO snN05J3pzUO1OyTtNTH5W2YQaW/nsAyMolYdHuYejxbXWYScWYRgEw4OP nmrjRQvke7vihGBYsRjWwz5brdZ9TG14W5uzKXYuy3cvzmsUvLCLtPlCY jvHmX/YFRwf6yz9J4ZRAAOENkkGkkVKOMSPY8CzArngNNNtXoYXZqTCV2 TMRQhH+utNqZLISUJh4m0QIyqO9HrXrqkj0ocBykR2e02Ar0osVUIs/pg yZECQIui55k9dYcgaOb9It08ITg+G+EfIhVfJfOpYdFu0dR+7TKv5OaF8 Q==; X-IronPort-AV: E=McAfee;i="6500,9779,10462"; a="296597104" X-IronPort-AV: E=Sophos;i="5.93,294,1654585200"; d="scan'208";a="296597104" Received: from fmsmga003.fm.intel.com ([10.253.24.29]) by fmsmga103.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 06 Sep 2022 06:50:05 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.93,294,1654585200"; d="scan'208";a="703214850" Received: from black.fi.intel.com ([10.237.72.28]) by FMSMGA003.fm.intel.com with ESMTP; 06 Sep 2022 06:50:00 -0700 Received: by black.fi.intel.com (Postfix, from userid 1003) id 86D8957F; Tue, 6 Sep 2022 16:50:10 +0300 (EEST) From: Andy Shevchenko To: Gene Chen , Andy Shevchenko , Andrew Jeffery , 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 , Matthias Brugger , Sean Wang , Kurt Kanzenbach , Andrew Lunn , Vivien Didelot , Florian Fainelli , Vladimir Oltean , "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , Lee Jones Subject: [PATCH v3 05/11] leds: bcm6358: Get rid of custom led_init_default_state_get() Date: Tue, 6 Sep 2022 16:49:58 +0300 Message-Id: <20220906135004.14885-6-andriy.shevchenko@linux.intel.com> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220906135004.14885-1-andriy.shevchenko@linux.intel.com> References: <20220906135004.14885-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-20220906_065006_346275_08B7FC7C X-CRM114-Status: GOOD ( 14.56 ) X-BeenThere: linux-mediatek@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-mediatek" Errors-To: linux-mediatek-bounces+linux-mediatek=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 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) From patchwork Tue Sep 6 13:49:59 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andy Shevchenko X-Patchwork-Id: 12967613 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 8A645ECAAA1 for ; Tue, 6 Sep 2022 14:26:40 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender:List-Subscribe:List-Help :List-Post:List-Archive:List-Unsubscribe:List-Id:Content-Transfer-Encoding: MIME-Version:References:In-Reply-To:Message-Id:Date:Subject:Cc:To:From: Reply-To:Content-Type:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner; bh=IR6Jzv3DBB4LPS3wuwZKNqFeWntYIN0Fg0BDCjTo7Pc=; b=4mZmeqUArb9lgStt5iLpLH8Vmu YyMa/k1Ddbtj7yEekHGx1xXQ0SuMnjYoegmvuec2uIgxkDrEV9eKl2MCp29MIkcVyo6vKe1Ieit9x sVQZfU8W1r9cBGVKFJ2l5fMvFLuIjj69qKcrC3dRyE643CEFgsq531uElUNfRYUOTZBpsDIYaSJAz iRcx3nMA7zd97IM/dYAEPz6rvyQUITxhQCtNuufuY7c/uqlRY5k+9w3Ct9sfjLzUBCVbBY0hvsitG ow9OCiEN+EhJY8f7W2ocUouGKaKsEJthrSx2bZxNtlal3LcO8pEoS9iu2JFVUDSdhSp+kWoxPT4Rw BdTZhqfg==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1oVZX6-00EHq6-AS; Tue, 06 Sep 2022 14:26:32 +0000 Received: from mga03.intel.com ([134.134.136.65]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1oVYxr-00Dzrm-E2; Tue, 06 Sep 2022 13:50:15 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1662472207; x=1694008207; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=OunVwjFJhL1Q/tamMZepaupTRMyzPHvHM30RUkvfBQg=; b=PVAY6PhECevtaoVXXdXR/OubRwP2sN7vKsil8Y2CVD18zr/6xu6OQveY QTEgCOczSOQDvs3DSKvP7K1hVt2G3s5eT7Uo0EOZe66fBhdTr65D1Sium P9Yo5xRQuHEwo+wqMIEaGXXu7evQQcn5Kf7uH2Sjvw1CaM4QYbOQNZUS1 vOVamzJxpI4A/BSkL9AeKymF2e9gI/3EPggNRg7KCl8wmTmi4wEbpCla3 5L9kE0nkTNHGmfiyj/9nvdayJWHPkphb27FIIeqgABG3KRBuZ0iNapJIC YnyxQvyyoOkioBrJvs90JrrCZvqni2caemKa9MbhYqIeK6lyw0ZYPc4Vu w==; X-IronPort-AV: E=McAfee;i="6500,9779,10462"; a="297908833" X-IronPort-AV: E=Sophos;i="5.93,294,1654585200"; d="scan'208";a="297908833" Received: from fmsmga002.fm.intel.com ([10.253.24.26]) by orsmga103.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 06 Sep 2022 06:50:05 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.93,294,1654585200"; d="scan'208";a="717702934" Received: from black.fi.intel.com ([10.237.72.28]) by fmsmga002.fm.intel.com with ESMTP; 06 Sep 2022 06:50:00 -0700 Received: by black.fi.intel.com (Postfix, from userid 1003) id 923FE5E4; Tue, 6 Sep 2022 16:50:10 +0300 (EEST) From: Andy Shevchenko To: Gene Chen , Andy Shevchenko , Andrew Jeffery , 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 , Matthias Brugger , Sean Wang , Kurt Kanzenbach , Andrew Lunn , Vivien Didelot , Florian Fainelli , Vladimir Oltean , "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , Lee Jones Subject: [PATCH v3 06/11] leds: mt6323: Get rid of custom led_init_default_state_get() Date: Tue, 6 Sep 2022 16:49:59 +0300 Message-Id: <20220906135004.14885-7-andriy.shevchenko@linux.intel.com> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220906135004.14885-1-andriy.shevchenko@linux.intel.com> References: <20220906135004.14885-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-20220906_065007_680371_68C6DF14 X-CRM114-Status: GOOD ( 15.95 ) X-BeenThere: linux-mediatek@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-mediatek" Errors-To: linux-mediatek-bounces+linux-mediatek=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 Reviewed-by: AngeloGioacchino Del Regno --- drivers/leds/leds-mt6323.c | 30 +++++++++++++++--------------- 1 file changed, 15 insertions(+), 15 deletions(-) diff --git a/drivers/leds/leds-mt6323.c b/drivers/leds/leds-mt6323.c index f59e0e8bda8b..17ee88043f52 100644 --- a/drivers/leds/leds-mt6323.c +++ b/drivers/leds/leds-mt6323.c @@ -339,23 +339,23 @@ static int mt6323_led_set_dt_default(struct led_classdev *cdev, struct device_node *np) { struct mt6323_led *led = container_of(cdev, struct mt6323_led, cdev); - const char *state; + enum led_default_state state; int ret = 0; - state = of_get_property(np, "default-state", NULL); - if (state) { - if (!strcmp(state, "keep")) { - ret = mt6323_get_led_hw_brightness(cdev); - if (ret < 0) - return ret; - led->current_brightness = ret; - ret = 0; - } else if (!strcmp(state, "on")) { - ret = - mt6323_led_set_brightness(cdev, cdev->max_brightness); - } else { - ret = mt6323_led_set_brightness(cdev, LED_OFF); - } + state = led_init_default_state_get(of_fwnode_handle(np)); + switch (state) { + case LEDS_DEFSTATE_ON: + ret = mt6323_led_set_brightness(cdev, cdev->max_brightness); + break; + case LEDS_DEFSTATE_KEEP: + ret = mt6323_get_led_hw_brightness(cdev); + if (ret < 0) + return ret; + led->current_brightness = ret; + ret = 0; + break; + default: + ret = mt6323_led_set_brightness(cdev, LED_OFF); } return ret; From patchwork Tue Sep 6 13:50:00 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andy Shevchenko X-Patchwork-Id: 12967619 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 D0CA8ECAAA1 for ; Tue, 6 Sep 2022 14:28:59 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender:List-Subscribe:List-Help :List-Post:List-Archive:List-Unsubscribe:List-Id:Content-Transfer-Encoding: MIME-Version:References:In-Reply-To:Message-Id:Date:Subject:Cc:To:From: Reply-To:Content-Type:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner; bh=Lx2FQRVWWgw6WPYO+fmeKD7FqE4cN7FhKtaqgCAtLVA=; b=sSrD/x9gZPh4DwdIYt3kthj1Et U40Pf03xie+OokM4wnITw8aOnMgFt8RiFVqAkTEa2sHTcpgh4F+xtwVSn/f/+oPlUQCVNuiMIegAZ xQRDvQ+GUGVoStxPKguSZohDK6X6wN/ryKanrnERfh0MA4eiogACCojcjQSms4Sldz1eKZXhA6STf Cgt0tv6r0IBL3cemEyK5bAK9NuJGP7jzIDPdA28fu75In12s6OXvuYZp9WD8ZhMRlkuXubEVgfI8F nTGWhBZ39VmecxJU+wPBKdkBJRh6+J5Da933G9hsmYQWajfj/zCOoAjDPCjnRqJgryjf0uWLjYBNC UKzFl/KQ==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1oVZZK-00EIwy-FJ; Tue, 06 Sep 2022 14:28:50 +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 1oVYy0-00Dzsd-Bu; Tue, 06 Sep 2022 13:50:21 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1662472216; x=1694008216; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=6f8YWbifkD3gaKrThtIFn69fcF7c6kePJ4btJm1Xl8s=; b=fRq9TRuxMNulBiWKaR9GYlXKwV6hXjtkD029STmaDBH25hXGMxjrBNBl JRNr0p9PJBRnQSjMgDs6gqfhxLoa38RZfnQdAB4mIGZFon97sCov2BJ+3 kGx1jkoznz5D+DPFZe//Su1zdgTiek1Bc2+S696VqQypFJnARTya8HRjp i7YDGSniYzCi1PozJi3CsfYpEQ/suR/Mhtul3GTcefD9eilC58hqQwRCV qizlrD9Q5zVEFQJCvlG1pYg1VSvr+NzWuffVZTGVX7WyVLThZew7G5cBp HjJh5d49WdDtE0tOUSqDaMd/j4/ef0uT5q/eUelEz6hPF0x6z5AEnedLy w==; X-IronPort-AV: E=McAfee;i="6500,9779,10462"; a="276990327" X-IronPort-AV: E=Sophos;i="5.93,294,1654585200"; d="scan'208";a="276990327" Received: from fmsmga006.fm.intel.com ([10.253.24.20]) by fmsmga107.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 06 Sep 2022 06:50:07 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.93,294,1654585200"; d="scan'208";a="859264824" Received: from black.fi.intel.com ([10.237.72.28]) by fmsmga006.fm.intel.com with ESMTP; 06 Sep 2022 06:50:00 -0700 Received: by black.fi.intel.com (Postfix, from userid 1003) id 9E9636CD; Tue, 6 Sep 2022 16:50:10 +0300 (EEST) From: Andy Shevchenko To: Gene Chen , Andy Shevchenko , Andrew Jeffery , 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 , Matthias Brugger , Sean Wang , Kurt Kanzenbach , Andrew Lunn , Vivien Didelot , Florian Fainelli , Vladimir Oltean , "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , Lee Jones Subject: [PATCH v3 07/11] leds: mt6360: Get rid of custom led_init_default_state_get() Date: Tue, 6 Sep 2022 16:50:00 +0300 Message-Id: <20220906135004.14885-8-andriy.shevchenko@linux.intel.com> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220906135004.14885-1-andriy.shevchenko@linux.intel.com> References: <20220906135004.14885-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-20220906_065016_680506_545652C6 X-CRM114-Status: GOOD ( 14.47 ) X-BeenThere: linux-mediatek@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-mediatek" Errors-To: linux-mediatek-bounces+linux-mediatek=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 Reviewed-by: Matthias Brugger Reviewed-by: AngeloGioacchino Del Regno --- drivers/leds/flash/leds-mt6360.c | 38 +++++--------------------------- 1 file changed, 6 insertions(+), 32 deletions(-) diff --git a/drivers/leds/flash/leds-mt6360.c b/drivers/leds/flash/leds-mt6360.c index e1066a52d2d2..1af6c5898343 100644 --- a/drivers/leds/flash/leds-mt6360.c +++ b/drivers/leds/flash/leds-mt6360.c @@ -71,10 +71,6 @@ enum { #define MT6360_STRBTO_STEPUS 32000 #define MT6360_STRBTO_MAXUS 2432000 -#define STATE_OFF 0 -#define STATE_KEEP 1 -#define STATE_ON 2 - struct mt6360_led { union { struct led_classdev isnk; @@ -84,7 +80,7 @@ struct mt6360_led { struct v4l2_flash *v4l2_flash; struct mt6360_priv *priv; u32 led_no; - u32 default_state; + enum led_default_state default_state; }; struct mt6360_priv { @@ -405,10 +401,10 @@ static int mt6360_isnk_init_default_state(struct mt6360_led *led) level = LED_OFF; switch (led->default_state) { - case STATE_ON: + case LEDS_DEFSTATE_ON: led->isnk.brightness = led->isnk.max_brightness; break; - case STATE_KEEP: + case LEDS_DEFSTATE_KEEP: led->isnk.brightness = min(level, led->isnk.max_brightness); break; default: @@ -443,10 +439,10 @@ static int mt6360_flash_init_default_state(struct mt6360_led *led) level = LED_OFF; switch (led->default_state) { - case STATE_ON: + case LEDS_DEFSTATE_ON: flash->led_cdev.brightness = flash->led_cdev.max_brightness; break; - case STATE_KEEP: + case LEDS_DEFSTATE_KEEP: flash->led_cdev.brightness = min(level, flash->led_cdev.max_brightness); break; @@ -760,25 +756,6 @@ static int mt6360_init_flash_properties(struct mt6360_led *led, return 0; } -static int mt6360_init_common_properties(struct mt6360_led *led, - struct led_init_data *init_data) -{ - const char *const states[] = { "off", "keep", "on" }; - const char *str; - int ret; - - if (!fwnode_property_read_string(init_data->fwnode, - "default-state", &str)) { - ret = match_string(states, ARRAY_SIZE(states), str); - if (ret < 0) - ret = STATE_OFF; - - led->default_state = ret; - } - - return 0; -} - static void mt6360_v4l2_flash_release(struct mt6360_priv *priv) { int i; @@ -852,10 +829,7 @@ static int mt6360_led_probe(struct platform_device *pdev) led->led_no = reg; led->priv = priv; - - ret = mt6360_init_common_properties(led, &init_data); - if (ret) - goto out_flash_release; + led->default_state = led_init_default_state_get(child); if (reg == MT6360_VIRTUAL_MULTICOLOR || reg <= MT6360_LED_ISNKML) From patchwork Tue Sep 6 13:50:01 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andy Shevchenko X-Patchwork-Id: 12967614 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 010E5ECAAD5 for ; Tue, 6 Sep 2022 14:26:45 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender:List-Subscribe:List-Help :List-Post:List-Archive:List-Unsubscribe:List-Id:Content-Transfer-Encoding: MIME-Version:References:In-Reply-To:Message-Id:Date:Subject:Cc:To:From: Reply-To:Content-Type:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner; bh=EyWyGm+IWdJHu3gONzDaN2BMjaUIuSwzcpBa+jGOmM8=; b=J2f7MQrkZ7/oWwWd7TZT606SLK Olm0C3pCEb/Ypejg2C+VO3utbgBe28Hc8QbiD+tzY4qE7TUyQr9YIIuRT6B752aNyUtD8aHGCjewF IADl1O+WVR4n38UGTzxUqQnikThmnwiPA4fmmq9ZVvxDoeeqdRWGhMtpJVhhnZr4Rk6f+oUJ4HFUr RHp4yVg3XVpLInyT69HN8+oTz4AHWA3jT4Q7ssuxYJj4t5zvr8GRLsB6ay2wZk96kHbIscPqKZrhC /vfJDD/l84SKUS5aAbPWl0MAKENd1XnPDa4qHGHDdUNB1SMtZiCYpD+s7K6SwdVxxXu0Gndosq4eg EDlXlldA==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1oVZXB-00EHtU-Ku; Tue, 06 Sep 2022 14:26:38 +0000 Received: from mga07.intel.com ([134.134.136.100]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1oVYxq-00Dzqm-De; Tue, 06 Sep 2022 13:50:13 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1662472206; x=1694008206; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=VQzFMWOPVcFhsKxRl9Czr0Mhj2oriMu0x8VLNQGEUCY=; b=hcnuI2Y9OnzhMvPJzriKoCKzeg1mdcTsU+pU4YGc8zCXegRuHeyarwXf CRuKRV279QQhDn56G3WvdoS/l5jr1+mwOJROViL8H30uYgXLXD1epRv5G fHzgDVcc1lRMcqFGHuoxNaANdsFdScRg0kPV57HI0duqPhn2MyQzUJMxm cxGuFUp1eB3V/NVDRU/jjebcdYNGxQ+CrHAOa0p4zJ8zGAgf6o2JgzzZe QPjVuO59rHsXfZj2+SQLHp5LOuKfYPt2LlM5QSQow9JgZEqmoufzwJ9/u OMBv98UYc8e/WrNcplpe+8QvBaRfJeAsdD8j4LZQfk0/UFwJzaUzlehOT A==; X-IronPort-AV: E=McAfee;i="6500,9779,10462"; a="360544220" X-IronPort-AV: E=Sophos;i="5.93,294,1654585200"; d="scan'208";a="360544220" Received: from orsmga006.jf.intel.com ([10.7.209.51]) by orsmga105.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 06 Sep 2022 06:50:05 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.93,294,1654585200"; d="scan'208";a="591269676" Received: from black.fi.intel.com ([10.237.72.28]) by orsmga006.jf.intel.com with ESMTP; 06 Sep 2022 06:50:00 -0700 Received: by black.fi.intel.com (Postfix, from userid 1003) id AAD8A6D1; Tue, 6 Sep 2022 16:50:10 +0300 (EEST) From: Andy Shevchenko To: Gene Chen , Andy Shevchenko , Andrew Jeffery , 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 , Matthias Brugger , Sean Wang , Kurt Kanzenbach , Andrew Lunn , Vivien Didelot , Florian Fainelli , Vladimir Oltean , "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , Lee Jones Subject: [PATCH v3 08/11] leds: pca955x: Get rid of custom led_init_default_state_get() Date: Tue, 6 Sep 2022 16:50:01 +0300 Message-Id: <20220906135004.14885-9-andriy.shevchenko@linux.intel.com> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220906135004.14885-1-andriy.shevchenko@linux.intel.com> References: <20220906135004.14885-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-20220906_065006_561382_05D334A5 X-CRM114-Status: GOOD ( 14.18 ) X-BeenThere: linux-mediatek@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-mediatek" Errors-To: linux-mediatek-bounces+linux-mediatek=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-pca955x.c | 26 ++++++-------------------- 1 file changed, 6 insertions(+), 20 deletions(-) diff --git a/drivers/leds/leds-pca955x.c b/drivers/leds/leds-pca955x.c index 81aaf21212d7..8dca6f99e699 100644 --- a/drivers/leds/leds-pca955x.c +++ b/drivers/leds/leds-pca955x.c @@ -130,7 +130,7 @@ struct pca955x_led { struct led_classdev led_cdev; int led_num; /* 0 .. 15 potentially */ u32 type; - int default_state; + enum led_default_state default_state; struct fwnode_handle *fwnode; }; @@ -443,7 +443,6 @@ pca955x_get_pdata(struct i2c_client *client, struct pca955x_chipdef *chip) return ERR_PTR(-ENOMEM); device_for_each_child_node(&client->dev, child) { - const char *state; u32 reg; int res; @@ -454,19 +453,9 @@ pca955x_get_pdata(struct i2c_client *client, struct pca955x_chipdef *chip) led = &pdata->leds[reg]; led->type = PCA955X_TYPE_LED; led->fwnode = child; - fwnode_property_read_u32(child, "type", &led->type); + led->default_state = led_init_default_state_get(child); - if (!fwnode_property_read_string(child, "default-state", - &state)) { - if (!strcmp(state, "keep")) - led->default_state = LEDS_GPIO_DEFSTATE_KEEP; - else if (!strcmp(state, "on")) - led->default_state = LEDS_GPIO_DEFSTATE_ON; - else - led->default_state = LEDS_GPIO_DEFSTATE_OFF; - } else { - led->default_state = LEDS_GPIO_DEFSTATE_OFF; - } + fwnode_property_read_u32(child, "type", &led->type); } pdata->num_leds = chip->bits; @@ -578,13 +567,11 @@ static int pca955x_probe(struct i2c_client *client) led->brightness_set_blocking = pca955x_led_set; led->brightness_get = pca955x_led_get; - if (pdata->leds[i].default_state == - LEDS_GPIO_DEFSTATE_OFF) { + if (pdata->leds[i].default_state == LEDS_DEFSTATE_OFF) { err = pca955x_led_set(led, LED_OFF); if (err) return err; - } else if (pdata->leds[i].default_state == - LEDS_GPIO_DEFSTATE_ON) { + } else if (pdata->leds[i].default_state == LEDS_DEFSTATE_ON) { err = pca955x_led_set(led, LED_FULL); if (err) return err; @@ -623,8 +610,7 @@ static int pca955x_probe(struct i2c_client *client) * brightness to see if it's using PWM1. If so, PWM1 * should not be written below. */ - if (pdata->leds[i].default_state == - LEDS_GPIO_DEFSTATE_KEEP) { + if (pdata->leds[i].default_state == LEDS_DEFSTATE_KEEP) { if (led->brightness != LED_FULL && led->brightness != LED_OFF && led->brightness != LED_HALF) From patchwork Tue Sep 6 13:50:02 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andy Shevchenko X-Patchwork-Id: 12967611 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 080A3ECAAD5 for ; Tue, 6 Sep 2022 14:26:21 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender:List-Subscribe:List-Help :List-Post:List-Archive:List-Unsubscribe:List-Id:Content-Transfer-Encoding: MIME-Version:References:In-Reply-To:Message-Id:Date:Subject:Cc:To:From: Reply-To:Content-Type:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner; bh=e7w6baOKr4KB2PiuqgQdQHmUSuRlMcuXittrTw63Bx0=; b=eguFR2AUGkFvvyxmBGkQqPGfWg KisrwCzq2x7mKNYy7nh3VoHxtN06bCa0//ZwF7FvIyxtJZ34YsgqUoqibMsHS9htMcoMtwUYJ5xvw 0zUQsXXmBFN+sjU0Af4wH2CLVeDfgmTxgv9UVdhlnvSD7YUBm1tPt1cEiKhCA2GdnYrY5eVV2NpPA IiZzodtRmK7aBZdwfCr5wRUPQLUP1S/PHWupDXcnT9U+sxqVSq4kgg4xgrRLYaDS62WvRTV7jiFkz QQB+FrECCoCBQ8gNeWoyftN1pY3b/Ksk6JqV9lCz5c0lMrMD/LtioDu/UFfdy2yt9k955JUrA34gN 9/R5QX+g==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1oVZWk-00EHdC-Qw; Tue, 06 Sep 2022 14:26:11 +0000 Received: from mga06b.intel.com ([134.134.136.31] helo=mga06.intel.com) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1oVYxq-00Dzqq-VX; Tue, 06 Sep 2022 13:50:15 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1662472206; x=1694008206; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=hvI26OhQ+1E3Y1b+RrDqvUOiyVnslqAALa2RhHdwGbY=; b=B6Rc3imjmYx3NXgud54mYhyRUS3FSx6x0cRS3zuEGu2IlGzQ3cJBvZdv s2rq7+j1jJmySoGE+eQd6Umt58FGz7XbuknX4bO0hazztHEeojVL4DsVZ d2OcUttkN/Tvd4C9c1MtzNb9P96/aKe2QYBh9FFNE6qhJWLgHAVGm2mTc PZPSVk9P7NS4YT9Tj1zC/dzFWsQTq6NE7JhZu/qUh8ujt11GV3tpIKxfB EqZkscJ/KuIcR1GgqsPDQDvHfuSrhjvu2aOe7zgrvX6JvgkrS/jZG+PnT cRXtPssU9D31cZ0EaWJtPssUcSyLbjrIXuQOmcw15/OPsA3j7x9lhyCUB A==; X-IronPort-AV: E=McAfee;i="6500,9779,10462"; a="358311668" X-IronPort-AV: E=Sophos;i="5.93,294,1654585200"; d="scan'208";a="358311668" Received: from fmsmga008.fm.intel.com ([10.253.24.58]) by orsmga104.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 06 Sep 2022 06:50:05 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.93,294,1654585200"; d="scan'208";a="675694894" Received: from black.fi.intel.com ([10.237.72.28]) by fmsmga008.fm.intel.com with ESMTP; 06 Sep 2022 06:50:00 -0700 Received: by black.fi.intel.com (Postfix, from userid 1003) id B5018238; Tue, 6 Sep 2022 16:50:10 +0300 (EEST) From: Andy Shevchenko To: Gene Chen , Andy Shevchenko , Andrew Jeffery , 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 , Matthias Brugger , Sean Wang , Kurt Kanzenbach , Andrew Lunn , Vivien Didelot , Florian Fainelli , Vladimir Oltean , "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , Lee Jones Subject: [PATCH v3 09/11] leds: pm8058: Get rid of custom led_init_default_state_get() Date: Tue, 6 Sep 2022 16:50:02 +0300 Message-Id: <20220906135004.14885-10-andriy.shevchenko@linux.intel.com> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220906135004.14885-1-andriy.shevchenko@linux.intel.com> References: <20220906135004.14885-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-20220906_065007_099730_FCD212D2 X-CRM114-Status: GOOD ( 13.77 ) X-BeenThere: linux-mediatek@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-mediatek" Errors-To: linux-mediatek-bounces+linux-mediatek=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); From patchwork Tue Sep 6 13:50:03 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andy Shevchenko X-Patchwork-Id: 12967612 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 A7246ECAAD5 for ; Tue, 6 Sep 2022 14:26:32 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender:List-Subscribe:List-Help :List-Post:List-Archive:List-Unsubscribe:List-Id:Content-Transfer-Encoding: MIME-Version:References:In-Reply-To:Message-Id:Date:Subject:Cc:To:From: Reply-To:Content-Type:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner; bh=h1QxN/MVkmbtPgFiMVZumDBjcbxGPv7gkFEK3COMvWI=; b=VUn4110k52qIj1q4BbCcp7XqbS 5D3T4u2kMxhm/pmWQ0p1ruKV4KyhQF4fMHMzd9UxDNwFGx0U7JY+uPTlQchCt22fUmmBeTr3iyz4x htWzroHwxwL0cEfCU3v48KOzOHfzXNWaaoKW44rE59f/e4QpHwlxLLrxlZ2ZHzjQjOKZyE7AQFCpQ jr3xjnpFKnO6XW1lqJ4HCosoJqEEEcDOSlhbmYeHuJsfVHCxFfpfd/fIG4ITiFI0Tkh2Fwr8FBZ+O mSpZuRiDO92IR8PU7mhL7zqagv+2FE9XfUDg0EraS5NXH0545RyOvEIuj+VuIPbuNefI95NxTEVbf lGhgKXyQ==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1oVZWx-00EHka-8X; Tue, 06 Sep 2022 14:26:23 +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 1oVYxt-00Dzsd-2w; Tue, 06 Sep 2022 13:50:15 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1662472209; x=1694008209; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=jvEYSO7lW++ymJ0bBLH7ZRL0Q9IiAhclprxNUtYU6Os=; b=QhcGXKdoUkO8rbN06j/WAXB23IoT+V1aRtaGlyX5jWZ8pNc/liURw06W diBGaLw/IG2yOsekGghYPMXlRsg9VmziXfqaMaqg4VlQ/qTh9pQaXNXvU sW9eBfvGEx8UJ6I7Cs5gHI4k6jF0MJSRlosAUi4InDd5D2Jas635WFYao KiFML5fNTQyVDU2981og9XsWiKbTFSDqNklYFr93qcionwJyJaBYt4cnS qdnykHi1bKD6ay+duMsklXlOmOVBJ61zcLo8tN5/RtzeSoQZbzVL5KLyD ETUPj35F1iNUSTq/2MXl4WryVwPd7itlUTm3/h8Fp0Y7aFVtmFpWQfoqU A==; X-IronPort-AV: E=McAfee;i="6500,9779,10462"; a="276990324" X-IronPort-AV: E=Sophos;i="5.93,294,1654585200"; d="scan'208";a="276990324" Received: from fmsmga006.fm.intel.com ([10.253.24.20]) by fmsmga107.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 06 Sep 2022 06:50:06 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.93,294,1654585200"; d="scan'208";a="859264825" Received: from black.fi.intel.com ([10.237.72.28]) by fmsmga006.fm.intel.com with ESMTP; 06 Sep 2022 06:50:00 -0700 Received: by black.fi.intel.com (Postfix, from userid 1003) id C9088725; Tue, 6 Sep 2022 16:50:10 +0300 (EEST) From: Andy Shevchenko To: Gene Chen , Andy Shevchenko , Andrew Jeffery , 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 , Matthias Brugger , Sean Wang , Kurt Kanzenbach , Andrew Lunn , Vivien Didelot , Florian Fainelli , Vladimir Oltean , "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , Lee Jones Subject: [PATCH v3 10/11] leds: syscon: Get rid of custom led_init_default_state_get() Date: Tue, 6 Sep 2022 16:50:03 +0300 Message-Id: <20220906135004.14885-11-andriy.shevchenko@linux.intel.com> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220906135004.14885-1-andriy.shevchenko@linux.intel.com> References: <20220906135004.14885-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-20220906_065009_304586_90DA7531 X-CRM114-Status: GOOD ( 14.56 ) X-BeenThere: linux-mediatek@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-mediatek" Errors-To: linux-mediatek-bounces+linux-mediatek=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-syscon.c | 49 ++++++++++++++++++-------------------- 1 file changed, 23 insertions(+), 26 deletions(-) diff --git a/drivers/leds/leds-syscon.c b/drivers/leds/leds-syscon.c index 7eddb8ecb44e..e38abb5e60c1 100644 --- a/drivers/leds/leds-syscon.c +++ b/drivers/leds/leds-syscon.c @@ -61,7 +61,8 @@ static int syscon_led_probe(struct platform_device *pdev) struct device *parent; struct regmap *map; struct syscon_led *sled; - const char *state; + enum led_default_state state; + u32 value; int ret; parent = dev->parent; @@ -86,34 +87,30 @@ static int syscon_led_probe(struct platform_device *pdev) if (of_property_read_u32(np, "mask", &sled->mask)) return -EINVAL; - state = of_get_property(np, "default-state", NULL); - if (state) { - if (!strcmp(state, "keep")) { - u32 val; - - ret = regmap_read(map, sled->offset, &val); - if (ret < 0) - return ret; - sled->state = !!(val & sled->mask); - } else if (!strcmp(state, "on")) { - sled->state = true; - ret = regmap_update_bits(map, sled->offset, - sled->mask, - sled->mask); - if (ret < 0) - return ret; - } else { - sled->state = false; - ret = regmap_update_bits(map, sled->offset, - sled->mask, 0); - if (ret < 0) - return ret; - } + init_data.fwnode = of_fwnode_handle(np); + + state = led_init_default_state_get(init_data.fwnode); + switch (state) { + case LEDS_DEFSTATE_ON: + ret = regmap_update_bits(map, sled->offset, sled->mask, sled->mask); + if (ret < 0) + return ret; + sled->state = true; + break; + case LEDS_DEFSTATE_KEEP: + ret = regmap_read(map, sled->offset, &value); + if (ret < 0) + return ret; + sled->state = !!(value & sled->mask); + break; + default: + ret = regmap_update_bits(map, sled->offset, sled->mask, 0); + if (ret < 0) + return ret; + sled->state = false; } sled->cdev.brightness_set = syscon_led_set; - init_data.fwnode = of_fwnode_handle(np); - ret = devm_led_classdev_register_ext(dev, &sled->cdev, &init_data); if (ret < 0) return ret; From patchwork Tue Sep 6 13:50:04 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andy Shevchenko X-Patchwork-Id: 12967610 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 6CD3BC6FA86 for ; Tue, 6 Sep 2022 14:26:14 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender:List-Subscribe:List-Help :List-Post:List-Archive:List-Unsubscribe:List-Id:Content-Transfer-Encoding: MIME-Version:References:In-Reply-To:Message-Id:Date:Subject:Cc:To:From: Reply-To:Content-Type:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner; bh=zB9RCZahTy8yJATnLOpF1pfodSkHXOFYZBuM0cS+Q/E=; b=pQfLhqmDSdMope5Vxxvtvj3Ha1 cJGaqWFFQiTX9LygNFxWfg5Ul3t2le/k9vKJZiv5JH3b9X9p6booG7ys6iYW2l/oJDsii70+xZ7Xw a52ldReL38LyOM+hGidKcMmYw3ony3Q++algXWxsqg/5I1cAPB2Ka2httegj3+dXExHi/hvlAu6vL GIA5CTS8FsFmfndmrP1vMF+91laaljve2URF/L7lz4NjI0+gxw/NpbH4NFYl7Aww77HM2ckVxbQ5X VkezY95qwZqUUdTm5FJpvDzv/hF6cx730SUjqOyvpxgOo5Qi5lKL25yMMHLzVk7MfmFR07pz99FXw x34zcS2g==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1oVZWe-00EHZM-6D; Tue, 06 Sep 2022 14:26:04 +0000 Received: from mga12.intel.com ([192.55.52.136]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1oVYxq-00Dzqs-Ot; Tue, 06 Sep 2022 13:50:13 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1662472206; x=1694008206; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=WhGrjx6LzV2jk/LAfomo4zdb3Tdn1LBofxlORU1JDv0=; b=fyv/ZN0dJdALwLITnmVAFVZZsMFz0grqM4qUPkalxRv0THtaJGUUkkIG evB0rjRh7WC1zmlKm6QCIpULGiWyhsiZ5TKuXo8xkgXRhFDOnbKaaqVJo qyOclGqILlalbvb7bJd+9KdmFt0f9T4gbjP9yYt6lV16rc5fOFUbRlbf9 iflLgn1COLLEN6kNNehFFZeH0qJBCvUyHxofnmSZV+q9q+uqku454Y7YH dRXqMfOmQ56GslsGeQGjLZdWPUuIRXWroMoVS6xfSPZUxnePhmc9zWtey h2UqmwKxJkuTVGsxqoZG6ihYa/3ZqGQbIy7RX2PSKD8nDhIUz+HFGf4oN w==; X-IronPort-AV: E=McAfee;i="6500,9779,10462"; a="276334191" X-IronPort-AV: E=Sophos;i="5.93,294,1654585200"; d="scan'208";a="276334191" Received: from orsmga002.jf.intel.com ([10.7.209.21]) by fmsmga106.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 06 Sep 2022 06:50:05 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.93,294,1654585200"; d="scan'208";a="614098830" Received: from black.fi.intel.com ([10.237.72.28]) by orsmga002.jf.intel.com with ESMTP; 06 Sep 2022 06:50:00 -0700 Received: by black.fi.intel.com (Postfix, from userid 1003) id D6828781; Tue, 6 Sep 2022 16:50:10 +0300 (EEST) From: Andy Shevchenko To: Gene Chen , Andy Shevchenko , Andrew Jeffery , 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 , Matthias Brugger , Sean Wang , Kurt Kanzenbach , Andrew Lunn , Vivien Didelot , Florian Fainelli , Vladimir Oltean , "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , Lee Jones Subject: [PATCH v3 11/11] net: dsa: hellcreek: Get rid of custom led_init_default_state_get() Date: Tue, 6 Sep 2022 16:50:04 +0300 Message-Id: <20220906135004.14885-12-andriy.shevchenko@linux.intel.com> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220906135004.14885-1-andriy.shevchenko@linux.intel.com> References: <20220906135004.14885-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-20220906_065006_875154_24DBFD3F X-CRM114-Status: GOOD ( 13.67 ) X-BeenThere: linux-mediatek@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-mediatek" Errors-To: linux-mediatek-bounces+linux-mediatek=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 Reviewed-by: Kurt Kanzenbach --- drivers/net/dsa/hirschmann/hellcreek_ptp.c | 45 ++++++++++++---------- 1 file changed, 24 insertions(+), 21 deletions(-) diff --git a/drivers/net/dsa/hirschmann/hellcreek_ptp.c b/drivers/net/dsa/hirschmann/hellcreek_ptp.c index b28baab6d56a..793b2c296314 100644 --- a/drivers/net/dsa/hirschmann/hellcreek_ptp.c +++ b/drivers/net/dsa/hirschmann/hellcreek_ptp.c @@ -297,7 +297,8 @@ static enum led_brightness hellcreek_led_is_gm_get(struct led_classdev *ldev) static int hellcreek_led_setup(struct hellcreek *hellcreek) { struct device_node *leds, *led = NULL; - const char *label, *state; + enum led_default_state state; + const char *label; int ret = -EINVAL; of_node_get(hellcreek->dev->of_node); @@ -318,16 +319,17 @@ static int hellcreek_led_setup(struct hellcreek *hellcreek) ret = of_property_read_string(led, "label", &label); hellcreek->led_sync_good.name = ret ? "sync_good" : label; - ret = of_property_read_string(led, "default-state", &state); - if (!ret) { - if (!strcmp(state, "on")) - hellcreek->led_sync_good.brightness = 1; - else if (!strcmp(state, "off")) - hellcreek->led_sync_good.brightness = 0; - else if (!strcmp(state, "keep")) - hellcreek->led_sync_good.brightness = - hellcreek_get_brightness(hellcreek, - STATUS_OUT_SYNC_GOOD); + state = led_init_default_state_get(of_fwnode_handle(led)); + switch (state) { + case LEDS_DEFSTATE_ON: + hellcreek->led_sync_good.brightness = 1; + break; + case LEDS_DEFSTATE_KEEP: + hellcreek->led_sync_good.brightness = + hellcreek_get_brightness(hellcreek, STATUS_OUT_SYNC_GOOD); + break; + default: + hellcreek->led_sync_good.brightness = 0; } hellcreek->led_sync_good.max_brightness = 1; @@ -344,16 +346,17 @@ static int hellcreek_led_setup(struct hellcreek *hellcreek) ret = of_property_read_string(led, "label", &label); hellcreek->led_is_gm.name = ret ? "is_gm" : label; - ret = of_property_read_string(led, "default-state", &state); - if (!ret) { - if (!strcmp(state, "on")) - hellcreek->led_is_gm.brightness = 1; - else if (!strcmp(state, "off")) - hellcreek->led_is_gm.brightness = 0; - else if (!strcmp(state, "keep")) - hellcreek->led_is_gm.brightness = - hellcreek_get_brightness(hellcreek, - STATUS_OUT_IS_GM); + state = led_init_default_state_get(of_fwnode_handle(led)); + switch (state) { + case LEDS_DEFSTATE_ON: + hellcreek->led_is_gm.brightness = 1; + break; + case LEDS_DEFSTATE_KEEP: + hellcreek->led_is_gm.brightness = + hellcreek_get_brightness(hellcreek, STATUS_OUT_IS_GM); + break; + default: + hellcreek->led_is_gm.brightness = 0; } hellcreek->led_is_gm.max_brightness = 1;