cregit-Linux how code gets into the kernel

Release 4.7 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 <asm/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 jonesdave jones4581.82%150.00%
alexey dobriyanalexey 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 dobriyanalexey dobriyan2076.92%150.00%
dave jonesdave 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 jonesdave jones4174.55%150.00%
alexey dobriyanalexey 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 dobriyanalexey dobriyan2492.31%150.00%
dave jonesdave 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 jonesdave jones13075.14%233.33%
thomas hoodthomas hood2112.14%116.67%
alexey dobriyanalexey dobriyan158.67%116.67%
jesper juhljesper juhl63.47%116.67%
robert p. j. dayrobert 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 dobriyanalexey dobriyan2076.92%150.00%
dave jonesdave 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 dobriyanalexey dobriyan5170.83%150.00%
dave jonesdave 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 dobriyanalexey dobriyan2076.92%150.00%
linus torvaldslinus 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 torvaldslinus torvalds8462.69%116.67%
dave jonesdave jones3626.87%116.67%
alexey dobriyanalexey dobriyan118.21%116.67%
adam belayadam belay10.75%116.67%
robert p. j. dayrobert p. j. day10.75%116.67%
andy shevchenkoandy 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 dobriyanalexey dobriyan2076.92%150.00%
linus torvaldslinus 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 torvaldslinus torvalds9778.86%125.00%
alexey dobriyanalexey dobriyan1814.63%125.00%
dave jonesdave jones75.69%125.00%
robert p. j. dayrobert 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 dobriyanalexey dobriyan2689.66%133.33%
linus torvaldslinus torvalds26.90%133.33%
al viroal 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 torvaldslinus torvalds12364.06%114.29%
andrew mortonandrew morton4925.52%114.29%
alexey dobriyanalexey dobriyan147.29%114.29%
al viroal viro52.60%342.86%
robert p. j. dayrobert 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 torvaldslinus torvalds6759.29%120.00%
adam belayadam belay2824.78%240.00%
alexey dobriyanalexey dobriyan1715.04%120.00%
dave jonesdave 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 belayadam belay7469.16%120.00%
alexey dobriyanalexey dobriyan1715.89%240.00%
dave jonesdave jones1211.21%120.00%
linus torvaldslinus 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 torvaldslinus torvalds8271.30%133.33%
dave jonesdave jones3126.96%133.33%
alexey dobriyanalexey dobriyan21.74%133.33%
Total115100.00%3100.00%


Overall Contributors

PersonTokensPropCommitsCommitProp
alexey dobriyanalexey dobriyan50532.52%210.53%
linus torvaldslinus torvalds50432.45%15.26%
dave jonesdave jones33821.76%210.53%
adam belayadam belay1076.89%315.79%
andrew mortonandrew morton523.35%15.26%
thomas hoodthomas hood251.61%15.26%
jesper juhljesper juhl60.39%15.26%
al viroal viro60.39%315.79%
robert p. j. dayrobert p. j. day40.26%15.26%
martin daleckimartin dalecki30.19%15.26%
bjorn helgaasbjorn helgaas10.06%15.26%
andy shevchenkoandy shevchenko10.06%15.26%
justin mattockjustin mattock10.06%15.26%
Total1553100.00%19100.00%
Information contained on this website is for historical information purposes only and does not indicate or represent copyright ownership.
{% endraw %}