From patchwork Tue Jul 12 10:08:27 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Vincent Knecht X-Patchwork-Id: 590181 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 vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 94AB2CCA487 for ; Tue, 12 Jul 2022 10:09:27 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232479AbiGLKJ0 (ORCPT ); Tue, 12 Jul 2022 06:09:26 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:58022 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232329AbiGLKJZ (ORCPT ); Tue, 12 Jul 2022 06:09:25 -0400 Received: from msg-4.mailo.com (ip-15.mailobj.net [213.182.54.15]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 1F24AAB7C1; Tue, 12 Jul 2022 03:09:21 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=mailoo.org; s=mailo; t=1657620538; bh=Dp2mRQO8dxIh3vCWhuPurEDJ8gsjkJ7IKTB/TsgnvYs=; h=X-EA-Auth:From:To:Cc:Subject:Date:Message-Id:X-Mailer:In-Reply-To: References:MIME-Version:Content-Transfer-Encoding; b=XtKDvcv+Gy6NF+/XudAD1oBjV3K4LHTzqyEq4qUrXw0I4xNsysPwsmRBh1wHlLxPR 5EJlOlMO82ciI6XLw60xf6nr5iw0wD0R1AG86w08CzNaukGkCzm7SUnNf1t8g6QokX gs+jl1s0HPBSJVW6UpclCGUfM2EGcwFeCFmemdwc= Received: by b-1.in.mailobj.net [192.168.90.11] with ESMTP via [213.182.55.207] Tue, 12 Jul 2022 12:08:58 +0200 (CEST) X-EA-Auth: 2cXlOqzqFt+sZNALTKZX+0wDnBy9K3GwWSXD4u/Qmsxzh2ZIBBmKYxP1gw7N5fw4mFdiAc9U+fFlbIk5Bgd0SrTT74aw8RkU/RjO5kvFAZw= From: Vincent Knecht To: Pavel Machek , Rob Herring , Krzysztof Kozlowski , Vincent Knecht , linux-leds@vger.kernel.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org Cc: ~postmarketos/upstreaming@lists.sr.ht, phone-devel@vger.kernel.org, hns@goldelico.com, Rob Herring Subject: [PATCH v5 01/12] dt-bindings: leds: Convert is31fl319x to dtschema Date: Tue, 12 Jul 2022 12:08:27 +0200 Message-Id: <20220712100841.1538395-2-vincent.knecht@mailoo.org> X-Mailer: git-send-email 2.35.3 In-Reply-To: <20220712100841.1538395-1-vincent.knecht@mailoo.org> References: <20220712100841.1538395-1-vincent.knecht@mailoo.org> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-leds@vger.kernel.org Convert leds-is31fl319x.txt to dtschema. Set license to the one recommended by DT project and set myself as maintainer. Reviewed-by: Rob Herring Signed-off-by: Vincent Knecht --- v3: - changed license back to (GPL-2.0-only OR BSD-2-Clause) and maintainer to myself, with Nikolaus agreement --- .../bindings/leds/issi,is31fl319x.yaml | 113 ++++++++++++++++++ .../bindings/leds/leds-is31fl319x.txt | 61 ---------- 2 files changed, 113 insertions(+), 61 deletions(-) create mode 100644 Documentation/devicetree/bindings/leds/issi,is31fl319x.yaml delete mode 100644 Documentation/devicetree/bindings/leds/leds-is31fl319x.txt diff --git a/Documentation/devicetree/bindings/leds/issi,is31fl319x.yaml b/Documentation/devicetree/bindings/leds/issi,is31fl319x.yaml new file mode 100644 index 000000000000..0d684aeeb8cd --- /dev/null +++ b/Documentation/devicetree/bindings/leds/issi,is31fl319x.yaml @@ -0,0 +1,113 @@ +# SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause) +%YAML 1.2 +--- +$id: http://devicetree.org/schemas/leds/issi,is31fl319x.yaml# +$schema: http://devicetree.org/meta-schemas/core.yaml# + +title: ISSI LED controllers bindings for IS31FL319{0,1,3,6,9} + +maintainers: + - Vincent Knecht + +description: | + The IS31FL319X are LED controllers with I2C interface. + Previously known as Si-En SN319{0,1,3,6,9}. + + For more product information please see the links below: + https://lumissil.com/assets/pdf/core/IS31FL3190_DS.pdf + https://lumissil.com/assets/pdf/core/IS31FL3191_DS.pdf + https://lumissil.com/assets/pdf/core/IS31FL3193_DS.pdf + https://lumissil.com/assets/pdf/core/IS31FL3196_DS.pdf + https://lumissil.com/assets/pdf/core/IS31FL3199_DS.pdf + +properties: + compatible: + enum: + - issi,is31fl3190 + - issi,is31fl3191 + - issi,is31fl3193 + - issi,is31fl3196 + - issi,is31fl3199 + - si-en,sn3199 + + reg: + maxItems: 1 + + shutdown-gpios: + maxItems: 1 + description: GPIO attached to the SDB pin. + + audio-gain-db: + $ref: /schemas/types.yaml#/definitions/uint32 + default: 0 + description: Audio gain selection for external analog modulation input. + enum: [0, 3, 6, 9, 12, 15, 18, 21] + + "#address-cells": + const: 1 + + "#size-cells": + const: 0 + +patternProperties: + "^led@[1-9]$": + type: object + $ref: common.yaml# + + properties: + reg: + description: Index of the LED. + minimum: 1 + maximum: 9 + + led-max-microamp: + default: 20000 + enum: [5000, 10000, 15000, 20000, 25000, 30000, 35000, 40000] + description: + Note that a driver will take the lowest of all LED limits + since the chip has a single global setting. The lowest value + will be chosen due to the PWM specificity, where lower + brightness is achieved by reducing the duty-cycle of pulses + and not the current, which will always have its peak value + equal to led-max-microamp. + +required: + - compatible + - reg + - "#address-cells" + - "#size-cells" + +additionalProperties: false + +examples: + - | + #include + #include + + i2c0 { + #address-cells = <1>; + #size-cells = <0>; + + led-controller@65 { + compatible = "issi,is31fl3196"; + reg = <0x65>; + #address-cells = <1>; + #size-cells = <0>; + + shutdown-gpios = <&gpio0 11 GPIO_ACTIVE_HIGH>; + + led@1 { + reg = <1>; + label = "red:aux"; + led-max-microamp = <10000>; + }; + + led@5 { + reg = <5>; + label = "green:power"; + linux,default-trigger = "default-on"; + }; + }; + }; +... + diff --git a/Documentation/devicetree/bindings/leds/leds-is31fl319x.txt b/Documentation/devicetree/bindings/leds/leds-is31fl319x.txt deleted file mode 100644 index 676d43ec8169..000000000000 --- a/Documentation/devicetree/bindings/leds/leds-is31fl319x.txt +++ /dev/null @@ -1,61 +0,0 @@ -LEDs connected to is31fl319x LED controller chip - -Required properties: -- compatible : Should be any of - "issi,is31fl3190" - "issi,is31fl3191" - "issi,is31fl3193" - "issi,is31fl3196" - "issi,is31fl3199" - "si-en,sn3199". -- #address-cells: Must be 1. -- #size-cells: Must be 0. -- reg: 0x64, 0x65, 0x66, or 0x67. - -Optional properties: -- audio-gain-db : audio gain selection for external analog modulation input. - Valid values: 0 - 21, step by 3 (rounded down) - Default: 0 -- shutdown-gpios : Specifier of the GPIO connected to SDB pin of the chip. - -Each led is represented as a sub-node of the issi,is31fl319x device. -There can be less leds subnodes than the chip can support but not more. - -Required led sub-node properties: -- reg : number of LED line - Valid values: 1 - number of leds supported by the chip variant. - -Optional led sub-node properties: -- label : see Documentation/devicetree/bindings/leds/common.txt. -- linux,default-trigger : - see Documentation/devicetree/bindings/leds/common.txt. -- led-max-microamp : (optional) - Valid values: 5000 - 40000, step by 5000 (rounded down) - Default: 20000 (20 mA) - Note: a driver will take the lowest of all led limits since the - chip has a single global setting. The lowest value will be chosen - due to the PWM specificity, where lower brightness is achieved - by reducing the dury-cycle of pulses and not the current, which - will always have its peak value equal to led-max-microamp. - -Examples: - -fancy_leds: leds@65 { - compatible = "issi,is31fl3196"; - #address-cells = <1>; - #size-cells = <0>; - reg = <0x65>; - shutdown-gpios = <&gpio0 11 GPIO_ACTIVE_HIGH>; - - red_aux: led@1 { - label = "red:aux"; - reg = <1>; - led-max-microamp = <10000>; - }; - - green_power: led@5 { - label = "green:power"; - reg = <5>; - linux,default-trigger = "default-on"; - }; -}; From patchwork Tue Jul 12 10:08:28 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Vincent Knecht X-Patchwork-Id: 590182 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 vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 5C28AC433EF for ; Tue, 12 Jul 2022 10:09:26 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232554AbiGLKJZ (ORCPT ); Tue, 12 Jul 2022 06:09:25 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:58062 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232136AbiGLKJZ (ORCPT ); Tue, 12 Jul 2022 06:09:25 -0400 Received: from msg-4.mailo.com (ip-15.mailobj.net [213.182.54.15]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 2A657AB7CD; Tue, 12 Jul 2022 03:09:21 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=mailoo.org; s=mailo; t=1657620541; bh=Obre5IIa+wQZbNnEgE6NenQzK6E616sCX+q9jkhLXDk=; h=X-EA-Auth:From:To:Cc:Subject:Date:Message-Id:X-Mailer:In-Reply-To: References:MIME-Version:Content-Transfer-Encoding; b=dcia4nptDEadJ6VnE9bxiXu8IaBt9Sssxcw0jQ0r1NodilfmB/SvTMK58BCGgJDfY qOXZyRg9k3fW8nm38CzvGVDKafz/38/bS7i7n4Gz8nxgqNVyux9IOCJMG4ag4/kyNT mT2rcgTO7GW0jI1zZiT7+2hz6vub/8PkgXg1hqGI= Received: by b-1.in.mailobj.net [192.168.90.11] with ESMTP via [213.182.55.207] Tue, 12 Jul 2022 12:09:01 +0200 (CEST) X-EA-Auth: W4/N4DzbLXrI9f1mQEmUFubnI1GrnUsm1t2VBR7btUs5J0A7MCDUxNVTZsfweTGHnqfFZvcLtbGaEr5PB9ZThZC3PHpWesKAtHducO/ayIw= From: Vincent Knecht To: Pavel Machek , Rob Herring , Krzysztof Kozlowski , Vincent Knecht , linux-leds@vger.kernel.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org Cc: ~postmarketos/upstreaming@lists.sr.ht, phone-devel@vger.kernel.org, hns@goldelico.com, Rob Herring Subject: [PATCH v5 02/12] dt-bindings: leds: is31fl319x: Document variants specificities Date: Tue, 12 Jul 2022 12:08:28 +0200 Message-Id: <20220712100841.1538395-3-vincent.knecht@mailoo.org> X-Mailer: git-send-email 2.35.3 In-Reply-To: <20220712100841.1538395-1-vincent.knecht@mailoo.org> References: <20220712100841.1538395-1-vincent.knecht@mailoo.org> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-leds@vger.kernel.org Add si-en compatibles for all chip variants and add conditionals depending on compatibles to document variants specs: - possible reg addresses - whether audio-gain-db is supported or not - maximum number of leds - led-max-microamp values Reviewed-by: Rob Herring Signed-off-by: Vincent Knecht --- .../bindings/leds/issi,is31fl319x.yaml | 84 ++++++++++++++++++- 1 file changed, 82 insertions(+), 2 deletions(-) diff --git a/Documentation/devicetree/bindings/leds/issi,is31fl319x.yaml b/Documentation/devicetree/bindings/leds/issi,is31fl319x.yaml index 0d684aeeb8cd..940333f2d69c 100644 --- a/Documentation/devicetree/bindings/leds/issi,is31fl319x.yaml +++ b/Documentation/devicetree/bindings/leds/issi,is31fl319x.yaml @@ -28,6 +28,10 @@ properties: - issi,is31fl3193 - issi,is31fl3196 - issi,is31fl3199 + - si-en,sn3190 + - si-en,sn3191 + - si-en,sn3193 + - si-en,sn3196 - si-en,sn3199 reg: @@ -61,8 +65,6 @@ patternProperties: maximum: 9 led-max-microamp: - default: 20000 - enum: [5000, 10000, 15000, 20000, 25000, 30000, 35000, 40000] description: Note that a driver will take the lowest of all LED limits since the chip has a single global setting. The lowest value @@ -71,6 +73,84 @@ patternProperties: and not the current, which will always have its peak value equal to led-max-microamp. +allOf: + - if: + properties: + compatible: + contains: + enum: + - issi,is31fl3190 + - issi,is31fl3191 + - issi,is31fl3193 + - si-en,sn3190 + - si-en,sn3191 + - si-en,sn3193 + then: + properties: + reg: + enum: [0x68, 0x69, 0x6a, 0x6b] + + audio-gain-db: false + + patternProperties: + "^led@[1-9]$": + properties: + led-max-microamp: + default: 42000 + enum: [5000, 10000, 17500, 30000, 42000] + else: + properties: + reg: + enum: [0x64, 0x65, 0x66, 0x67] + + patternProperties: + "^led@[1-9]$": + properties: + led-max-microamp: + default: 20000 + enum: [5000, 10000, 15000, 20000, 25000, 30000, 35000, 40000] + - if: + properties: + compatible: + contains: + enum: + - issi,is31fl3190 + - issi,is31fl3191 + - si-en,sn3190 + - si-en,sn3191 + then: + patternProperties: + "^led@[1-9]$": + properties: + reg: + maximum: 1 + - if: + properties: + compatible: + contains: + enum: + - issi,is31fl3193 + - si-en,sn3193 + then: + patternProperties: + "^led@[1-9]$": + properties: + reg: + maximum: 3 + - if: + properties: + compatible: + contains: + enum: + - issi,is31fl3196 + - si-en,sn3196 + then: + patternProperties: + "^led@[1-9]$": + properties: + reg: + maximum: 6 + required: - compatible - reg From patchwork Tue Jul 12 10:08:34 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Vincent Knecht X-Patchwork-Id: 590179 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 vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 84509CCA482 for ; Tue, 12 Jul 2022 10:09:55 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232317AbiGLKJx (ORCPT ); Tue, 12 Jul 2022 06:09:53 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:58494 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232903AbiGLKJh (ORCPT ); Tue, 12 Jul 2022 06:09:37 -0400 Received: from msg-2.mailo.com (msg-2.mailo.com [213.182.54.12]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id BF817AB7F2; Tue, 12 Jul 2022 03:09:32 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=mailoo.org; s=mailo; t=1657620562; bh=kNonhr4zx1gBwqi84AZnY1idautIXixqqCWCbkJNdOk=; h=X-EA-Auth:From:To:Cc:Subject:Date:Message-Id:X-Mailer:In-Reply-To: References:MIME-Version:Content-Transfer-Encoding; b=J2UfVlH8qf5jH7X/4Cuv2P6RTHigpXwSxs/8pEYW0060HYypDnQ18vXvLK7sPfkLY YNZ3A8HVk9iqq338T1TXIeK5pfuU/t2Tl54kYTuvjrIiG0pvyIQSx+FlvKWLghCU2K hMi1d6k8mS1rXEgtUcrKYqIJOMpQ34zZTjcRIHHY= Received: by b-3.in.mailobj.net [192.168.90.13] with ESMTP via [213.182.55.207] Tue, 12 Jul 2022 12:09:22 +0200 (CEST) X-EA-Auth: C/bbevPzM6cNNz9cI8u/tulE/4VTHyY+gw+geBuk0R9v3MT5OGG+ehG0CBjqUnaoqYdfQ1BaqEc6cF1QYinG7gzjJNe8wWmy6EyB4gGxghM= From: Vincent Knecht To: Pavel Machek , Rob Herring , Krzysztof Kozlowski , Vincent Knecht , linux-leds@vger.kernel.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org Cc: ~postmarketos/upstreaming@lists.sr.ht, phone-devel@vger.kernel.org, hns@goldelico.com, Andy Shevchenko Subject: [PATCH v5 08/12] leds: is31fl319x: Make use of device properties Date: Tue, 12 Jul 2022 12:08:34 +0200 Message-Id: <20220712100841.1538395-9-vincent.knecht@mailoo.org> X-Mailer: git-send-email 2.35.3 In-Reply-To: <20220712100841.1538395-1-vincent.knecht@mailoo.org> References: <20220712100841.1538395-1-vincent.knecht@mailoo.org> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-leds@vger.kernel.org From: Andy Shevchenko Convert the module to be property provider agnostic and allow it to be used on non-OF platforms. Add mod_devicetable.h include. Signed-off-by: Andy Shevchenko Signed-off-by: Vincent Knecht --- drivers/leds/Kconfig | 2 +- drivers/leds/leds-is31fl319x.c | 44 ++++++++++++++++------------------ 2 files changed, 21 insertions(+), 25 deletions(-) diff --git a/drivers/leds/Kconfig b/drivers/leds/Kconfig index a49979f41eee..9a896be26dc7 100644 --- a/drivers/leds/Kconfig +++ b/drivers/leds/Kconfig @@ -697,7 +697,7 @@ config LEDS_MENF21BMC config LEDS_IS31FL319X tristate "LED Support for ISSI IS31FL319x I2C LED controller family" - depends on LEDS_CLASS && I2C && OF + depends on LEDS_CLASS && I2C select REGMAP_I2C help This option enables support for LEDs connected to ISSI IS31FL319x diff --git a/drivers/leds/leds-is31fl319x.c b/drivers/leds/leds-is31fl319x.c index 056cf3bcffdc..b1a0ca340e24 100644 --- a/drivers/leds/leds-is31fl319x.c +++ b/drivers/leds/leds-is31fl319x.c @@ -11,9 +11,9 @@ #include #include #include +#include #include -#include -#include +#include #include #include #include @@ -362,25 +362,23 @@ static const struct of_device_id of_is31fl319x_match[] = { }; MODULE_DEVICE_TABLE(of, of_is31fl319x_match); -static int is31fl319x_parse_child_dt(const struct device *dev, - const struct device_node *child, +static int is31fl319x_parse_child_fw(const struct device *dev, + const struct fwnode_handle *child, struct is31fl319x_led *led, struct is31fl319x_chip *is31) { struct led_classdev *cdev = &led->cdev; int ret; - if (of_property_read_string(child, "label", &cdev->name)) - cdev->name = child->name; + if (fwnode_property_read_string(child, "label", &cdev->name)) + cdev->name = fwnode_get_name(child); - ret = of_property_read_string(child, "linux,default-trigger", - &cdev->default_trigger); + ret = fwnode_property_read_string(child, "linux,default-trigger", &cdev->default_trigger); if (ret < 0 && ret != -EINVAL) /* is optional */ return ret; led->max_microamp = is31->cdef->current_default; - ret = of_property_read_u32(child, "led-max-microamp", - &led->max_microamp); + ret = fwnode_property_read_u32(child, "led-max-microamp", &led->max_microamp); if (!ret) { if (led->max_microamp < is31->cdef->current_min) return -EINVAL; /* not supported */ @@ -391,16 +389,12 @@ static int is31fl319x_parse_child_dt(const struct device *dev, return 0; } -static int is31fl319x_parse_dt(struct device *dev, - struct is31fl319x_chip *is31) +static int is31fl319x_parse_fw(struct device *dev, struct is31fl319x_chip *is31) { - struct device_node *np = dev_of_node(dev), *child; + struct fwnode_handle *fwnode = dev_fwnode(dev), *child; int count; int ret; - if (!np) - return -ENODEV; - is31->shutdown_gpio = devm_gpiod_get_optional(dev, "shutdown", GPIOD_OUT_HIGH); if (IS_ERR(is31->shutdown_gpio)) { ret = PTR_ERR(is31->shutdown_gpio); @@ -410,7 +404,9 @@ static int is31fl319x_parse_dt(struct device *dev, is31->cdef = device_get_match_data(dev); - count = of_get_available_child_count(np); + count = 0; + fwnode_for_each_available_child_node(fwnode, child) + count++; dev_dbg(dev, "probing with %d leds defined in DT\n", count); @@ -420,11 +416,11 @@ static int is31fl319x_parse_dt(struct device *dev, return -ENODEV; } - for_each_available_child_of_node(np, child) { + fwnode_for_each_available_child_node(fwnode, child) { struct is31fl319x_led *led; u32 reg; - ret = of_property_read_u32(child, "reg", ®); + ret = fwnode_property_read_u32(child, "reg", ®); if (ret) { dev_err(dev, "Failed to read led 'reg' property\n"); goto put_child_node; @@ -444,7 +440,7 @@ static int is31fl319x_parse_dt(struct device *dev, goto put_child_node; } - ret = is31fl319x_parse_child_dt(dev, child, led, is31); + ret = is31fl319x_parse_child_fw(dev, child, led, is31); if (ret) { dev_err(dev, "led %u DT parsing failed\n", reg); goto put_child_node; @@ -455,7 +451,7 @@ static int is31fl319x_parse_dt(struct device *dev, is31->audio_gain_db = 0; if (is31->cdef->is_3196or3199) { - ret = of_property_read_u32(np, "audio-gain-db", &is31->audio_gain_db); + ret = fwnode_property_read_u32(fwnode, "audio-gain-db", &is31->audio_gain_db); if (!ret) is31->audio_gain_db = min(is31->audio_gain_db, IS31FL3196_AUDIO_GAIN_DB_MAX); @@ -464,7 +460,7 @@ static int is31fl319x_parse_dt(struct device *dev, return 0; put_child_node: - of_node_put(child); + fwnode_handle_put(child); return ret; } @@ -521,7 +517,7 @@ static int is31fl319x_probe(struct i2c_client *client, mutex_init(&is31->lock); - err = is31fl319x_parse_dt(&client->dev, is31); + err = is31fl319x_parse_fw(&client->dev, is31); if (err) goto free_mutex; @@ -619,7 +615,7 @@ MODULE_DEVICE_TABLE(i2c, is31fl319x_id); static struct i2c_driver is31fl319x_driver = { .driver = { .name = "leds-is31fl319x", - .of_match_table = of_match_ptr(of_is31fl319x_match), + .of_match_table = of_is31fl319x_match, }, .probe = is31fl319x_probe, .remove = is31fl319x_remove, From patchwork Tue Jul 12 10:08:35 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Vincent Knecht X-Patchwork-Id: 590178 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 vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 91978CCA489 for ; Tue, 12 Jul 2022 10:09:57 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229918AbiGLKJ4 (ORCPT ); Tue, 12 Jul 2022 06:09:56 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:58476 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232885AbiGLKJi (ORCPT ); Tue, 12 Jul 2022 06:09:38 -0400 Received: from msg-2.mailo.com (msg-2.mailo.com [213.182.54.12]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id BD989AB7EF; Tue, 12 Jul 2022 03:09:32 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=mailoo.org; s=mailo; t=1657620565; bh=ot1QY0W2gqQ8FHzqL+n9MiYv5sQHYxZYX0Y2iqO3/ds=; h=X-EA-Auth:From:To:Cc:Subject:Date:Message-Id:X-Mailer:In-Reply-To: References:MIME-Version:Content-Transfer-Encoding; b=M1WqVbKPG1BCZUunTQVsTCtvajxL+sB1QmEwh2OMpPja0TgmRs2H8xANY0sqVZ6Bk DaWQmZTrjd4J8QQIEkM4mQeS9/uAfh4RHThUD1+phSQDKkqJzBQwAMgTDoi3ghJCYa Sv0n+Zepadm2vD9PIOGJg0DKiEtLJzc9kS4KTuQg= Received: by b-3.in.mailobj.net [192.168.90.13] with ESMTP via [213.182.55.207] Tue, 12 Jul 2022 12:09:25 +0200 (CEST) X-EA-Auth: aTk9wxyFnYR65KRpSAkuG5a0sOVuECX1n5dNry6wlRbP49nAbXGWd/ji9zl1Y6cPEqJ1KW199GphGo4s0Yq+g1gyeO5xXYWsiJqRLJg0oB4= From: Vincent Knecht To: Pavel Machek , Rob Herring , Krzysztof Kozlowski , Vincent Knecht , linux-leds@vger.kernel.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org Cc: ~postmarketos/upstreaming@lists.sr.ht, phone-devel@vger.kernel.org, hns@goldelico.com, Andy Shevchenko Subject: [PATCH v5 09/12] leds: is31fl319x: Make use of dev_err_probe() Date: Tue, 12 Jul 2022 12:08:35 +0200 Message-Id: <20220712100841.1538395-10-vincent.knecht@mailoo.org> X-Mailer: git-send-email 2.35.3 In-Reply-To: <20220712100841.1538395-1-vincent.knecht@mailoo.org> References: <20220712100841.1538395-1-vincent.knecht@mailoo.org> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-leds@vger.kernel.org From: Andy Shevchenko Simplify the error handling in probe function by switching from dev_err() to dev_err_probe(). Signed-off-by: Andy Shevchenko Signed-off-by: Vincent Knecht --- drivers/leds/leds-is31fl319x.c | 33 +++++++++++++-------------------- 1 file changed, 13 insertions(+), 20 deletions(-) diff --git a/drivers/leds/leds-is31fl319x.c b/drivers/leds/leds-is31fl319x.c index b1a0ca340e24..d9cf70505c43 100644 --- a/drivers/leds/leds-is31fl319x.c +++ b/drivers/leds/leds-is31fl319x.c @@ -396,11 +396,9 @@ static int is31fl319x_parse_fw(struct device *dev, struct is31fl319x_chip *is31) int ret; is31->shutdown_gpio = devm_gpiod_get_optional(dev, "shutdown", GPIOD_OUT_HIGH); - if (IS_ERR(is31->shutdown_gpio)) { - ret = PTR_ERR(is31->shutdown_gpio); - dev_err(dev, "Failed to get shutdown gpio: %d\n", ret); - return ret; - } + if (IS_ERR(is31->shutdown_gpio)) + return dev_err_probe(dev, PTR_ERR(is31->shutdown_gpio), + "Failed to get shutdown gpio\n"); is31->cdef = device_get_match_data(dev); @@ -410,11 +408,10 @@ static int is31fl319x_parse_fw(struct device *dev, struct is31fl319x_chip *is31) dev_dbg(dev, "probing with %d leds defined in DT\n", count); - if (!count || count > is31->cdef->num_leds) { - dev_err(dev, "Number of leds defined must be between 1 and %u\n", - is31->cdef->num_leds); - return -ENODEV; - } + if (!count || count > is31->cdef->num_leds) + return dev_err_probe(dev, -ENODEV, + "Number of leds defined must be between 1 and %u\n", + is31->cdef->num_leds); fwnode_for_each_available_child_node(fwnode, child) { struct is31fl319x_led *led; @@ -422,27 +419,25 @@ static int is31fl319x_parse_fw(struct device *dev, struct is31fl319x_chip *is31) ret = fwnode_property_read_u32(child, "reg", ®); if (ret) { - dev_err(dev, "Failed to read led 'reg' property\n"); + ret = dev_err_probe(dev, ret, "Failed to read led 'reg' property\n"); goto put_child_node; } if (reg < 1 || reg > is31->cdef->num_leds) { - dev_err(dev, "invalid led reg %u\n", reg); - ret = -EINVAL; + ret = dev_err_probe(dev, -EINVAL, "invalid led reg %u\n", reg); goto put_child_node; } led = &is31->leds[reg - 1]; if (led->configured) { - dev_err(dev, "led %u is already configured\n", reg); - ret = -EINVAL; + ret = dev_err_probe(dev, -EINVAL, "led %u is already configured\n", reg); goto put_child_node; } ret = is31fl319x_parse_child_fw(dev, child, led, is31); if (ret) { - dev_err(dev, "led %u DT parsing failed\n", reg); + ret = dev_err_probe(dev, ret, "led %u DT parsing failed\n", reg); goto put_child_node; } @@ -530,8 +525,7 @@ static int is31fl319x_probe(struct i2c_client *client, is31->client = client; is31->regmap = devm_regmap_init_i2c(client, is31->cdef->is31fl319x_regmap_config); if (IS_ERR(is31->regmap)) { - dev_err(&client->dev, "failed to allocate register map\n"); - err = PTR_ERR(is31->regmap); + err = dev_err_probe(dev, PTR_ERR(is31->regmap), "failed to allocate register map\n"); goto free_mutex; } @@ -540,8 +534,7 @@ static int is31fl319x_probe(struct i2c_client *client, /* check for write-reply from chip (we can't read any registers) */ err = regmap_write(is31->regmap, is31->cdef->reset_reg, 0x00); if (err < 0) { - dev_err(&client->dev, "no response from chip write: err = %d\n", err); - err = -EIO; /* does not answer */ + err = dev_err_probe(dev, err, "no response from chip write\n"); goto free_mutex; } From patchwork Tue Jul 12 10:08:37 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Vincent Knecht X-Patchwork-Id: 590177 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 vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id ACF6BC433EF for ; Tue, 12 Jul 2022 10:10:32 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232913AbiGLKKa (ORCPT ); Tue, 12 Jul 2022 06:10:30 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:59242 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230316AbiGLKJ5 (ORCPT ); Tue, 12 Jul 2022 06:09:57 -0400 Received: from msg-2.mailo.com (msg-2.mailo.com [213.182.54.12]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 8689BAC07D; Tue, 12 Jul 2022 03:09:40 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=mailoo.org; s=mailo; t=1657620571; bh=DPGdqSGhmEWAw3do58iJLw426/BrSVvrm6dZCPnb6sg=; h=X-EA-Auth:From:To:Cc:Subject:Date:Message-Id:X-Mailer:In-Reply-To: References:MIME-Version:Content-Transfer-Encoding; b=BIab1jSnrcfjyXtaTMcv7H4c7NE2AllXhnRsNsf1gOGJv/aFzXPAcxwGaJGfeyKTn 6Z2VU9VVNaUOegGkPy1cJBkSxGXe4MXXKWrQLuIaEl4cDoMU+YO0bH7VyQ7W2QIHU9 jYCngFyhKbVQyEGK/2p0TMgwRdDhSiPbpmtPfejQ= Received: by b-3.in.mailobj.net [192.168.90.13] with ESMTP via [213.182.55.207] Tue, 12 Jul 2022 12:09:31 +0200 (CEST) X-EA-Auth: fIrO8Uw6UjpI8UagY7F1eZ1Uw0kxVaPs37zeJksxAxhmSq+YBb/2S1e6o2g3EKOv74B247gUIO06e/piUEPUmhAwo9gB2YmeaWYA0PpaIX0= From: Vincent Knecht To: Pavel Machek , Rob Herring , Krzysztof Kozlowski , Vincent Knecht , linux-leds@vger.kernel.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org Cc: ~postmarketos/upstreaming@lists.sr.ht, phone-devel@vger.kernel.org, hns@goldelico.com, Andy Shevchenko Subject: [PATCH v5 11/12] leds: is31fl319x: use simple i2c probe function Date: Tue, 12 Jul 2022 12:08:37 +0200 Message-Id: <20220712100841.1538395-12-vincent.knecht@mailoo.org> X-Mailer: git-send-email 2.35.3 In-Reply-To: <20220712100841.1538395-1-vincent.knecht@mailoo.org> References: <20220712100841.1538395-1-vincent.knecht@mailoo.org> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-leds@vger.kernel.org From: Andy Shevchenko The i2c probe functions here don't use the id information provided in their second argument, so the single-parameter i2c probe function ("probe_new") can be used instead. Signed-off-by: Andy Shevchenko Signed-off-by: Vincent Knecht --- drivers/leds/leds-is31fl319x.c | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/drivers/leds/leds-is31fl319x.c b/drivers/leds/leds-is31fl319x.c index 233ed67830a3..52b59b62f437 100644 --- a/drivers/leds/leds-is31fl319x.c +++ b/drivers/leds/leds-is31fl319x.c @@ -494,8 +494,7 @@ static inline int is31fl3196_db_to_gain(u32 dezibel) return dezibel / IS31FL3196_AUDIO_GAIN_DB_STEP; } -static int is31fl319x_probe(struct i2c_client *client, - const struct i2c_device_id *id) +static int is31fl319x_probe(struct i2c_client *client) { struct is31fl319x_chip *is31; struct device *dev = &client->dev; @@ -597,7 +596,7 @@ static struct i2c_driver is31fl319x_driver = { .name = "leds-is31fl319x", .of_match_table = of_is31fl319x_match, }, - .probe = is31fl319x_probe, + .probe_new = is31fl319x_probe, .id_table = is31fl319x_id, }; From patchwork Tue Jul 12 10:08:38 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Vincent Knecht X-Patchwork-Id: 590176 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 vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id C1402CCA47C for ; Tue, 12 Jul 2022 10:10:41 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232644AbiGLKKj (ORCPT ); Tue, 12 Jul 2022 06:10:39 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:59058 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232941AbiGLKKK (ORCPT ); Tue, 12 Jul 2022 06:10:10 -0400 Received: from msg-1.mailo.com (msg-1.mailo.com [213.182.54.11]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id A7E44ACECB; Tue, 12 Jul 2022 03:09:41 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=mailoo.org; s=mailo; t=1657620574; bh=RqYJd9WMWhQUUPRvy802P6+p3an2H7CBe1ZE7v+RG6w=; h=X-EA-Auth:From:To:Cc:Subject:Date:Message-Id:X-Mailer:In-Reply-To: References:MIME-Version:Content-Transfer-Encoding; b=El4ILC98AkU+I3Dq50xTlRQoOKxrSKTUcRVgbyv0OtHFG6I2NdOA4ZrUttZwuKfGw y6+AGHIt7sOVj4C433VdY7k/rVou4+pZ4DW55PPsD1+Ma52+s5q3dIi9DIsCDx8Hwc GVtB+uNMqnVvh+HyrydWTqQ6+pSIz9GFGCcrsdMU= Received: by b-3.in.mailobj.net [192.168.90.13] with ESMTP via [213.182.55.207] Tue, 12 Jul 2022 12:09:34 +0200 (CEST) X-EA-Auth: 1ZnJIAviytXjtFSUkRB449lCznmGB4XeZrGQZaNC9QK2ENtalrcSZv0MzIjhZzjrYoD5RKUJOwcskrzMzHvOgZS6RhqV+cds6nFq4/RRlwg= From: Vincent Knecht To: Pavel Machek , Rob Herring , Krzysztof Kozlowski , Vincent Knecht , linux-leds@vger.kernel.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org Cc: ~postmarketos/upstreaming@lists.sr.ht, phone-devel@vger.kernel.org, hns@goldelico.com, Andy Shevchenko Subject: [PATCH v5 12/12] leds: is31fl319x: sort header inclusion alphabetically Date: Tue, 12 Jul 2022 12:08:38 +0200 Message-Id: <20220712100841.1538395-13-vincent.knecht@mailoo.org> X-Mailer: git-send-email 2.35.3 In-Reply-To: <20220712100841.1538395-1-vincent.knecht@mailoo.org> References: <20220712100841.1538395-1-vincent.knecht@mailoo.org> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-leds@vger.kernel.org From: Andy Shevchenko Sort header inclusion alphabetically. Signed-off-by: Andy Shevchenko Signed-off-by: Vincent Knecht --- drivers/leds/leds-is31fl319x.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/drivers/leds/leds-is31fl319x.c b/drivers/leds/leds-is31fl319x.c index 52b59b62f437..f2d05ae91753 100644 --- a/drivers/leds/leds-is31fl319x.c +++ b/drivers/leds/leds-is31fl319x.c @@ -8,7 +8,9 @@ * effect LEDs. */ +#include #include +#include #include #include #include @@ -16,8 +18,6 @@ #include #include #include -#include -#include /* register numbers */ #define IS31FL319X_SHUTDOWN 0x00