Remove some duplicate code for Surface Aggregator client device removal and
rename a function for consistency.
Maximilian Luz (3):
platform/surface: aggregator: Make client device removal more generic
platform/surface: aggregator_registry: Use generic client removal
function
platform/surface: aggregator_registry: Rename device registration
function
drivers/platform/surface/aggregator/bus.c | 24 +++++---------
drivers/platform/surface/aggregator/bus.h | 3 --
drivers/platform/surface/aggregator/core.c | 3 +-
.../surface/surface_aggregator_registry.c | 32 ++++++-------------
include/linux/surface_aggregator/device.h | 9 ++++++
5 files changed, 28 insertions(+), 43 deletions(-)
--
2.33.1
Rename the device registration function to better align names with the
newly introduced device removal function.
Signed-off-by: Maximilian Luz <[email protected]>
---
drivers/platform/surface/surface_aggregator_registry.c | 8 ++++----
1 file changed, 4 insertions(+), 4 deletions(-)
diff --git a/drivers/platform/surface/surface_aggregator_registry.c b/drivers/platform/surface/surface_aggregator_registry.c
index d63f975bfd4c..2e0d3a808d47 100644
--- a/drivers/platform/surface/surface_aggregator_registry.c
+++ b/drivers/platform/surface/surface_aggregator_registry.c
@@ -274,8 +274,8 @@ static int ssam_hub_add_device(struct device *parent, struct ssam_controller *ct
return status;
}
-static int ssam_hub_add_devices(struct device *parent, struct ssam_controller *ctrl,
- struct fwnode_handle *node)
+static int ssam_hub_register_clients(struct device *parent, struct ssam_controller *ctrl,
+ struct fwnode_handle *node)
{
struct fwnode_handle *child;
int status;
@@ -389,7 +389,7 @@ static void ssam_base_hub_update_workfn(struct work_struct *work)
hub->state = state;
if (hub->state == SSAM_BASE_HUB_CONNECTED)
- status = ssam_hub_add_devices(&hub->sdev->dev, hub->sdev->ctrl, node);
+ status = ssam_hub_register_clients(&hub->sdev->dev, hub->sdev->ctrl, node);
else
ssam_remove_clients(&hub->sdev->dev);
@@ -585,7 +585,7 @@ static int ssam_platform_hub_probe(struct platform_device *pdev)
set_secondary_fwnode(&pdev->dev, root);
- status = ssam_hub_add_devices(&pdev->dev, ctrl, root);
+ status = ssam_hub_register_clients(&pdev->dev, ctrl, root);
if (status) {
set_secondary_fwnode(&pdev->dev, NULL);
software_node_unregister_node_group(nodes);
--
2.33.1
Use generic client removal function introduced in the previous commit
instead of defining our own one.
Signed-off-by: Maximilian Luz <[email protected]>
---
.../surface/surface_aggregator_registry.c | 24 ++++---------------
1 file changed, 5 insertions(+), 19 deletions(-)
diff --git a/drivers/platform/surface/surface_aggregator_registry.c b/drivers/platform/surface/surface_aggregator_registry.c
index 1679811eff50..d63f975bfd4c 100644
--- a/drivers/platform/surface/surface_aggregator_registry.c
+++ b/drivers/platform/surface/surface_aggregator_registry.c
@@ -249,20 +249,6 @@ static int ssam_uid_from_string(const char *str, struct ssam_device_uid *uid)
return 0;
}
-static int ssam_hub_remove_devices_fn(struct device *dev, void *data)
-{
- if (!is_ssam_device(dev))
- return 0;
-
- ssam_device_remove(to_ssam_device(dev));
- return 0;
-}
-
-static void ssam_hub_remove_devices(struct device *parent)
-{
- device_for_each_child_reverse(parent, NULL, ssam_hub_remove_devices_fn);
-}
-
static int ssam_hub_add_device(struct device *parent, struct ssam_controller *ctrl,
struct fwnode_handle *node)
{
@@ -308,7 +294,7 @@ static int ssam_hub_add_devices(struct device *parent, struct ssam_controller *c
return 0;
err:
- ssam_hub_remove_devices(parent);
+ ssam_remove_clients(parent);
return status;
}
@@ -405,7 +391,7 @@ static void ssam_base_hub_update_workfn(struct work_struct *work)
if (hub->state == SSAM_BASE_HUB_CONNECTED)
status = ssam_hub_add_devices(&hub->sdev->dev, hub->sdev->ctrl, node);
else
- ssam_hub_remove_devices(&hub->sdev->dev);
+ ssam_remove_clients(&hub->sdev->dev);
if (status)
dev_err(&hub->sdev->dev, "failed to update base-hub devices: %d\n", status);
@@ -487,7 +473,7 @@ static int ssam_base_hub_probe(struct ssam_device *sdev)
err:
ssam_notifier_unregister(sdev->ctrl, &hub->notif);
cancel_delayed_work_sync(&hub->update_work);
- ssam_hub_remove_devices(&sdev->dev);
+ ssam_remove_clients(&sdev->dev);
return status;
}
@@ -499,7 +485,7 @@ static void ssam_base_hub_remove(struct ssam_device *sdev)
ssam_notifier_unregister(sdev->ctrl, &hub->notif);
cancel_delayed_work_sync(&hub->update_work);
- ssam_hub_remove_devices(&sdev->dev);
+ ssam_remove_clients(&sdev->dev);
}
static const struct ssam_device_id ssam_base_hub_match[] = {
@@ -613,7 +599,7 @@ static int ssam_platform_hub_remove(struct platform_device *pdev)
{
const struct software_node **nodes = platform_get_drvdata(pdev);
- ssam_hub_remove_devices(&pdev->dev);
+ ssam_remove_clients(&pdev->dev);
set_secondary_fwnode(&pdev->dev, NULL);
software_node_unregister_node_group(nodes);
return 0;
--
2.33.1
Hi,
On 10/28/21 02:22, Maximilian Luz wrote:
> Remove some duplicate code for Surface Aggregator client device removal and
> rename a function for consistency.
>
> Maximilian Luz (3):
> platform/surface: aggregator: Make client device removal more generic
> platform/surface: aggregator_registry: Use generic client removal
> function
> platform/surface: aggregator_registry: Rename device registration
> function
Thanks, the series looks good to me:
Reviewed-by: Hans de Goede <[email protected]>
I'll merge this once 5.16-rc1 is out.
Regards,
Hans