scsi sysfs (base 1/3)
Subsystems (3)
PATCH 1/1 scsi sysfs (base 1/3)
This is re-roll 3 of previous patch for SCSI sysfs cleanups. It includes updates from previous email comments.
This patch is against bk://linux-scsi.bkbits.net/scsi-misc-2.5
Changes:
[base]
- Concentrate scsi sysfs support functions into one file
- Added wrapper functions the reduce init / cleanup issues and mixed object issues (use of container_of with mixed types).
- Moved init_scsi initcall level to subsys_initcall.
- Added scsi-host class support. Future ../class/scsi_host/devices should equal scsi_host_list.
- Removed extra scsi(n) level in tree. Future ../class/scsi_host/devices/(n) children should equal host_queue.
- Changed call to scsi_add_host in scsi_debug to new format.
- Added support for scsi-host class.
[upper level]
- Minor changes to Scsi_Device_Template init.
[arm scsi]
- Added support for newer scsi_add_host.
- Needs compile check on arm.
Testing:
2x with ips, aic, qlogicisp, scsi_debug.
insmod / rmmod with shutdown.
-andmike
--
Michael Anderson
[email protected]
Makefile | 3 hosts.c | 29 ++++-- hosts.h | 19 +++- scsi.c | 42 +-------- scsi.h | 9 +- scsi_debug.c | 3 scsi_scan.c | 85 ------------------- scsi_syms.c | 4 scsi_sysfs.c | 259 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 9 files changed, 313 insertions(+), 140 deletions(-)
------
drivers/scsi/Makefile +2 -1
@@ -123,7 +123,8 @@ obj-$(CONFIG_CHR_DEV_SG) += sg.o scsi_mod-objs := scsi.o hosts.o scsi_ioctl.o constants.o scsicam.o \ - scsi_error.o scsi_lib.o scsi_scan.o scsi_syms.o + scsi_error.o scsi_lib.o scsi_scan.o scsi_syms.o \ + scsi_sysfs.o ifdef CONFIG_PROC_FS scsi_mod-objs += scsi_proc.o
drivers/scsi/hosts.c +19 -10
@@ -288,7 +288,7 @@return 0 ; } -int scsi_add_host (struct Scsi_Host *shost) +int __scsi_add_host (struct Scsi_Host *shost) {Scsi_Host_Template *sht = shost->hostt;struct scsi_device *sdev;
@@ -297,7 +297,6 @@printk (KERN_INFO "scsi%d : %s\n" , shost->host_no, sht->info ? sht->info (shost) : sht->name); -device_register (&shost->host_driverfs_dev);scsi_scan_host (shost); list_for_each_entry (sdev, &shost->my_devices, siblings) {
@@ -310,6 +309,22 @@ }/** +* scsi_add_host - add a scsi host +* @shost: scsi host pointer to add +* @dev: a struct device of type scsi class +* +* Return value: +* 0 on success / != 0 for error +**/ +int scsi_add_host (struct Scsi_Host *shost,struct device *dev) +{ + dev->class_data = shost; + shost->host_gendev = dev; + +return __scsi_add_host (shost); +} + +/** * scsi_unregister - unregister a scsi host * @shost: scsi host to be unregistered **/
@@ -333,9 +348,8 @@ shost->hostt->present--; -/* Cleanup proc and driverfs */ +/* Cleanup proc */ scsi_proc_host_rm (shost); -device_unregister (&shost->host_driverfs_dev);kfree (shost); }
@@ -448,11 +462,6 @@scsi_proc_host_add (shost); -strncpy (shost->host_driverfs_dev.name, shost_tp->proc_name, -DEVICE_NAME_SIZE -1 ); -sprintf (shost->host_driverfs_dev.bus_id,"scsi%d" , - shost->host_no); - shost->eh_notify = &sem;kernel_thread ((int (*)(void *)) scsi_error_handler, (void *) shost,0 );/*
@@ -509,7 +518,7 @@*/ list_for_each_entry (shost, &scsi_host_list, sh_list)if (shost->hostt == shost_tp) -if (scsi_add_host (shost)) +if (__scsi_add_host (shost)) goto out_of_space;return 0 ;
drivers/scsi/hosts.h +14 -5
@@ -488,7 +488,7 @@/* * Support for driverfs filesystem */ -struct device host_driverfs_dev; +struct device *host_gendev;/* * We should ensure that this is aligned, both for better performance
@@ -499,6 +499,8 @@ __attribute__ ((aligned (sizeof(unsigned long)))); }; +#define to_scsi_host (d) d->class_data +/* * These two functions are used to allocate and free a pseudo device * which will connect to the host adapter itself rather than any
@@ -524,7 +526,7 @@ struct pci_dev *pdev) { shost->pci_dev = pdev; - shost->host_driverfs_dev.parent=&pdev->dev; + shost->host_gendev = &pdev->dev; }
@@ -539,7 +541,6 @@ {struct list_head list;const char * name; -const char * tag;struct module * module;/* Used for loadable modules */ unsigned char scsi_type;int (*attach)(Scsi_Device *);/* Attach devices to arrays */
@@ -567,7 +568,7 @@/* * HBA registration/unregistration. */ -extern int scsi_add_host (struct Scsi_Host *); +extern int scsi_add_host (struct Scsi_Host *,struct device *);extern int scsi_remove_host (struct Scsi_Host *);/*
@@ -605,7 +606,15 @@break ; return sdev; } - + +/* +* sysfs support +*/ +extern int scsi_upper_driver_register (struct Scsi_Device_Template *); +extern void scsi_upper_driver_unregister (struct Scsi_Device_Template *); + +extern struct device_class shost_devclass; +#endif /* * Overrides for Emacs so that we follow Linus's tabbing style.
drivers/scsi/scsi.c +6 -36
82 lines not on this page · raw message
drivers/scsi/scsi.h +6 -3
@@ -401,9 +401,6 @@extern unsigned int scsi_logging_level;/* What do we log? */ -extern struct bus_type scsi_driverfs_bus_type; - -/* * These are the error handling functions defined in scsi_error.c */
@@ -986,5 +983,11 @@#define SCSI_SENSE_VALID (scmd) ((scmd->sense_buffer[0] & 0x70) == 0x70)int scsi_set_medium_removal (Scsi_Device *dev,char state); + +extern int scsi_device_register (struct scsi_device *); +extern void scsi_device_unregister (struct scsi_device *); + +extern int scsi_sysfs_register (void ); +extern void scsi_sysfs_unregister (void );#endif
drivers/scsi/scsi_debug.c +2 -1
@@ -155,6 +155,7 @@static char sdebug_proc_name[] ="scsi_debug" ;static struct device_driver sdebug_driverfs_driver = { .name = sdebug_proc_name, + .devclass = &shost_devclass, };/* function declarations */
@@ -1501,7 +1502,7 @@printk (KERN_ERR "sdebug_add_shost: scsi_register failed\n" );return ; } - err =scsi_add_host (hpnt); + err =scsi_add_host (hpnt, scsi_debug_hosts[num].dev);if (err) {printk (KERN_ERR "sdebug_add_shost: scsi_add_host failed\n" );scsi_unregister (hpnt);
drivers/scsi/scsi_scan.c +3 -82
103 lines not on this page · raw message
drivers/scsi/scsi_syms.c +2 -2
@@ -104,6 +104,6 @@EXPORT_SYMBOL (scsi_delete_timer);/* -* driverfs support for determining driver types +* sysfs support */ -EXPORT_SYMBOL (scsi_driverfs_bus_type); +EXPORT_SYMBOL (shost_devclass);
drivers/scsi/scsi_sysfs.c new file +259 -0
259 lines not on this page · raw message
PATCH 1/1 scsi sysfs (upper 2/3)
[upper level]
- Minor changes to Scsi_Device_Template init.
-andmike
--
Michael Anderson
[email protected]
sd.c | 5 +++-- sg.c | 8 +++++--- sr.c | 6 ++++-- st.c | 10 ++++++---- 4 files changed, 18 insertions(+), 11 deletions(-)
------
drivers/scsi/sd.c +3 -2
@@ -105,11 +105,13 @@ .module = THIS_MODULE, .list = LIST_HEAD_INIT(sd_template.list), .name = "disk", - .tag = "sd", .scsi_type = TYPE_DISK, .attach = sd_attach, .detach = sd_detach, .init_command = sd_init_command, + .scsi_driverfs_driver = { + .name = "sd", + }, };static struct scsi_disk *sd_find_by_sdev (Scsi_Device *sd)
@@ -1343,7 +1345,6 @@scsi_unregister_device (&sd_template);for (i =0 ; i <SD_MAJORS ; i++)unregister_blkdev (SD_MAJOR (i),"sd" ); -driver_unregister (&sd_template.scsi_driverfs_driver); }/*
drivers/scsi/sg.c +5 -3
@@ -122,10 +122,12 @@ .module = THIS_MODULE, .list = LIST_HEAD_INIT(sg_template.list), .name = "generic", - .tag = "sg", .scsi_type = 0xff, .attach = sg_attach, - .detach = sg_detach + .detach = sg_detach, + .scsi_driverfs_driver = { + .name = "sg", + }, }; typedef struct sg_scatter_hold { /* holding area for scsi scatter gather info */
@@ -1464,7 +1466,7 @@sprintf (sdp->sg_driverfs_dev.name,"%sgeneric" , scsidp->sdev_driverfs_dev.name); sdp->sg_driverfs_dev.parent = &scsidp->sdev_driverfs_dev; - sdp->sg_driverfs_dev.bus = &scsi_driverfs_bus_type; + sdp->sg_driverfs_dev.bus = scsidp->sdev_driverfs_dev.bus; sg_nr_dev++; sg_dev_arr[k] = sdp;
drivers/scsi/sr.c +4 -2
@@ -73,11 +73,13 @@ .module = THIS_MODULE, .list = LIST_HEAD_INIT(sr_template.list), .name = "cdrom", - .tag = "sr", .scsi_type = TYPE_ROM, .attach = sr_attach, .detach = sr_detach, - .init_command = sr_init_command + .init_command = sr_init_command, + .scsi_driverfs_driver = { + .name = "sr", + }, };static int sr_nr_dev;/* XXX(hch) bad hack, we want a bitmap instead */
drivers/scsi/st.c +6 -4
@@ -176,10 +176,12 @@ .module = THIS_MODULE, .list = LIST_HEAD_INIT(st_template.list), .name = "tape", - .tag = "st", .scsi_type = TYPE_TAPE, .attach = st_attach, - .detach = st_detach + .detach = st_detach, + .scsi_driverfs_driver = { + .name = "st", + }, };static int st_compression (Scsi_Tape *,int );
@@ -3826,7 +3828,7 @@sprintf (tpnt->driverfs_dev_r[mode].name,"%s%s" , SDp->sdev_driverfs_dev.name, name); tpnt->driverfs_dev_r[mode].parent = &SDp->sdev_driverfs_dev; - tpnt->driverfs_dev_r[mode].bus = &scsi_driverfs_bus_type; + tpnt->driverfs_dev_r[mode].bus = SDp->sdev_driverfs_dev.bus; tpnt->driverfs_dev_r[mode].driver_data = (void *)(long )__mkdev (SCSI_TAPE_MAJOR , dev_num + (mode <<5 ));device_register (&tpnt->driverfs_dev_r[mode]);
@@ -3845,7 +3847,7 @@sprintf (tpnt->driverfs_dev_n[mode].name,"%s%s" , SDp->sdev_driverfs_dev.name, name); tpnt->driverfs_dev_n[mode].parent= &SDp->sdev_driverfs_dev; - tpnt->driverfs_dev_n[mode].bus = &scsi_driverfs_bus_type; + tpnt->driverfs_dev_n[mode].bus = SDp->sdev_driverfs_dev.bus; tpnt->driverfs_dev_n[mode].driver_data = (void *)(long )__mkdev (SCSI_TAPE_MAJOR , dev_num + (mode <<5 ) +128 );device_register (&tpnt->driverfs_dev_n[mode]);
PATCH 1/1 scsi sysfs (arm scsi 3/3)
[arm scsi]
- Added support for newer scsi_add_host.
- Needs compile check on arm.
-andmike
--
Michael Anderson
[email protected]
acornscsi.c | 2 +- arxescsi.c | 2 +- cumana_1.c | 2 +- cumana_2.c | 2 +- eesox.c | 2 +- oak.c | 2 +- powertec.c | 2 +- 7 files changed, 7 insertions(+), 7 deletions(-)
------
drivers/acorn/scsi/acornscsi.c +1 -1
@@ -3051,7 +3051,7 @@acornscsi_resetcard (ashost); - ret =scsi_add_host (host); + ret =scsi_add_host (host, &ec->dev);if (ret ==0 ) goto out;
drivers/acorn/scsi/arxescsi.c +1 -1
@@ -398,7 +398,7 @@fas216_init (host); - ret =scsi_add_host (host); + ret =scsi_add_host (host, &ec->dev);if (ret ==0 ) goto out;
drivers/acorn/scsi/cumana_1.c +1 -1
@@ -299,7 +299,7 @@NCR5380_print_options (host);printk ("\n" ); - ret =scsi_add_host (host); + ret =scsi_add_host (host, &ec->dev);if (ret ==0 ) goto out;
drivers/acorn/scsi/cumana_2.c +1 -1
@@ -505,7 +505,7 @@fas216_init (host); - ret =scsi_add_host (host); + ret =scsi_add_host (host, &ec->dev);if (ret ==0 ) goto out;
drivers/acorn/scsi/eesox.c +1 -1
@@ -504,7 +504,7 @@ }fas216_init (host); - ret =scsi_add_host (host); + ret =scsi_add_host (host, &ec->dev);if (ret ==0 ) goto out;
drivers/acorn/scsi/oak.c +1 -1
@@ -160,7 +160,7 @@NCR5380_print_options (host);printk ("\n" ); - ret =scsi_add_host (host); + ret =scsi_add_host (host, &ec->dev);if (ret ==0 ) goto out;
drivers/acorn/scsi/powertec.c +1 -1
@@ -378,7 +378,7 @@fas216_init (host); - ret =scsi_add_host (host); + ret =scsi_add_host (host, &ec->dev);if (ret ==0 ) goto out;
Re: [PATCH] scsi sysfs (upper 2/3)
In reply to Mike AndersonQuoted 8 lines · On 2002.11.26 03:12 Mike Anderson wrote:
[upper level]
(quoted diff) +0
-2- Minor changes to Scsi_Device_Template init. -andmike --Michael Anderson
[email protected]
Quoted 6 lines
sd.c | 5 +++-- sg.c | 8 +++++--- sr.c | 6 ++++-- st.c | 10 ++++++---- 4 files changed, 18 insertions(+), 11 deletions(-)------
Ahum,
If you touch st.c like that, you have to do osst.c too!
Thanks, Willem Riede (osst maintainer).