@@ -54,30 +54,6 @@ static struct class_device_attribute *scsi_sysfs_shost_attrs[] = {
5454 NULL
5555};
5656
57- static void scsi_host_cls_release (struct class_device * class_dev )
58- {
59- struct Scsi_Host * shost ;
60-
61- shost = class_to_shost (class_dev );
62- put_device (& shost -> shost_gendev );
63- }
64-
65- static void scsi_host_dev_release (struct device * dev )
66- {
67- struct Scsi_Host * shost ;
68- struct device * parent ;
69-
70- parent = dev -> parent ;
71- shost = dev_to_shost (dev );
72- scsi_free_shost (shost );
73- put_device (parent );
74- }
75-
76- struct class shost_class = {
77- .name = "scsi_host" ,
78- .release = scsi_host_cls_release ,
79- };
80-
8157static void scsi_device_cls_release (struct class_device * class_dev )
8258{
8359 struct scsi_device * sdev ;
@@ -119,27 +95,18 @@ int scsi_sysfs_register(void)
11995 int error ;
12096
12197 error = bus_register (& scsi_bus_type );
122- if (error )
123- return error ;
124- error = class_register (& shost_class );
125- if (error )
126- goto bus_unregister ;
127- error = class_register (& sdev_class );
128- if (error )
129- goto class_unregister ;
130- return 0 ;
98+ if (!error ) {
99+ error = class_register (& sdev_class );
100+ if (error )
101+ bus_unregister (& scsi_bus_type );
102+ }
131103
132- class_unregister :
133- class_unregister (& shost_class );
134- bus_unregister :
135- bus_unregister (& scsi_bus_type );
136104 return error ;
137105}
138106
139107void scsi_sysfs_unregister (void )
140108{
141109 class_unregister (& sdev_class );
142- class_unregister (& shost_class );
143110 bus_unregister (& scsi_bus_type );
144111}
145112
@@ -403,22 +370,6 @@ int scsi_register_interface(struct class_interface *intf)
403370}
404371
405372
406- void scsi_sysfs_init_host (struct Scsi_Host * shost )
407- {
408- device_initialize (& shost -> shost_gendev );
409- snprintf (shost -> shost_gendev .bus_id , BUS_ID_SIZE , "host%d" ,
410- shost -> host_no );
411- snprintf (shost -> shost_gendev .name , DEVICE_NAME_SIZE , "%s" ,
412- shost -> hostt -> proc_name );
413- shost -> shost_gendev .release = scsi_host_dev_release ;
414-
415- class_device_initialize (& shost -> shost_classdev );
416- shost -> shost_classdev .dev = & shost -> shost_gendev ;
417- shost -> shost_classdev .class = & shost_class ;
418- snprintf (shost -> shost_classdev .class_id , BUS_ID_SIZE , "host%d" ,
419- shost -> host_no );
420- }
421-
422373static struct class_device_attribute * class_attr_overridden (
423374 struct class_device_attribute * * attrs ,
424375 struct class_device_attribute * attr )
@@ -461,31 +412,16 @@ static int class_attr_add(struct class_device *classdev,
461412 * @shost: scsi host struct to add to subsystem
462413 * @dev: parent struct device pointer
463414 **/
464- int scsi_sysfs_add_host (struct Scsi_Host * shost , struct device * dev )
415+ int scsi_sysfs_add_host (struct Scsi_Host * shost )
465416{
466417 int error , i ;
467418
468- if (!shost -> shost_gendev .parent )
469- shost -> shost_gendev .parent = dev ? dev : & legacy_bus ;
470-
471- error = device_add (& shost -> shost_gendev );
472- if (error )
473- return error ;
474-
475- set_bit (SHOST_ADD , & shost -> shost_state );
476- get_device (shost -> shost_gendev .parent );
477-
478- error = class_device_add (& shost -> shost_classdev );
479- if (error )
480- goto clean_device ;
481-
482- get_device (& shost -> shost_gendev );
483419 if (shost -> hostt -> shost_attrs ) {
484420 for (i = 0 ; shost -> hostt -> shost_attrs [i ]; i ++ ) {
485421 error = class_attr_add (& shost -> shost_classdev ,
486422 shost -> hostt -> shost_attrs [i ]);
487423 if (error )
488- goto clean_class ;
424+ return error ;
489425 }
490426 }
491427
@@ -495,31 +431,9 @@ int scsi_sysfs_add_host(struct Scsi_Host *shost, struct device *dev)
495431 error = class_device_create_file (& shost -> shost_classdev ,
496432 scsi_sysfs_shost_attrs [i ]);
497433 if (error )
498- goto clean_class ;
434+ return error ;
499435 }
500436 }
501437
502- return error ;
503-
504- clean_class :
505- class_device_del (& shost -> shost_classdev );
506- clean_device :
507- device_del (& shost -> shost_gendev );
508-
509- return error ;
510- }
511-
512- /**
513- * scsi_sysfs_remove_host - remove scsi host from subsystem
514- * @shost: scsi host to remove from subsystem
515- **/
516- void scsi_sysfs_remove_host (struct Scsi_Host * shost )
517- {
518- unsigned long flags ;
519- spin_lock_irqsave (shost -> host_lock , flags );
520- set_bit (SHOST_DEL , & shost -> shost_state );
521- spin_unlock_irqrestore (shost -> host_lock , flags );
522-
523- class_device_unregister (& shost -> shost_classdev );
524- device_del (& shost -> shost_gendev );
438+ return 0 ;
525439}
0 commit comments