From patchwork Fri Aug 5 15:48: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: 12937462 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 6A18EC25B0C for ; Fri, 5 Aug 2022 15:51:27 +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=1pRszFWMO9cM5hiV+YKHn/Ov8to69xKGvGnM9umiguo=; b=iZpufHhyNaYcIU oIfwFxX2vcn/3MnmdGD+/nb0LFFd9Or5Eh+tyA4YTLSer0szDWGhD0I0kRQFRI+20lbT4wzkdeZMc xkksUlrNMuvGBLbhwthg98iK3XXqOnojzM1C7Abd2Ca0wfFmJQ+8LHB0Zx61jIx3jBH/LFK142DIm 0ZNzi0yECDb/WyZsi1AxPUEmvjzTNqMxyX/5wBtxfvPb+KHlDVkwLhSYdznhAIhk+DVCbnwyNl4zA 3jZPy4FzwLYzRm6lecA2eSYLBf9zJQzblWuTkXJDmsescuXgdvQOvvajxYhrX+VFXML4h4Uzq8d3y ht17gTAYi1YwRtz0ZdLw==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1oJzai-00GQsu-KD; Fri, 05 Aug 2022 15:50:25 +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 1oJzZc-00GQAu-9m; Fri, 05 Aug 2022 15:49:19 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1659714556; x=1691250556; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=b85nclneF9BX61RtcZxdbpTMJV7DSQfjZ+m4p4X2wC0=; b=YMcgYAjR2DYR4apILOKV1JBUokCKRLklir3fEnab/QV+UTWqBEVCAbWj EwN3U/9jczfqCMFkr9VXehhCsLhWUwra+zEH/xXZvkXgDreavvAvs+WJg B32z0w0Hug751kQrf+PYp7FnkM2qwJ68nBBEfjnz+52KeXr2LmbWxVfqW +Cl2/mpurAT+OW+Wylc9eFW7Xn8+pPMAWXx9bV3bMKKppqmMBGDaqPWlX 4EHNlSvztsu+cZJuDgqPYbRJmV9YrZkMmVUiP3GLnrzlzyXOvTgBDa0J3 q6gKIDww7pxtwwLXIDT5AK1BMIIKJHElMzXViajtooIx6xQEjwWsl5ehB Q==; X-IronPort-AV: E=McAfee;i="6400,9594,10430"; a="316120606" X-IronPort-AV: E=Sophos;i="5.93,216,1654585200"; d="scan'208";a="316120606" Received: from fmsmga005.fm.intel.com ([10.253.24.32]) by fmsmga101.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 05 Aug 2022 08:49:11 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.93,216,1654585200"; d="scan'208";a="931271130" Received: from black.fi.intel.com ([10.237.72.28]) by fmsmga005.fm.intel.com with ESMTP; 05 Aug 2022 08:49:05 -0700 Received: by black.fi.intel.com (Postfix, from userid 1003) id 94660D9; 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 01/11] leds: add missing includes and forward declarations in leds.h Date: Fri, 5 Aug 2022 18:48:57 +0300 Message-Id: <20220805154907.32263-2-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_084916_458470_2F751650 X-CRM114-Status: GOOD ( 12.77 ) 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 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 Fri Aug 5 15:48: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: 12937458 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 6BBC4C00140 for ; Fri, 5 Aug 2022 15:50:22 +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=GWSwGFZLo+Ee4qTdqwVPoWn3OTbe3XjEZ/iloyChPPI=; b=xY2mexOvBsMTIh lx5OZo8qugBpla9d/mWG8W+jQG/7n6PBgRg9b9S3hz3wQLKGAB7znq/O6RfpSoi6qDAPmBtdAfRdL aLbmV1iq3JFckAR5Bwj9ZmZsyR6ZkseQ+N2FNs6NU/KSZtHxEpCLP1+J5yaLYqp1WZs6YllpM0vwO zBUwTbqzue2LVVM+1NdV5JO+gzrKSu3K16CohDlmcd/tXhommRZwAe+noXSSOZqlTE0K8qABP+DQT +wwGFs6aX4pJTM6q8AcBgDm+hCeQ7VqSfhJKWv6gpBtpnl/OpEu48r+iuxQ36TeFnwTgBWx16v0cq jXNel9aOrdFDxwUoLsgg==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1oJzZh-00GQFl-8I; Fri, 05 Aug 2022 15:49:21 +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 1oJzZa-00GQAi-Ck; Fri, 05 Aug 2022 15:49:15 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1659714554; x=1691250554; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=NEeFuL7s2HGlJGPjMrfp/6jwPjBk7uYpbdHP2kx39AA=; b=UN85D6cedeSjCr0zZI1HJkONBXtj8G011ePFStuqLv0y8TTLLPQqh2JG yDselZhjQs25kAr7Hmu0eU0seAP8pJbj9KSkNDTPQ7nZqzl/z19mz3mX1 kKo5vbTZF3Q2f217WSjTfWotuFzrx3b4vKOCzaZgzyRUDqjJKQsjg6ut3 DAz8ieweQOVf/L7zubqOILHcNyN6b9Vv/iMdnJeIKL91qz6GwrpAsQC4O R0pQFbSOjHMDohdlMhk6998kUCkKdxiOMtP3roerV+RSyG8MPgOXscET6 PcKC0xL0i+57T/BBT8R0llbTvrJAPy72PXlcmS59n1PGT1hMzTsQeafb7 w==; X-IronPort-AV: E=McAfee;i="6400,9594,10430"; a="351943660" X-IronPort-AV: E=Sophos;i="5.93,216,1654585200"; d="scan'208";a="351943660" Received: from fmsmga003.fm.intel.com ([10.253.24.29]) by orsmga104.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 05 Aug 2022 08:49:10 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.93,216,1654585200"; d="scan'208";a="693037566" Received: from black.fi.intel.com ([10.237.72.28]) by FMSMGA003.fm.intel.com with ESMTP; 05 Aug 2022 08:49:05 -0700 Received: by black.fi.intel.com (Postfix, from userid 1003) id 9D8FC11C; 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 02/11] leds: Move led_init_default_state_get() to the global header Date: Fri, 5 Aug 2022 18:48:58 +0300 Message-Id: <20220805154907.32263-3-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_084914_496054_C4954562 X-CRM114-Status: GOOD ( 12.95 ) 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 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 Fri Aug 5 15:48: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: 12937459 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 33AA5C25B08 for ; Fri, 5 Aug 2022 15:50:34 +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=7NKxjfL1GzKsu0sQudg3Oi5UDe/ybFSnaPmrNv2RS7o=; b=2DAId0qlG8tVuk BegtU0e4Xyyh+iMJr/kRG8bCem8f+Yr9fzSXYZ1KqwZ2utHQ7V6ZWZyzEikQUndnCaUfArH6H0AtE pAOyqBQ9BX1KwZk/L7P5HNfj2kFb9hzk9i9y0ujtafvmL9kmx+7UPq7c3RBwdJIqwAiZW8dL6OLOc sVD699YvIGfC0+1Rv9bEwywEsoK952or03ew9Fa1aIN3eSdw/OHK5g5ZRQQRk1/mvsnBryNHjUWkc TQ0sfAzui8hmYrtaL+XW1PL1amYdxu5LhxNlCfG/w8JhfZpiE3eZGW1LOhq58aZ9JaflC1ZzpuDPo c4r4Gtg1owQI+7gaPe2Q==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1oJzZt-00GQOK-C7; Fri, 05 Aug 2022 15:49:33 +0000 Received: from mga09.intel.com ([134.134.136.24]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1oJzZa-00GQAj-Gl; Fri, 05 Aug 2022 15:49:16 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1659714554; x=1691250554; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=nHnWOVfew8TcWbs/bmlCO+Rb3gJGgB68Y5o1rear14Y=; b=gQHJzDoGI2K1KZzab3ed1D7o4FF7HykSwpVMDlgWz8K5ffvekYWT1bqy ubgAtnF8iP+w9PKCIaEZ9kGI+h6mpxrdru9vUbVLyaY8esYrlzs9HJW/1 8UXx57QiY+aVGKtWfEp3lO+WT+S7psqEeWMDonLspcFOJINWhqITexXNU tGerpKwDeFXxQBhkyrGewRTTPKdFo2vcqm5UoCYBNRbMz02edEUjfLwkg FnF8mEguKsTr4BDtBjgRWkoSwDywmHuBM1+kBtwz+IauxMZqpb7EbwNHI bZ+wKXgsxPXIoF5zJxTqdIMzgA+V20Q9bbHnKT23euhgELQwHautLGZgQ w==; X-IronPort-AV: E=McAfee;i="6400,9594,10430"; a="291003131" X-IronPort-AV: E=Sophos;i="5.93,216,1654585200"; d="scan'208";a="291003131" Received: from orsmga002.jf.intel.com ([10.7.209.21]) by orsmga102.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 05 Aug 2022 08:49:10 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.93,216,1654585200"; d="scan'208";a="603631124" Received: from black.fi.intel.com ([10.237.72.28]) by orsmga002.jf.intel.com with ESMTP; 05 Aug 2022 08:49:05 -0700 Received: by black.fi.intel.com (Postfix, from userid 1003) id A69711D0; 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 03/11] leds: an30259a: Get rid of custom led_init_default_state_get() Date: Fri, 5 Aug 2022 18:48:59 +0300 Message-Id: <20220805154907.32263-4-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_084914_646040_FD96E440 X-CRM114-Status: GOOD ( 15.11 ) 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-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 a0df1fb28774..d7db47cf859b 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 Fri Aug 5 15:49: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: 12937483 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 BD75EC3F6B0 for ; Fri, 5 Aug 2022 15:52:19 +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=2piQYBZaXPTQaU8aGb+/rjX8mAq5qG5XAPzQ8foZf9I=; b=TbrUpZXjK4TTdn 5GGoEH1guX9Krnga6LPOOIPNYrWrXZRgOXxRd2cduXoXJjSgzvfMvGVU85paCFxd+Yi8EGM16RV9Z 6RIlaGZ6f4zP3BahuBBKRlvmLgol52kosftRu1Arsr+4H/tPJa5K5n+wprnquGmcIxjZ79mybUXhM Au6gVu97ylbaecAieOzL+90QMjyzPyT11wLe9Y5x/uMxCYK/NvHUmlARMHYNlMyPd/hnOWjvrxl63 QKslF+T8JmMQIiwDHS8JvLHC4OerIjLfVe2ELwl3/r60ScCb2e/qbgmM8bpf4/Jx6iwJM0jwNHbGK ooNuEJjLaxQpoUbTMdBg==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1oJzbU-00GRRe-Mc; Fri, 05 Aug 2022 15:51:12 +0000 Received: from mga09.intel.com ([134.134.136.24]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1oJzZc-00GQAj-8C; Fri, 05 Aug 2022 15:49:20 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1659714556; x=1691250556; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=LCJNwKIb2JZh9SO69nCDrOY4AomaNFhl38g2hoPWX0w=; b=lA7TxeLnUugM0QJBbRSM6Ryxh+UXgilgkULGY1AjvqSUByy7GRRNYMN3 ZiIJQj6kNB4D2k4ji3D9h3qR01DAEbBPbPV2qBE5EYFUYlxsl3UvV0mRU FnIDI6GNxGgSng4DQPI0eQDHFdSpz7Gn9bWIggK9AqkOK1RO0dzQydq40 RpuTeyzm6rpb0/oIGhIkdmsZ5IAF+u3u4FkJpZR+u710M/7zWndKjXv3T Obo1FWlhZfaOX5M6dV2spZ6YF0/l9/+BzfHGPDbbX7Sly5BNMvA1cHJYm Beb3Ue5Iatap5jtis/G+DQ9R1IcePZk2xlVOPnQF3UN+TKYujIGzcQ8zf g==; X-IronPort-AV: E=McAfee;i="6400,9594,10430"; a="291003129" X-IronPort-AV: E=Sophos;i="5.93,216,1654585200"; d="scan'208";a="291003129" Received: from fmsmga004.fm.intel.com ([10.253.24.48]) by orsmga102.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 05 Aug 2022 08:49:10 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.93,216,1654585200"; d="scan'208";a="671727790" Received: from black.fi.intel.com ([10.237.72.28]) by fmsmga004.fm.intel.com with ESMTP; 05 Aug 2022 08:49:05 -0700 Received: by black.fi.intel.com (Postfix, from userid 1003) id AFA151DF; 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 04/11] leds: bcm6328: Get rid of custom led_init_default_state_get() Date: Fri, 5 Aug 2022 18:49:00 +0300 Message-Id: <20220805154907.32263-5-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_084916_412897_D6B480D4 X-CRM114-Status: GOOD ( 15.79 ) 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-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 Fri Aug 5 15:49: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: 12937461 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 A87ACC00140 for ; Fri, 5 Aug 2022 15:51: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: 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=+wASZY2swmOp/jRIb91+UJY/D9PIO5zrJTOgDB7V3Kg=; b=lu3OANpWhFNgDO OL10s7pXUghbN1O94ZcJWeWT8hWzQBj/HFOhsRcH7DnePwcP+V0cbhbbrLBkYYfbcgnPkXZ9hnaux oc+Xr1ppSQx/fWHDSOnDTNBEG0beDP8A8HxkGanvkNeT8c2Fmggh8s72Lhpv5LCFpR2Jmr0UbXWK6 otMNluTisGpl7pjU7p5xXtpLWT2qE6R+lgtp5a1sZqzpYAVpJncHaR36UUoYXCFA6pbiURa2CF5hr ZHn5tniFmZvH6gNlIPAUOLm75sicEt9Y4zahhbPLTpqlqFxaQg8W53Y6gMUOY8FrOQMbBNcxSli0m PAVuMaVFwUVqfXyA8gGg==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1oJzaP-00GQfZ-Mb; Fri, 05 Aug 2022 15:50:06 +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 1oJzZc-00GQE1-A6; Fri, 05 Aug 2022 15:49:17 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1659714556; x=1691250556; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=1IsTbKM8jNHxj4ziPqVComygZINDozfOXf+AY99bFeg=; b=T+4kcgxqSchOdDxr/wPUz19NRr7Z7aqqH1IVL+dBpzHnoge9HXdtiCWU fy65ae//p4XQOUgiO414HrLhTtHiOrLQkrYj3m8SUb8JT7Rw8n9hz5TYh uR9Oo2GXLNKTkVSu2ufaDv71DfYHDSDpJuWkxU8HpMQyaED2lSsmFDeT0 H2Q2YKNk9lwoEP8eib3S0/hSh1bYPNs6Lecdsvc9ZIUvLMd/u3zeH55a4 WZ3AYwF39ukUcR323kGPgWzE3ZjqHbDrkj8W0pBhm/ui0ia+lQI37da0J KxvDujPfMbt3Dg4LhhEODhpSmUY4gck2uyAejyHplxswOjNbt3IWrLtrV g==; X-IronPort-AV: E=McAfee;i="6400,9594,10430"; a="316120622" X-IronPort-AV: E=Sophos;i="5.93,216,1654585200"; d="scan'208";a="316120622" Received: from fmsmga005.fm.intel.com ([10.253.24.32]) by fmsmga101.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 05 Aug 2022 08:49:15 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.93,216,1654585200"; d="scan'208";a="931271163" Received: from black.fi.intel.com ([10.237.72.28]) by fmsmga005.fm.intel.com with ESMTP; 05 Aug 2022 08:49:10 -0700 Received: by black.fi.intel.com (Postfix, from userid 1003) id BCCB5303; 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 05/11] leds: bcm6358: Get rid of custom led_init_default_state_get() Date: Fri, 5 Aug 2022 18:49:01 +0300 Message-Id: <20220805154907.32263-6-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_084916_424536_39777CDA X-CRM114-Status: GOOD ( 14.47 ) 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-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 Fri Aug 5 15:49: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: 12937488 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 17B65C00140 for ; Fri, 5 Aug 2022 15:55:56 +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=wCMA6R5Hyv8UbEsrm1DuIaTvfVoYa99BKLWjmE5L6d0=; b=yRVRUOP7qpnDdJ 3rugggx11IEV9Euwd+2XRybc1UyyNdxe+IkvsJGv+nJpSJzxzURFJnzM00ocruHrg+fQuIJLF+7V2 xJlY1WX85kOHVvujDjNm61vW6wgutW7IUXXBqkuJqBVwdK2SI148LX6Ppa6S8RKjDPo9ff+y+Lfr9 SstsryVr6RndhZcP/LCALQiYy8EOahvhWW8x3mOYuFq7gDfq1B8oAiJw68eao7XUQMvV6+y6zI4ig 8USeShHlQuyXu0onOCTOxxM8qpSXlKS30ube9JuilZiBmYOkTfIVqp6n7+8B/SWT/JIuS8jLCw97T SZBOLV4QN4Yp4dsCrQSA==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1oJzev-00GTqY-VW; Fri, 05 Aug 2022 15:54:46 +0000 Received: from mga04.intel.com ([192.55.52.120]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1oJzZo-00GQLd-Ed; Fri, 05 Aug 2022 15:49:29 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1659714568; x=1691250568; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=OunVwjFJhL1Q/tamMZepaupTRMyzPHvHM30RUkvfBQg=; b=RzkCwn+LJAI35cNKKjuaKnGSUAQaHauyGrjcwnlCFsjYpuVXRjh7fZqg vPn45ZYRUKQEd2X2yubyyyh55nGAm/MZutdPtjI/Jyltro3d44iEL6FYG SGhcSse+9mp2OAGNyaPKbabsdBUzestHmyRuDFH8W/TKXyjcLW+3n1+ZO TNtZTN2BGj0sxAf5Tu5dzeUGM3gKEur2KDq6Lr1QZDpkD9tMtkW+xOXDe 2jMiWbMlzGnx29acSQiKBu2GBSMokEDGlF3uLz46EigKB4CAfktW2GqxY 2dWvzcYfq9gul1trUWFbXBn8TnqJvmxxMvpqJs1c5Re6sLgtG1hMYjs/S g==; X-IronPort-AV: E=McAfee;i="6400,9594,10430"; a="288988428" X-IronPort-AV: E=Sophos;i="5.93,216,1654585200"; d="scan'208";a="288988428" Received: from fmsmga003.fm.intel.com ([10.253.24.29]) by fmsmga104.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="693037586" Received: from black.fi.intel.com ([10.237.72.28]) by FMSMGA003.fm.intel.com with ESMTP; 05 Aug 2022 08:49:10 -0700 Received: by black.fi.intel.com (Postfix, from userid 1003) id C8674347; 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 06/11] leds: mt6323: Get rid of custom led_init_default_state_get() Date: Fri, 5 Aug 2022 18:49:02 +0300 Message-Id: <20220805154907.32263-7-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_084928_587908_C8F7E9CE X-CRM114-Status: GOOD ( 15.02 ) 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-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 Fri Aug 5 15:49: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: 12937487 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 3723DC00140 for ; Fri, 5 Aug 2022 15:55:09 +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=1lhLqXkMWRrpE2aDCZ2m/tqh+b57onMaQf2fHBrDqOs=; b=Zm3yOh5N9CixPo AqKOw0pBW6F6naSnaXJhM3E06uKDYWDw0rLkq437Ecb+pTJkZT7Sz8A4kt57v4AfntJ+fo8yizCQy FX1zzxTHXhMzCQEVbOMjfrqWY5ttw40NHt97ZcFNYx8V/j2XIk7DF8Lo8qRfT0xjQ+NJSoOLYB6gN P96VYuNrsdQ2JdHXvwaeUzTDP1HM+xOiC6fcmZkA0HylZclcDNq6RrjY6wHnLKUJTn0TkwjfWYDIr B9gAfHcu2ucBu52/IT/JCh5kkliz5aGYIQNR5c94S2YvvMNXwM3n3yFMPX9JdCgTYeNpL+eqRQK9z c1nvSadkX3uwHHOylnSQ==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1oJzeD-00GTPW-Nw; Fri, 05 Aug 2022 15:54:02 +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-00GQJM-IU; Fri, 05 Aug 2022 15:49:23 +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=6f8YWbifkD3gaKrThtIFn69fcF7c6kePJ4btJm1Xl8s=; b=jQN5gKG08On0/qGMFHAOUb5VOcK/8RElClzgK9GtAkUpWJdEjADy4CbQ 2yXyZLQX9qrWvII1Nv0YjkG5b1QZqO0JMO2d6ZpbRn1beeT9uZqCqRIpf CUFPfXIQTSJLuLyO36Kbu5Gez6qKAbFu7hWGJWtzBngj+Dqi/fTY/D1Gy 9Wi2DBAzgSBd5bSC5rCIyjVWnJOuz1uvE/ZD7g7szUlmh7g5oBUPJOGO8 x2IZtDX0rk+Et68sMmdi7nGc5LccXlaL2Ws48paxSSMlyGFe1l4fJPlOC GOKCIojn5RUfL6hu1DQ2EQnLSW+G3gmKw0fBO1fmW5/yVLgvExcTjOT40 w==; X-IronPort-AV: E=McAfee;i="6400,9594,10430"; a="270608790" X-IronPort-AV: E=Sophos;i="5.93,216,1654585200"; d="scan'208";a="270608790" Received: from orsmga003.jf.intel.com ([10.7.209.27]) 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="554142979" Received: from black.fi.intel.com ([10.237.72.28]) by orsmga003.jf.intel.com with ESMTP; 05 Aug 2022 08:49:10 -0700 Received: by black.fi.intel.com (Postfix, from userid 1003) id D4D10417; 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 07/11] leds: mt6360: Get rid of custom led_init_default_state_get() Date: Fri, 5 Aug 2022 18:49:03 +0300 Message-Id: <20220805154907.32263-8-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_659486_22AD6211 X-CRM114-Status: GOOD ( 14.88 ) 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 Reviewed-by: Matthias Brugger --- 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 Fri Aug 5 15:49: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: 12937485 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 B5DD9C00140 for ; Fri, 5 Aug 2022 15:53:47 +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=QW9nZL8mGbNqHxl+eopbmJrB65PZ7msUmBdqfU5cXmM=; b=PY0eSYo4RD6aEN vo8VHOnaPBt+Cj1lxdWRnDq2lAcd27xVLp/gWs1gFgnm8eEZLdirH+TNytUCAF7e/d2+I2uvYVxV0 UD2vqD/NjsGMvgj9ivW1xGAQiK9cAvheehihnKJZq99vZBLwJt+maHJXFp8lgoAVoLAQm+aFRuZrG EBAUywXYxv5Me9stTLgoTi9xTcc+uAB/tX7nN39I8oDcFMpaaD9F/JahM1VpZeGiiwNqFmAx6VArj Ih5d3PD9+GRd6O0wCzdGM9jkqalG3Z7Q/6vwu6jwXWTpDtkfTh1ZZFZo16wPnQ2oXM6Yb3eoRwDVd A3/y75KLXYG7zTZs4j/A==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1oJzcm-00GSPS-Rw; Fri, 05 Aug 2022 15:52:35 +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 1oJzZf-00GQFY-Hv; Fri, 05 Aug 2022 15:49:21 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1659714559; x=1691250559; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=VQzFMWOPVcFhsKxRl9Czr0Mhj2oriMu0x8VLNQGEUCY=; b=KS87/PFud5pn+W3b/ZGkNaAFFOhS+7ErxiCgAsquYvk/4xfX+AnVxzXY r4nc+d7rds2DqWFpy+5pckwr+5jSmBvLhSB9sgWkSS0+2+iyWcNZjXqar 1xX8pwnJkImSTxvufnZ1up0ZXtttLOyoWPh1chOQ4ImUKQUenhnOn2JSv UvONSKeK/Ol/WAH18tLlmFL1/gJBukFLvMF+AKc86RPHF05nBpt177qV5 9TMQH65jerJYe+1sRzdPQ8PZt2HaZ+fmqostP8EBptAvt68vP03IVU7aC G6UCj6c08vpNE5VkIK+24AhYbfctcoapYvrucA00L+hVxspQbqzMq4H22 Q==; X-IronPort-AV: E=McAfee;i="6400,9594,10430"; a="270608785" X-IronPort-AV: E=Sophos;i="5.93,216,1654585200"; d="scan'208";a="270608785" 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="600399032" 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 E0D9141F; 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 08/11] leds: pca955x: Get rid of custom led_init_default_state_get() Date: Fri, 5 Aug 2022 18:49:04 +0300 Message-Id: <20220805154907.32263-9-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_084919_637670_6A0B3CBD X-CRM114-Status: GOOD ( 13.62 ) 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-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 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); From patchwork Fri Aug 5 15:49:06 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andy Shevchenko X-Patchwork-Id: 12937482 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 73F23C00140 for ; Fri, 5 Aug 2022 15:51:58 +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=KzE6i8ajJnH6H25Dxi6rywZ3TMUuYv+j2aAzl0WDa1Q=; b=UVPqQBYzToIQUp E3P7HIC6LaTbn1fUbA9FmcxRU+fKBIf9yS9F4YJXtXdoGJWtChIxN3hPm0dDntlnkPzhZEU5CEdmW 9mAh+pwMv2Y8JZVtkj+C+qLYwqf4WKhuDyHVcdXxIIxo7n1GoNJv+xXlPidVVnp/11Bs6C7l9fDCj tl8hkaxr0EkEWsEF2TQ4mkwKnAAHrIhSxrGpPtOiOQhFehCNm1x8GmADPeIMdBU+LttRgEWaSDhpI y/UjAJeuUaNSUYFNcQa/Ad3wSd8PQ62H8w8tdP+cShiEPL8es84q3oP0gsMDuuSkzVaVh1FlT1yHK OyNBYofDJAeJ8ZN1FwAw==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1oJzb6-00GRAx-78; Fri, 05 Aug 2022 15:50:49 +0000 Received: from mga05.intel.com ([192.55.52.43]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1oJzZd-00GQED-T0; Fri, 05 Aug 2022 15:49:20 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1659714557; x=1691250557; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=jvEYSO7lW++ymJ0bBLH7ZRL0Q9IiAhclprxNUtYU6Os=; b=k+Q37mw0fhr06w4It0UVo6zrRbeoai3Z5yjp7ClljP6AO5jYhph/jX50 jdss+q1pAnf5H7AxI7VVKU9PQDZzi5lqlN2clNNejMi2jhLm/ZFb27kCb 8uFNjOOoUvS3YakHwx4uo9pDGTCN78ZqSTHEoIqaM44seehoNrguPwysE 2MOJm7EEoNiF7sTSek67HAubymRfiqllByNI851/Mjo8+p+KA8b5B0wZF bzCaDkYrYYK3/BVf0FlvhlKR9iY4EtxUhHUFH+J4n+S1Xyhh2EVDnQ37i KzldRggQ54YIrq0C6p0siCdM2Hxb4a06P6EBW0sMka5gC+cDnFVEFrEUO A==; X-IronPort-AV: E=McAfee;i="6400,9594,10430"; a="376523448" X-IronPort-AV: E=Sophos;i="5.93,216,1654585200"; d="scan'208";a="376523448" Received: from fmsmga002.fm.intel.com ([10.253.24.26]) by fmsmga105.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 05 Aug 2022 08:49:15 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.93,216,1654585200"; d="scan'208";a="706647818" Received: from black.fi.intel.com ([10.237.72.28]) by fmsmga002.fm.intel.com with ESMTP; 05 Aug 2022 08:49:11 -0700 Received: by black.fi.intel.com (Postfix, from userid 1003) id 0458B58E; 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 10/11] leds: syscon: Get rid of custom led_init_default_state_get() Date: Fri, 5 Aug 2022 18:49:06 +0300 Message-Id: <20220805154907.32263-11-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_084918_053732_A3043A39 X-CRM114-Status: GOOD ( 15.49 ) 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-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 Fri Aug 5 15:49:07 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andy Shevchenko X-Patchwork-Id: 12937484 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 8D43FC25B07 for ; Fri, 5 Aug 2022 15:53:00 +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=8gAjaA2IHWXkiUz8gLORtGKcGnv0BWZmgKcXYVlVjS8=; b=cZhYA7tfNji/ra zaXJVqUEoDl5fEyCgMuGbzVRc14k0/AmwLJAd0GKXou2pZ3yPpSuCCnvGzz6MaD/YGletHzeaGddq hlR+PoXJS1w7TKBZ0GkuSBiZrVYWwhwbd5T10dga+KYJmMHxKs8V9Ohv3/tHPOsQieQvaheWCXOuc RpB1eg6tNs7XjNcCQtLSgKCbdxM6Gu/HnKBV/tdEWKXaQblbp1KHZyKupy1zLxFhFGDm2hFrq9Ce7 9/ri5QfwjTJrdvZpaSHnSOciC+5/YSsYZ1xlczXeL772ZAd1Gb8hcNpHSRAt2q/Z+J4TZMRxU7Tss QjfAMxjf8m5EDzelB8jQ==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1oJzc0-00GRnP-Fk; Fri, 05 Aug 2022 15:51:44 +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 1oJzZe-00GQEG-3A; Fri, 05 Aug 2022 15:49:20 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1659714558; x=1691250558; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=kK0hPRdSyvWlZo38p4QMgn/ySqgObmyyzYJGxFidk7g=; b=Qnt+8NEkI9qxk2kTr2GcyCoErBD2G4oUa9yfwnubeei6SrNr/i27y3Re pmyYaDtqMpxyzLfiKH3V+EYUDcqlBG2JD0rXgHv4Ly3leVhMRZ82oqxCN BE1enzJM9I3HV/sPzomsNwhwkKgLk2YU4fuwKV1oNErx7AcIog2kynMiO wznFdUHQ3AnSoWu/mjalgCrmlG7aI32wcGbh3OOO8XRYO7xgg8Jkl0452 flvXgb2sUv1E6jBO0YWVwfa+fQCL+vc5ChuoqQbaLAUlFxMXg7FdMqZ8S Gbx9+q065U0/GcONrYqHluXKr4hU9HucD3FbEAw8jMX9/fkMAvBCZbj2h w==; X-IronPort-AV: E=McAfee;i="6400,9594,10430"; a="287794487" X-IronPort-AV: E=Sophos;i="5.93,216,1654585200"; d="scan'208";a="287794487" Received: from fmsmga001.fm.intel.com ([10.253.24.23]) by fmsmga102.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 05 Aug 2022 08:49:15 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.93,216,1654585200"; d="scan'208";a="745891350" Received: from black.fi.intel.com ([10.237.72.28]) by fmsmga001.fm.intel.com with ESMTP; 05 Aug 2022 08:49:11 -0700 Received: by black.fi.intel.com (Postfix, from userid 1003) id 0FAF764F; Fri, 5 Aug 2022 18:49:17 +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 11/11] net: dsa: hellcreek: Get rid of custom led_init_default_state_get() Date: Fri, 5 Aug 2022 18:49:07 +0300 Message-Id: <20220805154907.32263-12-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_084918_218306_5C98E086 X-CRM114-Status: GOOD ( 14.69 ) 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 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;