Skip to contentSkip to conversation

rework shost/sdev attribute handling

PATCH New Christoph Hellwig 1 participant 1 message Jul 7, 2003

Subsystems (3)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 rework shost/sdev attribute handling

Hi James,

I've finally found some time to look over the per-driver sdev/shost attribute handling and I'm not so happy with it. First it adds new writeable variables to the host templates which is otherwise almost readonly, the other thing is that it needs per-template procedure calls in the drivers wheras we have moved away from that. Also it looks a bit coplicated :)

I've attached a patch below that makes the attributes handling a lot simpler. Details:

- the shost_attrs and sdev_attrs in the host template are now used to store the attributes overriden or added by the LLDD.
- the midlayer creates those first and then the generic attributes that haven't been overridded and the other way around.
- the host attributes are properly unregistered now and don't leak anymore.

Unlike the first patch the attribute inheritance is back.

drivers/scsi/53c700.c +6 -19
diff -Nru a/drivers/scsi/53c700.c b/drivers/scsi/53c700.c
@@ -172,7 +172,7 @@
 STATIC int NCR_700_slave_configure(Scsi_Device *SDpnt);
 STATIC void NCR_700_slave_destroy(Scsi_Device *SDpnt);
 
-static struct device_attribute **NCR_700_dev_attrs = NULL;
+STATIC struct device_attribute *NCR_700_dev_attrs[];
 
 static char *NCR_700_phase[] = {
 	"",
@@ -2027,25 +2027,12 @@
 	.show = NCR_700_show_active_tags,
 };
 
-STATIC int __init
-NCR_700_init(void)
-{
-	scsi_sysfs_modify_sdev_attribute(&NCR_700_dev_attrs,
-					 &NCR_700_queue_depth_attr);
-	scsi_sysfs_modify_sdev_attribute(&NCR_700_dev_attrs,
-					 &NCR_700_active_tags_attr);
-	return 0;
-}
-
-/* NULL exit routine to keep modutils happy */
-STATIC void __exit
-NCR_700_exit(void)
-{
-}
+STATIC struct device_attribute *NCR_700_dev_attrs[] = {
+	&NCR_700_queue_depth_attr,
+	&NCR_700_active_tags_attr,
+	NULL,
+};
 
 EXPORT_SYMBOL(NCR_700_detect);
 EXPORT_SYMBOL(NCR_700_release);
 EXPORT_SYMBOL(NCR_700_intr);
-
-module_init(NCR_700_init);
-module_exit(NCR_700_exit);
drivers/scsi/NCR_D700.c +0 -1
diff -Nru a/drivers/scsi/NCR_D700.c b/drivers/scsi/NCR_D700.c
@@ -387,7 +387,6 @@
 static void __exit NCR_D700_exit(void)
 {
 	mca_unregister_driver(&NCR_D700_driver);
-	scsi_sysfs_release_attributes(&NCR_D700_driver_template);
 }
 
 module_init(NCR_D700_init);
drivers/scsi/NCR_Q720.c +0 -1
diff -Nru a/drivers/scsi/NCR_Q720.c b/drivers/scsi/NCR_Q720.c
@@ -347,7 +347,6 @@
 NCR_Q720_exit(void)
 {
 	mca_unregister_driver(&NCR_Q720_driver);
-	//scsi_sysfs_release_attributes(&NCR_Q720_driver_template);
 }
 
 module_init(NCR_Q720_init);
drivers/scsi/hosts.c +0 -6
diff -Nru a/drivers/scsi/hosts.c b/drivers/scsi/hosts.c
@@ -151,12 +151,6 @@
 		dump_stack();
         }
 
-	/* if its not set in the template, use the default */
-	if (!sht->shost_attrs)
-		 sht->shost_attrs = scsi_sysfs_shost_attrs;
-	if (!sht->sdev_attrs)
-		 sht->sdev_attrs = scsi_sysfs_sdev_attrs;
-
 	shost = kmalloc(sizeof(struct Scsi_Host) + privsize, gfp_mask);
 	if (!shost)
 		return NULL;
drivers/scsi/lasi700.c +0 -1
diff -Nru a/drivers/scsi/lasi700.c b/drivers/scsi/lasi700.c
@@ -165,7 +165,6 @@
 lasi700_exit(void)
 {
 	unregister_parisc_driver(&lasi700_driver);
-	scsi_sysfs_release_attributes(&lasi700_template);
 }
 
 module_init(lasi700_init);
drivers/scsi/scsi.h +0 -5
diff -Nru a/drivers/scsi/scsi.h b/drivers/scsi/scsi.h
@@ -174,11 +174,6 @@
 #define SCSI_MLQUEUE_DEVICE_BUSY 0x1056
 #define SCSI_MLQUEUE_EH_RETRY    0x1057
 
-extern int scsi_sysfs_modify_sdev_attribute(struct device_attribute ***dev_attrs,
-					    struct device_attribute *attr);
-extern int scsi_sysfs_modify_shost_attribute(struct class_device_attribute ***class_attrs,
-					     struct class_device_attribute *attr);
-
 /*
  * Legacy dma direction interfaces.
  *
drivers/scsi/scsi_priv.h +0 -5
diff -Nru a/drivers/scsi/scsi_priv.h b/drivers/scsi/scsi_priv.h
@@ -117,11 +117,6 @@
 extern int scsi_sysfs_register(void);
 extern void scsi_sysfs_unregister(void);
 
-/* definitions for the linker default sections covering the host
- * class and device attributes */
-extern struct class_device_attribute *scsi_sysfs_shost_attrs[];
-extern struct device_attribute *scsi_sysfs_sdev_attrs[];
-
 extern struct class shost_class;
 extern struct bus_type scsi_bus_type;
 
drivers/scsi/scsi_sysfs.c +112 -145

308 lines not on this page · raw message

include/scsi/scsi_host.h +2 -4
diff -Nru a/include/scsi/scsi_host.h b/include/scsi/scsi_host.h
@@ -329,12 +329,12 @@
 #define SCSI_DEFAULT_HOST_BLOCKED	7
 
 	/*
-	 * Pointer to the sysfs class properties for this host
+	 * Pointer to the sysfs class properties for this host, NULL terminated.
 	 */
 	struct class_device_attribute **shost_attrs;
 
 	/*
-	 * Pointer to the SCSI device properties for this host
+	 * Pointer to the SCSI device properties for this host, NULL terminated.
 	 */
 	struct device_attribute **sdev_attrs;
 
@@ -499,8 +499,6 @@
 {
         return shost->shost_gendev.parent;
 }
-
-extern void scsi_sysfs_release_attributes(struct scsi_host_template *);
 
 extern void scsi_unblock_requests(struct Scsi_Host *);
 extern void scsi_block_requests(struct Scsi_Host *);