Change the binding logic to ensure that the MFD driver will be load after having the SPMI controller registered. Signed-off-by: Mauro Carvalho Chehab <mchehab+huawei@xxxxxxxxxx> --- drivers/staging/hikey9xx/hi6421-spmi-pmic.c | 84 +++++++-------------- 1 file changed, 29 insertions(+), 55 deletions(-) diff --git a/drivers/staging/hikey9xx/hi6421-spmi-pmic.c b/drivers/staging/hikey9xx/hi6421-spmi-pmic.c index be42fed16bd2..939f7bd5d8ba 100644 --- a/drivers/staging/hikey9xx/hi6421-spmi-pmic.c +++ b/drivers/staging/hikey9xx/hi6421-spmi-pmic.c @@ -24,13 +24,14 @@ #include <linux/err.h> #include <linux/interrupt.h> #include <linux/io.h> +#include <linux/mfd/core.h> #include <linux/platform_device.h> #include <linux/of.h> #include <linux/of_address.h> #include <linux/of_device.h> #include <linux/of_gpio.h> #include <linux/of_irq.h> -#include <linux/mfd/hisi_pmic.h> +#include <linux/mfd/hi6421-spmi-pmic.h> #include <linux/irq.h> #include <linux/spmi.h> #ifndef NO_IRQ @@ -53,11 +54,8 @@ /*define the first group interrupt register number*/ #define HISI_PMIC_FIRST_GROUP_INT_NUM 2 -static const struct of_device_id of_hisi_pmic_match_tbl[] = { - { - .compatible = "hisilicon-hisi-pmic-spmi", - }, - { /* end */ } +static const struct mfd_cell hi6421v600_devs[] = { + { .name = "hi6421v600-regulator", }, }; /* @@ -477,6 +475,22 @@ static int hisi_pmic_probe(struct spmi_device *pdev) goto request_theaded_irq; } + dev_set_drvdata(&pdev->dev, pmic); + + /* + * The logic below will rely that the pmic is already stored at + * drvdata. + */ + dev_dbg(&pdev->dev, "SPMI-PMIC: adding childs for %pOF\n", + pdev->dev.of_node); + ret = devm_mfd_add_devices(&pdev->dev, PLATFORM_DEVID_NONE, + hi6421v600_devs, ARRAY_SIZE(hi6421v600_devs), + NULL, 0, NULL); + if (ret) { + dev_err(&pdev->dev, "Failed to add child devices: %d\n", ret); + return ret; + } + after_irq_register: return 0; @@ -497,61 +511,21 @@ static void hisi_pmic_remove(struct spmi_device *pdev) devm_kfree(&pdev->dev, pmic); } -static int hisi_pmic_suspend(struct device *dev, pm_message_t state) -{ - struct hisi_pmic *pmic = dev_get_drvdata(dev); +static const struct of_device_id pmic_spmi_id_table[] = { + { .compatible = "hisilicon,hi6421-spmi-pmic" }, + { } +}; +MODULE_DEVICE_TABLE(of, pmic_spmi_id_table); - if (!pmic) { - pr_err("%s:pmic is NULL\n", __func__); - return -ENOMEM; - } - - pr_info("%s:+\n", __func__); - pr_info("%s:-\n", __func__); - - return 0; -} - -static int hisi_pmic_resume(struct device *dev) -{ - struct hisi_pmic *pmic = dev_get_drvdata(dev); - - if (!pmic) { - pr_err("%s:pmic is NULL\n", __func__); - return -ENOMEM; - } - - pr_info("%s:+\n", __func__); - pr_info("%s:-\n", __func__); - - return 0; -} - -MODULE_DEVICE_TABLE(spmi, pmic_spmi_id); static struct spmi_driver hisi_pmic_driver = { .driver = { - .name = "hisi_pmic", - .owner = THIS_MODULE, - .of_match_table = of_hisi_pmic_match_tbl, - .suspend = hisi_pmic_suspend, - .resume = hisi_pmic_resume, + .name = "hi6421-spmi-pmic", + .of_match_table = pmic_spmi_id_table, }, .probe = hisi_pmic_probe, .remove = hisi_pmic_remove, }; +module_spmi_driver(hisi_pmic_driver); -static int __init hisi_pmic_init(void) -{ - return spmi_driver_register(&hisi_pmic_driver); -} - -static void __exit hisi_pmic_exit(void) -{ - spmi_driver_unregister(&hisi_pmic_driver); -} - -subsys_initcall_sync(hisi_pmic_init); -module_exit(hisi_pmic_exit); - -MODULE_DESCRIPTION("PMIC driver"); +MODULE_DESCRIPTION("HiSilicon Hi6421v600 SPMI PMIC driver"); MODULE_LICENSE("GPL v2"); -- 2.26.2 _______________________________________________ devel mailing list devel@xxxxxxxxxxxxxxxxxxxxxx http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel