Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
L
linux
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Kirill Smelkov
linux
Commits
c8880651
Commit
c8880651
authored
Feb 04, 2021
by
Rafael J. Wysocki
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch 'acpi-scan' into acpi-messages
parents
1048ba83
83e2c8fc
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
49 additions
and
50 deletions
+49
-50
drivers/acpi/scan.c
drivers/acpi/scan.c
+49
-50
No files found.
drivers/acpi/scan.c
View file @
c8880651
...
@@ -578,29 +578,31 @@ static void acpi_scan_drop_device(acpi_handle handle, void *context)
...
@@ -578,29 +578,31 @@ static void acpi_scan_drop_device(acpi_handle handle, void *context)
mutex_unlock
(
&
acpi_device_del_lock
);
mutex_unlock
(
&
acpi_device_del_lock
);
}
}
static
int
acpi_get_device_data
(
acpi_handle
handle
,
struct
acpi_device
**
devic
e
,
static
struct
acpi_device
*
handle_to_device
(
acpi_handle
handl
e
,
void
(
*
callback
)(
void
*
))
void
(
*
callback
)(
void
*
))
{
{
struct
acpi_device
*
adev
=
NULL
;
acpi_status
status
;
acpi_status
status
;
if
(
!
device
)
return
-
EINVAL
;
*
device
=
NULL
;
status
=
acpi_get_data_full
(
handle
,
acpi_scan_drop_device
,
status
=
acpi_get_data_full
(
handle
,
acpi_scan_drop_device
,
(
void
**
)
device
,
callback
);
(
void
**
)
&
adev
,
callback
);
if
(
ACPI_FAILURE
(
status
)
||
!*
device
)
{
if
(
ACPI_FAILURE
(
status
)
||
!
adev
)
{
ACPI_DEBUG_PRINT
((
ACPI_DB_INFO
,
"No context for object [%p]
\n
"
,
acpi_handle_debug
(
handle
,
"No context!
\n
"
);
handle
));
return
NULL
;
return
-
ENODEV
;
}
}
return
0
;
return
adev
;
}
}
int
acpi_bus_get_device
(
acpi_handle
handle
,
struct
acpi_device
**
device
)
int
acpi_bus_get_device
(
acpi_handle
handle
,
struct
acpi_device
**
device
)
{
{
return
acpi_get_device_data
(
handle
,
device
,
NULL
);
if
(
!
device
)
return
-
EINVAL
;
*
device
=
handle_to_device
(
handle
,
NULL
);
if
(
!*
device
)
return
-
ENODEV
;
return
0
;
}
}
EXPORT_SYMBOL
(
acpi_bus_get_device
);
EXPORT_SYMBOL
(
acpi_bus_get_device
);
...
@@ -612,10 +614,7 @@ static void get_acpi_device(void *dev)
...
@@ -612,10 +614,7 @@ static void get_acpi_device(void *dev)
struct
acpi_device
*
acpi_bus_get_acpi_device
(
acpi_handle
handle
)
struct
acpi_device
*
acpi_bus_get_acpi_device
(
acpi_handle
handle
)
{
{
struct
acpi_device
*
adev
=
NULL
;
return
handle_to_device
(
handle
,
get_acpi_device
);
acpi_get_device_data
(
handle
,
&
adev
,
get_acpi_device
);
return
adev
;
}
}
void
acpi_bus_put_acpi_device
(
struct
acpi_device
*
adev
)
void
acpi_bus_put_acpi_device
(
struct
acpi_device
*
adev
)
...
@@ -623,12 +622,23 @@ void acpi_bus_put_acpi_device(struct acpi_device *adev)
...
@@ -623,12 +622,23 @@ void acpi_bus_put_acpi_device(struct acpi_device *adev)
put_device
(
&
adev
->
dev
);
put_device
(
&
adev
->
dev
);
}
}
static
struct
acpi_device_bus_id
*
acpi_device_bus_id_match
(
const
char
*
dev_id
)
{
struct
acpi_device_bus_id
*
acpi_device_bus_id
;
/* Find suitable bus_id and instance number in acpi_bus_id_list. */
list_for_each_entry
(
acpi_device_bus_id
,
&
acpi_bus_id_list
,
node
)
{
if
(
!
strcmp
(
acpi_device_bus_id
->
bus_id
,
dev_id
))
return
acpi_device_bus_id
;
}
return
NULL
;
}
int
acpi_device_add
(
struct
acpi_device
*
device
,
int
acpi_device_add
(
struct
acpi_device
*
device
,
void
(
*
release
)(
struct
device
*
))
void
(
*
release
)(
struct
device
*
))
{
{
struct
acpi_device_bus_id
*
acpi_device_bus_id
;
int
result
;
int
result
;
struct
acpi_device_bus_id
*
acpi_device_bus_id
,
*
new_bus_id
;
int
found
=
0
;
if
(
device
->
handle
)
{
if
(
device
->
handle
)
{
acpi_status
status
;
acpi_status
status
;
...
@@ -654,38 +664,26 @@ int acpi_device_add(struct acpi_device *device,
...
@@ -654,38 +664,26 @@ int acpi_device_add(struct acpi_device *device,
INIT_LIST_HEAD
(
&
device
->
del_list
);
INIT_LIST_HEAD
(
&
device
->
del_list
);
mutex_init
(
&
device
->
physical_node_lock
);
mutex_init
(
&
device
->
physical_node_lock
);
new_bus_id
=
kzalloc
(
sizeof
(
struct
acpi_device_bus_id
),
GFP_KERNEL
);
if
(
!
new_bus_id
)
{
pr_err
(
PREFIX
"Memory allocation error
\n
"
);
result
=
-
ENOMEM
;
goto
err_detach
;
}
mutex_lock
(
&
acpi_device_lock
);
mutex_lock
(
&
acpi_device_lock
);
/*
* Find suitable bus_id and instance number in acpi_bus_id_list
acpi_device_bus_id
=
acpi_device_bus_id_match
(
acpi_device_hid
(
device
));
* If failed, create one and link it into acpi_bus_id_list
if
(
acpi_device_bus_id
)
{
*/
acpi_device_bus_id
->
instance_no
++
;
list_for_each_entry
(
acpi_device_bus_id
,
&
acpi_bus_id_list
,
node
)
{
}
else
{
if
(
!
strcmp
(
acpi_device_bus_id
->
bus_id
,
acpi_device_bus_id
=
kzalloc
(
sizeof
(
*
acpi_device_bus_id
),
acpi_device_hid
(
device
)))
{
GFP_KERNEL
);
acpi_device_bus_id
->
instance_no
++
;
if
(
!
acpi_device_bus_id
)
{
found
=
1
;
result
=
-
ENOMEM
;
kfree
(
new_bus_id
);
goto
err_unlock
;
break
;
}
}
}
if
(
!
found
)
{
acpi_device_bus_id
=
new_bus_id
;
acpi_device_bus_id
->
bus_id
=
acpi_device_bus_id
->
bus_id
=
kstrdup_const
(
acpi_device_hid
(
device
),
GFP_KERNEL
);
kstrdup_const
(
acpi_device_hid
(
device
),
GFP_KERNEL
);
if
(
!
acpi_device_bus_id
->
bus_id
)
{
if
(
!
acpi_device_bus_id
->
bus_id
)
{
pr_err
(
PREFIX
"Memory allocation error for bus id
\n
"
);
kfree
(
acpi_device_bus_id
);
result
=
-
ENOMEM
;
result
=
-
ENOMEM
;
goto
err_
free_new_bus_id
;
goto
err_
unlock
;
}
}
acpi_device_bus_id
->
instance_no
=
0
;
list_add_tail
(
&
acpi_device_bus_id
->
node
,
&
acpi_bus_id_list
);
list_add_tail
(
&
acpi_device_bus_id
->
node
,
&
acpi_bus_id_list
);
}
}
dev_set_name
(
&
device
->
dev
,
"%s:%02x"
,
acpi_device_bus_id
->
bus_id
,
acpi_device_bus_id
->
instance_no
);
dev_set_name
(
&
device
->
dev
,
"%s:%02x"
,
acpi_device_bus_id
->
bus_id
,
acpi_device_bus_id
->
instance_no
);
...
@@ -695,10 +693,12 @@ int acpi_device_add(struct acpi_device *device,
...
@@ -695,10 +693,12 @@ int acpi_device_add(struct acpi_device *device,
if
(
device
->
wakeup
.
flags
.
valid
)
if
(
device
->
wakeup
.
flags
.
valid
)
list_add_tail
(
&
device
->
wakeup_list
,
&
acpi_wakeup_device_list
);
list_add_tail
(
&
device
->
wakeup_list
,
&
acpi_wakeup_device_list
);
mutex_unlock
(
&
acpi_device_lock
);
mutex_unlock
(
&
acpi_device_lock
);
if
(
device
->
parent
)
if
(
device
->
parent
)
device
->
dev
.
parent
=
&
device
->
parent
->
dev
;
device
->
dev
.
parent
=
&
device
->
parent
->
dev
;
device
->
dev
.
bus
=
&
acpi_bus_type
;
device
->
dev
.
bus
=
&
acpi_bus_type
;
device
->
dev
.
release
=
release
;
device
->
dev
.
release
=
release
;
result
=
device_add
(
&
device
->
dev
);
result
=
device_add
(
&
device
->
dev
);
...
@@ -714,20 +714,19 @@ int acpi_device_add(struct acpi_device *device,
...
@@ -714,20 +714,19 @@ int acpi_device_add(struct acpi_device *device,
return
0
;
return
0
;
err:
err:
mutex_lock
(
&
acpi_device_lock
);
mutex_lock
(
&
acpi_device_lock
);
if
(
device
->
parent
)
if
(
device
->
parent
)
list_del
(
&
device
->
node
);
list_del
(
&
device
->
node
);
list_del
(
&
device
->
wakeup_list
);
err_free_new_bus_id:
list_del
(
&
device
->
wakeup_list
);
if
(
!
found
)
kfree
(
new_bus_id
);
err_unlock:
mutex_unlock
(
&
acpi_device_lock
);
mutex_unlock
(
&
acpi_device_lock
);
err_detach:
acpi_detach_data
(
device
->
handle
,
acpi_scan_drop_device
);
acpi_detach_data
(
device
->
handle
,
acpi_scan_drop_device
);
return
result
;
return
result
;
}
}
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment