From bfaecf465a058b167abc7c0dfad985f167ff3af1 Mon Sep 17 00:00:00 2001 From: qinyu Date: Thu, 23 Feb 2023 16:10:47 +0800 Subject: power: supply: fix null pointer check order in __power_supply_register There is an null pointer check order issue here: if we have to check !desc and !desc->name anyway, check it before dereferencing it in pr_warn(). Signed-off-by: qinyu Signed-off-by: Sebastian Reichel --- drivers/power/supply/power_supply_core.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/drivers/power/supply/power_supply_core.c b/drivers/power/supply/power_supply_core.c index cc5b2e22b42a..f3d7c1da299f 100644 --- a/drivers/power/supply/power_supply_core.c +++ b/drivers/power/supply/power_supply_core.c @@ -1207,13 +1207,13 @@ __power_supply_register(struct device *parent, struct power_supply *psy; int rc; + if (!desc || !desc->name || !desc->properties || !desc->num_properties) + return ERR_PTR(-EINVAL); + if (!parent) pr_warn("%s: Expected proper parent device for '%s'\n", __func__, desc->name); - if (!desc || !desc->name || !desc->properties || !desc->num_properties) - return ERR_PTR(-EINVAL); - if (psy_has_property(desc, POWER_SUPPLY_PROP_USB_TYPE) && (!desc->usb_types || !desc->num_usb_types)) return ERR_PTR(-EINVAL); -- cgit v1.2.3-70-g09d2 From f0cf05759497dbc90303adcbdf3d13a54bdaf97b Mon Sep 17 00:00:00 2001 From: Bastien Nocera Date: Mon, 20 Feb 2023 14:10:18 +0100 Subject: ABI: testing: sysfs-class-power: Document absence of "present" property Document how the absence of the "present" property in the sysfs power_supply class should be handled. Link: https://gitlab.freedesktop.org/upower/upower/-/merge_requests/173 Cc: Mario Limonciello Signed-off-by: Bastien Nocera Signed-off-by: Sebastian Reichel --- Documentation/ABI/testing/sysfs-class-power | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/Documentation/ABI/testing/sysfs-class-power b/Documentation/ABI/testing/sysfs-class-power index e434fc523291..7c81f0a25a48 100644 --- a/Documentation/ABI/testing/sysfs-class-power +++ b/Documentation/ABI/testing/sysfs-class-power @@ -437,7 +437,8 @@ What: /sys/class/power_supply//present Date: May 2007 Contact: linux-pm@vger.kernel.org Description: - Reports whether a battery is present or not in the system. + Reports whether a battery is present or not in the system. If the + property does not exist, the battery is considered to be present. Access: Read -- cgit v1.2.3-70-g09d2 From 13af134bdc6a9dacec4687e57b2ea8d3e08ff04f Mon Sep 17 00:00:00 2001 From: ChiaEn Wu Date: Fri, 17 Feb 2023 17:55:55 +0800 Subject: dt-bindings: power: supply: Revise Richtek RT9467 compatible name Revise RT9467 compatible name from "richtek,rt9467-charger" to "richtek,rt9467" because it has to match the "compatible name" in the source code. Fixes: e1b4620fb503 ("dt-bindings: power: supply: Add Richtek RT9467 battery charger") Reported-by: Rob Herring Signed-off-by: ChiaEn Wu Reviewed-by: Krzysztof Kozlowski Signed-off-by: Sebastian Reichel --- .../power/supply/richtek,rt9467-charger.yaml | 82 ---------------------- .../bindings/power/supply/richtek,rt9467.yaml | 82 ++++++++++++++++++++++ 2 files changed, 82 insertions(+), 82 deletions(-) delete mode 100644 Documentation/devicetree/bindings/power/supply/richtek,rt9467-charger.yaml create mode 100644 Documentation/devicetree/bindings/power/supply/richtek,rt9467.yaml diff --git a/Documentation/devicetree/bindings/power/supply/richtek,rt9467-charger.yaml b/Documentation/devicetree/bindings/power/supply/richtek,rt9467-charger.yaml deleted file mode 100644 index 92c570643d2c..000000000000 --- a/Documentation/devicetree/bindings/power/supply/richtek,rt9467-charger.yaml +++ /dev/null @@ -1,82 +0,0 @@ -# SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause) -%YAML 1.2 ---- -$id: http://devicetree.org/schemas/power/supply/richtek,rt9467-charger.yaml# -$schema: http://devicetree.org/meta-schemas/core.yaml# - -title: Richtek RT9467 Switching Battery Charger with Power Path Management - -maintainers: - - ChiYuan Huang - - ChiaEn Wu - -description: | - RT9467 is a switch-mode single cell Li-Ion/Li-Polymer battery charger for - portable applications. It integrates a synchronous PWM controller, power - MOSFETs, input current sensing and regulation, high-accuracy voltage - regulation, and charge termination. The charge current is regulated through - integrated sensing resistors. - - The RT9467 also features USB On-The-Go (OTG) support. It also integrates - D+/D- pin for USB host/charging port detection. - - Datasheet is available at - https://www.richtek.com/assets/product_file/RT9467/DS9467-01.pdf - -properties: - compatible: - const: richtek,rt9467-charger - - reg: - maxItems: 1 - - wakeup-source: true - - interrupts: - maxItems: 1 - - charge-enable-gpios: - description: GPIO is used to turn on and off charging. - maxItems: 1 - - usb-otg-vbus-regulator: - type: object - description: OTG boost regulator. - unevaluatedProperties: false - $ref: /schemas/regulator/regulator.yaml# - - properties: - enable-gpios: true - -required: - - compatible - - reg - - wakeup-source - - interrupts - -additionalProperties: false - -examples: - - | - #include - #include - i2c { - #address-cells = <1>; - #size-cells = <0>; - - charger@5b { - compatible = "richtek,rt9467-charger"; - reg = <0x5b>; - wakeup-source; - interrupts-extended = <&gpio_intc 32 IRQ_TYPE_LEVEL_LOW>; - charge-enable-gpios = <&gpio26 1 GPIO_ACTIVE_LOW>; - - rt9467_otg_vbus: usb-otg-vbus-regulator { - regulator-name = "rt9467-usb-otg-vbus"; - regulator-min-microvolt = <4425000>; - regulator-max-microvolt = <5825000>; - regulator-min-microamp = <500000>; - regulator-max-microamp = <3000000>; - }; - }; - }; diff --git a/Documentation/devicetree/bindings/power/supply/richtek,rt9467.yaml b/Documentation/devicetree/bindings/power/supply/richtek,rt9467.yaml new file mode 100644 index 000000000000..3723717dc1f6 --- /dev/null +++ b/Documentation/devicetree/bindings/power/supply/richtek,rt9467.yaml @@ -0,0 +1,82 @@ +# SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause) +%YAML 1.2 +--- +$id: http://devicetree.org/schemas/power/supply/richtek,rt9467.yaml# +$schema: http://devicetree.org/meta-schemas/core.yaml# + +title: Richtek RT9467 Switching Battery Charger with Power Path Management + +maintainers: + - ChiYuan Huang + - ChiaEn Wu + +description: | + RT9467 is a switch-mode single cell Li-Ion/Li-Polymer battery charger for + portable applications. It integrates a synchronous PWM controller, power + MOSFETs, input current sensing and regulation, high-accuracy voltage + regulation, and charge termination. The charge current is regulated through + integrated sensing resistors. + + The RT9467 also features USB On-The-Go (OTG) support. It also integrates + D+/D- pin for USB host/charging port detection. + + Datasheet is available at + https://www.richtek.com/assets/product_file/RT9467/DS9467-01.pdf + +properties: + compatible: + const: richtek,rt9467 + + reg: + maxItems: 1 + + wakeup-source: true + + interrupts: + maxItems: 1 + + charge-enable-gpios: + description: GPIO is used to turn on and off charging. + maxItems: 1 + + usb-otg-vbus-regulator: + type: object + description: OTG boost regulator. + unevaluatedProperties: false + $ref: /schemas/regulator/regulator.yaml# + + properties: + enable-gpios: true + +required: + - compatible + - reg + - wakeup-source + - interrupts + +additionalProperties: false + +examples: + - | + #include + #include + i2c { + #address-cells = <1>; + #size-cells = <0>; + + charger@5b { + compatible = "richtek,rt9467"; + reg = <0x5b>; + wakeup-source; + interrupts-extended = <&gpio_intc 32 IRQ_TYPE_LEVEL_LOW>; + charge-enable-gpios = <&gpio26 1 GPIO_ACTIVE_LOW>; + + rt9467_otg_vbus: usb-otg-vbus-regulator { + regulator-name = "rt9467-usb-otg-vbus"; + regulator-min-microvolt = <4425000>; + regulator-max-microvolt = <5825000>; + regulator-min-microamp = <500000>; + regulator-max-microamp = <3000000>; + }; + }; + }; -- cgit v1.2.3-70-g09d2