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] [thread-next>] [day] [month] [year] [list]
Message-ID: <20200502003412.gfyeu4g6acfp6ml7@earth.universe>
Date:   Sat, 2 May 2020 02:34:12 +0200
From:   Sebastian Reichel <sebastian.reichel@...labora.com>
To:     Mathew King <mathewk@...omium.org>
Cc:     linux-kernel@...r.kernel.org, linux-pm@...r.kernel.org
Subject: Re: [PATCH 2/4] power_supply: Use designated initializer for
 property text arrays

Hi,

On Fri, Apr 24, 2020 at 11:35:31AM -0600, Mathew King wrote:
> Use designated initializers for the sysfs power supply text values. This
> will help ensure that the text values are kept in sync with the enum
> values from power_supply.h.
> 
> Signed-off-by: Mathew King <mathewk@...omium.org>
> ---

Thanks, looks good to me, but does not apply without the first patch
(or due to other changes in power-supply's for-next branch).

-- Sebastian

>  drivers/power/supply/power_supply_sysfs.c | 76 ++++++++++++++++++-----
>  1 file changed, 61 insertions(+), 15 deletions(-)
> 
> diff --git a/drivers/power/supply/power_supply_sysfs.c b/drivers/power/supply/power_supply_sysfs.c
> index b579081599d7..328107589770 100644
> --- a/drivers/power/supply/power_supply_sysfs.c
> +++ b/drivers/power/supply/power_supply_sysfs.c
> @@ -35,41 +35,87 @@ struct power_supply_attr {
>  }
>  
>  static const char * const power_supply_type_text[] = {
> -	"Unknown", "Battery", "UPS", "Mains", "USB",
> -	"USB_DCP", "USB_CDP", "USB_ACA", "USB_C",
> -	"USB_PD", "USB_PD_DRP", "BrickID"
> +	[POWER_SUPPLY_TYPE_UNKNOWN]		= "Unknown",
> +	[POWER_SUPPLY_TYPE_BATTERY]		= "Battery",
> +	[POWER_SUPPLY_TYPE_UPS]			= "UPS",
> +	[POWER_SUPPLY_TYPE_MAINS]		= "Mains",
> +	[POWER_SUPPLY_TYPE_USB]			= "USB",
> +	[POWER_SUPPLY_TYPE_USB_DCP]		= "USB_DCP",
> +	[POWER_SUPPLY_TYPE_USB_CDP]		= "USB_CDP",
> +	[POWER_SUPPLY_TYPE_USB_ACA]		= "USB_ACA",
> +	[POWER_SUPPLY_TYPE_USB_TYPE_C]		= "USB_C",
> +	[POWER_SUPPLY_TYPE_USB_PD]		= "USB_PD",
> +	[POWER_SUPPLY_TYPE_USB_PD_DRP]		= "USB_PD_DRP",
> +	[POWER_SUPPLY_TYPE_APPLE_BRICK_ID]	= "BrickID",
>  };
>  
> -static const char * const power_supply_usb_type_text[] = {
> -	"Unknown", "SDP", "DCP", "CDP", "ACA", "C",
> -	"PD", "PD_DRP", "PD_PPS", "BrickID"
> +static const char * const POWER_SUPPLY_USB_TYPE_TEXT[] = {
> +	[POWER_SUPPLY_USB_TYPE_UNKNOWN]		= "Unknown",
> +	[POWER_SUPPLY_USB_TYPE_SDP]		= "SDP",
> +	[POWER_SUPPLY_USB_TYPE_DCP]		= "DCP",
> +	[POWER_SUPPLY_USB_TYPE_CDP]		= "CDP",
> +	[POWER_SUPPLY_USB_TYPE_ACA]		= "ACA",
> +	[POWER_SUPPLY_USB_TYPE_C]		= "C",
> +	[POWER_SUPPLY_USB_TYPE_PD]		= "PD",
> +	[POWER_SUPPLY_USB_TYPE_PD_DRP]		= "PD_DRP",
> +	[POWER_SUPPLY_USB_TYPE_PD_PPS]		= "PD_PPS",
> +	[POWER_SUPPLY_USB_TYPE_APPLE_BRICK_ID]	= "BrickID",
>  };
>  
>  static const char * const power_supply_status_text[] = {
> -	"Unknown", "Charging", "Discharging", "Not charging", "Full"
> +	[POWER_SUPPLY_STATUS_UNKNOWN]		= "Unknown",
> +	[POWER_SUPPLY_STATUS_CHARGING]		= "Charging",
> +	[POWER_SUPPLY_STATUS_DISCHARGING]	= "Discharging",
> +	[POWER_SUPPLY_STATUS_NOT_CHARGING]	= "Not charging",
> +	[POWER_SUPPLY_STATUS_FULL]		= "Full",
>  };
>  
>  static const char * const power_supply_charge_type_text[] = {
> -	"Unknown", "N/A", "Trickle", "Fast", "Standard", "Adaptive", "Custom"
> +	[POWER_SUPPLY_CHARGE_TYPE_UNKNOWN]	= "Unknown",
> +	[POWER_SUPPLY_CHARGE_TYPE_NONE]		= "N/A",
> +	[POWER_SUPPLY_CHARGE_TYPE_TRICKLE]	= "Trickle",
> +	[POWER_SUPPLY_CHARGE_TYPE_FAST]		= "Fast",
> +	[POWER_SUPPLY_CHARGE_TYPE_STANDARD]	= "Standard",
> +	[POWER_SUPPLY_CHARGE_TYPE_ADAPTIVE]	= "Adaptive",
> +	[POWER_SUPPLY_CHARGE_TYPE_CUSTOM]	= "Custom",
>  };
>  
>  static const char * const power_supply_health_text[] = {
> -	"Unknown", "Good", "Overheat", "Dead", "Over voltage",
> -	"Unspecified failure", "Cold", "Watchdog timer expire",
> -	"Safety timer expire", "Over current"
> +	[POWER_SUPPLY_HEALTH_UNKNOWN]		    = "Unknown",
> +	[POWER_SUPPLY_HEALTH_GOOD]		    = "Good",
> +	[POWER_SUPPLY_HEALTH_OVERHEAT]		    = "Overheat",
> +	[POWER_SUPPLY_HEALTH_DEAD]		    = "Dead",
> +	[POWER_SUPPLY_HEALTH_OVERVOLTAGE]	    = "Over voltage",
> +	[POWER_SUPPLY_HEALTH_UNSPEC_FAILURE]	    = "Unspecified failure",
> +	[POWER_SUPPLY_HEALTH_COLD]		    = "Cold",
> +	[POWER_SUPPLY_HEALTH_WATCHDOG_TIMER_EXPIRE] = "Watchdog timer expire",
> +	[POWER_SUPPLY_HEALTH_SAFETY_TIMER_EXPIRE]   = "Safety timer expire",
> +	[POWER_SUPPLY_HEALTH_OVERCURRENT]	    = "Over current",
>  };
>  
>  static const char * const power_supply_technology_text[] = {
> -	"Unknown", "NiMH", "Li-ion", "Li-poly", "LiFe", "NiCd",
> -	"LiMn"
> +	[POWER_SUPPLY_TECHNOLOGY_UNKNOWN]	= "Unknown",
> +	[POWER_SUPPLY_TECHNOLOGY_NiMH]		= "NiMH",
> +	[POWER_SUPPLY_TECHNOLOGY_LION]		= "Li-ion",
> +	[POWER_SUPPLY_TECHNOLOGY_LIPO]		= "Li-poly",
> +	[POWER_SUPPLY_TECHNOLOGY_LiFe]		= "LiFe",
> +	[POWER_SUPPLY_TECHNOLOGY_NiCd]		= "NiCd",
> +	[POWER_SUPPLY_TECHNOLOGY_LiMn]		= "LiMn",
>  };
>  
>  static const char * const power_supply_capacity_level_text[] = {
> -	"Unknown", "Critical", "Low", "Normal", "High", "Full"
> +	[POWER_SUPPLY_CAPACITY_LEVEL_UNKNOWN]	= "Unknown",
> +	[POWER_SUPPLY_CAPACITY_LEVEL_CRITICAL]	= "Critical",
> +	[POWER_SUPPLY_CAPACITY_LEVEL_LOW]	= "Low",
> +	[POWER_SUPPLY_CAPACITY_LEVEL_NORMAL]	= "Normal",
> +	[POWER_SUPPLY_CAPACITY_LEVEL_HIGH]	= "High",
> +	[POWER_SUPPLY_CAPACITY_LEVEL_FULL]	= "Full",
>  };
>  
>  static const char * const power_supply_scope_text[] = {
> -	"Unknown", "System", "Device"
> +	[POWER_SUPPLY_SCOPE_UNKNOWN]	= "Unknown",
> +	[POWER_SUPPLY_SCOPE_SYSTEM]	= "System",
> +	[POWER_SUPPLY_SCOPE_DEVICE]	= "Device",
>  };
>  
>  static struct power_supply_attr power_supply_attrs[] = {
> -- 
> 2.26.2.303.gf8c07b1a785-goog
> 

Download attachment "signature.asc" of type "application/pgp-signature" (834 bytes)

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ