* [patch 1/3] driver core: Introduce default attribute groups.
[not found] <20071205114119.905238262@de.ibm.com>
@ 2007-12-05 11:50 ` Cornelia Huck
2007-12-05 16:24 ` Greg KH
2007-12-05 11:50 ` [patch 2/3] netiucv: Use device_driver " Cornelia Huck
2007-12-05 11:50 ` [patch 3/3] zfcp: " Cornelia Huck
2 siblings, 1 reply; 4+ messages in thread
From: Cornelia Huck @ 2007-12-05 11:50 UTC (permalink / raw)
To: gregkh; +Cc: linux-kernel, Cornelia Huck
This is lot like default attributes for devices (and indeed,
a lot of the code is lifted from there).
Signed-off-by: Cornelia Huck <cornelia.huck@de.ibm.com>
---
drivers/base/driver.c | 44 +++++++++++++++++++++++++++++++++++++++++++-
include/linux/device.h | 2 ++
2 files changed, 45 insertions(+), 1 deletion(-)
Index: linux-2.6/drivers/base/driver.c
===================================================================
--- linux-2.6.orig/drivers/base/driver.c 2007-12-05 09:53:15.000000000 +0100
+++ linux-2.6/drivers/base/driver.c 2007-12-05 12:41:02.000000000 +0100
@@ -151,6 +151,39 @@ void put_driver(struct device_driver * d
kobject_put(&drv->p->kobj);
}
+static int driver_add_groups(struct device_driver *drv,
+ struct attribute_group **groups)
+{
+ int error = 0;
+ int i;
+ struct driver_private *priv = drv->p;
+
+ if (groups) {
+ for (i = 0; groups[i]; i++) {
+ error = sysfs_create_group(&priv->kobj, groups[i]);
+ if (error) {
+ while (--i >= 0)
+ sysfs_remove_group(&priv->kobj,
+ groups[i]);
+ break;
+ }
+ }
+ }
+ return error;
+}
+
+static void driver_remove_groups(struct device_driver *drv,
+ struct attribute_group **groups)
+{
+ int i;
+ struct driver_private *priv = drv->p;
+
+ if (groups)
+ for (i = 0; groups[i]; i++)
+ sysfs_remove_group(&priv->kobj, groups[i]);
+}
+
+
/**
* driver_register - register driver with bus
* @drv: driver to register
@@ -161,12 +194,20 @@ void put_driver(struct device_driver * d
*/
int driver_register(struct device_driver * drv)
{
+ int ret;
+
if ((drv->bus->probe && drv->probe) ||
(drv->bus->remove && drv->remove) ||
(drv->bus->shutdown && drv->shutdown)) {
printk(KERN_WARNING "Driver '%s' needs updating - please use bus_type methods\n", drv->name);
}
- return bus_add_driver(drv);
+ ret = bus_add_driver(drv);
+ if (ret)
+ return ret;
+ ret = driver_add_groups(drv, drv->groups);
+ if (ret)
+ bus_remove_driver(drv);
+ return ret;
}
/**
@@ -178,6 +219,7 @@ int driver_register(struct device_driver
void driver_unregister(struct device_driver * drv)
{
+ driver_remove_groups(drv, drv->groups);
bus_remove_driver(drv);
}
Index: linux-2.6/include/linux/device.h
===================================================================
--- linux-2.6.orig/include/linux/device.h 2007-12-05 09:53:15.000000000 +0100
+++ linux-2.6/include/linux/device.h 2007-12-05 12:25:36.000000000 +0100
@@ -126,6 +126,8 @@ struct device_driver {
int (*suspend) (struct device * dev, pm_message_t state);
int (*resume) (struct device * dev);
+ struct attribute_group **groups;
+
struct driver_private *p;
};
^ permalink raw reply [flat|nested] 4+ messages in thread
* [patch 2/3] netiucv: Use device_driver default attribute groups.
[not found] <20071205114119.905238262@de.ibm.com>
2007-12-05 11:50 ` [patch 1/3] driver core: Introduce default attribute groups Cornelia Huck
@ 2007-12-05 11:50 ` Cornelia Huck
2007-12-05 11:50 ` [patch 3/3] zfcp: " Cornelia Huck
2 siblings, 0 replies; 4+ messages in thread
From: Cornelia Huck @ 2007-12-05 11:50 UTC (permalink / raw)
To: gregkh; +Cc: linux-kernel, Ursula Braun, Cornelia Huck
CC: Ursula Braun <ubraun@linux.vnet.ibm.com>
Signed-off-by: Cornelia Huck <cornelia.huck@de.ibm.com>
---
drivers/s390/net/netiucv.c | 16 ++++++----------
1 files changed, 6 insertions(+), 10 deletions(-)
--- linux-2.6.orig/drivers/s390/net/netiucv.c
+++ linux-2.6/drivers/s390/net/netiucv.c
@@ -2089,6 +2089,11 @@ static struct attribute_group netiucv_dr
.attrs = netiucv_drv_attrs,
};
+static struct attribute_group *netiucv_drv_attr_groups[] = {
+ &netiucv_drv_attr_group,
+ NULL,
+};
+
static void netiucv_banner(void)
{
PRINT_INFO("NETIUCV driver initialized\n");
@@ -2113,7 +2118,6 @@ static void __exit netiucv_exit(void)
netiucv_unregister_device(dev);
}
- sysfs_remove_group(&netiucv_driver.kobj, &netiucv_drv_attr_group);
driver_unregister(&netiucv_driver);
iucv_unregister(&netiucv_handler, 1);
iucv_unregister_dbf_views();
@@ -2133,6 +2137,7 @@ static int __init netiucv_init(void)
if (rc)
goto out_dbf;
IUCV_DBF_TEXT(trace, 3, __FUNCTION__);
+ netiucv_driver.groups = netiucv_drv_attr_groups;
rc = driver_register(&netiucv_driver);
if (rc) {
PRINT_ERR("NETIUCV: failed to register driver.\n");
@@ -2140,18 +2145,9 @@ static int __init netiucv_init(void)
goto out_iucv;
}
- rc = sysfs_create_group(&netiucv_driver.kobj, &netiucv_drv_attr_group);
- if (rc) {
- PRINT_ERR("NETIUCV: failed to add driver attributes.\n");
- IUCV_DBF_TEXT_(setup, 2,
- "ret %d - netiucv_drv_attr_group\n", rc);
- goto out_driver;
- }
netiucv_banner();
return rc;
-out_driver:
- driver_unregister(&netiucv_driver);
out_iucv:
iucv_unregister(&netiucv_handler, 1);
out_dbf:
^ permalink raw reply [flat|nested] 4+ messages in thread
* [patch 3/3] zfcp: Use device_driver default attribute groups.
[not found] <20071205114119.905238262@de.ibm.com>
2007-12-05 11:50 ` [patch 1/3] driver core: Introduce default attribute groups Cornelia Huck
2007-12-05 11:50 ` [patch 2/3] netiucv: Use device_driver " Cornelia Huck
@ 2007-12-05 11:50 ` Cornelia Huck
2 siblings, 0 replies; 4+ messages in thread
From: Cornelia Huck @ 2007-12-05 11:50 UTC (permalink / raw)
To: gregkh; +Cc: linux-kernel, Swen Schillig, Cornelia Huck
CC: Swen Schillig <swen@vnet.ibm.com>
Signed-off-by: Cornelia Huck <cornelia.huck@de.ibm.com>
---
drivers/s390/scsi/zfcp_ccw.c | 14 ++++----------
drivers/s390/scsi/zfcp_ext.h | 3 +--
drivers/s390/scsi/zfcp_sysfs_driver.c | 27 ++++-----------------------
3 files changed, 9 insertions(+), 35 deletions(-)
--- linux-2.6.orig/drivers/s390/scsi/zfcp_ccw.c
+++ linux-2.6/drivers/s390/scsi/zfcp_ccw.c
@@ -52,6 +52,9 @@ static struct ccw_driver zfcp_ccw_driver
.set_offline = zfcp_ccw_set_offline,
.notify = zfcp_ccw_notify,
.shutdown = zfcp_ccw_shutdown,
+ .driver = {
+ .groups = zfcp_driver_attr_groups,
+ },
};
MODULE_DEVICE_TABLE(ccw, zfcp_ccw_device_id);
@@ -251,16 +254,7 @@ zfcp_ccw_notify(struct ccw_device *ccw_d
int __init
zfcp_ccw_register(void)
{
- int retval;
-
- retval = ccw_driver_register(&zfcp_ccw_driver);
- if (retval)
- goto out;
- retval = zfcp_sysfs_driver_create_files(&zfcp_ccw_driver.driver);
- if (retval)
- ccw_driver_unregister(&zfcp_ccw_driver);
- out:
- return retval;
+ return ccw_driver_register(&zfcp_ccw_driver);
}
/**
--- linux-2.6.orig/drivers/s390/scsi/zfcp_ext.h
+++ linux-2.6/drivers/s390/scsi/zfcp_ext.h
@@ -27,8 +27,7 @@
extern struct zfcp_data zfcp_data;
/******************************** SYSFS *************************************/
-extern int zfcp_sysfs_driver_create_files(struct device_driver *);
-extern void zfcp_sysfs_driver_remove_files(struct device_driver *);
+extern struct attribute_group *zfcp_driver_attr_groups[];
extern int zfcp_sysfs_adapter_create_files(struct device *);
extern void zfcp_sysfs_adapter_remove_files(struct device *);
extern int zfcp_sysfs_port_create_files(struct device *, u32);
--- linux-2.6.orig/drivers/s390/scsi/zfcp_sysfs_driver.c
+++ linux-2.6/drivers/s390/scsi/zfcp_sysfs_driver.c
@@ -98,28 +98,9 @@ static struct attribute_group zfcp_drive
.attrs = zfcp_driver_attrs,
};
-/**
- * zfcp_sysfs_create_driver_files - create sysfs driver files
- * @dev: pointer to belonging device
- *
- * Create all sysfs attributes of the zfcp device driver
- */
-int
-zfcp_sysfs_driver_create_files(struct device_driver *drv)
-{
- return sysfs_create_group(&drv->kobj, &zfcp_driver_attr_group);
-}
-
-/**
- * zfcp_sysfs_remove_driver_files - remove sysfs driver files
- * @dev: pointer to belonging device
- *
- * Remove all sysfs attributes of the zfcp device driver
- */
-void
-zfcp_sysfs_driver_remove_files(struct device_driver *drv)
-{
- sysfs_remove_group(&drv->kobj, &zfcp_driver_attr_group);
-}
+struct attribute_group *zfcp_driver_attr_groups[] = {
+ &zfcp_driver_attr_group,
+ NULL,
+};
#undef ZFCP_LOG_AREA
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [patch 1/3] driver core: Introduce default attribute groups.
2007-12-05 11:50 ` [patch 1/3] driver core: Introduce default attribute groups Cornelia Huck
@ 2007-12-05 16:24 ` Greg KH
0 siblings, 0 replies; 4+ messages in thread
From: Greg KH @ 2007-12-05 16:24 UTC (permalink / raw)
To: Cornelia Huck; +Cc: linux-kernel
On Wed, Dec 05, 2007 at 12:50:23PM +0100, Cornelia Huck wrote:
> This is lot like default attributes for devices (and indeed,
> a lot of the code is lifted from there).
>
> Signed-off-by: Cornelia Huck <cornelia.huck@de.ibm.com>
>
> ---
> drivers/base/driver.c | 44 +++++++++++++++++++++++++++++++++++++++++++-
> include/linux/device.h | 2 ++
> 2 files changed, 45 insertions(+), 1 deletion(-)
>
> Index: linux-2.6/drivers/base/driver.c
> ===================================================================
> --- linux-2.6.orig/drivers/base/driver.c 2007-12-05 09:53:15.000000000 +0100
> +++ linux-2.6/drivers/base/driver.c 2007-12-05 12:41:02.000000000 +0100
> @@ -151,6 +151,39 @@ void put_driver(struct device_driver * d
> kobject_put(&drv->p->kobj);
> }
>
> +static int driver_add_groups(struct device_driver *drv,
> + struct attribute_group **groups)
Heh, I just added a driver_add_group() function, to fix up some other
ppc driver :)
I'll delete that and use this series instead, it's nicer.
thanks,
greg k-h
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2007-12-05 16:23 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
[not found] <20071205114119.905238262@de.ibm.com>
2007-12-05 11:50 ` [patch 1/3] driver core: Introduce default attribute groups Cornelia Huck
2007-12-05 16:24 ` Greg KH
2007-12-05 11:50 ` [patch 2/3] netiucv: Use device_driver " Cornelia Huck
2007-12-05 11:50 ` [patch 3/3] zfcp: " Cornelia Huck
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).