Skip to content

Commit

Permalink
Pull pnp into release branch
Browse files Browse the repository at this point in the history
  • Loading branch information
Len Brown committed Aug 25, 2007
2 parents 4548a9d + b173491 commit a672975
Show file tree
Hide file tree
Showing 13 changed files with 42 additions and 200 deletions.
16 changes: 8 additions & 8 deletions drivers/pnp/card.c
Original file line number Diff line number Diff line change
Expand Up @@ -25,13 +25,13 @@ static const struct pnp_card_device_id *match_card(struct pnp_card_driver *drv,
int found;
struct pnp_dev *dev;

if (i == PNP_MAX_DEVICES
|| !*drv_id->devs[i].id)
if (i == PNP_MAX_DEVICES ||
!*drv_id->devs[i].id)
return drv_id;
found = 0;
card_for_each_dev(card, dev) {
if (compare_pnp_id
(dev->id, drv_id->devs[i].id)) {
if (compare_pnp_id(dev->id,
drv_id->devs[i].id)) {
found = 1;
break;
}
Expand Down Expand Up @@ -183,7 +183,7 @@ static int pnp_interface_attach_card(struct pnp_card *card)

return 0;

err_name:
err_name:
device_remove_file(&card->dev, &dev_attr_name);
return rc;
}
Expand Down Expand Up @@ -321,10 +321,10 @@ struct pnp_dev *pnp_request_card_device(struct pnp_card_link *clink,
pos = pos->next;
}

done:
done:
return NULL;

found:
found:
dev->card_link = clink;
dev->dev.driver = &drv->link.driver;
if (pnp_bus_type.probe(&dev->dev))
Expand All @@ -334,7 +334,7 @@ struct pnp_dev *pnp_request_card_device(struct pnp_card_link *clink,

return dev;

err_out:
err_out:
dev->dev.driver = NULL;
dev->card_link = NULL;
return NULL;
Expand Down
7 changes: 1 addition & 6 deletions drivers/pnp/core.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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,
Expand Down
6 changes: 1 addition & 5 deletions drivers/pnp/driver.c
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,7 @@ static int pnp_device_probe(struct device *dev)
goto fail;
return error;

fail:
fail:
pnp_device_detach(pnp_dev);
return error;
}
Expand Down Expand Up @@ -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)
Expand Down
9 changes: 5 additions & 4 deletions drivers/pnp/interface.c
Original file line number Diff line number Diff line change
Expand Up @@ -459,7 +459,8 @@ pnp_set_current_resources(struct device *dmdev, struct device_attribute *attr,
up(&pnp_res_mutex);
goto done;
}
done:

done:
if (retval < 0)
return retval;
return count;
Expand Down Expand Up @@ -499,10 +500,10 @@ int pnp_interface_attach_device(struct pnp_dev *dev)

return 0;

err_res:
err_res:
device_remove_file(&dev->dev, &dev_attr_resources);
err_opt:
err_opt:
device_remove_file(&dev->dev, &dev_attr_options);
err:
err:
return rc;
}
24 changes: 7 additions & 17 deletions drivers/pnp/isapnp/core.c
Original file line number Diff line number Diff line change
Expand Up @@ -47,9 +47,6 @@
#if 0
#define ISAPNP_REGION_OK
#endif
#if 0
#define ISAPNP_DEBUG
#endif

int isapnp_disable; /* Disable ISA PnP */
static int isapnp_rdp; /* Read Data Port */
Expand Down Expand Up @@ -93,7 +90,6 @@ MODULE_LICENSE("GPL");

static unsigned char isapnp_checksum_value;
static DEFINE_MUTEX(isapnp_cfg_mutex);
static int isapnp_detected;
static int isapnp_csn_count;

/* some prototypes */
Expand Down Expand Up @@ -335,7 +331,7 @@ static int __init isapnp_isolate(void)
} else if (iteration > 1) {
break;
}
__next:
__next:
if (csn == 255)
break;
checksum = 0x6a;
Expand Down Expand Up @@ -733,7 +729,7 @@ static int __init isapnp_create_device(struct pnp_card *card,
"isapnp: unexpected or unknown tag type 0x%x for logical device %i (device %i), ignored\n",
type, dev->number, card->number);
}
__skip:
__skip:
if (size > 0)
isapnp_skip_bytes(size);
}
Expand Down Expand Up @@ -788,7 +784,7 @@ static void __init isapnp_parse_resource_map(struct pnp_card *card)
"isapnp: unexpected or unknown tag type 0x%x for device %i, ignored\n",
type, card->number);
}
__skip:
__skip:
if (size > 0)
isapnp_skip_bytes(size);
}
Expand Down Expand Up @@ -940,9 +936,6 @@ EXPORT_SYMBOL(isapnp_protocol);
EXPORT_SYMBOL(isapnp_present);
EXPORT_SYMBOL(isapnp_cfg_begin);
EXPORT_SYMBOL(isapnp_cfg_end);
#if 0
EXPORT_SYMBOL(isapnp_read_byte);
#endif
EXPORT_SYMBOL(isapnp_write_byte);

static int isapnp_read_resources(struct pnp_dev *dev,
Expand Down Expand Up @@ -993,6 +986,7 @@ static int isapnp_get_resources(struct pnp_dev *dev,
struct pnp_resource_table *res)
{
int ret;

pnp_init_resource_table(res);
isapnp_cfg_begin(dev->card->number, dev->number);
ret = isapnp_read_resources(dev, res);
Expand Down Expand Up @@ -1046,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);
Expand All @@ -1069,7 +1063,6 @@ static int __init isapnp_init(void)
struct pnp_dev *dev;

if (isapnp_disable) {
isapnp_detected = 0;
printk(KERN_INFO "isapnp: ISA Plug & Play support disabled\n");
return 0;
}
Expand Down Expand Up @@ -1117,15 +1110,13 @@ static int __init isapnp_init(void)
}
isapnp_set_rdp();
}
isapnp_detected = 1;
if (isapnp_rdp < 0x203 || isapnp_rdp > 0x3ff) {
cards = isapnp_isolate();
if (cards < 0 || (isapnp_rdp < 0x203 || isapnp_rdp > 0x3ff)) {
#ifdef ISAPNP_REGION_OK
release_region(_PIDXR, 1);
#endif
release_region(_PNPWRP, 1);
isapnp_detected = 0;
printk(KERN_INFO
"isapnp: No Plug & Play device found\n");
return 0;
Expand All @@ -1148,13 +1139,12 @@ static int __init isapnp_init(void)
}
}
}
if (cards) {
if (cards)
printk(KERN_INFO
"isapnp: %i Plug & Play card%s detected total\n", cards,
cards > 1 ? "s" : "");
} else {
else
printk(KERN_INFO "isapnp: No Plug & Play card found\n");
}

isapnp_proc_init();
return 0;
Expand Down
45 changes: 0 additions & 45 deletions drivers/pnp/isapnp/proc.c
Original file line number Diff line number Diff line change
Expand Up @@ -112,33 +112,6 @@ static int isapnp_proc_attach_device(struct pnp_dev *dev)
return 0;
}

#ifdef MODULE
static int __exit isapnp_proc_detach_device(struct pnp_dev *dev)
{
struct pnp_card *bus = dev->card;
struct proc_dir_entry *de;
char name[16];

if (!(de = bus->procdir))
return -EINVAL;
sprintf(name, "%02x", dev->number);
remove_proc_entry(name, de);
return 0;
}

static int __exit isapnp_proc_detach_bus(struct pnp_card *bus)
{
struct proc_dir_entry *de;
char name[16];

if (!(de = bus->procdir))
return -EINVAL;
sprintf(name, "%02x", bus->number);
remove_proc_entry(name, isapnp_proc_bus_dir);
return 0;
}
#endif /* MODULE */

int __init isapnp_proc_init(void)
{
struct pnp_dev *dev;
Expand All @@ -149,21 +122,3 @@ int __init isapnp_proc_init(void)
}
return 0;
}

#ifdef MODULE
int __exit isapnp_proc_done(void)
{
struct pnp_dev *dev;
struct pnp_bus *card;

isapnp_for_each_dev(dev) {
isapnp_proc_detach_device(dev);
}
isapnp_for_each_card(card) {
isapnp_proc_detach_bus(card);
}
if (isapnp_proc_bus_dir)
remove_proc_entry("isapnp", proc_bus);
return 0;
}
#endif /* MODULE */
27 changes: 2 additions & 25 deletions drivers/pnp/manager.c
Original file line number Diff line number Diff line change
Expand Up @@ -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.");
Expand Down Expand Up @@ -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.");
Expand Down Expand Up @@ -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.");
Expand Down Expand Up @@ -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.");
Expand Down Expand Up @@ -390,7 +378,7 @@ static int pnp_assign_resources(struct pnp_dev *dev, int depnum)
up(&pnp_res_mutex);
return 1;

fail:
fail:
pnp_clean_resource_table(&dev->res);
up(&pnp_res_mutex);
return 0;
Expand All @@ -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 (!dev || !res)
return -EINVAL;
if (!pnp_can_configure(dev))
return -ENODEV;
bak = pnp_alloc(sizeof(struct pnp_resource_table));
Expand Down Expand Up @@ -444,7 +430,7 @@ int pnp_manual_config_dev(struct pnp_dev *dev, struct pnp_resource_table *res,
kfree(bak);
return 0;

fail:
fail:
dev->res = *bak;
up(&pnp_res_mutex);
kfree(bak);
Expand All @@ -460,9 +446,6 @@ int pnp_auto_config_dev(struct pnp_dev *dev)
struct pnp_option *dep;
int i = 1;

if (!dev)
return -EINVAL;

if (!pnp_can_configure(dev)) {
pnp_dbg("Device %s does not support resource configuration.",
dev->dev.bus_id);
Expand Down Expand Up @@ -541,8 +524,6 @@ int pnp_activate_dev(struct pnp_dev *dev)
{
int error;

if (!dev)
return -EINVAL;
if (dev->active)
return 0; /* the device is already active */

Expand All @@ -568,8 +549,6 @@ int pnp_disable_dev(struct pnp_dev *dev)
{
int error;

if (!dev)
return -EINVAL;
if (!dev->active)
return 0; /* the device is already disabled */

Expand All @@ -596,8 +575,6 @@ int pnp_disable_dev(struct pnp_dev *dev)
void pnp_resource_change(struct resource *resource, resource_size_t start,
resource_size_t size)
{
if (resource == NULL)
return;
resource->flags &= ~(IORESOURCE_AUTO | IORESOURCE_UNSET);
resource->start = start;
resource->end = start + size - 1;
Expand Down
Loading

0 comments on commit a672975

Please sign in to comment.