Lines Matching +full:device +full:- +full:id
1 // SPDX-License-Identifier: GPL-2.0
3 * driver.c - device id matching, driver model, etc.
29 int compare_pnp_id(struct pnp_id *pos, const char *id) in compare_pnp_id() argument
31 if (!pos || !id || (strlen(id) != 7)) in compare_pnp_id()
33 if (memcmp(id, "ANYDEVS", 7) == 0) in compare_pnp_id()
36 if (memcmp(pos->id, id, 3) == 0) in compare_pnp_id()
37 if (compare_func(pos->id, id) == 1) in compare_pnp_id()
39 pos = pos->next; in compare_pnp_id()
47 const struct pnp_device_id *drv_id = drv->id_table; in match_device()
52 while (*drv_id->id) { in match_device()
53 if (compare_pnp_id(dev->id, drv_id->id)) in match_device()
63 if (pnp_dev->status != PNP_READY) { in pnp_device_attach()
65 return -EBUSY; in pnp_device_attach()
67 pnp_dev->status = PNP_ATTACHED; in pnp_device_attach()
75 if (pnp_dev->status == PNP_ATTACHED) in pnp_device_detach()
76 pnp_dev->status = PNP_READY; in pnp_device_detach()
80 static int pnp_device_probe(struct device *dev) in pnp_device_probe()
87 pnp_drv = to_pnp_driver(dev->driver); in pnp_device_probe()
93 if (pnp_dev->active == 0) { in pnp_device_probe()
94 if (!(pnp_drv->flags & PNP_DRIVER_RES_DO_NOT_CHANGE)) { in pnp_device_probe()
99 } else if ((pnp_drv->flags & PNP_DRIVER_RES_DISABLE) in pnp_device_probe()
106 if (pnp_drv->probe) { in pnp_device_probe()
109 error = pnp_drv->probe(pnp_dev, dev_id); in pnp_device_probe()
112 pnp_dev->driver = pnp_drv; in pnp_device_probe()
124 static int pnp_device_remove(struct device *dev) in pnp_device_remove()
127 struct pnp_driver *drv = pnp_dev->driver; in pnp_device_remove()
130 if (drv->remove) in pnp_device_remove()
131 drv->remove(pnp_dev); in pnp_device_remove()
132 pnp_dev->driver = NULL; in pnp_device_remove()
135 if (pnp_dev->active && in pnp_device_remove()
136 (!drv || !(drv->flags & PNP_DRIVER_RES_DO_NOT_CHANGE))) in pnp_device_remove()
143 static void pnp_device_shutdown(struct device *dev) in pnp_device_shutdown()
146 struct pnp_driver *drv = pnp_dev->driver; in pnp_device_shutdown()
148 if (drv && drv->shutdown) in pnp_device_shutdown()
149 drv->shutdown(pnp_dev); in pnp_device_shutdown()
152 static int pnp_bus_match(struct device *dev, struct device_driver *drv) in pnp_bus_match()
162 static int __pnp_bus_suspend(struct device *dev, pm_message_t state) in __pnp_bus_suspend()
165 struct pnp_driver *pnp_drv = pnp_dev->driver; in __pnp_bus_suspend()
171 if (pnp_drv->driver.pm && pnp_drv->driver.pm->suspend) { in __pnp_bus_suspend()
172 error = pnp_drv->driver.pm->suspend(dev); in __pnp_bus_suspend()
173 suspend_report_result(pnp_drv->driver.pm->suspend, error); in __pnp_bus_suspend()
178 if (pnp_drv->suspend) { in __pnp_bus_suspend()
179 error = pnp_drv->suspend(pnp_dev, state); in __pnp_bus_suspend()
191 pnp_dev->protocol->suspend(pnp_dev, state); in __pnp_bus_suspend()
195 static int pnp_bus_suspend(struct device *dev) in pnp_bus_suspend()
200 static int pnp_bus_freeze(struct device *dev) in pnp_bus_freeze()
205 static int pnp_bus_poweroff(struct device *dev) in pnp_bus_poweroff()
210 static int pnp_bus_resume(struct device *dev) in pnp_bus_resume()
213 struct pnp_driver *pnp_drv = pnp_dev->driver; in pnp_bus_resume()
219 if (pnp_dev->protocol->resume) { in pnp_bus_resume()
220 error = pnp_dev->protocol->resume(pnp_dev); in pnp_bus_resume()
231 if (pnp_drv->driver.pm && pnp_drv->driver.pm->resume) { in pnp_bus_resume()
232 error = pnp_drv->driver.pm->resume(dev); in pnp_bus_resume()
237 if (pnp_drv->resume) { in pnp_bus_resume()
238 error = pnp_drv->resume(pnp_dev); in pnp_bus_resume()
269 drv->driver.name = drv->name; in pnp_register_driver()
270 drv->driver.bus = &pnp_bus_type; in pnp_register_driver()
272 return driver_register(&drv->driver); in pnp_register_driver()
277 driver_unregister(&drv->driver); in pnp_unregister_driver()
281 * pnp_add_id - adds an EISA id to the specified device
282 * @dev: pointer to the desired device
283 * @id: pointer to an EISA id string
285 struct pnp_id *pnp_add_id(struct pnp_dev *dev, const char *id) in pnp_add_id() argument
293 dev_id->id[0] = id[0]; in pnp_add_id()
294 dev_id->id[1] = id[1]; in pnp_add_id()
295 dev_id->id[2] = id[2]; in pnp_add_id()
296 dev_id->id[3] = tolower(id[3]); in pnp_add_id()
297 dev_id->id[4] = tolower(id[4]); in pnp_add_id()
298 dev_id->id[5] = tolower(id[5]); in pnp_add_id()
299 dev_id->id[6] = tolower(id[6]); in pnp_add_id()
300 dev_id->id[7] = '\0'; in pnp_add_id()
302 dev_id->next = NULL; in pnp_add_id()
303 ptr = dev->id; in pnp_add_id()
304 while (ptr && ptr->next) in pnp_add_id()
305 ptr = ptr->next; in pnp_add_id()
307 ptr->next = dev_id; in pnp_add_id()
309 dev->id = dev_id; in pnp_add_id()