Lines Matching +full:device +full:- +full:id

1 // SPDX-License-Identifier: GPL-2.0
6 #include <linux/device.h>
11 #include <linux/dma-mapping.h>
14 static struct device isa_bus = {
19 struct device dev;
20 struct device *next;
21 unsigned int id; member
26 static int isa_bus_match(struct device *dev, struct device_driver *driver) in isa_bus_match()
30 if (dev->platform_data == isa_driver) { in isa_bus_match()
31 if (!isa_driver->match || in isa_bus_match()
32 isa_driver->match(dev, to_isa_dev(dev)->id)) in isa_bus_match()
34 dev->platform_data = NULL; in isa_bus_match()
39 static int isa_bus_probe(struct device *dev) in isa_bus_probe()
41 struct isa_driver *isa_driver = dev->platform_data; in isa_bus_probe()
43 if (isa_driver && isa_driver->probe) in isa_bus_probe()
44 return isa_driver->probe(dev, to_isa_dev(dev)->id); in isa_bus_probe()
49 static int isa_bus_remove(struct device *dev) in isa_bus_remove()
51 struct isa_driver *isa_driver = dev->platform_data; in isa_bus_remove()
53 if (isa_driver && isa_driver->remove) in isa_bus_remove()
54 return isa_driver->remove(dev, to_isa_dev(dev)->id); in isa_bus_remove()
59 static void isa_bus_shutdown(struct device *dev) in isa_bus_shutdown()
61 struct isa_driver *isa_driver = dev->platform_data; in isa_bus_shutdown()
63 if (isa_driver && isa_driver->shutdown) in isa_bus_shutdown()
64 isa_driver->shutdown(dev, to_isa_dev(dev)->id); in isa_bus_shutdown()
67 static int isa_bus_suspend(struct device *dev, pm_message_t state) in isa_bus_suspend()
69 struct isa_driver *isa_driver = dev->platform_data; in isa_bus_suspend()
71 if (isa_driver && isa_driver->suspend) in isa_bus_suspend()
72 return isa_driver->suspend(dev, to_isa_dev(dev)->id, state); in isa_bus_suspend()
77 static int isa_bus_resume(struct device *dev) in isa_bus_resume()
79 struct isa_driver *isa_driver = dev->platform_data; in isa_bus_resume()
81 if (isa_driver && isa_driver->resume) in isa_bus_resume()
82 return isa_driver->resume(dev, to_isa_dev(dev)->id); in isa_bus_resume()
97 static void isa_dev_release(struct device *dev) in isa_dev_release()
104 struct device *dev = isa_driver->devices; in isa_unregister_driver()
107 struct device *tmp = to_isa_dev(dev)->next; in isa_unregister_driver()
111 driver_unregister(&isa_driver->driver); in isa_unregister_driver()
118 unsigned int id; in isa_register_driver() local
120 isa_driver->driver.bus = &isa_bus_type; in isa_register_driver()
121 isa_driver->devices = NULL; in isa_register_driver()
123 error = driver_register(&isa_driver->driver); in isa_register_driver()
127 for (id = 0; id < ndev; id++) { in isa_register_driver()
132 error = -ENOMEM; in isa_register_driver()
136 isa_dev->dev.parent = &isa_bus; in isa_register_driver()
137 isa_dev->dev.bus = &isa_bus_type; in isa_register_driver()
139 dev_set_name(&isa_dev->dev, "%s.%u", in isa_register_driver()
140 isa_driver->driver.name, id); in isa_register_driver()
141 isa_dev->dev.platform_data = isa_driver; in isa_register_driver()
142 isa_dev->dev.release = isa_dev_release; in isa_register_driver()
143 isa_dev->id = id; in isa_register_driver()
145 isa_dev->dev.coherent_dma_mask = DMA_BIT_MASK(24); in isa_register_driver()
146 isa_dev->dev.dma_mask = &isa_dev->dev.coherent_dma_mask; in isa_register_driver()
148 error = device_register(&isa_dev->dev); in isa_register_driver()
150 put_device(&isa_dev->dev); in isa_register_driver()
154 if (isa_dev->dev.platform_data) { in isa_register_driver()
155 isa_dev->next = isa_driver->devices; in isa_register_driver()
156 isa_driver->devices = &isa_dev->dev; in isa_register_driver()
158 device_unregister(&isa_dev->dev); in isa_register_driver()
161 if (!error && !isa_driver->devices) in isa_register_driver()
162 error = -ENODEV; in isa_register_driver()