Lines Matching +full:ctrl +full:- +full:module
1 // SPDX-License-Identifier: GPL-2.0+
3 * Surface System Aggregator Module bus and device integration.
5 * Copyright (C) 2019-2022 Maximilian Luz <luzmaximilian@gmail.com>
20 /* -- Device and bus functions. --------------------------------------------- */
28 sdev->uid.domain, sdev->uid.category, sdev->uid.target, in modalias_show()
29 sdev->uid.instance, sdev->uid.function); in modalias_show()
46 sdev->uid.domain, sdev->uid.category, in ssam_device_uevent()
47 sdev->uid.target, sdev->uid.instance, in ssam_device_uevent()
48 sdev->uid.function); in ssam_device_uevent()
55 ssam_controller_put(sdev->ctrl); in ssam_device_release()
56 fwnode_handle_put(sdev->dev.fwnode); in ssam_device_release()
69 * ssam_device_alloc() - Allocate and initialize a SSAM client device.
70 * @ctrl: The controller under which the device should be added.
81 struct ssam_device *ssam_device_alloc(struct ssam_controller *ctrl, in ssam_device_alloc() argument
90 device_initialize(&sdev->dev); in ssam_device_alloc()
91 sdev->dev.bus = &ssam_bus_type; in ssam_device_alloc()
92 sdev->dev.type = &ssam_device_type; in ssam_device_alloc()
93 sdev->dev.parent = ssam_controller_device(ctrl); in ssam_device_alloc()
94 sdev->ctrl = ssam_controller_get(ctrl); in ssam_device_alloc()
95 sdev->uid = uid; in ssam_device_alloc()
97 dev_set_name(&sdev->dev, "%02x:%02x:%02x:%02x:%02x", in ssam_device_alloc()
98 sdev->uid.domain, sdev->uid.category, sdev->uid.target, in ssam_device_alloc()
99 sdev->uid.instance, sdev->uid.function); in ssam_device_alloc()
106 * ssam_device_add() - Add a SSAM client device.
110 * controller. Thus, this function will fail with %-ENODEV if the controller
126 * set up device-links for this purpose.
138 * controller device, i.e. it ensures that the controller (sdev->ctrl) in ssam_device_add()
151 ssam_controller_statelock(sdev->ctrl); in ssam_device_add()
153 if (sdev->ctrl->state != SSAM_CONTROLLER_STARTED) { in ssam_device_add()
154 ssam_controller_stateunlock(sdev->ctrl); in ssam_device_add()
155 return -ENODEV; in ssam_device_add()
158 status = device_add(&sdev->dev); in ssam_device_add()
160 ssam_controller_stateunlock(sdev->ctrl); in ssam_device_add()
166 * ssam_device_remove() - Remove a SSAM client device.
173 device_unregister(&sdev->dev); in ssam_device_remove()
178 * ssam_device_id_compatible() - Check if a device ID matches a UID.
192 if (id->domain != uid.domain || id->category != uid.category) in ssam_device_id_compatible()
195 if ((id->match_flags & SSAM_MATCH_TARGET) && id->target != uid.target) in ssam_device_id_compatible()
198 if ((id->match_flags & SSAM_MATCH_INSTANCE) && id->instance != uid.instance) in ssam_device_id_compatible()
201 if ((id->match_flags & SSAM_MATCH_FUNCTION) && id->function != uid.function) in ssam_device_id_compatible()
208 * ssam_device_id_is_null() - Check if a device ID is null.
219 return id->match_flags == 0 && in ssam_device_id_is_null()
220 id->domain == 0 && in ssam_device_id_is_null()
221 id->category == 0 && in ssam_device_id_is_null()
222 id->target == 0 && in ssam_device_id_is_null()
223 id->instance == 0 && in ssam_device_id_is_null()
224 id->function == 0 && in ssam_device_id_is_null()
225 id->driver_data == 0; in ssam_device_id_is_null()
229 * ssam_device_id_match() - Find the matching ID table entry for the given UID.
250 * ssam_device_get_match() - Find and return the ID matching the device in the
269 sdrv = to_ssam_device_driver(dev->dev.driver); in ssam_device_get_match()
273 if (!sdrv->match_table) in ssam_device_get_match()
276 return ssam_device_id_match(sdrv->match_table, dev->uid); in ssam_device_get_match()
281 * ssam_device_get_match_data() - Find the ID matching the device in the
306 return (const void *)id->driver_data; in ssam_device_get_match_data()
318 return !!ssam_device_id_match(sdrv->match_table, sdev->uid); in ssam_bus_match()
323 return to_ssam_device_driver(dev->driver) in ssam_bus_probe()
324 ->probe(to_ssam_device(dev)); in ssam_bus_probe()
329 struct ssam_device_driver *sdrv = to_ssam_device_driver(dev->driver); in ssam_bus_remove()
331 if (sdrv->remove) in ssam_bus_remove()
332 sdrv->remove(to_ssam_device(dev)); in ssam_bus_remove()
343 * __ssam_device_driver_register() - Register a SSAM client device driver.
345 * @owner: The module owning the provided driver.
348 * to register a driver from inside its owning module.
351 struct module *owner) in __ssam_device_driver_register()
353 sdrv->driver.owner = owner; in __ssam_device_driver_register()
354 sdrv->driver.bus = &ssam_bus_type; in __ssam_device_driver_register()
357 sdrv->driver.probe_type = PROBE_PREFER_ASYNCHRONOUS; in __ssam_device_driver_register()
359 return driver_register(&sdrv->driver); in __ssam_device_driver_register()
364 * ssam_device_driver_unregister - Unregister a SSAM device driver.
369 driver_unregister(&sdrv->driver); in ssam_device_driver_unregister()
374 /* -- Bus registration. ----------------------------------------------------- */
377 * ssam_bus_register() - Register and set-up the SSAM client device bus.
385 * ssam_bus_unregister() - Unregister the SSAM client device bus.
393 /* -- Helpers for controller and hub devices. ------------------------------- */
402 return -EINVAL; in ssam_device_uid_from_string()
404 uid->domain = d; in ssam_device_uid_from_string()
405 uid->category = tc; in ssam_device_uid_from_string()
406 uid->target = tid; in ssam_device_uid_from_string()
407 uid->instance = iid; in ssam_device_uid_from_string()
408 uid->function = fn; in ssam_device_uid_from_string()
422 return -ENODEV; in ssam_get_uid_for_node()
428 static int ssam_add_client_device(struct device *parent, struct ssam_controller *ctrl, in ssam_add_client_device() argument
439 sdev = ssam_device_alloc(ctrl, uid); in ssam_add_client_device()
441 return -ENOMEM; in ssam_add_client_device()
443 sdev->dev.parent = parent; in ssam_add_client_device()
444 sdev->dev.fwnode = fwnode_handle_get(node); in ssam_add_client_device()
445 sdev->dev.of_node = to_of_node(node); in ssam_add_client_device()
455 * __ssam_register_clients() - Register client devices defined under the
458 * @ctrl: The controller with which client should be registered.
478 int __ssam_register_clients(struct device *parent, struct ssam_controller *ctrl, in __ssam_register_clients() argument
487 * this fails with -ENODEV, the node does not specify any SSAM in __ssam_register_clients()
490 status = ssam_add_client_device(parent, ctrl, child); in __ssam_register_clients()
491 if (status && status != -ENODEV) { in __ssam_register_clients()
515 * ssam_remove_clients() - Remove SSAM client devices registered as direct