Release 4.11 drivers/pnp/core.c
/*
* core.c - contains all core device and protocol registration functions
*
* Copyright 2002 Adam Belay <ambx1@neo.rr.com>
*/
#include <linux/pnp.h>
#include <linux/types.h>
#include <linux/list.h>
#include <linux/device.h>
#include <linux/module.h>
#include <linux/mutex.h>
#include <linux/init.h>
#include <linux/string.h>
#include <linux/slab.h>
#include <linux/errno.h>
#include <linux/dma-mapping.h>
#include "base.h"
static LIST_HEAD(pnp_protocols);
LIST_HEAD(pnp_global);
DEFINE_MUTEX(pnp_lock);
/*
* ACPI or PNPBIOS should tell us about all platform devices, so we can
* skip some blind probes. ISAPNP typically enumerates only plug-in ISA
* devices, not built-in things like COM ports.
*/
int pnp_platform_devices;
EXPORT_SYMBOL(pnp_platform_devices);
void *pnp_alloc(long size)
{
void *result;
result = kzalloc(size, GFP_KERNEL);
if (!result) {
printk(KERN_ERR "pnp: Out of Memory\n");
return NULL;
}
return result;
}
Contributors
Person | Tokens | Prop | Commits | CommitProp |
Adam Belay | 40 | 97.56% | 1 | 50.00% |
Yoann Padioleau | 1 | 2.44% | 1 | 50.00% |
Total | 41 | 100.00% | 2 | 100.00% |
static void pnp_remove_protocol(struct pnp_protocol *protocol)
{
mutex_lock(&pnp_lock);
list_del(&protocol->protocol_list);
mutex_unlock(&pnp_lock);
}
Contributors
Person | Tokens | Prop | Commits | CommitProp |
Rafael J. Wysocki | 31 | 100.00% | 1 | 100.00% |
Total | 31 | 100.00% | 1 | 100.00% |
/**
* pnp_protocol_register - adds a pnp protocol to the pnp layer
* @protocol: pointer to the corresponding pnp_protocol structure
*
* Ex protocols: ISAPNP, PNPBIOS, etc
*/
int pnp_register_protocol(struct pnp_protocol *protocol)
{
struct list_head *pos;
int nodenum, ret;
INIT_LIST_HEAD(&protocol->devices);
INIT_LIST_HEAD(&protocol->cards);
nodenum = 0;
mutex_lock(&pnp_lock);
/* assign the lowest unused number */
list_for_each(pos, &pnp_protocols) {
struct pnp_protocol *cur = to_pnp_protocol(pos);
if (cur->number == nodenum) {
pos = &pnp_protocols;
nodenum++;
}
}
protocol->number = nodenum;
dev_set_name(&protocol->dev, "pnp%d", nodenum);
list_add_tail(&protocol->protocol_list, &pnp_protocols);
mutex_unlock(&pnp_lock);
ret = device_register(&protocol->dev);
if (ret)
pnp_remove_protocol(protocol);
return ret;
}
Contributors
Person | Tokens | Prop | Commits | CommitProp |
Adam Belay | 104 | 74.29% | 2 | 40.00% |
Rafael J. Wysocki | 35 | 25.00% | 2 | 40.00% |
Kay Sievers | 1 | 0.71% | 1 | 20.00% |
Total | 140 | 100.00% | 5 | 100.00% |
/**
* pnp_protocol_unregister - removes a pnp protocol from the pnp layer
* @protocol: pointer to the corresponding pnp_protocol structure
*/
void pnp_unregister_protocol(struct pnp_protocol *protocol)
{
pnp_remove_protocol(protocol);
device_unregister(&protocol->dev);
}
Contributors
Person | Tokens | Prop | Commits | CommitProp |
Adam Belay | 22 | 95.65% | 2 | 66.67% |
Rafael J. Wysocki | 1 | 4.35% | 1 | 33.33% |
Total | 23 | 100.00% | 3 | 100.00% |
static void pnp_free_ids(struct pnp_dev *dev)
{
struct pnp_id *id;
struct pnp_id *next;
id = dev->id;
while (id) {
next = id->next;
kfree(id);
id = next;
}
}
Contributors
Person | Tokens | Prop | Commits | CommitProp |
Adam Belay | 48 | 100.00% | 2 | 100.00% |
Total | 48 | 100.00% | 2 | 100.00% |
void pnp_free_resource(struct pnp_resource *pnp_res)
{
list_del(&pnp_res->list);
kfree(pnp_res);
}
Contributors
Person | Tokens | Prop | Commits | CommitProp |
Björn Helgaas | 23 | 100.00% | 1 | 100.00% |
Total | 23 | 100.00% | 1 | 100.00% |
void pnp_free_resources(struct pnp_dev *dev)
{
struct pnp_resource *pnp_res, *tmp;
list_for_each_entry_safe(pnp_res, tmp, &dev->resources, list) {
pnp_free_resource(pnp_res);
}
}
Contributors
Person | Tokens | Prop | Commits | CommitProp |
Björn Helgaas | 35 | 100.00% | 1 | 100.00% |
Total | 35 | 100.00% | 1 | 100.00% |
static void pnp_release_device(struct device *dmdev)
{
struct pnp_dev *dev = to_pnp_dev(dmdev);
pnp_free_ids(dev);
pnp_free_resources(dev);
pnp_free_options(dev);
kfree(dev);
}
Contributors
Person | Tokens | Prop | Commits | CommitProp |
Adam Belay | 33 | 80.49% | 2 | 50.00% |
Björn Helgaas | 8 | 19.51% | 2 | 50.00% |
Total | 41 | 100.00% | 4 | 100.00% |
struct pnp_dev *pnp_alloc_dev(struct pnp_protocol *protocol, int id,
const char *pnpid)
{
struct pnp_dev *dev;
struct pnp_id *dev_id;
dev = kzalloc(sizeof(struct pnp_dev), GFP_KERNEL);
if (!dev)
return NULL;
INIT_LIST_HEAD(&dev->resources);
INIT_LIST_HEAD(&dev->options);
dev->protocol = protocol;
dev->number = id;
dev->dma_mask = DMA_BIT_MASK(24);
dev->dev.parent = &dev->protocol->dev;
dev->dev.bus = &pnp_bus_type;
dev->dev.dma_mask = &dev->dma_mask;
dev->dev.coherent_dma_mask = dev->dma_mask;
dev->dev.release = &pnp_release_device;
dev_set_name(&dev->dev, "%02x:%02x", dev->protocol->number, dev->number);
dev_id = pnp_add_id(dev, pnpid);
if (!dev_id) {
kfree(dev);
return NULL;
}
return dev;
}
Contributors
Person | Tokens | Prop | Commits | CommitProp |
Björn Helgaas | 135 | 72.19% | 4 | 40.00% |
Adam Belay | 23 | 12.30% | 1 | 10.00% |
David Brownell | 18 | 9.63% | 1 | 10.00% |
Yang Hongyang | 4 | 2.14% | 1 | 10.00% |
Jaroslav Kysela | 4 | 2.14% | 1 | 10.00% |
Kay Sievers | 2 | 1.07% | 1 | 10.00% |
Thomas Renninger | 1 | 0.53% | 1 | 10.00% |
Total | 187 | 100.00% | 10 | 100.00% |
static void pnp_delist_device(struct pnp_dev *dev)
{
mutex_lock(&pnp_lock);
list_del(&dev->global_list);
list_del(&dev->protocol_list);
mutex_unlock(&pnp_lock);
}
Contributors
Person | Tokens | Prop | Commits | CommitProp |
Rafael J. Wysocki | 39 | 100.00% | 1 | 100.00% |
Total | 39 | 100.00% | 1 | 100.00% |
int __pnp_add_device(struct pnp_dev *dev)
{
int ret;
pnp_fixup_device(dev);
dev->status = PNP_READY;
mutex_lock(&pnp_lock);
list_add_tail(&dev->global_list, &pnp_global);
list_add_tail(&dev->protocol_list, &dev->protocol->devices);
mutex_unlock(&pnp_lock);
ret = device_register(&dev->dev);
if (ret)
pnp_delist_device(dev);
else if (dev->protocol->can_wakeup)
device_set_wakeup_capable(&dev->dev,
dev->protocol->can_wakeup(dev));
return ret;
}
Contributors
Person | Tokens | Prop | Commits | CommitProp |
Adam Belay | 38 | 34.55% | 2 | 25.00% |
Rafael J. Wysocki | 26 | 23.64% | 2 | 25.00% |
Alan Stern | 25 | 22.73% | 1 | 12.50% |
Björn Helgaas | 14 | 12.73% | 1 | 12.50% |
Jaroslav Kysela | 6 | 5.45% | 1 | 12.50% |
Drew Moseley | 1 | 0.91% | 1 | 12.50% |
Total | 110 | 100.00% | 8 | 100.00% |
/*
* pnp_add_device - adds a pnp device to the pnp layer
* @dev: pointer to dev to add
*
* adds to driver model, name database, fixups, interface, etc.
*/
int pnp_add_device(struct pnp_dev *dev)
{
int ret;
char buf[128];
int len = 0;
struct pnp_id *id;
if (dev->card)
return -EINVAL;
ret = __pnp_add_device(dev);
if (ret)
return ret;
buf[0] = '\0';
for (id = dev->id; id; id = id->next)
len += scnprintf(buf + len, sizeof(buf) - len, " %s", id->id);
dev_printk(KERN_DEBUG, &dev->dev, "%s device, IDs%s (%s)\n",
dev->protocol->name, buf,
dev->active ? "active" : "disabled");
return 0;
}
Contributors
Person | Tokens | Prop | Commits | CommitProp |
Björn Helgaas | 104 | 80.62% | 3 | 60.00% |
Adam Belay | 25 | 19.38% | 2 | 40.00% |
Total | 129 | 100.00% | 5 | 100.00% |
void __pnp_remove_device(struct pnp_dev *dev)
{
pnp_delist_device(dev);
device_unregister(&dev->dev);
}
Contributors
Person | Tokens | Prop | Commits | CommitProp |
Adam Belay | 22 | 95.65% | 2 | 66.67% |
Rafael J. Wysocki | 1 | 4.35% | 1 | 33.33% |
Total | 23 | 100.00% | 3 | 100.00% |
static int __init pnp_init(void)
{
return bus_register(&pnp_bus_type);
}
Contributors
Person | Tokens | Prop | Commits | CommitProp |
Adam Belay | 16 | 100.00% | 1 | 100.00% |
Total | 16 | 100.00% | 1 | 100.00% |
subsys_initcall(pnp_init);
int pnp_debug;
#if defined(CONFIG_PNP_DEBUG_MESSAGES)
module_param_named(debug, pnp_debug, int, 0644);
#endif
Overall Contributors
Person | Tokens | Prop | Commits | CommitProp |
Adam Belay | 418 | 42.74% | 3 | 10.71% |
Björn Helgaas | 345 | 35.28% | 10 | 35.71% |
Rafael J. Wysocki | 137 | 14.01% | 2 | 7.14% |
Alan Stern | 25 | 2.56% | 1 | 3.57% |
David Brownell | 21 | 2.15% | 1 | 3.57% |
Jaroslav Kysela | 10 | 1.02% | 2 | 7.14% |
Thomas Renninger | 8 | 0.82% | 2 | 7.14% |
Yang Hongyang | 4 | 0.41% | 1 | 3.57% |
Thomas Gleixner | 3 | 0.31% | 1 | 3.57% |
Kay Sievers | 3 | 0.31% | 1 | 3.57% |
Yoann Padioleau | 1 | 0.10% | 1 | 3.57% |
Drew Moseley | 1 | 0.10% | 1 | 3.57% |
Adrian Bunk | 1 | 0.10% | 1 | 3.57% |
Alan Cox | 1 | 0.10% | 1 | 3.57% |
Total | 978 | 100.00% | 28 | 100.00% |
Information contained on this website is for historical information purposes only and does not indicate or represent copyright ownership.