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
nexedi
linux
Commits
bce2e9d2
Commit
bce2e9d2
authored
Jan 07, 2003
by
Greg Kroah-Hartman
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
PCI hotplug: clean up the try_module_get() logic a bit.
parent
3aba1ea5
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
20 additions
and
21 deletions
+20
-21
drivers/hotplug/pci_hotplug_core.c
drivers/hotplug/pci_hotplug_core.c
+20
-21
No files found.
drivers/hotplug/pci_hotplug_core.c
View file @
bce2e9d2
...
@@ -561,7 +561,7 @@ static void fs_remove_file (struct dentry *dentry)
...
@@ -561,7 +561,7 @@ static void fs_remove_file (struct dentry *dentry)
up
(
&
parent
->
d_inode
->
i_sem
);
up
(
&
parent
->
d_inode
->
i_sem
);
}
}
/*
yuck, WFT is this?
*/
/*
Weee, fun with macros...
*/
#define GET_STATUS(name,type) \
#define GET_STATUS(name,type) \
static int get_##name (struct hotplug_slot *slot, type *value) \
static int get_##name (struct hotplug_slot *slot, type *value) \
{ \
{ \
...
@@ -661,29 +661,26 @@ static ssize_t power_write_file (struct file *file, const char *ubuff, size_t co
...
@@ -661,29 +661,26 @@ static ssize_t power_write_file (struct file *file, const char *ubuff, size_t co
power
=
(
u8
)(
lpower
&
0xff
);
power
=
(
u8
)(
lpower
&
0xff
);
dbg
(
"power = %d
\n
"
,
power
);
dbg
(
"power = %d
\n
"
,
power
);
if
(
!
try_module_get
(
slot
->
ops
->
owner
))
{
retval
=
-
ENODEV
;
goto
exit
;
}
switch
(
power
)
{
switch
(
power
)
{
case
0
:
case
0
:
if
(
!
slot
->
ops
->
disable_slot
)
if
(
slot
->
ops
->
disable_slot
)
break
;
if
(
try_module_get
(
slot
->
ops
->
owner
))
{
retval
=
slot
->
ops
->
disable_slot
(
slot
);
retval
=
slot
->
ops
->
disable_slot
(
slot
);
module_put
(
slot
->
ops
->
owner
);
}
break
;
break
;
case
1
:
case
1
:
if
(
!
slot
->
ops
->
enable_slot
)
if
(
slot
->
ops
->
enable_slot
)
break
;
if
(
try_module_get
(
slot
->
ops
->
owner
))
{
retval
=
slot
->
ops
->
enable_slot
(
slot
);
retval
=
slot
->
ops
->
enable_slot
(
slot
);
module_put
(
slot
->
ops
->
owner
);
}
break
;
break
;
default:
default:
err
(
"Illegal value specified for power
\n
"
);
err
(
"Illegal value specified for power
\n
"
);
retval
=
-
EINVAL
;
retval
=
-
EINVAL
;
}
}
module_put
(
slot
->
ops
->
owner
);
exit:
exit:
kfree
(
buff
);
kfree
(
buff
);
...
@@ -770,12 +767,13 @@ static ssize_t attention_write_file (struct file *file, const char *ubuff, size_
...
@@ -770,12 +767,13 @@ static ssize_t attention_write_file (struct file *file, const char *ubuff, size_
attention
=
(
u8
)(
lattention
&
0xff
);
attention
=
(
u8
)(
lattention
&
0xff
);
dbg
(
" - attention = %d
\n
"
,
attention
);
dbg
(
" - attention = %d
\n
"
,
attention
);
if
(
slot
->
ops
->
set_attention_status
)
{
if
(
!
try_module_get
(
slot
->
ops
->
owner
))
{
if
(
try_module_get
(
slot
->
ops
->
owner
))
{
retval
=
-
ENODEV
;
goto
exit
;
}
if
(
slot
->
ops
->
set_attention_status
)
retval
=
slot
->
ops
->
set_attention_status
(
slot
,
attention
);
retval
=
slot
->
ops
->
set_attention_status
(
slot
,
attention
);
module_put
(
slot
->
ops
->
owner
);
module_put
(
slot
->
ops
->
owner
);
}
}
exit:
exit:
kfree
(
buff
);
kfree
(
buff
);
...
@@ -1007,12 +1005,13 @@ static ssize_t test_write_file (struct file *file, const char *ubuff, size_t cou
...
@@ -1007,12 +1005,13 @@ static ssize_t test_write_file (struct file *file, const char *ubuff, size_t cou
test
=
(
u32
)(
ltest
&
0xffffffff
);
test
=
(
u32
)(
ltest
&
0xffffffff
);
dbg
(
"test = %d
\n
"
,
test
);
dbg
(
"test = %d
\n
"
,
test
);
if
(
slot
->
ops
->
hardware_test
)
{
if
(
!
try_module_get
(
slot
->
ops
->
owner
))
{
if
(
try_module_get
(
slot
->
ops
->
owner
))
{
retval
=
-
ENODEV
;
goto
exit
;
}
if
(
slot
->
ops
->
hardware_test
)
retval
=
slot
->
ops
->
hardware_test
(
slot
,
test
);
retval
=
slot
->
ops
->
hardware_test
(
slot
,
test
);
module_put
(
slot
->
ops
->
owner
);
module_put
(
slot
->
ops
->
owner
);
}
}
exit:
exit:
kfree
(
buff
);
kfree
(
buff
);
...
...
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