[1/4] power: supply: core: Constify usb_types
diff mbox series

Message ID 20200413183853.1088823-2-sebastian.reichel@collabora.com
State New
Headers show
Series
  • Add support for constant power-supply property tables
Related show

Commit Message

Sebastian Reichel April 13, 2020, 6:38 p.m. UTC
usb_types is a list of USB types supported by the
hardware, which does not change at runtime. Let's
mark it as const for improved security.

Signed-off-by: Sebastian Reichel <sebastian.reichel@collabora.com>
---
 drivers/power/supply/power_supply_sysfs.c | 2 +-
 include/linux/power_supply.h              | 2 +-
 2 files changed, 2 insertions(+), 2 deletions(-)

Comments

Enric Balletbo i Serra April 14, 2020, 3:56 p.m. UTC | #1
Hi Sebastian,

On 13/4/20 20:38, Sebastian Reichel wrote:
> usb_types is a list of USB types supported by the
> hardware, which does not change at runtime. Let's
> mark it as const for improved security.
> 
> Signed-off-by: Sebastian Reichel <sebastian.reichel@collabora.com>

Reviewed-by: Enric Balletbo i Serra <enric.balletbo@collabora.com>

> ---
>  drivers/power/supply/power_supply_sysfs.c | 2 +-
>  include/linux/power_supply.h              | 2 +-
>  2 files changed, 2 insertions(+), 2 deletions(-)
> 
> diff --git a/drivers/power/supply/power_supply_sysfs.c b/drivers/power/supply/power_supply_sysfs.c
> index f37ad4eae60b..45dafc1820ff 100644
> --- a/drivers/power/supply/power_supply_sysfs.c
> +++ b/drivers/power/supply/power_supply_sysfs.c
> @@ -78,7 +78,7 @@ static const char * const power_supply_scope_text[] = {
>  };
>  
>  static ssize_t power_supply_show_usb_type(struct device *dev,
> -					  enum power_supply_usb_type *usb_types,
> +					  const enum power_supply_usb_type *usb_types,
>  					  ssize_t num_usb_types,
>  					  union power_supply_propval *value,
>  					  char *buf)
> diff --git a/include/linux/power_supply.h b/include/linux/power_supply.h
> index dcd5a71e6c67..0392c9cc8f1c 100644
> --- a/include/linux/power_supply.h
> +++ b/include/linux/power_supply.h
> @@ -223,7 +223,7 @@ struct power_supply_config {
>  struct power_supply_desc {
>  	const char *name;
>  	enum power_supply_type type;
> -	enum power_supply_usb_type *usb_types;
> +	const enum power_supply_usb_type *usb_types;
>  	size_t num_usb_types;
>  	enum power_supply_property *properties;
>  	size_t num_properties;
>

Patch
diff mbox series

diff --git a/drivers/power/supply/power_supply_sysfs.c b/drivers/power/supply/power_supply_sysfs.c
index f37ad4eae60b..45dafc1820ff 100644
--- a/drivers/power/supply/power_supply_sysfs.c
+++ b/drivers/power/supply/power_supply_sysfs.c
@@ -78,7 +78,7 @@  static const char * const power_supply_scope_text[] = {
 };
 
 static ssize_t power_supply_show_usb_type(struct device *dev,
-					  enum power_supply_usb_type *usb_types,
+					  const enum power_supply_usb_type *usb_types,
 					  ssize_t num_usb_types,
 					  union power_supply_propval *value,
 					  char *buf)
diff --git a/include/linux/power_supply.h b/include/linux/power_supply.h
index dcd5a71e6c67..0392c9cc8f1c 100644
--- a/include/linux/power_supply.h
+++ b/include/linux/power_supply.h
@@ -223,7 +223,7 @@  struct power_supply_config {
 struct power_supply_desc {
 	const char *name;
 	enum power_supply_type type;
-	enum power_supply_usb_type *usb_types;
+	const enum power_supply_usb_type *usb_types;
 	size_t num_usb_types;
 	enum power_supply_property *properties;
 	size_t num_properties;