PNP: remove null pointer checks

2007-10-17 Thread Linux Kernel Mailing List
Gitweb: 
http://git.kernel.org/git/?p=linux/kernel/git/torvalds/linux-2.6.git;a=commit;h=402b310cb6e523779149139b20f46899a890e963
Commit: 402b310cb6e523779149139b20f46899a890e963
Parent: 9cd8047b463f213c294f756119ac353312e7a152
Author: Bjorn Helgaas <[EMAIL PROTECTED]>
AuthorDate: Tue Oct 16 23:31:09 2007 -0700
Committer:  Linus Torvalds <[EMAIL PROTECTED]>
CommitDate: Wed Oct 17 08:43:04 2007 -0700

    PNP: remove null pointer checks

Remove some null pointer checks.  Null pointers in these areas indicate
programming errors, and I think it's better to oops immediately rather than
return an error that is easily ignored.

Signed-off-by: Bjorn Helgaas <[EMAIL PROTECTED]>
Cc: Adam Belay <[EMAIL PROTECTED]>
Cc: Len Brown <[EMAIL PROTECTED]>
Signed-off-by: Andrew Morton <[EMAIL PROTECTED]>
Signed-off-by: Linus Torvalds <[EMAIL PROTECTED]>
---
 drivers/pnp/card.c  |   15 ---
 include/linux/pnp.h |6 +++---
 2 files changed, 3 insertions(+), 18 deletions(-)

diff --git a/drivers/pnp/card.c b/drivers/pnp/card.c
index 6c0440c..fae2891 100644
--- a/drivers/pnp/card.c
+++ b/drivers/pnp/card.c
@@ -104,10 +104,6 @@ int pnp_add_card_id(struct pnp_id *id, struct pnp_card 
*card)
 {
struct pnp_id *ptr;
 
-   if (!id)
-   return -EINVAL;
-   if (!card)
-   return -EINVAL;
id->next = NULL;
ptr = card->id;
while (ptr && ptr->next)
@@ -124,8 +120,6 @@ static void pnp_free_card_ids(struct pnp_card *card)
struct pnp_id *id;
struct pnp_id *next;
 
-   if (!card)
-   return;
id = card->id;
while (id) {
next = id->next;
@@ -197,9 +191,6 @@ int pnp_add_card(struct pnp_card *card)
int error;
struct list_head *pos, *temp;
 
-   if (!card || !card->protocol)
-   return -EINVAL;
-
sprintf(card->dev.bus_id, "%02x:%02x", card->protocol->number,
card->number);
card->dev.parent = &card->protocol->dev;
@@ -243,8 +234,6 @@ void pnp_remove_card(struct pnp_card *card)
 {
struct list_head *pos, *temp;
 
-   if (!card)
-   return;
device_unregister(&card->dev);
spin_lock(&pnp_lock);
list_del(&card->global_list);
@@ -263,8 +252,6 @@ void pnp_remove_card(struct pnp_card *card)
  */
 int pnp_add_card_device(struct pnp_card *card, struct pnp_dev *dev)
 {
-   if (!card || !dev || !dev->protocol)
-   return -EINVAL;
dev->dev.parent = &card->dev;
dev->card_link = NULL;
snprintf(dev->dev.bus_id, BUS_ID_SIZE, "%02x:%02x.%02x",
@@ -348,8 +335,6 @@ void pnp_release_card_device(struct pnp_dev *dev)
 {
struct pnp_card_driver *drv = dev->card_link->driver;
 
-   if (!drv)
-   return;
drv->link.remove = &card_remove;
device_release_driver(&dev->dev);
drv->link.remove = &card_remove_first;
diff --git a/include/linux/pnp.h b/include/linux/pnp.h
index 16b46aa..664d68c 100644
--- a/include/linux/pnp.h
+++ b/include/linux/pnp.h
@@ -243,11 +243,11 @@ struct pnp_fixup {
 #define PNP_CONFIGURABLE   0x0008
 #define PNP_REMOVABLE  0x0010
 
-#define pnp_can_read(dev)  (((dev)->protocol) && ((dev)->protocol->get) && 
\
+#define pnp_can_read(dev)  (((dev)->protocol->get) && \
 ((dev)->capabilities & PNP_READ))
-#define pnp_can_write(dev) (((dev)->protocol) && ((dev)->protocol->set) && 
\
+#define pnp_can_write(dev) (((dev)->protocol->set) && \
 ((dev)->capabilities & PNP_WRITE))
-#define pnp_can_disable(dev)   (((dev)->protocol) && 
((dev)->protocol->disable) && \
+#define pnp_can_disable(dev)   (((dev)->protocol->disable) && \
 ((dev)->capabilities & PNP_DISABLE))
 #define pnp_can_configure(dev) ((!(dev)->active) && \
 ((dev)->capabilities & PNP_CONFIGURABLE))
-
To unsubscribe from this list: send the line "unsubscribe git-commits-head" in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html


PNP: remove null pointer checks

2007-08-25 Thread Linux Kernel Mailing List
Gitweb: 
http://git.kernel.org/git/?p=linux/kernel/git/torvalds/linux-2.6.git;a=commit;h=b173491339b9ae7f1322241ce6228c1268513a39
Commit: b173491339b9ae7f1322241ce6228c1268513a39
Parent: 4f0217e30249ac0eb13b65ef64f2aee627465da2
Author: Bjorn Helgaas <[EMAIL PROTECTED]>
AuthorDate: Wed Aug 15 10:32:13 2007 -0600
Committer:  Len Brown <[EMAIL PROTECTED]>
CommitDate: Fri Aug 24 01:27:24 2007 -0400

    PNP: remove null pointer checks

Remove some null pointer checks.  Null pointers in these areas indicate
programming errors, and I think it's better to oops immediately rather
than return an error that is easily ignored.

Signed-off-by: Bjorn Helgaas <[EMAIL PROTECTED]>
Acked-by: Adam Belay <[EMAIL PROTECTED]>
Signed-off-by: Len Brown <[EMAIL PROTECTED]>
---
 drivers/pnp/core.c|7 +--
 drivers/pnp/driver.c  |4 
 drivers/pnp/isapnp/core.c |2 +-
 drivers/pnp/manager.c |   23 ---
 drivers/pnp/resource.c|   26 --
 5 files changed, 2 insertions(+), 60 deletions(-)

diff --git a/drivers/pnp/core.c b/drivers/pnp/core.c
index 61066fd..d5964fe 100644
--- a/drivers/pnp/core.c
+++ b/drivers/pnp/core.c
@@ -52,9 +52,6 @@ int pnp_register_protocol(struct pnp_protocol *protocol)
int nodenum;
struct list_head *pos;
 
-   if (!protocol)
-   return -EINVAL;
-
INIT_LIST_HEAD(&protocol->devices);
INIT_LIST_HEAD(&protocol->cards);
nodenum = 0;
@@ -94,8 +91,6 @@ static void pnp_free_ids(struct pnp_dev *dev)
struct pnp_id *id;
struct pnp_id *next;
 
-   if (!dev)
-   return;
id = dev->id;
while (id) {
next = id->next;
@@ -143,7 +138,7 @@ int __pnp_add_device(struct pnp_dev *dev)
  */
 int pnp_add_device(struct pnp_dev *dev)
 {
-   if (!dev || !dev->protocol || dev->card)
+   if (dev->card)
return -EINVAL;
dev->dev.parent = &dev->protocol->dev;
sprintf(dev->dev.bus_id, "%02x:%02x", dev->protocol->number,
diff --git a/drivers/pnp/driver.c b/drivers/pnp/driver.c
index 9be01b0..2fa64a6 100644
--- a/drivers/pnp/driver.c
+++ b/drivers/pnp/driver.c
@@ -232,10 +232,6 @@ int pnp_add_id(struct pnp_id *id, struct pnp_dev *dev)
 {
struct pnp_id *ptr;
 
-   if (!id)
-   return -EINVAL;
-   if (!dev)
-   return -EINVAL;
id->next = NULL;
ptr = dev->id;
while (ptr && ptr->next)
diff --git a/drivers/pnp/isapnp/core.c b/drivers/pnp/isapnp/core.c
index 1a0d33a..b035d60 100644
--- a/drivers/pnp/isapnp/core.c
+++ b/drivers/pnp/isapnp/core.c
@@ -1040,7 +1040,7 @@ static int isapnp_set_resources(struct pnp_dev *dev,
 
 static int isapnp_disable_resources(struct pnp_dev *dev)
 {
-   if (!dev || !dev->active)
+   if (!dev->active)
return -EINVAL;
isapnp_cfg_begin(dev->card->number, dev->number);
isapnp_deactivate(dev->number);
diff --git a/drivers/pnp/manager.c b/drivers/pnp/manager.c
index 329dc6c..0826287 100644
--- a/drivers/pnp/manager.c
+++ b/drivers/pnp/manager.c
@@ -21,9 +21,6 @@ static int pnp_assign_port(struct pnp_dev *dev, struct 
pnp_port *rule, int idx)
resource_size_t *start, *end;
unsigned long *flags;
 
-   if (!dev || !rule)
-   return -EINVAL;
-
if (idx >= PNP_MAX_PORT) {
pnp_err
("More than 4 ports is incompatible with pnp 
specifications.");
@@ -66,9 +63,6 @@ static int pnp_assign_mem(struct pnp_dev *dev, struct pnp_mem 
*rule, int idx)
resource_size_t *start, *end;
unsigned long *flags;
 
-   if (!dev || !rule)
-   return -EINVAL;
-
if (idx >= PNP_MAX_MEM) {
pnp_err
("More than 8 mems is incompatible with pnp 
specifications.");
@@ -127,9 +121,6 @@ static int pnp_assign_irq(struct pnp_dev *dev, struct 
pnp_irq *rule, int idx)
5, 10, 11, 12, 9, 14, 15, 7, 3, 4, 13, 0, 1, 6, 8, 2
};
 
-   if (!dev || !rule)
-   return -EINVAL;
-
if (idx >= PNP_MAX_IRQ) {
pnp_err
("More than 2 irqs is incompatible with pnp 
specifications.");
@@ -181,9 +172,6 @@ static int pnp_assign_dma(struct pnp_dev *dev, struct 
pnp_dma *rule, int idx)
1, 3, 5, 6, 7, 0, 2, 4
};
 
-   if (!dev || !rule)
-   return -EINVAL;
-
if (idx >= PNP_MAX_DMA) {
pnp_err
("More than 2 dmas is incompatible with pnp 
specifications.");
@@ -410,8 +398,6 @@ int pnp_manual_config_dev(struct pnp_dev *dev, struct 
pnp_resource_table *res,
int i;
struct pnp_resource_table *bak;
 
-   if (!