cregit-Linux how code gets into the kernel

Release 4.11 drivers/pnp/pnpbios/proc.c

/*
 * /proc/bus/pnp interface for Plug and Play devices
 *
 * Written by David Hinds, dahinds@users.sourceforge.net
 * Modified by Thomas Hood
 *
 * The .../devices and .../<node> and .../boot/<node> files are
 * utilized by the lspnp and setpnp utilities, supplied with the
 * pcmcia-cs package.
 *     http://pcmcia-cs.sourceforge.net
 *
 * The .../escd file is utilized by the lsescd utility written by
 * Gunther Mayer.
 *
 * The .../legacy_device_resources file is not used yet.
 *
 * The other files are human-readable.
 */

#include <linux/module.h>
#include <linux/kernel.h>
#include <linux/slab.h>
#include <linux/types.h>
#include <linux/proc_fs.h>
#include <linux/pnp.h>
#include <linux/seq_file.h>
#include <linux/init.h>

#include <linux/uaccess.h>

#include "pnpbios.h"


static struct proc_dir_entry *proc_pnp = NULL;

static struct proc_dir_entry *proc_pnp_boot = NULL;


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; 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; }

Contributors

PersonTokensPropCommitsCommitProp
Dave Jones4581.82%150.00%
Alexey Dobriyan1018.18%150.00%
Total55100.00%2100.00%


static int pnpconfig_proc_open(struct inode *inode, struct file *file) { return single_open(file, pnpconfig_proc_show, NULL); }

Contributors

PersonTokensPropCommitsCommitProp
Alexey Dobriyan2076.92%150.00%
Dave Jones623.08%150.00%
Total26100.00%2100.00%

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; 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; }

Contributors

PersonTokensPropCommitsCommitProp
Dave Jones4174.55%150.00%
Alexey Dobriyan1425.45%150.00%
Total55100.00%2100.00%


static int escd_info_proc_open(struct inode *inode, struct file *file) { return single_open(file, escd_info_proc_show, NULL); }

Contributors

PersonTokensPropCommitsCommitProp
Alexey Dobriyan2492.31%150.00%
Dave Jones27.69%150.00%
Total26100.00%2100.00%

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 escd_proc_show(struct seq_file *m, void *v) { struct escd_info_struc escd; char *tmpbuf; int escd_size; if (pnp_bios_escd_info(&escd)) return -EIO; /* sanity check */ if (escd.escd_size > MAX_SANE_ESCD_SIZE) { printk(KERN_ERR "PnPBIOS: %s: ESCD size reported by BIOS escd_info call is too great\n", __func__); return -EFBIG; } tmpbuf = kzalloc(escd.escd_size, GFP_KERNEL); if (!tmpbuf) return -ENOMEM; if (pnp_bios_read_escd(tmpbuf, escd.nv_storage_base)) { kfree(tmpbuf); return -EIO; } escd_size = (unsigned char)(tmpbuf[0]) + (unsigned char)(tmpbuf[1]) * 256; /* sanity check */ if (escd_size > MAX_SANE_ESCD_SIZE) { printk(KERN_ERR "PnPBIOS: %s: ESCD size reported by" " BIOS read_escd call is too great\n", __func__); kfree(tmpbuf); return -EFBIG; } seq_write(m, tmpbuf, escd_size); kfree(tmpbuf); return 0; }

Contributors

PersonTokensPropCommitsCommitProp
Dave Jones13075.14%233.33%
Thomas Hood2112.14%116.67%
Alexey Dobriyan158.67%116.67%
Jesper Juhl63.47%116.67%
Robert P. J. Day10.58%116.67%
Total173100.00%6100.00%


static int escd_proc_open(struct inode *inode, struct file *file) { return single_open(file, escd_proc_show, NULL); }

Contributors

PersonTokensPropCommitsCommitProp
Alexey Dobriyan2076.92%150.00%
Dave Jones623.08%150.00%
Total26100.00%2100.00%

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) { 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; }

Contributors

PersonTokensPropCommitsCommitProp
Alexey Dobriyan5170.83%150.00%
Dave Jones2129.17%150.00%
Total72100.00%2100.00%


static int pnp_legacyres_proc_open(struct inode *inode, struct file *file) { return single_open(file, pnp_legacyres_proc_show, NULL); }

Contributors

PersonTokensPropCommitsCommitProp
Alexey Dobriyan2076.92%150.00%
Linus Torvalds623.08%150.00%
Total26100.00%2100.00%

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; node = kzalloc(node_info.max_node_size, GFP_KERNEL); if (!node) return -ENOMEM; for (nodenum = 0; nodenum < 0xff;) { u8 thisnodenum = nodenum; if (pnp_bios_get_dev_node(&nodenum, PNPMODE_DYNAMIC, node)) break; seq_printf(m, "%02x\t%08x\t%3phC\t%04x\n", node->handle, node->eisa_id, node->type_code, node->flags); if (nodenum <= thisnodenum) { printk(KERN_ERR "%s Node number 0x%x is out of sequence following node 0x%x. Aborting.\n", "PnPBIOS: proc_read_devices:", (unsigned int)nodenum, (unsigned int)thisnodenum); break; } } kfree(node); return 0; }

Contributors

PersonTokensPropCommitsCommitProp
Linus Torvalds8462.69%116.67%
Dave Jones3626.87%116.67%
Alexey Dobriyan118.21%116.67%
Robert P. J. Day10.75%116.67%
Adam Belay10.75%116.67%
Andy Shevchenko10.75%116.67%
Total134100.00%6100.00%


static int pnp_devices_proc_open(struct inode *inode, struct file *file) { return single_open(file, pnp_devices_proc_show, NULL); }

Contributors

PersonTokensPropCommitsCommitProp
Alexey Dobriyan2076.92%150.00%
Linus Torvalds623.08%150.00%
Total26100.00%2100.00%

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; int len; node = kzalloc(node_info.max_node_size, GFP_KERNEL); if (!node) return -ENOMEM; if (pnp_bios_get_dev_node(&nodenum, boot, node)) { kfree(node); return -EIO; } len = node->size - sizeof(struct pnp_bios_node); seq_write(m, node->data, len); kfree(node); return 0; }

Contributors

PersonTokensPropCommitsCommitProp
Linus Torvalds9778.86%125.00%
Alexey Dobriyan1814.63%125.00%
Dave Jones75.69%125.00%
Robert P. J. Day10.81%125.00%
Total123100.00%4100.00%


static int pnpbios_proc_open(struct inode *inode, struct file *file) { return single_open(file, pnpbios_proc_show, PDE_DATA(inode)); }

Contributors

PersonTokensPropCommitsCommitProp
Alexey Dobriyan2689.66%133.33%
Linus Torvalds26.90%133.33%
Al Viro13.45%133.33%
Total29100.00%3100.00%


static ssize_t pnpbios_proc_write(struct file *file, const char __user *buf, size_t count, loff_t *pos) { void *data = PDE_DATA(file_inode(file)); struct pnp_bios_node *node; int boot = (long)data >> 8; u8 nodenum = (long)data; int ret = count; node = kzalloc(node_info.max_node_size, GFP_KERNEL); if (!node) return -ENOMEM; if (pnp_bios_get_dev_node(&nodenum, boot, node)) { ret = -EIO; goto out; } if (count != node->size - sizeof(struct pnp_bios_node)) { ret = -EINVAL; goto out; } if (copy_from_user(node->data, buf, count)) { ret = -EFAULT; goto out; } if (pnp_bios_set_dev_node(node->handle, boot, node) != 0) { ret = -EINVAL; goto out; } ret = count; out: kfree(node); return ret; }

Contributors

PersonTokensPropCommitsCommitProp
Linus Torvalds12364.06%114.29%
Andrew Morton4925.52%114.29%
Alexey Dobriyan147.29%114.29%
Al Viro52.60%342.86%
Robert P. J. Day10.52%114.29%
Total192100.00%7100.00%

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]; sprintf(name, "%02x", node->handle); if (!proc_pnp) return -EIO; if (!pnpbios_dont_use_current_config) { proc_create_data(name, 0644, proc_pnp, &pnpbios_proc_fops, (void *)(long)(node->handle)); } if (!proc_pnp_boot) return -EIO; if (proc_create_data(name, 0644, proc_pnp_boot, &pnpbios_proc_fops, (void *)(long)(node->handle + 0x100))) return 0; return -EIO; }

Contributors

PersonTokensPropCommitsCommitProp
Linus Torvalds6759.29%120.00%
Adam Belay2824.78%240.00%
Alexey Dobriyan1715.04%120.00%
Dave Jones10.88%120.00%
Total113100.00%5100.00%

/* * When this is called, pnpbios functions are assumed to * work and the pnpbios_dont_use_current_config flag * should already have been set to the appropriate value */
int __init pnpbios_proc_init(void) { proc_pnp = proc_mkdir("bus/pnp", NULL); if (!proc_pnp) return -EIO; proc_pnp_boot = proc_mkdir("boot", proc_pnp); if (!proc_pnp_boot) return -EIO; 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; }

Contributors

PersonTokensPropCommitsCommitProp
Adam Belay7469.16%120.00%
Alexey Dobriyan1715.89%240.00%
Dave Jones1211.21%120.00%
Linus Torvalds43.74%120.00%
Total107100.00%5100.00%


void __exit pnpbios_proc_exit(void) { int i; char name[3]; if (!proc_pnp) return; for (i = 0; i < 0xff; i++) { sprintf(name, "%02x", i); if (!pnpbios_dont_use_current_config) remove_proc_entry(name, proc_pnp); remove_proc_entry(name, proc_pnp_boot); } remove_proc_entry("legacy_device_resources", proc_pnp); remove_proc_entry("escd", proc_pnp); remove_proc_entry("escd_info", proc_pnp); remove_proc_entry("configuration_info", proc_pnp); remove_proc_entry("devices", proc_pnp); remove_proc_entry("boot", proc_pnp); remove_proc_entry("bus/pnp", NULL); }

Contributors

PersonTokensPropCommitsCommitProp
Linus Torvalds8271.30%133.33%
Dave Jones3126.96%133.33%
Alexey Dobriyan21.74%133.33%
Total115100.00%3100.00%


Overall Contributors

PersonTokensPropCommitsCommitProp
Linus Torvalds50532.52%210.00%
Alexey Dobriyan50532.52%210.00%
Dave Jones33821.76%210.00%
Adam Belay1076.89%315.00%
Andrew Morton513.28%15.00%
Thomas Hood251.61%15.00%
Al Viro60.39%315.00%
Jesper Juhl60.39%15.00%
Robert P. J. Day40.26%15.00%
Martin Dalecki30.19%15.00%
Justin P. Mattock10.06%15.00%
Björn Helgaas10.06%15.00%
Andy Shevchenko10.06%15.00%
Total1553100.00%20100.00%
Information contained on this website is for historical information purposes only and does not indicate or represent copyright ownership.
Created with cregit.