@@ -135,12 +135,12 @@ bool acpi_scan_is_offline(struct acpi_device *adev, bool uevent)
135135static acpi_status acpi_bus_offline (acpi_handle handle , u32 lvl , void * data ,
136136 void * * ret_p )
137137{
138- struct acpi_device * device = NULL ;
138+ struct acpi_device * device = acpi_fetch_acpi_dev ( handle ) ;
139139 struct acpi_device_physical_node * pn ;
140140 bool second_pass = (bool )data ;
141141 acpi_status status = AE_OK ;
142142
143- if (acpi_bus_get_device ( handle , & device ) )
143+ if (! device )
144144 return AE_OK ;
145145
146146 if (device -> handler && !device -> handler -> hotplug .enabled ) {
@@ -180,10 +180,10 @@ static acpi_status acpi_bus_offline(acpi_handle handle, u32 lvl, void *data,
180180static acpi_status acpi_bus_online (acpi_handle handle , u32 lvl , void * data ,
181181 void * * ret_p )
182182{
183- struct acpi_device * device = NULL ;
183+ struct acpi_device * device = acpi_fetch_acpi_dev ( handle ) ;
184184 struct acpi_device_physical_node * pn ;
185185
186- if (acpi_bus_get_device ( handle , & device ) )
186+ if (! device )
187187 return AE_OK ;
188188
189189 mutex_lock (& device -> physical_node_lock );
@@ -599,6 +599,19 @@ int acpi_bus_get_device(acpi_handle handle, struct acpi_device **device)
599599}
600600EXPORT_SYMBOL (acpi_bus_get_device );
601601
602+ /**
603+ * acpi_fetch_acpi_dev - Retrieve ACPI device object.
604+ * @handle: ACPI handle associated with the requested ACPI device object.
605+ *
606+ * Return a pointer to the ACPI device object associated with @handle, if
607+ * present, or NULL otherwise.
608+ */
609+ struct acpi_device * acpi_fetch_acpi_dev (acpi_handle handle )
610+ {
611+ return handle_to_device (handle , NULL );
612+ }
613+ EXPORT_SYMBOL_GPL (acpi_fetch_acpi_dev );
614+
602615static void get_acpi_device (void * dev )
603616{
604617 acpi_dev_get (dev );
@@ -799,7 +812,7 @@ static const char * const acpi_ignore_dep_ids[] = {
799812
800813static struct acpi_device * acpi_bus_get_parent (acpi_handle handle )
801814{
802- struct acpi_device * device = NULL ;
815+ struct acpi_device * device ;
803816 acpi_status status ;
804817
805818 /*
@@ -814,7 +827,9 @@ static struct acpi_device *acpi_bus_get_parent(acpi_handle handle)
814827 status = acpi_get_parent (handle , & handle );
815828 if (ACPI_FAILURE (status ))
816829 return status == AE_NULL_ENTRY ? NULL : acpi_root ;
817- } while (acpi_bus_get_device (handle , & device ));
830+
831+ device = acpi_fetch_acpi_dev (handle );
832+ } while (!device );
818833 return device ;
819834}
820835
@@ -2003,11 +2018,10 @@ static bool acpi_bus_scan_second_pass;
20032018static acpi_status acpi_bus_check_add (acpi_handle handle , bool check_dep ,
20042019 struct acpi_device * * adev_p )
20052020{
2006- struct acpi_device * device = NULL ;
2021+ struct acpi_device * device = acpi_fetch_acpi_dev ( handle ) ;
20072022 acpi_object_type acpi_type ;
20082023 int type ;
20092024
2010- acpi_bus_get_device (handle , & device );
20112025 if (device )
20122026 goto out ;
20132027
@@ -2548,8 +2562,8 @@ int __init acpi_scan_init(void)
25482562 if (result )
25492563 goto out ;
25502564
2551- result = acpi_bus_get_device (ACPI_ROOT_OBJECT , & acpi_root );
2552- if (result )
2565+ acpi_root = acpi_fetch_acpi_dev (ACPI_ROOT_OBJECT );
2566+ if (! acpi_root )
25532567 goto out ;
25542568
25552569 /* Fixed feature devices do not exist on HW-reduced platform */
0 commit comments