Lines Matching +full:protocol +full:- +full:id
1 // SPDX-License-Identifier: GPL-2.0
3 * core.c - contains all core device and protocol registration functions
18 #include <linux/dma-mapping.h>
28 * skip some blind probes. ISAPNP typically enumerates only plug-in ISA
29 * devices, not built-in things like COM ports.
46 static void pnp_remove_protocol(struct pnp_protocol *protocol) in pnp_remove_protocol() argument
49 list_del(&protocol->protocol_list); in pnp_remove_protocol()
54 * pnp_register_protocol - adds a pnp protocol to the pnp layer
55 * @protocol: pointer to the corresponding pnp_protocol structure
59 int pnp_register_protocol(struct pnp_protocol *protocol) in pnp_register_protocol() argument
64 INIT_LIST_HEAD(&protocol->devices); in pnp_register_protocol()
65 INIT_LIST_HEAD(&protocol->cards); in pnp_register_protocol()
73 if (cur->number == nodenum) { in pnp_register_protocol()
79 protocol->number = nodenum; in pnp_register_protocol()
80 dev_set_name(&protocol->dev, "pnp%d", nodenum); in pnp_register_protocol()
82 list_add_tail(&protocol->protocol_list, &pnp_protocols); in pnp_register_protocol()
86 ret = device_register(&protocol->dev); in pnp_register_protocol()
88 pnp_remove_protocol(protocol); in pnp_register_protocol()
94 * pnp_unregister_protocol - removes a pnp protocol from the pnp layer
95 * @protocol: pointer to the corresponding pnp_protocol structure
97 void pnp_unregister_protocol(struct pnp_protocol *protocol) in pnp_unregister_protocol() argument
99 pnp_remove_protocol(protocol); in pnp_unregister_protocol()
100 device_unregister(&protocol->dev); in pnp_unregister_protocol()
105 struct pnp_id *id; in pnp_free_ids() local
108 id = dev->id; in pnp_free_ids()
109 while (id) { in pnp_free_ids()
110 next = id->next; in pnp_free_ids()
111 kfree(id); in pnp_free_ids()
112 id = next; in pnp_free_ids()
118 list_del(&pnp_res->list); in pnp_free_resource()
126 list_for_each_entry_safe(pnp_res, tmp, &dev->resources, list) { in pnp_free_resources()
141 struct pnp_dev *pnp_alloc_dev(struct pnp_protocol *protocol, int id, in pnp_alloc_dev() argument
151 INIT_LIST_HEAD(&dev->resources); in pnp_alloc_dev()
152 INIT_LIST_HEAD(&dev->options); in pnp_alloc_dev()
153 dev->protocol = protocol; in pnp_alloc_dev()
154 dev->number = id; in pnp_alloc_dev()
155 dev->dma_mask = DMA_BIT_MASK(24); in pnp_alloc_dev()
157 dev->dev.parent = &dev->protocol->dev; in pnp_alloc_dev()
158 dev->dev.bus = &pnp_bus_type; in pnp_alloc_dev()
159 dev->dev.dma_mask = &dev->dma_mask; in pnp_alloc_dev()
160 dev->dev.coherent_dma_mask = dev->dma_mask; in pnp_alloc_dev()
161 dev->dev.release = &pnp_release_device; in pnp_alloc_dev()
163 dev_set_name(&dev->dev, "%02x:%02x", dev->protocol->number, dev->number); in pnp_alloc_dev()
177 list_del(&dev->global_list); in pnp_delist_device()
178 list_del(&dev->protocol_list); in pnp_delist_device()
187 dev->status = PNP_READY; in __pnp_add_device()
191 list_add_tail(&dev->global_list, &pnp_global); in __pnp_add_device()
192 list_add_tail(&dev->protocol_list, &dev->protocol->devices); in __pnp_add_device()
196 ret = device_register(&dev->dev); in __pnp_add_device()
199 else if (dev->protocol->can_wakeup) in __pnp_add_device()
200 device_set_wakeup_capable(&dev->dev, in __pnp_add_device()
201 dev->protocol->can_wakeup(dev)); in __pnp_add_device()
207 * pnp_add_device - adds a pnp device to the pnp layer
217 struct pnp_id *id; in pnp_add_device() local
219 if (dev->card) in pnp_add_device()
220 return -EINVAL; in pnp_add_device()
227 for (id = dev->id; id; id = id->next) in pnp_add_device()
228 len += scnprintf(buf + len, sizeof(buf) - len, " %s", id->id); in pnp_add_device()
230 dev_printk(KERN_DEBUG, &dev->dev, "%s device, IDs%s (%s)\n", in pnp_add_device()
231 dev->protocol->name, buf, in pnp_add_device()
232 dev->active ? "active" : "disabled"); in pnp_add_device()
239 device_unregister(&dev->dev); in __pnp_remove_device()