greybus: arche-ctrl: Don't expose driver internals to arche-platform driver
authorViresh Kumar <viresh.kumar@linaro.org>
Wed, 20 Apr 2016 06:18:37 +0000 (11:48 +0530)
committerGreg Kroah-Hartman <gregkh@google.com>
Sat, 23 Apr 2016 00:37:21 +0000 (09:37 +0900)
We have chosen the *ugly* way of registering two platform drivers from
the module_init() of only one of them, so that we can avoid having two
separate modules for them.

But we should still be doing this in a sane way. There is no need to
expose internals of arche-ctrl to arche-platform, like PM-ops, probe,
resume, id-table, etc. Just expose an init and a exit callback.

Signed-off-by: Viresh Kumar <viresh.kumar@linaro.org>
Reviewed-by: Vaibhav Hiremath <vaibhav.hiremath@linaro.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
drivers/staging/greybus/arche-apb-ctrl.c
drivers/staging/greybus/arche-platform.c
drivers/staging/greybus/arche_platform.h

index 3a092a5b7fb856b345a97ec21ddf32a16f564c4a..a9d78a85939ab6e9d0af8d3521fedb719a6e3598 100644 (file)
@@ -358,7 +358,7 @@ static int apb_ctrl_get_devtree_data(struct platform_device *pdev,
        return 0;
 }
 
-int arche_apb_ctrl_probe(struct platform_device *pdev)
+static int arche_apb_ctrl_probe(struct platform_device *pdev)
 {
        int ret;
        struct arche_apb_ctrl_drvdata *apb;
@@ -393,7 +393,7 @@ int arche_apb_ctrl_probe(struct platform_device *pdev)
        return 0;
 }
 
-int arche_apb_ctrl_remove(struct platform_device *pdev)
+static int arche_apb_ctrl_remove(struct platform_device *pdev)
 {
        device_remove_file(&pdev->dev, &dev_attr_state);
        poweroff_seq(pdev);
@@ -430,6 +430,30 @@ static int arche_apb_ctrl_resume(struct device *dev)
        return 0;
 }
 
-SIMPLE_DEV_PM_OPS(arche_apb_ctrl_pm_ops,
-                 arche_apb_ctrl_suspend,
-                 arche_apb_ctrl_resume);
+static SIMPLE_DEV_PM_OPS(arche_apb_ctrl_pm_ops, arche_apb_ctrl_suspend,
+                        arche_apb_ctrl_resume);
+
+static struct of_device_id arche_apb_ctrl_of_match[] = {
+       { .compatible = "usbffff,2", },
+       { },
+};
+
+static struct platform_driver arche_apb_ctrl_device_driver = {
+       .probe          = arche_apb_ctrl_probe,
+       .remove         = arche_apb_ctrl_remove,
+       .driver         = {
+               .name   = "arche-apb-ctrl",
+               .pm     = &arche_apb_ctrl_pm_ops,
+               .of_match_table = arche_apb_ctrl_of_match,
+       }
+};
+
+int __init arche_apb_init(void)
+{
+       return platform_driver_register(&arche_apb_ctrl_device_driver);
+}
+
+void __exit arche_apb_exit(void)
+{
+       platform_driver_unregister(&arche_apb_ctrl_device_driver);
+}
index 3ff4f69685bd7ebf47e79ba2892d677cc3475c5c..d1083cfbc0812d42fc87b629db84867fc59480e8 100644 (file)
@@ -580,11 +580,6 @@ static struct of_device_id arche_platform_of_match[] = {
        { },
 };
 
-static struct of_device_id arche_apb_ctrl_of_match[] = {
-       { .compatible = "usbffff,2", },
-       { },
-};
-
 static struct of_device_id arche_combined_id[] = {
        { .compatible = "google,arche-platform", }, /* Use PID/VID of SVC device */
        { .compatible = "usbffff,2", },
@@ -602,16 +597,6 @@ static struct platform_driver arche_platform_device_driver = {
        }
 };
 
-static struct platform_driver arche_apb_ctrl_device_driver = {
-       .probe          = arche_apb_ctrl_probe,
-       .remove         = arche_apb_ctrl_remove,
-       .driver         = {
-               .name   = "arche-apb-ctrl",
-               .pm     = &arche_apb_ctrl_pm_ops,
-               .of_match_table = arche_apb_ctrl_of_match,
-       }
-};
-
 static int __init arche_init(void)
 {
        int retval;
@@ -620,7 +605,7 @@ static int __init arche_init(void)
        if (retval)
                return retval;
 
-       retval = platform_driver_register(&arche_apb_ctrl_device_driver);
+       retval = arche_apb_init();
        if (retval)
                platform_driver_unregister(&arche_platform_device_driver);
 
@@ -630,7 +615,7 @@ module_init(arche_init);
 
 static void __exit arche_exit(void)
 {
-       platform_driver_unregister(&arche_apb_ctrl_device_driver);
+       arche_apb_exit();
        platform_driver_unregister(&arche_platform_device_driver);
 }
 module_exit(arche_exit);
index 700c548d68dbaaee16d6863c2f89617500e6d5bd..69b627b978b80c5f43813c9d77f816bee98e5c23 100644 (file)
@@ -18,8 +18,8 @@ enum arche_platform_state {
 };
 
 
-int arche_apb_ctrl_probe(struct platform_device *pdev);
-int arche_apb_ctrl_remove(struct platform_device *pdev);
+int __init arche_apb_init(void);
+void __exit arche_apb_exit(void);
 
 /* Operational states for the APB device */
 int apb_ctrl_coldboot(struct device *dev);
@@ -27,7 +27,4 @@ int apb_ctrl_fw_flashing(struct device *dev);
 int apb_ctrl_standby_boot(struct device *dev);
 void apb_ctrl_poweroff(struct device *dev);
 
-
-extern const struct dev_pm_ops arche_apb_ctrl_pm_ops;
-
 #endif /* __ARCHE_PLATFORM_H */