diff --git a/drivers/power/supply/power_supply_sysfs.c b/drivers/power/supply/power_supply_sysfs.c index 04d9cb354bc5..bc4987648e8c 100644 --- a/drivers/power/supply/power_supply_sysfs.c +++ b/drivers/power/supply/power_supply_sysfs.c @@ -628,29 +628,12 @@ void power_supply_init_attrs(struct device_type *dev_type) __power_supply_attrs[i] = &power_supply_attrs[i].attr; } -static char *kstruprdup(const char *str, gfp_t gfp) -{ - char *ret, *ustr; - - ustr = ret = kmalloc(strlen(str) + 1, gfp); - - if (!ret) - return NULL; - - while (*str) - *ustr++ = toupper(*str++); - - *ustr = 0; - - return ret; -} - int power_supply_uevent(struct device *dev, struct kobj_uevent_env *env) { struct power_supply *psy = dev_get_drvdata(dev); int ret = 0, j; char *prop_buf; - char *attrname; + char attrname[64]; if (!psy || !psy->desc) { dev_dbg(dev, "No power supply yet\n"); @@ -667,7 +650,8 @@ int power_supply_uevent(struct device *dev, struct kobj_uevent_env *env) for (j = 0; j < psy->desc->num_properties; j++) { struct device_attribute *attr; - char *line; + const char *str; + char *line, *ustr; attr = &power_supply_attrs[psy->desc->properties[j]]; @@ -686,14 +670,14 @@ int power_supply_uevent(struct device *dev, struct kobj_uevent_env *env) if (line) *line = 0; - attrname = kstruprdup(attr->attr.name, GFP_KERNEL); - if (!attrname) { - ret = -ENOMEM; - goto out; - } + str = attr->attr.name; + ustr = attrname; + while (*str) + *ustr++ = toupper(*str++); + + *ustr = 0; ret = add_uevent_var(env, "POWER_SUPPLY_%s=%s", attrname, prop_buf); - kfree(attrname); if (ret) goto out; }