@@ -203,37 +203,6 @@ static int dev_uevent(struct kset *kset, struct kobject *kobj,
203203 if (dev -> driver )
204204 add_uevent_var (env , "DRIVER=%s" , dev -> driver -> name );
205205
206- #ifdef CONFIG_SYSFS_DEPRECATED
207- if (dev -> class ) {
208- struct device * parent = dev -> parent ;
209-
210- /* find first bus device in parent chain */
211- while (parent && !parent -> bus )
212- parent = parent -> parent ;
213- if (parent && parent -> bus ) {
214- const char * path ;
215-
216- path = kobject_get_path (& parent -> kobj , GFP_KERNEL );
217- if (path ) {
218- add_uevent_var (env , "PHYSDEVPATH=%s" , path );
219- kfree (path );
220- }
221-
222- add_uevent_var (env , "PHYSDEVBUS=%s" , parent -> bus -> name );
223-
224- if (parent -> driver )
225- add_uevent_var (env , "PHYSDEVDRIVER=%s" ,
226- parent -> driver -> name );
227- }
228- } else if (dev -> bus ) {
229- add_uevent_var (env , "PHYSDEVBUS=%s" , dev -> bus -> name );
230-
231- if (dev -> driver )
232- add_uevent_var (env , "PHYSDEVDRIVER=%s" ,
233- dev -> driver -> name );
234- }
235- #endif
236-
237206 /* have the bus specific function add its stuff */
238207 if (dev -> bus && dev -> bus -> uevent ) {
239208 retval = dev -> bus -> uevent (dev , env );
@@ -578,24 +547,6 @@ void device_initialize(struct device *dev)
578547 set_dev_node (dev , -1 );
579548}
580549
581- #ifdef CONFIG_SYSFS_DEPRECATED
582- static struct kobject * get_device_parent (struct device * dev ,
583- struct device * parent )
584- {
585- /* class devices without a parent live in /sys/class/<classname>/ */
586- if (dev -> class && (!parent || parent -> class != dev -> class ))
587- return & dev -> class -> p -> class_subsys .kobj ;
588- /* all other devices keep their parent */
589- else if (parent )
590- return & parent -> kobj ;
591-
592- return NULL ;
593- }
594-
595- static inline void cleanup_device_parent (struct device * dev ) {}
596- static inline void cleanup_glue_dir (struct device * dev ,
597- struct kobject * glue_dir ) {}
598- #else
599550static struct kobject * virtual_device_parent (struct device * dev )
600551{
601552 static struct kobject * virtual_dir = NULL ;
@@ -666,6 +617,14 @@ static struct kobject *get_device_parent(struct device *dev,
666617 struct kobject * parent_kobj ;
667618 struct kobject * k ;
668619
620+ #ifdef CONFIG_SYSFS_DEPRECATED
621+ /* block disks show up in /sys/block */
622+ if (dev -> class == & block_class ) {
623+ if (parent && parent -> class == & block_class )
624+ return & parent -> kobj ;
625+ return & block_class .p -> class_subsys .kobj ;
626+ }
627+ #endif
669628 /*
670629 * If we have no parent, we live in "virtual".
671630 * Class-devices with a non class-device as parent, live
@@ -719,7 +678,6 @@ static void cleanup_device_parent(struct device *dev)
719678{
720679 cleanup_glue_dir (dev , dev -> kobj .parent );
721680}
722- #endif
723681
724682static void setup_parent (struct device * dev , struct device * parent )
725683{
@@ -742,70 +700,29 @@ static int device_add_class_symlinks(struct device *dev)
742700 if (error )
743701 goto out ;
744702
745- #ifdef CONFIG_SYSFS_DEPRECATED
746- /* stacked class devices need a symlink in the class directory */
747- if (dev -> kobj .parent != & dev -> class -> p -> class_subsys .kobj &&
748- device_is_not_partition (dev )) {
749- error = sysfs_create_link (& dev -> class -> p -> class_subsys .kobj ,
750- & dev -> kobj , dev_name (dev ));
751- if (error )
752- goto out_subsys ;
753- }
754-
755703 if (dev -> parent && device_is_not_partition (dev )) {
756- struct device * parent = dev -> parent ;
757- char * class_name ;
758-
759- /*
760- * stacked class devices have the 'device' link
761- * pointing to the bus device instead of the parent
762- */
763- while (parent -> class && !parent -> bus && parent -> parent )
764- parent = parent -> parent ;
765-
766- error = sysfs_create_link (& dev -> kobj ,
767- & parent -> kobj ,
704+ error = sysfs_create_link (& dev -> kobj , & dev -> parent -> kobj ,
768705 "device" );
769706 if (error )
770- goto out_busid ;
771-
772- class_name = make_class_name (dev -> class -> name ,
773- & dev -> kobj );
774- if (class_name )
775- error = sysfs_create_link (& dev -> parent -> kobj ,
776- & dev -> kobj , class_name );
777- kfree (class_name );
778- if (error )
779- goto out_device ;
707+ goto out_subsys ;
780708 }
781- return 0 ;
782709
783- out_device :
784- if (dev -> parent && device_is_not_partition (dev ))
785- sysfs_remove_link (& dev -> kobj , "device" );
786- out_busid :
787- if (dev -> kobj .parent != & dev -> class -> p -> class_subsys .kobj &&
788- device_is_not_partition (dev ))
789- sysfs_delete_link (& dev -> class -> p -> class_subsys .kobj , & dev -> kobj ,
790- dev_name (dev ));
791- #else
710+ #ifdef CONFIG_SYSFS_DEPRECATED
711+ /* /sys/block has directories and does not need symlinks */
712+ if (dev -> class == & block_class )
713+ return 0 ;
714+ #endif
715+
792716 /* link in the class directory pointing to the device */
793717 error = sysfs_create_link (& dev -> class -> p -> class_subsys .kobj ,
794718 & dev -> kobj , dev_name (dev ));
795719 if (error )
796- goto out_subsys ;
720+ goto out_device ;
797721
798- if (dev -> parent && device_is_not_partition (dev )) {
799- error = sysfs_create_link (& dev -> kobj , & dev -> parent -> kobj ,
800- "device" );
801- if (error )
802- goto out_busid ;
803- }
804722 return 0 ;
805723
806- out_busid :
807- sysfs_delete_link (& dev -> class -> p -> class_subsys .kobj , & dev -> kobj , dev_name (dev ));
808- #endif
724+ out_device :
725+ sysfs_remove_link (& dev -> kobj , "device" );
809726
810727out_subsys :
811728 sysfs_remove_link (& dev -> kobj , "subsystem" );
@@ -818,30 +735,14 @@ static void device_remove_class_symlinks(struct device *dev)
818735 if (!dev -> class )
819736 return ;
820737
821- #ifdef CONFIG_SYSFS_DEPRECATED
822- if (dev -> parent && device_is_not_partition (dev )) {
823- char * class_name ;
824-
825- class_name = make_class_name (dev -> class -> name , & dev -> kobj );
826- if (class_name ) {
827- sysfs_remove_link (& dev -> parent -> kobj , class_name );
828- kfree (class_name );
829- }
830- sysfs_remove_link (& dev -> kobj , "device" );
831- }
832-
833- if (dev -> kobj .parent != & dev -> class -> p -> class_subsys .kobj &&
834- device_is_not_partition (dev ))
835- sysfs_delete_link (& dev -> class -> p -> class_subsys .kobj , & dev -> kobj ,
836- dev_name (dev ));
837- #else
838738 if (dev -> parent && device_is_not_partition (dev ))
839739 sysfs_remove_link (& dev -> kobj , "device" );
840-
841- sysfs_delete_link (& dev -> class -> p -> class_subsys .kobj , & dev -> kobj , dev_name (dev ));
842- #endif
843-
844740 sysfs_remove_link (& dev -> kobj , "subsystem" );
741+ #ifdef CONFIG_SYSFS_DEPRECATED
742+ if (dev -> class == & block_class )
743+ return ;
744+ #endif
745+ sysfs_delete_link (& dev -> class -> p -> class_subsys .kobj , & dev -> kobj , dev_name (dev ));
845746}
846747
847748/**
@@ -1613,41 +1514,23 @@ int device_rename(struct device *dev, const char *new_name)
16131514 pr_debug ("device: '%s': %s: renaming to '%s'\n" , dev_name (dev ),
16141515 __func__ , new_name );
16151516
1616- #ifdef CONFIG_SYSFS_DEPRECATED
1617- if ((dev -> class ) && (dev -> parent ))
1618- old_class_name = make_class_name (dev -> class -> name , & dev -> kobj );
1619- #endif
1620-
16211517 old_device_name = kstrdup (dev_name (dev ), GFP_KERNEL );
16221518 if (!old_device_name ) {
16231519 error = - ENOMEM ;
16241520 goto out ;
16251521 }
16261522
1627- #ifndef CONFIG_SYSFS_DEPRECATED
16281523 if (dev -> class ) {
16291524 error = sysfs_rename_link (& dev -> class -> p -> class_subsys .kobj ,
16301525 & dev -> kobj , old_device_name , new_name );
16311526 if (error )
16321527 goto out ;
16331528 }
1634- #endif
1529+
16351530 error = kobject_rename (& dev -> kobj , new_name );
16361531 if (error )
16371532 goto out ;
16381533
1639- #ifdef CONFIG_SYSFS_DEPRECATED
1640- if (old_class_name ) {
1641- new_class_name = make_class_name (dev -> class -> name , & dev -> kobj );
1642- if (new_class_name ) {
1643- error = sysfs_rename_link (& dev -> parent -> kobj ,
1644- & dev -> kobj ,
1645- old_class_name ,
1646- new_class_name );
1647- }
1648- }
1649- #endif
1650-
16511534out :
16521535 put_device (dev );
16531536
@@ -1664,40 +1547,13 @@ static int device_move_class_links(struct device *dev,
16641547 struct device * new_parent )
16651548{
16661549 int error = 0 ;
1667- #ifdef CONFIG_SYSFS_DEPRECATED
1668- char * class_name ;
16691550
1670- class_name = make_class_name (dev -> class -> name , & dev -> kobj );
1671- if (!class_name ) {
1672- error = - ENOMEM ;
1673- goto out ;
1674- }
1675- if (old_parent ) {
1676- sysfs_remove_link (& dev -> kobj , "device" );
1677- sysfs_remove_link (& old_parent -> kobj , class_name );
1678- }
1679- if (new_parent ) {
1680- error = sysfs_create_link (& dev -> kobj , & new_parent -> kobj ,
1681- "device" );
1682- if (error )
1683- goto out ;
1684- error = sysfs_create_link (& new_parent -> kobj , & dev -> kobj ,
1685- class_name );
1686- if (error )
1687- sysfs_remove_link (& dev -> kobj , "device" );
1688- } else
1689- error = 0 ;
1690- out :
1691- kfree (class_name );
1692- return error ;
1693- #else
16941551 if (old_parent )
16951552 sysfs_remove_link (& dev -> kobj , "device" );
16961553 if (new_parent )
16971554 error = sysfs_create_link (& dev -> kobj , & new_parent -> kobj ,
16981555 "device" );
16991556 return error ;
1700- #endif
17011557}
17021558
17031559/**
0 commit comments