From: Greg KH <greg@kroah.com>
To: linux-kernel@vger.kernel.org, pcihpd-discuss@lists.sourceforge.net
Subject: Re: [PATCH] PCI hotplug changes for 2.5.54
Date: Tue, 7 Jan 2003 17:58:19 -0800 [thread overview]
Message-ID: <20030108015819.GD30924@kroah.com> (raw)
In-Reply-To: <20030108015714.GC30924@kroah.com>
ChangeSet 1.896, 2003/01/07 16:41:22-08:00, greg@kroah.com
PCI hotplug: clean up the try_module_get() logic a bit.
diff -Nru a/drivers/hotplug/pci_hotplug_core.c b/drivers/hotplug/pci_hotplug_core.c
--- a/drivers/hotplug/pci_hotplug_core.c Tue Jan 7 16:44:10 2003
+++ b/drivers/hotplug/pci_hotplug_core.c Tue Jan 7 16:44:10 2003
@@ -561,7 +561,7 @@
up(&parent->d_inode->i_sem);
}
-/* yuck, WFT is this? */
+/* Weee, fun with macros... */
#define GET_STATUS(name,type) \
static int get_##name (struct hotplug_slot *slot, type *value) \
{ \
@@ -661,29 +661,26 @@
power = (u8)(lpower & 0xff);
dbg ("power = %d\n", power);
+ if (!try_module_get(slot->ops->owner)) {
+ retval = -ENODEV;
+ goto exit;
+ }
switch (power) {
case 0:
- if (!slot->ops->disable_slot)
- break;
- if (try_module_get(slot->ops->owner)) {
+ if (slot->ops->disable_slot)
retval = slot->ops->disable_slot(slot);
- module_put(slot->ops->owner);
- }
break;
case 1:
- if (!slot->ops->enable_slot)
- break;
- if (try_module_get(slot->ops->owner)) {
+ if (slot->ops->enable_slot)
retval = slot->ops->enable_slot(slot);
- module_put(slot->ops->owner);
- }
break;
default:
err ("Illegal value specified for power\n");
retval = -EINVAL;
}
+ module_put(slot->ops->owner);
exit:
kfree (buff);
@@ -770,12 +767,13 @@
attention = (u8)(lattention & 0xff);
dbg (" - attention = %d\n", attention);
- if (slot->ops->set_attention_status) {
- if (try_module_get(slot->ops->owner)) {
- retval = slot->ops->set_attention_status(slot, attention);
- module_put(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);
+ module_put(slot->ops->owner);
exit:
kfree (buff);
@@ -1007,12 +1005,13 @@
test = (u32)(ltest & 0xffffffff);
dbg ("test = %d\n", test);
- if (slot->ops->hardware_test) {
- if (try_module_get(slot->ops->owner)) {
- retval = slot->ops->hardware_test(slot, test);
- module_put(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);
+ module_put(slot->ops->owner);
exit:
kfree (buff);
prev parent reply other threads:[~2003-01-08 1:50 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2003-01-08 1:55 [BK PATCH] PCI hotplug changes for 2.5.54 Greg KH
2003-01-08 1:55 ` [PATCH] " Greg KH
2003-01-08 1:57 ` Greg KH
2003-01-08 1:58 ` Greg KH [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20030108015819.GD30924@kroah.com \
--to=greg@kroah.com \
--cc=linux-kernel@vger.kernel.org \
--cc=pcihpd-discuss@lists.sourceforge.net \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.