Lines Matching +full:drv +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()
44 static const struct pnp_device_id *match_device(const struct pnp_driver *drv, in match_device() argument
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()
76 if (pnp_dev->status == PNP_ATTACHED) in pnp_device_detach()
77 pnp_dev->status = PNP_READY; in pnp_device_detach()
89 pnp_drv = to_pnp_driver(dev->driver); in pnp_device_probe()
95 if (pnp_dev->active == 0) { in pnp_device_probe()
96 if (!(pnp_drv->flags & PNP_DRIVER_RES_DO_NOT_CHANGE)) { in pnp_device_probe()
101 } else if ((pnp_drv->flags & PNP_DRIVER_RES_DISABLE) in pnp_device_probe()
108 if (pnp_drv->probe) { in pnp_device_probe()
111 error = pnp_drv->probe(pnp_dev, dev_id); in pnp_device_probe()
114 pnp_dev->driver = pnp_drv; in pnp_device_probe()
129 struct pnp_driver *drv = pnp_dev->driver; in pnp_device_remove() local
131 if (drv) { in pnp_device_remove()
132 if (drv->remove) in pnp_device_remove()
133 drv->remove(pnp_dev); in pnp_device_remove()
134 pnp_dev->driver = NULL; in pnp_device_remove()
137 if (pnp_dev->active && in pnp_device_remove()
138 (!drv || !(drv->flags & PNP_DRIVER_RES_DO_NOT_CHANGE))) in pnp_device_remove()
147 struct pnp_driver *drv = pnp_dev->driver; in pnp_device_shutdown() local
149 if (drv && drv->shutdown) in pnp_device_shutdown()
150 drv->shutdown(pnp_dev); in pnp_device_shutdown()
153 static int pnp_bus_match(struct device *dev, const struct device_driver *drv) in pnp_bus_match() argument
156 const struct pnp_driver *pnp_drv = to_pnp_driver(drv); in pnp_bus_match()
166 struct pnp_driver *pnp_drv = pnp_dev->driver; in __pnp_bus_suspend()
172 if (pnp_drv->driver.pm && pnp_drv->driver.pm->suspend) { in __pnp_bus_suspend()
173 error = pnp_drv->driver.pm->suspend(dev); in __pnp_bus_suspend()
174 suspend_report_result(dev, pnp_drv->driver.pm->suspend, error); in __pnp_bus_suspend()
179 if (pnp_drv->suspend) { in __pnp_bus_suspend()
180 error = pnp_drv->suspend(pnp_dev, state); in __pnp_bus_suspend()
185 /* can_write is necessary to be able to re-start the device on resume */ in __pnp_bus_suspend()
193 pnp_dev->protocol->suspend(pnp_dev, state); in __pnp_bus_suspend()
215 struct pnp_driver *pnp_drv = pnp_dev->driver; in pnp_bus_resume()
221 if (pnp_dev->protocol->resume) { in pnp_bus_resume()
222 error = pnp_dev->protocol->resume(pnp_dev); in pnp_bus_resume()
233 if (pnp_drv->driver.pm && pnp_drv->driver.pm->resume) { in pnp_bus_resume()
234 error = pnp_drv->driver.pm->resume(dev); in pnp_bus_resume()
239 if (pnp_drv->resume) { in pnp_bus_resume()
240 error = pnp_drv->resume(pnp_dev); in pnp_bus_resume()
271 return dev->bus == &pnp_bus_type; in dev_is_pnp()
275 int pnp_register_driver(struct pnp_driver *drv) in pnp_register_driver() argument
277 drv->driver.name = drv->name; in pnp_register_driver()
278 drv->driver.bus = &pnp_bus_type; in pnp_register_driver()
280 return driver_register(&drv->driver); in pnp_register_driver()
284 void pnp_unregister_driver(struct pnp_driver *drv) in pnp_unregister_driver() argument
286 driver_unregister(&drv->driver); in pnp_unregister_driver()
291 * pnp_add_id - adds an EISA id to the specified device
293 * @id: pointer to an EISA id string
295 struct pnp_id *pnp_add_id(struct pnp_dev *dev, const char *id) in pnp_add_id() argument
303 dev_id->id[0] = id[0]; in pnp_add_id()
304 dev_id->id[1] = id[1]; in pnp_add_id()
305 dev_id->id[2] = id[2]; in pnp_add_id()
306 dev_id->id[3] = tolower(id[3]); in pnp_add_id()
307 dev_id->id[4] = tolower(id[4]); in pnp_add_id()
308 dev_id->id[5] = tolower(id[5]); in pnp_add_id()
309 dev_id->id[6] = tolower(id[6]); in pnp_add_id()
310 dev_id->id[7] = '\0'; in pnp_add_id()
312 dev_id->next = NULL; in pnp_add_id()
313 ptr = dev->id; in pnp_add_id()
314 while (ptr && ptr->next) in pnp_add_id()
315 ptr = ptr->next; in pnp_add_id()
317 ptr->next = dev_id; in pnp_add_id()
319 dev->id = dev_id; in pnp_add_id()