Skip to content

Commit c11db11

Browse files
committed
registry: Remove base hub driver
The base hub was a virtual device hub for Surface System Aggregator Module (SSAM) client devices contained in the detachable Surface Book 3 base. Remove it as it is no longer needed. In the previous change, we have moved all devices from the base hub to the KIP hub. That change has also removed the only base-hub-device that ever existed, as it was essentially replaced by the KIP-hub-device and thus was no longer needed. This means that there is no remaining hub-device against which the base hub driver can load, i.e. it is now essentially dead code. So remove the driver as well. Signed-off-by: Maximilian Luz <[email protected]>
1 parent 44e223b commit c11db11

File tree

1 file changed

+0
-213
lines changed

1 file changed

+0
-213
lines changed

module/src/clients/surface_aggregator_registry.c

Lines changed: 0 additions & 213 deletions
Original file line numberDiff line numberDiff line change
@@ -325,212 +325,6 @@ static int ssam_hub_register_clients(struct device *parent, struct ssam_controll
325325
}
326326

327327

328-
/* -- SSAM base-hub driver. ------------------------------------------------- */
329-
330-
/*
331-
* Some devices (especially battery) may need a bit of time to be fully usable
332-
* after being (re-)connected. This delay has been determined via
333-
* experimentation.
334-
*/
335-
#define SSAM_BASE_UPDATE_CONNECT_DELAY msecs_to_jiffies(2500)
336-
337-
enum ssam_base_hub_state {
338-
SSAM_BASE_HUB_UNINITIALIZED,
339-
SSAM_BASE_HUB_CONNECTED,
340-
SSAM_BASE_HUB_DISCONNECTED,
341-
};
342-
343-
struct ssam_base_hub {
344-
struct ssam_device *sdev;
345-
346-
enum ssam_base_hub_state state;
347-
struct delayed_work update_work;
348-
349-
struct ssam_event_notifier notif;
350-
};
351-
352-
SSAM_DEFINE_SYNC_REQUEST_R(ssam_bas_query_opmode, u8, {
353-
.target_category = SSAM_SSH_TC_BAS,
354-
.target_id = 0x01,
355-
.command_id = 0x0d,
356-
.instance_id = 0x00,
357-
});
358-
359-
#define SSAM_BAS_OPMODE_TABLET 0x00
360-
#define SSAM_EVENT_BAS_CID_CONNECTION 0x0c
361-
362-
static int ssam_base_hub_query_state(struct ssam_base_hub *hub, enum ssam_base_hub_state *state)
363-
{
364-
u8 opmode;
365-
int status;
366-
367-
status = ssam_retry(ssam_bas_query_opmode, hub->sdev->ctrl, &opmode);
368-
if (status < 0) {
369-
dev_err(&hub->sdev->dev, "failed to query base state: %d\n", status);
370-
return status;
371-
}
372-
373-
if (opmode != SSAM_BAS_OPMODE_TABLET)
374-
*state = SSAM_BASE_HUB_CONNECTED;
375-
else
376-
*state = SSAM_BASE_HUB_DISCONNECTED;
377-
378-
return 0;
379-
}
380-
381-
static ssize_t ssam_base_hub_state_show(struct device *dev, struct device_attribute *attr,
382-
char *buf)
383-
{
384-
struct ssam_base_hub *hub = dev_get_drvdata(dev);
385-
bool connected = hub->state == SSAM_BASE_HUB_CONNECTED;
386-
387-
return sysfs_emit(buf, "%d\n", connected);
388-
}
389-
390-
static struct device_attribute ssam_base_hub_attr_state =
391-
__ATTR(state, 0444, ssam_base_hub_state_show, NULL);
392-
393-
static struct attribute *ssam_base_hub_attrs[] = {
394-
&ssam_base_hub_attr_state.attr,
395-
NULL,
396-
};
397-
398-
static const struct attribute_group ssam_base_hub_group = {
399-
.attrs = ssam_base_hub_attrs,
400-
};
401-
402-
static void ssam_base_hub_update_workfn(struct work_struct *work)
403-
{
404-
struct ssam_base_hub *hub = container_of(work, struct ssam_base_hub, update_work.work);
405-
struct fwnode_handle *node = dev_fwnode(&hub->sdev->dev);
406-
enum ssam_base_hub_state state;
407-
int status = 0;
408-
409-
status = ssam_base_hub_query_state(hub, &state);
410-
if (status)
411-
return;
412-
413-
if (hub->state == state)
414-
return;
415-
hub->state = state;
416-
417-
if (hub->state == SSAM_BASE_HUB_CONNECTED)
418-
status = ssam_hub_register_clients(&hub->sdev->dev, hub->sdev->ctrl, node);
419-
else
420-
ssam_remove_clients(&hub->sdev->dev);
421-
422-
if (status)
423-
dev_err(&hub->sdev->dev, "failed to update base-hub devices: %d\n", status);
424-
}
425-
426-
static u32 ssam_base_hub_notif(struct ssam_event_notifier *nf, const struct ssam_event *event)
427-
{
428-
struct ssam_base_hub *hub = container_of(nf, struct ssam_base_hub, notif);
429-
unsigned long delay;
430-
431-
if (event->command_id != SSAM_EVENT_BAS_CID_CONNECTION)
432-
return 0;
433-
434-
if (event->length < 1) {
435-
dev_err(&hub->sdev->dev, "unexpected payload size: %u\n", event->length);
436-
return 0;
437-
}
438-
439-
/*
440-
* Delay update when the base is being connected to give devices/EC
441-
* some time to set up.
442-
*/
443-
delay = event->data[0] ? SSAM_BASE_UPDATE_CONNECT_DELAY : 0;
444-
445-
schedule_delayed_work(&hub->update_work, delay);
446-
447-
/*
448-
* Do not return SSAM_NOTIF_HANDLED: The event should be picked up and
449-
* consumed by the detachment system driver. We're just a (more or less)
450-
* silent observer.
451-
*/
452-
return 0;
453-
}
454-
455-
static int __maybe_unused ssam_base_hub_resume(struct device *dev)
456-
{
457-
struct ssam_base_hub *hub = dev_get_drvdata(dev);
458-
459-
schedule_delayed_work(&hub->update_work, 0);
460-
return 0;
461-
}
462-
static SIMPLE_DEV_PM_OPS(ssam_base_hub_pm_ops, NULL, ssam_base_hub_resume);
463-
464-
static int ssam_base_hub_probe(struct ssam_device *sdev)
465-
{
466-
struct ssam_base_hub *hub;
467-
int status;
468-
469-
hub = devm_kzalloc(&sdev->dev, sizeof(*hub), GFP_KERNEL);
470-
if (!hub)
471-
return -ENOMEM;
472-
473-
hub->sdev = sdev;
474-
hub->state = SSAM_BASE_HUB_UNINITIALIZED;
475-
476-
hub->notif.base.priority = INT_MAX; /* This notifier should run first. */
477-
hub->notif.base.fn = ssam_base_hub_notif;
478-
hub->notif.event.reg = SSAM_EVENT_REGISTRY_SAM;
479-
hub->notif.event.id.target_category = SSAM_SSH_TC_BAS,
480-
hub->notif.event.id.instance = 0,
481-
hub->notif.event.mask = SSAM_EVENT_MASK_NONE;
482-
hub->notif.event.flags = SSAM_EVENT_SEQUENCED;
483-
484-
INIT_DELAYED_WORK(&hub->update_work, ssam_base_hub_update_workfn);
485-
486-
ssam_device_set_drvdata(sdev, hub);
487-
488-
status = ssam_device_notifier_register(sdev, &hub->notif);
489-
if (status)
490-
return status;
491-
492-
status = sysfs_create_group(&sdev->dev.kobj, &ssam_base_hub_group);
493-
if (status)
494-
goto err;
495-
496-
schedule_delayed_work(&hub->update_work, 0);
497-
return 0;
498-
499-
err:
500-
ssam_device_notifier_unregister(sdev, &hub->notif);
501-
cancel_delayed_work_sync(&hub->update_work);
502-
ssam_remove_clients(&sdev->dev);
503-
return status;
504-
}
505-
506-
static void ssam_base_hub_remove(struct ssam_device *sdev)
507-
{
508-
struct ssam_base_hub *hub = ssam_device_get_drvdata(sdev);
509-
510-
sysfs_remove_group(&sdev->dev.kobj, &ssam_base_hub_group);
511-
512-
ssam_device_notifier_unregister(sdev, &hub->notif);
513-
cancel_delayed_work_sync(&hub->update_work);
514-
ssam_remove_clients(&sdev->dev);
515-
}
516-
517-
static const struct ssam_device_id ssam_base_hub_match[] = {
518-
{ SSAM_VDEV(HUB, 0x02, SSAM_ANY_IID, 0x00) },
519-
{ },
520-
};
521-
522-
static struct ssam_device_driver ssam_base_hub_driver = {
523-
.probe = ssam_base_hub_probe,
524-
.remove = ssam_base_hub_remove,
525-
.match_table = ssam_base_hub_match,
526-
.driver = {
527-
.name = "surface_aggregator_base_hub",
528-
.probe_type = PROBE_PREFER_ASYNCHRONOUS,
529-
.pm = &ssam_base_hub_pm_ops,
530-
},
531-
};
532-
533-
534328
/* -- SSAM KIP-subsystem hub driver. ---------------------------------------- */
535329

536330
/*
@@ -872,19 +666,13 @@ static int __init ssam_device_hub_init(void)
872666
if (status)
873667
goto err_platform;
874668

875-
status = ssam_device_driver_register(&ssam_base_hub_driver);
876-
if (status)
877-
goto err_base;
878-
879669
status = ssam_device_driver_register(&ssam_kip_hub_driver);
880670
if (status)
881671
goto err_kip;
882672

883673
return 0;
884674

885675
err_kip:
886-
ssam_device_driver_unregister(&ssam_base_hub_driver);
887-
err_base:
888676
platform_driver_unregister(&ssam_platform_hub_driver);
889677
err_platform:
890678
return status;
@@ -894,7 +682,6 @@ module_init(ssam_device_hub_init);
894682
static void __exit ssam_device_hub_exit(void)
895683
{
896684
ssam_device_driver_unregister(&ssam_kip_hub_driver);
897-
ssam_device_driver_unregister(&ssam_base_hub_driver);
898685
platform_driver_unregister(&ssam_platform_hub_driver);
899686
}
900687
module_exit(ssam_device_hub_exit);

0 commit comments

Comments
 (0)