Message ID | 16ca50739c664b3fa373306f3c08882d9d4cf55d.1585944770.git.mirq-linux@rere.qmqm.pl (mailing list archive) |
---|---|
State | Not Applicable, archived |
Headers | show |
Series | extensions and fixes | expand |
Hi, On Fri, Apr 03, 2020 at 10:20:32PM +0200, Michał Mirosław wrote: > Reduce power_supply_show_usb_type() parameter count by folding > power_supply_desc dereference into the function. This makes following > patch making usb_types const easier. > > Signed-off-by: Michał Mirosław <mirq-linux@rere.qmqm.pl> > --- Thanks, queued. -- Sebastian > drivers/power/supply/power_supply_sysfs.c | 10 ++++------ > 1 file changed, 4 insertions(+), 6 deletions(-) > > diff --git a/drivers/power/supply/power_supply_sysfs.c b/drivers/power/supply/power_supply_sysfs.c > index f37ad4eae60b..51de3f47b25d 100644 > --- a/drivers/power/supply/power_supply_sysfs.c > +++ b/drivers/power/supply/power_supply_sysfs.c > @@ -78,8 +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, > - ssize_t num_usb_types, > + const struct power_supply_desc *desc, > union power_supply_propval *value, > char *buf) > { > @@ -88,8 +87,8 @@ static ssize_t power_supply_show_usb_type(struct device *dev, > bool match = false; > int i; > > - for (i = 0; i < num_usb_types; ++i) { > - usb_type = usb_types[i]; > + for (i = 0; i < desc->num_usb_types; ++i) { > + usb_type = desc->usb_types[i]; > > if (value->intval == usb_type) { > count += sprintf(buf + count, "[%s] ", > @@ -163,8 +162,7 @@ static ssize_t power_supply_show_property(struct device *dev, > power_supply_type_text[value.intval]); > break; > case POWER_SUPPLY_PROP_USB_TYPE: > - ret = power_supply_show_usb_type(dev, psy->desc->usb_types, > - psy->desc->num_usb_types, > + ret = power_supply_show_usb_type(dev, psy->desc, > &value, buf); > break; > case POWER_SUPPLY_PROP_SCOPE: > -- > 2.20.1 >
diff --git a/drivers/power/supply/power_supply_sysfs.c b/drivers/power/supply/power_supply_sysfs.c index f37ad4eae60b..51de3f47b25d 100644 --- a/drivers/power/supply/power_supply_sysfs.c +++ b/drivers/power/supply/power_supply_sysfs.c @@ -78,8 +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, - ssize_t num_usb_types, + const struct power_supply_desc *desc, union power_supply_propval *value, char *buf) { @@ -88,8 +87,8 @@ static ssize_t power_supply_show_usb_type(struct device *dev, bool match = false; int i; - for (i = 0; i < num_usb_types; ++i) { - usb_type = usb_types[i]; + for (i = 0; i < desc->num_usb_types; ++i) { + usb_type = desc->usb_types[i]; if (value->intval == usb_type) { count += sprintf(buf + count, "[%s] ", @@ -163,8 +162,7 @@ static ssize_t power_supply_show_property(struct device *dev, power_supply_type_text[value.intval]); break; case POWER_SUPPLY_PROP_USB_TYPE: - ret = power_supply_show_usb_type(dev, psy->desc->usb_types, - psy->desc->num_usb_types, + ret = power_supply_show_usb_type(dev, psy->desc, &value, buf); break; case POWER_SUPPLY_PROP_SCOPE:
Reduce power_supply_show_usb_type() parameter count by folding power_supply_desc dereference into the function. This makes following patch making usb_types const easier. Signed-off-by: Michał Mirosław <mirq-linux@rere.qmqm.pl> --- drivers/power/supply/power_supply_sysfs.c | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-)