Lines Matching +full:re +full:- +full:initialization
1 // SPDX-License-Identifier: GPL-2.0+
7 * (hot-)removal.
9 * Copyright (C) 2020-2022 Maximilian Luz <luzmaximilian@gmail.com>
21 /* -- SSAM generic subsystem hub driver framework. -------------------------- */
24 SSAM_HUB_UNINITIALIZED, /* Only set during initialization. */
73 status = hub->ops.get_state(hub, &state); in ssam_hub_update_workfn()
78 * There is a small possibility that hub devices were hot-removed and in ssam_hub_update_workfn()
79 * re-added before we were able to remove them here. In that case, both in ssam_hub_update_workfn()
82 * leave child devices without proper (re-)initialization and the in ssam_hub_update_workfn()
83 * hot-remove flag set. in ssam_hub_update_workfn()
85 * Therefore, we check whether devices have been hot-removed via an in ssam_hub_update_workfn()
88 * "connected"), we further need to re-schedule this work (with the in ssam_hub_update_workfn()
97 if (test_and_clear_bit(SSAM_HUB_HOT_REMOVED, &hub->flags)) { in ssam_hub_update_workfn()
99 schedule_delayed_work(&hub->update_work, hub->connect_delay); in ssam_hub_update_workfn()
104 if (hub->state == state) in ssam_hub_update_workfn()
106 hub->state = state; in ssam_hub_update_workfn()
108 if (hub->state == SSAM_HUB_CONNECTED) in ssam_hub_update_workfn()
109 status = ssam_device_register_clients(hub->sdev); in ssam_hub_update_workfn()
111 ssam_remove_clients(&hub->sdev->dev); in ssam_hub_update_workfn()
114 dev_err(&hub->sdev->dev, "failed to update hub child devices: %d\n", status); in ssam_hub_update_workfn()
131 /* Mark devices as hot-removed before we remove any. */ in ssam_hub_update()
133 set_bit(SSAM_HUB_HOT_REMOVED, &hub->flags); in ssam_hub_update()
134 device_for_each_child_reverse(&hub->sdev->dev, NULL, ssam_hub_mark_hot_removed); in ssam_hub_update()
141 delay = connected ? hub->connect_delay : 0; in ssam_hub_update()
143 schedule_delayed_work(&hub->update_work, delay); in ssam_hub_update()
150 schedule_delayed_work(&hub->update_work, 0); in ssam_hub_resume()
164 return -EINVAL; in ssam_hub_probe()
167 hub = devm_kzalloc(&sdev->dev, sizeof(*hub), GFP_KERNEL); in ssam_hub_probe()
169 return -ENOMEM; in ssam_hub_probe()
171 hub->sdev = sdev; in ssam_hub_probe()
172 hub->state = SSAM_HUB_UNINITIALIZED; in ssam_hub_probe()
174 hub->notif.base.priority = INT_MAX; /* This notifier should run first. */ in ssam_hub_probe()
175 hub->notif.base.fn = desc->ops.notify; in ssam_hub_probe()
176 hub->notif.event.reg = desc->event.reg; in ssam_hub_probe()
177 hub->notif.event.id = desc->event.id; in ssam_hub_probe()
178 hub->notif.event.mask = desc->event.mask; in ssam_hub_probe()
179 hub->notif.event.flags = SSAM_EVENT_SEQUENCED; in ssam_hub_probe()
181 hub->connect_delay = msecs_to_jiffies(desc->connect_delay_ms); in ssam_hub_probe()
182 hub->ops.get_state = desc->ops.get_state; in ssam_hub_probe()
184 INIT_DELAYED_WORK(&hub->update_work, ssam_hub_update_workfn); in ssam_hub_probe()
188 status = ssam_device_notifier_register(sdev, &hub->notif); in ssam_hub_probe()
192 schedule_delayed_work(&hub->update_work, 0); in ssam_hub_probe()
200 ssam_device_notifier_unregister(sdev, &hub->notif); in ssam_hub_remove()
201 cancel_delayed_work_sync(&hub->update_work); in ssam_hub_remove()
202 ssam_remove_clients(&sdev->dev); in ssam_hub_remove()
206 /* -- SSAM base-subsystem hub driver. --------------------------------------- */
210 * after being (re-)connected. This delay has been determined via
230 status = ssam_retry(ssam_bas_query_opmode, hub->sdev->ctrl, &opmode); in ssam_base_hub_query_state()
232 dev_err(&hub->sdev->dev, "failed to query base state: %d\n", status); in ssam_base_hub_query_state()
248 if (event->command_id != SSAM_EVENT_BAS_CID_CONNECTION) in ssam_base_hub_notif()
251 if (event->length < 1) { in ssam_base_hub_notif()
252 dev_err(&hub->sdev->dev, "unexpected payload size: %u\n", event->length); in ssam_base_hub_notif()
256 ssam_hub_update(hub, event->data[0]); in ssam_base_hub_notif()
260 * consumed by the detachment system driver. We're just a (more or less) in ssam_base_hub_notif()
283 /* -- SSAM KIP-subsystem hub driver. ---------------------------------------- */
287 * (re-)connected. This delay has been determined via experimentation.
305 status = ssam_retry(__ssam_kip_query_state, hub->sdev->ctrl, &connected); in ssam_kip_hub_query_state()
307 dev_err(&hub->sdev->dev, "failed to query KIP connection state: %d\n", status); in ssam_kip_hub_query_state()
319 if (event->command_id != SSAM_EVENT_KIP_CID_CONNECTION) in ssam_kip_hub_notif()
322 if (event->length < 1) { in ssam_kip_hub_notif()
323 dev_err(&hub->sdev->dev, "unexpected payload size: %u\n", event->length); in ssam_kip_hub_notif()
327 ssam_hub_update(hub, event->data[0]); in ssam_kip_hub_notif()
348 /* -- Driver registration. -------------------------------------------------- */