diff options
author | David S. Miller <davem@davemloft.net> | 2010-01-22 22:45:46 -0800 |
---|---|---|
committer | David S. Miller <davem@davemloft.net> | 2010-01-22 22:45:46 -0800 |
commit | 6be325719b3e54624397e413efd4b33a997e55a3 (patch) | |
tree | 57f321a56794cab2222e179b16731e0d76a4a68a /drivers/pnp | |
parent | 26d92f9276a56d55511a427fb70bd70886af647a (diff) | |
parent | 92dcffb916d309aa01778bf8963a6932e4014d07 (diff) | |
download | linux-6be325719b3e54624397e413efd4b33a997e55a3.tar.bz2 |
Merge branch 'master' of /home/davem/src/GIT/linux-2.6/
Diffstat (limited to 'drivers/pnp')
-rw-r--r-- | drivers/pnp/interface.c | 36 | ||||
-rw-r--r-- | drivers/pnp/pnpacpi/core.c | 20 | ||||
-rw-r--r-- | drivers/pnp/pnpacpi/rsparser.c | 9 | ||||
-rw-r--r-- | drivers/pnp/pnpbios/proc.c | 204 |
4 files changed, 159 insertions, 110 deletions
diff --git a/drivers/pnp/interface.c b/drivers/pnp/interface.c index c3f1c8e9d254..68b0c04987e4 100644 --- a/drivers/pnp/interface.c +++ b/drivers/pnp/interface.c @@ -310,8 +310,7 @@ static ssize_t pnp_set_current_resources(struct device *dmdev, goto done; } - while (isspace(*buf)) - ++buf; + buf = skip_spaces(buf); if (!strnicmp(buf, "disable", 7)) { retval = pnp_disable_dev(dev); goto done; @@ -353,19 +352,13 @@ static ssize_t pnp_set_current_resources(struct device *dmdev, pnp_init_resources(dev); mutex_lock(&pnp_res_mutex); while (1) { - while (isspace(*buf)) - ++buf; + buf = skip_spaces(buf); if (!strnicmp(buf, "io", 2)) { - buf += 2; - while (isspace(*buf)) - ++buf; + buf = skip_spaces(buf + 2); start = simple_strtoul(buf, &buf, 0); - while (isspace(*buf)) - ++buf; + buf = skip_spaces(buf); if (*buf == '-') { - buf += 1; - while (isspace(*buf)) - ++buf; + buf = skip_spaces(buf + 1); end = simple_strtoul(buf, &buf, 0); } else end = start; @@ -373,16 +366,11 @@ static ssize_t pnp_set_current_resources(struct device *dmdev, continue; } if (!strnicmp(buf, "mem", 3)) { - buf += 3; - while (isspace(*buf)) - ++buf; + buf = skip_spaces(buf + 3); start = simple_strtoul(buf, &buf, 0); - while (isspace(*buf)) - ++buf; + buf = skip_spaces(buf); if (*buf == '-') { - buf += 1; - while (isspace(*buf)) - ++buf; + buf = skip_spaces(buf + 1); end = simple_strtoul(buf, &buf, 0); } else end = start; @@ -390,17 +378,13 @@ static ssize_t pnp_set_current_resources(struct device *dmdev, continue; } if (!strnicmp(buf, "irq", 3)) { - buf += 3; - while (isspace(*buf)) - ++buf; + buf = skip_spaces(buf + 3); start = simple_strtoul(buf, &buf, 0); pnp_add_irq_resource(dev, start, 0); continue; } if (!strnicmp(buf, "dma", 3)) { - buf += 3; - while (isspace(*buf)) - ++buf; + buf = skip_spaces(buf + 3); start = simple_strtoul(buf, &buf, 0); pnp_add_dma_resource(dev, start, 0); continue; diff --git a/drivers/pnp/pnpacpi/core.c b/drivers/pnp/pnpacpi/core.c index 83b8b5ac49c9..5314bf630bc4 100644 --- a/drivers/pnp/pnpacpi/core.c +++ b/drivers/pnp/pnpacpi/core.c @@ -80,7 +80,8 @@ static int pnpacpi_get_resources(struct pnp_dev *dev) static int pnpacpi_set_resources(struct pnp_dev *dev) { - acpi_handle handle = dev->data; + struct acpi_device *acpi_dev = dev->data; + acpi_handle handle = acpi_dev->handle; struct acpi_buffer buffer; int ret; @@ -103,7 +104,8 @@ static int pnpacpi_set_resources(struct pnp_dev *dev) static int pnpacpi_disable_resources(struct pnp_dev *dev) { - acpi_handle handle = dev->data; + struct acpi_device *acpi_dev = dev->data; + acpi_handle handle = acpi_dev->handle; int ret; dev_dbg(&dev->dev, "disable resources\n"); @@ -121,6 +123,8 @@ static int pnpacpi_disable_resources(struct pnp_dev *dev) #ifdef CONFIG_ACPI_SLEEP static int pnpacpi_suspend(struct pnp_dev *dev, pm_message_t state) { + struct acpi_device *acpi_dev = dev->data; + acpi_handle handle = acpi_dev->handle; int power_state; power_state = acpi_pm_device_sleep_state(&dev->dev, NULL); @@ -128,16 +132,19 @@ static int pnpacpi_suspend(struct pnp_dev *dev, pm_message_t state) power_state = (state.event == PM_EVENT_ON) ? ACPI_STATE_D0 : ACPI_STATE_D3; - return acpi_bus_set_power((acpi_handle) dev->data, power_state); + return acpi_bus_set_power(handle, power_state); } static int pnpacpi_resume(struct pnp_dev *dev) { - return acpi_bus_set_power((acpi_handle) dev->data, ACPI_STATE_D0); + struct acpi_device *acpi_dev = dev->data; + acpi_handle handle = acpi_dev->handle; + + return acpi_bus_set_power(handle, ACPI_STATE_D0); } #endif -static struct pnp_protocol pnpacpi_protocol = { +struct pnp_protocol pnpacpi_protocol = { .name = "Plug and Play ACPI", .get = pnpacpi_get_resources, .set = pnpacpi_set_resources, @@ -147,6 +154,7 @@ static struct pnp_protocol pnpacpi_protocol = { .resume = pnpacpi_resume, #endif }; +EXPORT_SYMBOL(pnpacpi_protocol); static int __init pnpacpi_add_device(struct acpi_device *device) { @@ -168,7 +176,7 @@ static int __init pnpacpi_add_device(struct acpi_device *device) if (!dev) return -ENOMEM; - dev->data = device->handle; + dev->data = device; /* .enabled means the device can decode the resources */ dev->active = device->status.enabled; status = acpi_get_handle(device->handle, "_SRS", &temp); diff --git a/drivers/pnp/pnpacpi/rsparser.c b/drivers/pnp/pnpacpi/rsparser.c index ef3a2cd3a7a0..5702b2c8691f 100644 --- a/drivers/pnp/pnpacpi/rsparser.c +++ b/drivers/pnp/pnpacpi/rsparser.c @@ -465,7 +465,8 @@ static acpi_status pnpacpi_allocated_resource(struct acpi_resource *res, int pnpacpi_parse_allocated_resource(struct pnp_dev *dev) { - acpi_handle handle = dev->data; + struct acpi_device *acpi_dev = dev->data; + acpi_handle handle = acpi_dev->handle; acpi_status status; pnp_dbg(&dev->dev, "parse allocated resources\n"); @@ -773,7 +774,8 @@ static __init acpi_status pnpacpi_option_resource(struct acpi_resource *res, int __init pnpacpi_parse_resource_option_data(struct pnp_dev *dev) { - acpi_handle handle = dev->data; + struct acpi_device *acpi_dev = dev->data; + acpi_handle handle = acpi_dev->handle; acpi_status status; struct acpipnp_parse_option_s parse_data; @@ -845,7 +847,8 @@ static acpi_status pnpacpi_type_resources(struct acpi_resource *res, void *data) int pnpacpi_build_resource_template(struct pnp_dev *dev, struct acpi_buffer *buffer) { - acpi_handle handle = dev->data; + struct acpi_device *acpi_dev = dev->data; + acpi_handle handle = acpi_dev->handle; struct acpi_resource *resource; int res_cnt = 0; acpi_status status; diff --git a/drivers/pnp/pnpbios/proc.c b/drivers/pnp/pnpbios/proc.c index b35d921bac6e..2d8ac43f78e8 100644 --- a/drivers/pnp/pnpbios/proc.c +++ b/drivers/pnp/pnpbios/proc.c @@ -24,6 +24,7 @@ #include <linux/types.h> #include <linux/proc_fs.h> #include <linux/pnp.h> +#include <linux/seq_file.h> #include <linux/init.h> #include <asm/uaccess.h> @@ -33,42 +34,65 @@ static struct proc_dir_entry *proc_pnp = NULL; static struct proc_dir_entry *proc_pnp_boot = NULL; -static int proc_read_pnpconfig(char *buf, char **start, off_t pos, - int count, int *eof, void *data) +static int pnpconfig_proc_show(struct seq_file *m, void *v) { struct pnp_isa_config_struc pnps; if (pnp_bios_isapnp_config(&pnps)) return -EIO; - return snprintf(buf, count, - "structure_revision %d\n" - "number_of_CSNs %d\n" - "ISA_read_data_port 0x%x\n", - pnps.revision, pnps.no_csns, pnps.isa_rd_data_port); + seq_printf(m, "structure_revision %d\n" + "number_of_CSNs %d\n" + "ISA_read_data_port 0x%x\n", + pnps.revision, pnps.no_csns, pnps.isa_rd_data_port); + return 0; } -static int proc_read_escdinfo(char *buf, char **start, off_t pos, - int count, int *eof, void *data) +static int pnpconfig_proc_open(struct inode *inode, struct file *file) +{ + return single_open(file, pnpconfig_proc_show, NULL); +} + +static const struct file_operations pnpconfig_proc_fops = { + .owner = THIS_MODULE, + .open = pnpconfig_proc_open, + .read = seq_read, + .llseek = seq_lseek, + .release = single_release, +}; + +static int escd_info_proc_show(struct seq_file *m, void *v) { struct escd_info_struc escd; if (pnp_bios_escd_info(&escd)) return -EIO; - return snprintf(buf, count, - "min_ESCD_write_size %d\n" + seq_printf(m, "min_ESCD_write_size %d\n" "ESCD_size %d\n" "NVRAM_base 0x%x\n", escd.min_escd_write_size, escd.escd_size, escd.nv_storage_base); + return 0; } +static int escd_info_proc_open(struct inode *inode, struct file *file) +{ + return single_open(file, escd_info_proc_show, NULL); +} + +static const struct file_operations escd_info_proc_fops = { + .owner = THIS_MODULE, + .open = escd_info_proc_open, + .read = seq_read, + .llseek = seq_lseek, + .release = single_release, +}; + #define MAX_SANE_ESCD_SIZE (32*1024) -static int proc_read_escd(char *buf, char **start, off_t pos, - int count, int *eof, void *data) +static int escd_proc_show(struct seq_file *m, void *v) { struct escd_info_struc escd; char *tmpbuf; - int escd_size, escd_left_to_read, n; + int escd_size; if (pnp_bios_escd_info(&escd)) return -EIO; @@ -76,7 +100,7 @@ static int proc_read_escd(char *buf, char **start, off_t pos, /* sanity check */ if (escd.escd_size > MAX_SANE_ESCD_SIZE) { printk(KERN_ERR - "PnPBIOS: proc_read_escd: ESCD size reported by BIOS escd_info call is too great\n"); + "PnPBIOS: %s: ESCD size reported by BIOS escd_info call is too great\n", __func__); return -EFBIG; } @@ -94,56 +118,75 @@ static int proc_read_escd(char *buf, char **start, off_t pos, /* sanity check */ if (escd_size > MAX_SANE_ESCD_SIZE) { - printk(KERN_ERR "PnPBIOS: proc_read_escd: ESCD size reported by" - " BIOS read_escd call is too great\n"); + printk(KERN_ERR "PnPBIOS: %s: ESCD size reported by" + " BIOS read_escd call is too great\n", __func__); kfree(tmpbuf); return -EFBIG; } - escd_left_to_read = escd_size - pos; - if (escd_left_to_read < 0) - escd_left_to_read = 0; - if (escd_left_to_read == 0) - *eof = 1; - n = min(count, escd_left_to_read); - memcpy(buf, tmpbuf + pos, n); + seq_write(m, tmpbuf, escd_size); kfree(tmpbuf); - *start = buf; - return n; + return 0; } -static int proc_read_legacyres(char *buf, char **start, off_t pos, - int count, int *eof, void *data) +static int escd_proc_open(struct inode *inode, struct file *file) +{ + return single_open(file, escd_proc_show, NULL); +} + +static const struct file_operations escd_proc_fops = { + .owner = THIS_MODULE, + .open = escd_proc_open, + .read = seq_read, + .llseek = seq_lseek, + .release = single_release, +}; + +static int pnp_legacyres_proc_show(struct seq_file *m, void *v) { - /* Assume that the following won't overflow the buffer */ - if (pnp_bios_get_stat_res(buf)) + void *buf; + + buf = kmalloc(65536, GFP_KERNEL); + if (!buf) + return -ENOMEM; + if (pnp_bios_get_stat_res(buf)) { + kfree(buf); return -EIO; + } + + seq_write(m, buf, 65536); + kfree(buf); + return 0; +} - return count; // FIXME: Return actual length +static int pnp_legacyres_proc_open(struct inode *inode, struct file *file) +{ + return single_open(file, pnp_legacyres_proc_show, NULL); } -static int proc_read_devices(char *buf, char **start, off_t pos, - int count, int *eof, void *data) +static const struct file_operations pnp_legacyres_proc_fops = { + .owner = THIS_MODULE, + .open = pnp_legacyres_proc_open, + .read = seq_read, + .llseek = seq_lseek, + .release = single_release, +}; + +static int pnp_devices_proc_show(struct seq_file *m, void *v) { struct pnp_bios_node *node; u8 nodenum; - char *p = buf; - - if (pos >= 0xff) - return 0; node = kzalloc(node_info.max_node_size, GFP_KERNEL); if (!node) return -ENOMEM; - for (nodenum = pos; nodenum < 0xff;) { + for (nodenum = 0; nodenum < 0xff;) { u8 thisnodenum = nodenum; - /* 26 = the number of characters per line sprintf'ed */ - if ((p - buf + 26) > count) - break; + if (pnp_bios_get_dev_node(&nodenum, PNPMODE_DYNAMIC, node)) break; - p += sprintf(p, "%02x\t%08x\t%02x:%02x:%02x\t%04x\n", + seq_printf(m, "%02x\t%08x\t%02x:%02x:%02x\t%04x\n", node->handle, node->eisa_id, node->type_code[0], node->type_code[1], node->type_code[2], node->flags); @@ -153,20 +196,29 @@ static int proc_read_devices(char *buf, char **start, off_t pos, "PnPBIOS: proc_read_devices:", (unsigned int)nodenum, (unsigned int)thisnodenum); - *eof = 1; break; } } kfree(node); - if (nodenum == 0xff) - *eof = 1; - *start = (char *)((off_t) nodenum - pos); - return p - buf; + return 0; +} + +static int pnp_devices_proc_open(struct inode *inode, struct file *file) +{ + return single_open(file, pnp_devices_proc_show, NULL); } -static int proc_read_node(char *buf, char **start, off_t pos, - int count, int *eof, void *data) +static const struct file_operations pnp_devices_proc_fops = { + .owner = THIS_MODULE, + .open = pnp_devices_proc_open, + .read = seq_read, + .llseek = seq_lseek, + .release = single_release, +}; + +static int pnpbios_proc_show(struct seq_file *m, void *v) { + void *data = m->private; struct pnp_bios_node *node; int boot = (long)data >> 8; u8 nodenum = (long)data; @@ -180,14 +232,20 @@ static int proc_read_node(char *buf, char **start, off_t pos, return -EIO; } len = node->size - sizeof(struct pnp_bios_node); - memcpy(buf, node->data, len); + seq_write(m, node->data, len); kfree(node); - return len; + return 0; +} + +static int pnpbios_proc_open(struct inode *inode, struct file *file) +{ + return single_open(file, pnpbios_proc_show, PDE(inode)->data); } -static int proc_write_node(struct file *file, const char __user * buf, - unsigned long count, void *data) +static ssize_t pnpbios_proc_write(struct file *file, const char __user *buf, + size_t count, loff_t *pos) { + void *data = PDE(file->f_path.dentry->d_inode)->data; struct pnp_bios_node *node; int boot = (long)data >> 8; u8 nodenum = (long)data; @@ -218,34 +276,33 @@ out: return ret; } +static const struct file_operations pnpbios_proc_fops = { + .owner = THIS_MODULE, + .open = pnpbios_proc_open, + .read = seq_read, + .llseek = seq_lseek, + .release = single_release, + .write = pnpbios_proc_write, +}; + int pnpbios_interface_attach_device(struct pnp_bios_node *node) { char name[3]; - struct proc_dir_entry *ent; sprintf(name, "%02x", node->handle); if (!proc_pnp) return -EIO; if (!pnpbios_dont_use_current_config) { - ent = create_proc_entry(name, 0, proc_pnp); - if (ent) { - ent->read_proc = proc_read_node; - ent->write_proc = proc_write_node; - ent->data = (void *)(long)(node->handle); - } + proc_create_data(name, 0644, proc_pnp, &pnpbios_proc_fops, + (void *)(long)(node->handle)); } if (!proc_pnp_boot) return -EIO; - ent = create_proc_entry(name, 0, proc_pnp_boot); - if (ent) { - ent->read_proc = proc_read_node; - ent->write_proc = proc_write_node; - ent->data = (void *)(long)(node->handle + 0x100); + if (proc_create_data(name, 0644, proc_pnp_boot, &pnpbios_proc_fops, + (void *)(long)(node->handle + 0x100))) return 0; - } - return -EIO; } @@ -262,14 +319,11 @@ int __init pnpbios_proc_init(void) proc_pnp_boot = proc_mkdir("boot", proc_pnp); if (!proc_pnp_boot) return -EIO; - create_proc_read_entry("devices", 0, proc_pnp, proc_read_devices, NULL); - create_proc_read_entry("configuration_info", 0, proc_pnp, - proc_read_pnpconfig, NULL); - create_proc_read_entry("escd_info", 0, proc_pnp, proc_read_escdinfo, - NULL); - create_proc_read_entry("escd", S_IRUSR, proc_pnp, proc_read_escd, NULL); - create_proc_read_entry("legacy_device_resources", 0, proc_pnp, - proc_read_legacyres, NULL); + proc_create("devices", 0, proc_pnp, &pnp_devices_proc_fops); + proc_create("configuration_info", 0, proc_pnp, &pnpconfig_proc_fops); + proc_create("escd_info", 0, proc_pnp, &escd_info_proc_fops); + proc_create("escd", S_IRUSR, proc_pnp, &escd_proc_fops); + proc_create("legacy_device_resources", 0, proc_pnp, &pnp_legacyres_proc_fops); return 0; } |