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.
34 static void pnp_remove_protocol(struct pnp_protocol *protocol) in pnp_remove_protocol() argument
37 list_del(&protocol->protocol_list); in pnp_remove_protocol()
42 * pnp_register_protocol - adds a pnp protocol to the pnp layer
43 * @protocol: pointer to the corresponding pnp_protocol structure
47 int pnp_register_protocol(struct pnp_protocol *protocol) in pnp_register_protocol() argument
52 INIT_LIST_HEAD(&protocol->devices); in pnp_register_protocol()
53 INIT_LIST_HEAD(&protocol->cards); in pnp_register_protocol()
61 if (cur->number == nodenum) { in pnp_register_protocol()
67 protocol->number = nodenum; in pnp_register_protocol()
68 dev_set_name(&protocol->dev, "pnp%d", nodenum); in pnp_register_protocol()
70 list_add_tail(&protocol->protocol_list, &pnp_protocols); in pnp_register_protocol()
74 ret = device_register(&protocol->dev); in pnp_register_protocol()
76 pnp_remove_protocol(protocol); in pnp_register_protocol()
82 * pnp_unregister_protocol - removes a pnp protocol from the pnp layer
83 * @protocol: pointer to the corresponding pnp_protocol structure
85 void pnp_unregister_protocol(struct pnp_protocol *protocol) in pnp_unregister_protocol() argument
87 pnp_remove_protocol(protocol); in pnp_unregister_protocol()
88 device_unregister(&protocol->dev); in pnp_unregister_protocol()
93 struct pnp_id *id; in pnp_free_ids() local
96 id = dev->id; in pnp_free_ids()
97 while (id) { in pnp_free_ids()
98 next = id->next; in pnp_free_ids()
99 kfree(id); in pnp_free_ids()
100 id = next; in pnp_free_ids()
106 list_del(&pnp_res->list); in pnp_free_resource()
114 list_for_each_entry_safe(pnp_res, tmp, &dev->resources, list) { in pnp_free_resources()
129 struct pnp_dev *pnp_alloc_dev(struct pnp_protocol *protocol, int id, in pnp_alloc_dev() argument
139 INIT_LIST_HEAD(&dev->resources); in pnp_alloc_dev()
140 INIT_LIST_HEAD(&dev->options); in pnp_alloc_dev()
141 dev->protocol = protocol; in pnp_alloc_dev()
142 dev->number = id; in pnp_alloc_dev()
143 dev->dma_mask = DMA_BIT_MASK(24); in pnp_alloc_dev()
145 dev->dev.parent = &dev->protocol->dev; in pnp_alloc_dev()
146 dev->dev.bus = &pnp_bus_type; in pnp_alloc_dev()
147 dev->dev.dma_mask = &dev->dma_mask; in pnp_alloc_dev()
148 dev->dev.coherent_dma_mask = dev->dma_mask; in pnp_alloc_dev()
149 dev->dev.release = &pnp_release_device; in pnp_alloc_dev()
151 dev_set_name(&dev->dev, "%02x:%02x", dev->protocol->number, dev->number); in pnp_alloc_dev()
165 list_del(&dev->global_list); in pnp_delist_device()
166 list_del(&dev->protocol_list); in pnp_delist_device()
175 dev->status = PNP_READY; in __pnp_add_device()
179 list_add_tail(&dev->global_list, &pnp_global); in __pnp_add_device()
180 list_add_tail(&dev->protocol_list, &dev->protocol->devices); in __pnp_add_device()
184 ret = device_register(&dev->dev); in __pnp_add_device()
187 else if (dev->protocol->can_wakeup) in __pnp_add_device()
188 device_set_wakeup_capable(&dev->dev, in __pnp_add_device()
189 dev->protocol->can_wakeup(dev)); in __pnp_add_device()
195 * pnp_add_device - adds a pnp device to the pnp layer
205 struct pnp_id *id; in pnp_add_device() local
207 if (dev->card) in pnp_add_device()
208 return -EINVAL; in pnp_add_device()
215 for (id = dev->id; id; id = id->next) in pnp_add_device()
216 len += scnprintf(buf + len, sizeof(buf) - len, " %s", id->id); in pnp_add_device()
218 dev_dbg(&dev->dev, "%s device, IDs%s (%s)\n", dev->protocol->name, buf, in pnp_add_device()
219 dev->active ? "active" : "disabled"); in pnp_add_device()
226 device_unregister(&dev->dev); in __pnp_remove_device()