@@ -509,14 +509,16 @@ EXPORT_SYMBOL_GPL(device_schedule_callback_owner);
509509
510510static void klist_children_get (struct klist_node * n )
511511{
512- struct device * dev = container_of (n , struct device , knode_parent );
512+ struct device_private * p = to_device_private_parent (n );
513+ struct device * dev = p -> device ;
513514
514515 get_device (dev );
515516}
516517
517518static void klist_children_put (struct klist_node * n )
518519{
519- struct device * dev = container_of (n , struct device , knode_parent );
520+ struct device_private * p = to_device_private_parent (n );
521+ struct device * dev = p -> device ;
520522
521523 put_device (dev );
522524}
@@ -546,7 +548,7 @@ void device_initialize(struct device *dev)
546548 dev -> p -> device = dev ;
547549 dev -> kobj .kset = devices_kset ;
548550 kobject_init (& dev -> kobj , & device_ktype );
549- klist_init (& dev -> klist_children , klist_children_get ,
551+ klist_init (& dev -> p -> klist_children , klist_children_get ,
550552 klist_children_put );
551553 INIT_LIST_HEAD (& dev -> dma_pools );
552554 init_MUTEX (& dev -> sem );
@@ -927,7 +929,8 @@ int device_add(struct device *dev)
927929 kobject_uevent (& dev -> kobj , KOBJ_ADD );
928930 bus_attach_device (dev );
929931 if (parent )
930- klist_add_tail (& dev -> knode_parent , & parent -> klist_children );
932+ klist_add_tail (& dev -> p -> knode_parent ,
933+ & parent -> p -> klist_children );
931934
932935 if (dev -> class ) {
933936 mutex_lock (& dev -> class -> p -> class_mutex );
@@ -1038,7 +1041,7 @@ void device_del(struct device *dev)
10381041 device_pm_remove (dev );
10391042 dpm_sysfs_remove (dev );
10401043 if (parent )
1041- klist_del (& dev -> knode_parent );
1044+ klist_del (& dev -> p -> knode_parent );
10421045 if (MAJOR (dev -> devt )) {
10431046 device_remove_sys_dev_entry (dev );
10441047 device_remove_file (dev , & devt_attr );
@@ -1102,7 +1105,14 @@ void device_unregister(struct device *dev)
11021105static struct device * next_device (struct klist_iter * i )
11031106{
11041107 struct klist_node * n = klist_next (i );
1105- return n ? container_of (n , struct device , knode_parent ) : NULL ;
1108+ struct device * dev = NULL ;
1109+ struct device_private * p ;
1110+
1111+ if (n ) {
1112+ p = to_device_private_parent (n );
1113+ dev = p -> device ;
1114+ }
1115+ return dev ;
11061116}
11071117
11081118/**
@@ -1124,7 +1134,7 @@ int device_for_each_child(struct device *parent, void *data,
11241134 struct device * child ;
11251135 int error = 0 ;
11261136
1127- klist_iter_init (& parent -> klist_children , & i );
1137+ klist_iter_init (& parent -> p -> klist_children , & i );
11281138 while ((child = next_device (& i )) && !error )
11291139 error = fn (child , data );
11301140 klist_iter_exit (& i );
@@ -1155,7 +1165,7 @@ struct device *device_find_child(struct device *parent, void *data,
11551165 if (!parent )
11561166 return NULL ;
11571167
1158- klist_iter_init (& parent -> klist_children , & i );
1168+ klist_iter_init (& parent -> p -> klist_children , & i );
11591169 while ((child = next_device (& i )))
11601170 if (match (child , data ) && get_device (child ))
11611171 break ;
@@ -1478,9 +1488,10 @@ int device_move(struct device *dev, struct device *new_parent)
14781488 old_parent = dev -> parent ;
14791489 dev -> parent = new_parent ;
14801490 if (old_parent )
1481- klist_remove (& dev -> knode_parent );
1491+ klist_remove (& dev -> p -> knode_parent );
14821492 if (new_parent ) {
1483- klist_add_tail (& dev -> knode_parent , & new_parent -> klist_children );
1493+ klist_add_tail (& dev -> p -> knode_parent ,
1494+ & new_parent -> p -> klist_children );
14841495 set_dev_node (dev , dev_to_node (new_parent ));
14851496 }
14861497
@@ -1492,11 +1503,11 @@ int device_move(struct device *dev, struct device *new_parent)
14921503 device_move_class_links (dev , new_parent , old_parent );
14931504 if (!kobject_move (& dev -> kobj , & old_parent -> kobj )) {
14941505 if (new_parent )
1495- klist_remove (& dev -> knode_parent );
1506+ klist_remove (& dev -> p -> knode_parent );
14961507 dev -> parent = old_parent ;
14971508 if (old_parent ) {
1498- klist_add_tail (& dev -> knode_parent ,
1499- & old_parent -> klist_children );
1509+ klist_add_tail (& dev -> p -> knode_parent ,
1510+ & old_parent -> p -> klist_children );
15001511 set_dev_node (dev , dev_to_node (old_parent ));
15011512 }
15021513 }
0 commit comments