Lines Matching +full:drv +full:- +full:id

1 // SPDX-License-Identifier: GPL-2.0-only
3 * tifm_core.c - TI FlashMedia driver
31 return card_type_name[nt][type - 1]; in tifm_media_type_name()
34 static int tifm_dev_match(struct tifm_dev *sock, struct tifm_device_id *id) in tifm_dev_match() argument
36 if (sock->type == id->type) in tifm_dev_match()
41 static int tifm_bus_match(struct device *dev, const struct device_driver *drv) in tifm_bus_match() argument
44 const struct tifm_driver *fm_drv = container_of_const(drv, struct tifm_driver, in tifm_bus_match()
46 struct tifm_device_id *ids = fm_drv->id_table; in tifm_bus_match()
49 while (ids->type) { in tifm_bus_match()
62 if (add_uevent_var(env, "TIFM_CARD_TYPE=%s", tifm_media_type_name(sock->type, 1))) in tifm_uevent()
63 return -ENOMEM; in tifm_uevent()
71 struct tifm_driver *drv = container_of(dev->driver, struct tifm_driver, in tifm_device_probe() local
73 int rc = -ENODEV; in tifm_device_probe()
76 if (dev->driver && drv->probe) { in tifm_device_probe()
77 rc = drv->probe(sock); in tifm_device_probe()
93 struct tifm_driver *drv = container_of(dev->driver, struct tifm_driver, in tifm_device_remove() local
96 if (dev->driver && drv->remove) { in tifm_device_remove()
97 sock->card_event = tifm_dummy_event; in tifm_device_remove()
98 sock->data_event = tifm_dummy_event; in tifm_device_remove()
99 drv->remove(sock); in tifm_device_remove()
100 sock->dev.driver = NULL; in tifm_device_remove()
111 struct tifm_driver *drv = container_of(dev->driver, struct tifm_driver, in tifm_device_suspend() local
114 if (dev->driver && drv->suspend) in tifm_device_suspend()
115 return drv->suspend(sock, state); in tifm_device_suspend()
122 struct tifm_driver *drv = container_of(dev->driver, struct tifm_driver, in tifm_device_resume() local
125 if (dev->driver && drv->resume) in tifm_device_resume()
126 return drv->resume(sock); in tifm_device_resume()
141 return sprintf(buf, "%x", sock->type); in type_show()
181 fm->dev.class = &tifm_adapter_class; in tifm_alloc_adapter()
182 fm->dev.parent = dev; in tifm_alloc_adapter()
183 device_initialize(&fm->dev); in tifm_alloc_adapter()
184 spin_lock_init(&fm->lock); in tifm_alloc_adapter()
185 fm->num_sockets = num_sockets; in tifm_alloc_adapter()
199 fm->id = rc; in tifm_add_adapter()
205 dev_set_name(&fm->dev, "tifm%u", fm->id); in tifm_add_adapter()
206 rc = device_add(&fm->dev); in tifm_add_adapter()
209 idr_remove(&tifm_adapter_idr, fm->id); in tifm_add_adapter()
222 for (cnt = 0; cnt < fm->num_sockets; ++cnt) { in tifm_remove_adapter()
223 if (fm->sockets[cnt]) in tifm_remove_adapter()
224 device_unregister(&fm->sockets[cnt]->dev); in tifm_remove_adapter()
228 idr_remove(&tifm_adapter_idr, fm->id); in tifm_remove_adapter()
230 device_del(&fm->dev); in tifm_remove_adapter()
236 put_device(&fm->dev); in tifm_free_adapter()
247 struct tifm_dev *tifm_alloc_device(struct tifm_adapter *fm, unsigned int id, in tifm_alloc_device() argument
257 spin_lock_init(&sock->lock); in tifm_alloc_device()
258 sock->type = type; in tifm_alloc_device()
259 sock->socket_id = id; in tifm_alloc_device()
260 sock->card_event = tifm_dummy_event; in tifm_alloc_device()
261 sock->data_event = tifm_dummy_event; in tifm_alloc_device()
263 sock->dev.parent = fm->dev.parent; in tifm_alloc_device()
264 sock->dev.bus = &tifm_bus_type; in tifm_alloc_device()
265 sock->dev.dma_mask = fm->dev.parent->dma_mask; in tifm_alloc_device()
266 sock->dev.release = tifm_free_device; in tifm_alloc_device()
268 dev_set_name(&sock->dev, "tifm_%s%u:%u", in tifm_alloc_device()
269 tifm_media_type_name(type, 2), fm->id, id); in tifm_alloc_device()
272 tifm_media_type_name(type, 0), fm->id, id); in tifm_alloc_device()
280 struct tifm_adapter *fm = dev_get_drvdata(sock->dev.parent); in tifm_eject()
281 fm->eject(fm, sock); in tifm_eject()
287 struct tifm_adapter *fm = dev_get_drvdata(sock->dev.parent); in tifm_has_ms_pif()
288 return fm->has_ms_pif(fm, sock); in tifm_has_ms_pif()
295 return dma_map_sg(&to_pci_dev(sock->dev.parent)->dev, sg, nents, in tifm_map_sg()
303 dma_unmap_sg(&to_pci_dev(sock->dev.parent)->dev, sg, nents, direction); in tifm_unmap_sg()
313 int tifm_register_driver(struct tifm_driver *drv) in tifm_register_driver() argument
315 drv->driver.bus = &tifm_bus_type; in tifm_register_driver()
317 return driver_register(&drv->driver); in tifm_register_driver()
321 void tifm_unregister_driver(struct tifm_driver *drv) in tifm_unregister_driver() argument
323 driver_unregister(&drv->driver); in tifm_unregister_driver()
333 return -ENOMEM; in tifm_init()