lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Date:   Wed, 27 May 2020 20:06:32 -0600
From:   Rob Herring <robh@...nel.org>
To:     Sebastian Reichel <sebastian.reichel@...labora.com>
Cc:     Sebastian Reichel <sre@...nel.org>, linux-pm@...r.kernel.org,
        devicetree@...r.kernel.org, linux-kernel@...r.kernel.org,
        kernel@...labora.com
Subject: Re: [PATCHv1 2/2] dt-bindings: power: supply: gpio-charger: convert
 to yaml

On Wed, May 13, 2020 at 01:56:01PM +0200, Sebastian Reichel wrote:
> Convert the gpio-charger bindings from text format to
> new YAML based representation.
> 
> Signed-off-by: Sebastian Reichel <sebastian.reichel@...labora.com>
> ---
>  .../bindings/power/supply/gpio-charger.txt    | 38 ----------
>  .../bindings/power/supply/gpio-charger.yaml   | 75 +++++++++++++++++++
>  2 files changed, 75 insertions(+), 38 deletions(-)
>  delete mode 100644 Documentation/devicetree/bindings/power/supply/gpio-charger.txt
>  create mode 100644 Documentation/devicetree/bindings/power/supply/gpio-charger.yaml
> 
> diff --git a/Documentation/devicetree/bindings/power/supply/gpio-charger.txt b/Documentation/devicetree/bindings/power/supply/gpio-charger.txt
> deleted file mode 100644
> index dbfd29029f69..000000000000
> --- a/Documentation/devicetree/bindings/power/supply/gpio-charger.txt
> +++ /dev/null
> @@ -1,38 +0,0 @@
> -gpio-charger
> -
> -Required properties :
> - - compatible : "gpio-charger"
> - - charger-type : power supply type, one of
> -     unknown
> -     battery
> -     ups
> -     mains
> -     usb-sdp (USB standard downstream port)
> -     usb-dcp (USB dedicated charging port)
> -     usb-cdp (USB charging downstream port)
> -     usb-aca (USB accessory charger adapter)
> -
> -Optional properties:
> - - gpios : GPIO indicating the charger presence.
> -   See GPIO binding in bindings/gpio/gpio.txt .
> - - charge-status-gpios: GPIO indicating whether a battery is charging.
> - - charge-current-limit-gpios: Output GPIOs specifiers for limiting the charge current
> - - charge-current-limit-mapping: List of touples with current in uA and a GPIO bitmap (in this order).
> -                                The GPIOs are encoded in the same order as specified in charge-current-limit-gpios.
> -				The touples must be provided in descending order of the current limit.
> -
> -Example:
> -
> -	usb_charger: charger {
> -		compatible = "gpio-charger";
> -		charger-type = "usb-sdp";
> -		gpios = <&gpd 28 GPIO_ACTIVE_LOW>;
> -		charge-status-gpios = <&gpc 27 GPIO_ACTIVE_LOW>;
> -
> -		charge-current-limit-gpios = <&gpioA 11 GPIO_ACTIVE_HIGH>, <&gpioA 12 GPIO_ACTIVE_HIGH>;
> -		charge-current-limit-mapping = <2500000 0x00>, <700000 0x01>, <0 0x02>;
> -	};
> -
> -	battery {
> -		power-supplies = <&usb_charger>;
> -	};
> diff --git a/Documentation/devicetree/bindings/power/supply/gpio-charger.yaml b/Documentation/devicetree/bindings/power/supply/gpio-charger.yaml
> new file mode 100644
> index 000000000000..14fb3e54f861
> --- /dev/null
> +++ b/Documentation/devicetree/bindings/power/supply/gpio-charger.yaml
> @@ -0,0 +1,75 @@
> +# SPDX-License-Identifier: GPL-2.0
> +%YAML 1.2
> +---
> +$id: http://devicetree.org/schemas/power/supply/gpio-charger.yaml#
> +$schema: http://devicetree.org/meta-schemas/core.yaml#
> +
> +title: simple battery chargers only communicating through GPIOs
> +
> +maintainers:
> +  - Sebastian Reichel <sre@...nel.org>
> +
> +description: |

Can drop '|' if formatting is not important.

> +  This binding is for all chargers, which are working more
> +  or less autonomously, only providing some status GPIOs
> +  and possibly some GPIOs for limited control over the
> +  charging process.
> +
> +properties:
> +  compatible:
> +    const: gpio-charger
> +
> +  charger-type:
> +    oneOf:
> +      - const: unknown
> +      - const: battery
> +      - const: ups
> +      - const: mains
> +      - const: usb-sdp                   # USB standard downstream port
> +      - const: usb-dcp                   # USB dedicated charging port
> +      - const: usb-cdp                   # USB charging downstream port
> +      - const: usb-aca                   # USB accessory charger adapter

Use enum rather than oneOf+const

Should have a description too.

> +
> +  gpios:
> +    maxItems: 1
> +    description: GPIO indicating the charger presence
> +
> +  charge-status-gpios:
> +    maxItems: 1
> +    description: GPIO indicating the charging status
> +
> +  charge-current-limit-gpios:
> +    minItems: 1
> +    maxItems: 32
> +    description: GPIOs used for current limiting
> +
> +  charge-current-limit-mapping:
> +    description: List of touples with current in uA and a GPIO bitmap (in
> +      this order). The GPIOs are encoded in the same order as specified in
> +      charge-current-limit-gpios. The touples must be provided in descending
> +      order of the current limit.
> +    $ref: "/meta-schemas/cell.yaml#array"

That's a first... A meta-schema is what checks this document. Not what 
you want. Should be like this:

$ref: /schemas/types.yaml#/definitions/uint32-matrix
items:
  items:
    - description: Current limit in uA
    - description: Encoded GPIO setting...

I guess there's not any more constraints we can add here.

> +
> +required:
> +  - compatible

blank line

At least 1 of the gpio properties is required, right? Can be expressed 
with required entries under a oneOf or anyOf.

> +additionalProperties: false
> +
> +dependencies:
> +  charge-current-limit-gpios: [ charge-current-limit-mapping ]
> +  charge-current-limit-mapping: [ charge-current-limit-gpios ]
> +
> +examples:
> +  - |
> +    #include <dt-bindings/gpio/gpio.h>
> +
> +    charger {
> +      compatible = "gpio-charger";
> +      charger-type = "usb-sdp";
> +
> +      gpios = <&gpd 28 GPIO_ACTIVE_LOW>;
> +      charge-status-gpios = <&gpc 27 GPIO_ACTIVE_LOW>;
> +
> +      charge-current-limit-gpios = <&gpioA 11 GPIO_ACTIVE_HIGH>,
> +                                   <&gpioA 12 GPIO_ACTIVE_HIGH>;
> +      charge-current-limit-mapping = <2500000 0x00>, <700000 0x01>, <0 0x02>;
> +    };
> -- 
> 2.26.2
> 

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ