Skip to content

Commit

Permalink
Driver core: Remove unneeded get_{device,driver}() calls.
Browse files Browse the repository at this point in the history
Driver core: Remove unneeded get_{device,driver}() calls.

Code trying to add/remove attributes must hold a reference to
the device resp. driver anyway, so let's remove those reference
count games.

Signed-off-by: Cornelia Huck <[email protected]>
Cc: Dave Young <[email protected]>
Signed-off-by: Greg Kroah-Hartman <[email protected]>
  • Loading branch information
cohuck authored and gregkh committed Feb 2, 2008
1 parent 44414e1 commit 0c98b19
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 12 deletions.
8 changes: 2 additions & 6 deletions drivers/base/core.c
Original file line number Diff line number Diff line change
Expand Up @@ -423,10 +423,8 @@ struct kset *devices_kset;
int device_create_file(struct device *dev, struct device_attribute *attr)
{
int error = 0;
if (get_device(dev)) {
if (dev)
error = sysfs_create_file(&dev->kobj, &attr->attr);
put_device(dev);
}
return error;
}

Expand All @@ -437,10 +435,8 @@ int device_create_file(struct device *dev, struct device_attribute *attr)
*/
void device_remove_file(struct device *dev, struct device_attribute *attr)
{
if (get_device(dev)) {
if (dev)
sysfs_remove_file(&dev->kobj, &attr->attr);
put_device(dev);
}
}

/**
Expand Down
9 changes: 3 additions & 6 deletions drivers/base/driver.c
Original file line number Diff line number Diff line change
Expand Up @@ -97,10 +97,9 @@ int driver_create_file(struct device_driver *drv,
struct driver_attribute *attr)
{
int error;
if (get_driver(drv)) {
if (drv)
error = sysfs_create_file(&drv->p->kobj, &attr->attr);
put_driver(drv);
} else
else
error = -EINVAL;
return error;
}
Expand All @@ -114,10 +113,8 @@ EXPORT_SYMBOL_GPL(driver_create_file);
void driver_remove_file(struct device_driver *drv,
struct driver_attribute *attr)
{
if (get_driver(drv)) {
if (drv)
sysfs_remove_file(&drv->p->kobj, &attr->attr);
put_driver(drv);
}
}
EXPORT_SYMBOL_GPL(driver_remove_file);

Expand Down

0 comments on commit 0c98b19

Please sign in to comment.