Skip to content
This repository has been archived by the owner on Aug 27, 2022. It is now read-only.

Commit

Permalink
Infiniband: make ipath driver use default driver groups.
Browse files Browse the repository at this point in the history
Make the ipath driver use the new driver functions so that it does not
touch the sysfs portion of the driver structure.

We also remove the redundant symlink from the device back to the driver,
as it is already in the sysfs tree.  Any userspace tools should be using
the standard symlink, not some driver specific one.

Cc: Roland Dreier <rdreier@cisco.com>
Cc: Bryan O'Sullivan <bryan.osullivan@qlogic.com>
Cc: Arthur Jones <arthur.jones@qlogic.com>
Cc: Cornelia Huck <cornelia.huck@de.ibm.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
  • Loading branch information
gregkh committed Jan 25, 2008
1 parent 0478b83 commit 23b9c1a
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 45 deletions.
13 changes: 8 additions & 5 deletions drivers/infiniband/hw/ehca/ehca_main.c
Original file line number Diff line number Diff line change
Expand Up @@ -590,6 +590,11 @@ static struct attribute_group ehca_drv_attr_grp = {
.attrs = ehca_drv_attrs
};

static struct attribute_group *ehca_drv_attr_groups[] = {
&ehca_drv_attr_grp,
NULL,
};

#define EHCA_RESOURCE_ATTR(name) \
static ssize_t ehca_show_##name(struct device *dev, \
struct device_attribute *attr, \
Expand Down Expand Up @@ -899,6 +904,9 @@ static struct of_platform_driver ehca_driver = {
.match_table = ehca_device_table,
.probe = ehca_probe,
.remove = ehca_remove,
.driver = {
.groups = ehca_drv_attr_groups,
},
};

void ehca_poll_eqs(unsigned long data)
Expand Down Expand Up @@ -957,10 +965,6 @@ int __init ehca_module_init(void)
goto module_init2;
}

ret = sysfs_create_group(&ehca_driver.driver.kobj, &ehca_drv_attr_grp);
if (ret) /* only complain; we can live without attributes */
ehca_gen_err("Cannot create driver attributes ret=%d", ret);

if (ehca_poll_all_eqs != 1) {
ehca_gen_err("WARNING!!!");
ehca_gen_err("It is possible to lose interrupts.");
Expand All @@ -986,7 +990,6 @@ void __exit ehca_module_exit(void)
if (ehca_poll_all_eqs == 1)
del_timer_sync(&poll_eqs_timer);

sysfs_remove_group(&ehca_driver.driver.kobj, &ehca_drv_attr_grp);
ibmebus_unregister_driver(&ehca_driver);

ehca_destroy_slab_caches();
Expand Down
17 changes: 4 additions & 13 deletions drivers/infiniband/hw/ipath/ipath_driver.c
Original file line number Diff line number Diff line change
Expand Up @@ -121,6 +121,9 @@ static struct pci_driver ipath_driver = {
.probe = ipath_init_one,
.remove = __devexit_p(ipath_remove_one),
.id_table = ipath_pci_tbl,
.driver = {
.groups = ipath_driver_attr_groups,
},
};

static void ipath_check_status(struct work_struct *work)
Expand Down Expand Up @@ -2217,25 +2220,15 @@ static int __init infinipath_init(void)
goto bail_unit;
}

ret = ipath_driver_create_group(&ipath_driver.driver);
if (ret < 0) {
printk(KERN_ERR IPATH_DRV_NAME ": Unable to create driver "
"sysfs entries: error %d\n", -ret);
goto bail_pci;
}

ret = ipath_init_ipathfs();
if (ret < 0) {
printk(KERN_ERR IPATH_DRV_NAME ": Unable to create "
"ipathfs: error %d\n", -ret);
goto bail_group;
goto bail_pci;
}

goto bail;

bail_group:
ipath_driver_remove_group(&ipath_driver.driver);

bail_pci:
pci_unregister_driver(&ipath_driver);

Expand All @@ -2250,8 +2243,6 @@ static void __exit infinipath_cleanup(void)
{
ipath_exit_ipathfs();

ipath_driver_remove_group(&ipath_driver.driver);

ipath_cdbg(VERBOSE, "Unregistering pci driver\n");
pci_unregister_driver(&ipath_driver);

Expand Down
3 changes: 1 addition & 2 deletions drivers/infiniband/hw/ipath/ipath_kernel.h
Original file line number Diff line number Diff line change
Expand Up @@ -938,8 +938,7 @@ struct device_driver;

extern const char ib_ipath_version[];

int ipath_driver_create_group(struct device_driver *);
void ipath_driver_remove_group(struct device_driver *);
extern struct attribute_group *ipath_driver_attr_groups[];

int ipath_device_create_group(struct device *, struct ipath_devdata *);
void ipath_device_remove_group(struct device *, struct ipath_devdata *);
Expand Down
30 changes: 5 additions & 25 deletions drivers/infiniband/hw/ipath/ipath_sysfs.c
Original file line number Diff line number Diff line change
Expand Up @@ -683,6 +683,11 @@ static struct attribute_group driver_attr_group = {
.attrs = driver_attributes
};

struct attribute_group *ipath_driver_attr_groups[] = {
&driver_attr_group,
NULL,
};

static DEVICE_ATTR(guid, S_IWUSR | S_IRUGO, show_guid, store_guid);
static DEVICE_ATTR(lmc, S_IWUSR | S_IRUGO, show_lmc, store_lmc);
static DEVICE_ATTR(lid, S_IWUSR | S_IRUGO, show_lid, store_lid);
Expand Down Expand Up @@ -753,24 +758,9 @@ int ipath_expose_reset(struct device *dev)
return ret;
}

int ipath_driver_create_group(struct device_driver *drv)
{
int ret;

ret = sysfs_create_group(&drv->kobj, &driver_attr_group);

return ret;
}

void ipath_driver_remove_group(struct device_driver *drv)
{
sysfs_remove_group(&drv->kobj, &driver_attr_group);
}

int ipath_device_create_group(struct device *dev, struct ipath_devdata *dd)
{
int ret;
char unit[5];

ret = sysfs_create_group(&dev->kobj, &dev_attr_group);
if (ret)
Expand All @@ -780,11 +770,6 @@ int ipath_device_create_group(struct device *dev, struct ipath_devdata *dd)
if (ret)
goto bail_attrs;

snprintf(unit, sizeof(unit), "%02d", dd->ipath_unit);
ret = sysfs_create_link(&dev->driver->kobj, &dev->kobj, unit);
if (ret == 0)
goto bail;

sysfs_remove_group(&dev->kobj, &dev_counter_attr_group);
bail_attrs:
sysfs_remove_group(&dev->kobj, &dev_attr_group);
Expand All @@ -794,11 +779,6 @@ int ipath_device_create_group(struct device *dev, struct ipath_devdata *dd)

void ipath_device_remove_group(struct device *dev, struct ipath_devdata *dd)
{
char unit[5];

snprintf(unit, sizeof(unit), "%02d", dd->ipath_unit);
sysfs_remove_link(&dev->driver->kobj, unit);

sysfs_remove_group(&dev->kobj, &dev_counter_attr_group);
sysfs_remove_group(&dev->kobj, &dev_attr_group);

Expand Down

0 comments on commit 23b9c1a

Please sign in to comment.