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

1 // SPDX-License-Identifier: GPL-2.0-or-later
18 * rio_match_device - Tell if a RIO device has a matching RIO device id structure
19 * @id: the RIO device id structure to match against
20 * @rdev: the RIO device structure to match against
22 * Used from driver probe and bus matching to check whether a RIO device
23 * matches a device id structure provided by a RIO driver. Returns the
27 *id, in rio_match_device()
30 while (id->vid || id->asm_vid) { in rio_match_device()
31 if (((id->vid == RIO_ANY_ID) || (id->vid == rdev->vid)) && in rio_match_device()
32 ((id->did == RIO_ANY_ID) || (id->did == rdev->did)) && in rio_match_device()
33 ((id->asm_vid == RIO_ANY_ID) in rio_match_device()
34 || (id->asm_vid == rdev->asm_vid)) in rio_match_device()
35 && ((id->asm_did == RIO_ANY_ID) in rio_match_device()
36 || (id->asm_did == rdev->asm_did))) in rio_match_device()
37 return id; in rio_match_device()
38 id++; in rio_match_device()
44 * rio_dev_get - Increments the reference count of the RIO device structure
46 * @rdev: RIO device being referenced
48 * Each live reference to a device should be refcounted.
51 * their probe() methods, when they bind to a device, and release
57 get_device(&rdev->dev); in rio_dev_get()
63 * rio_dev_put - Release a use of the RIO device structure
65 * @rdev: RIO device being disconnected
67 * Must be called when a user of a device is finished with it.
68 * When the last user of the device calls this function, the
69 * memory of the device is freed.
74 put_device(&rdev->dev); in rio_dev_put()
78 * rio_device_probe - Tell if a RIO device structure has a matching RIO device id structure
79 * @dev: the RIO device structure to match against
81 * return 0 and set rio_dev->driver when drv claims rio_dev, else error
83 static int rio_device_probe(struct device *dev) in rio_device_probe()
85 struct rio_driver *rdrv = to_rio_driver(dev->driver); in rio_device_probe()
87 int error = -ENODEV; in rio_device_probe()
88 const struct rio_device_id *id; in rio_device_probe() local
90 if (!rdev->driver && rdrv->probe) { in rio_device_probe()
91 if (!rdrv->id_table) in rio_device_probe()
93 id = rio_match_device(rdrv->id_table, rdev); in rio_device_probe()
95 if (id) in rio_device_probe()
96 error = rdrv->probe(rdev, id); in rio_device_probe()
98 rdev->driver = rdrv; in rio_device_probe()
107 * rio_device_remove - Remove a RIO device from the system
109 * @dev: the RIO device structure to match against
111 * Remove a RIO device from the system. If it has an associated
115 static int rio_device_remove(struct device *dev) in rio_device_remove()
118 struct rio_driver *rdrv = rdev->driver; in rio_device_remove()
121 if (rdrv->remove) in rio_device_remove()
122 rdrv->remove(rdev); in rio_device_remove()
123 rdev->driver = NULL; in rio_device_remove()
131 static void rio_device_shutdown(struct device *dev) in rio_device_shutdown()
134 struct rio_driver *rdrv = rdev->driver; in rio_device_shutdown()
138 if (rdrv && rdrv->shutdown) in rio_device_shutdown()
139 rdrv->shutdown(rdev); in rio_device_shutdown()
143 * rio_register_driver - register a new RIO driver
148 * occurred, the driver remains registered even if no device
154 rdrv->driver.name = rdrv->name; in rio_register_driver()
155 rdrv->driver.bus = &rio_bus_type; in rio_register_driver()
158 return driver_register(&rdrv->driver); in rio_register_driver()
162 * rio_unregister_driver - unregister a RIO driver
167 * function for each device it was responsible for, and marks those
172 driver_unregister(&rdrv->driver); in rio_unregister_driver()
177 rdev->dev.bus = &rio_bus_type; in rio_attach_device()
182 * rio_match_bus - Tell if a RIO device structure has a matching RIO driver device id structure
183 * @dev: the standard device structure to match against
186 * Used by a driver to check whether a RIO device present in the
191 static int rio_match_bus(struct device *dev, struct device_driver *drv) in rio_match_bus()
195 const struct rio_device_id *id = rdrv->id_table; in rio_match_bus() local
198 if (!id) in rio_match_bus()
201 found_id = rio_match_device(id, rdev); in rio_match_bus()
209 static int rio_uevent(struct device *dev, struct kobj_uevent_env *env) in rio_uevent()
214 return -ENODEV; in rio_uevent()
218 return -ENODEV; in rio_uevent()
221 rdev->vid, rdev->did, rdev->asm_vid, rdev->asm_did)) in rio_uevent()
222 return -ENOMEM; in rio_uevent()
245 * rio_bus_init - Register the RapidIO bus with the device model
247 * Registers the RIO mport device class and RIO bus type with the Linux
248 * device model.