* [PATCH 1/2] mfd: ssbi: Add MODULE_DEVICE_TABLE @ 2013-06-02 6:02 Stephen Boyd 2013-06-02 6:02 ` [PATCH 2/2] mfd: ssbi: Use devm_* to simplify code Stephen Boyd 0 siblings, 1 reply; 4+ messages in thread From: Stephen Boyd @ 2013-06-02 6:02 UTC (permalink / raw) To: Samuel Ortiz, Lee Jones; +Cc: linux-kernel, linux-arm-msm, David Brown This allows the ssbi module to be autoloaded on boot. Cc: David Brown <davidb@codeaurora.org> Signed-off-by: Stephen Boyd <sboyd@codeaurora.org> --- drivers/mfd/ssbi.c | 1 + 1 file changed, 1 insertion(+) diff --git a/drivers/mfd/ssbi.c b/drivers/mfd/ssbi.c index f32da02..e561d3b 100644 --- a/drivers/mfd/ssbi.c +++ b/drivers/mfd/ssbi.c @@ -350,6 +350,7 @@ static struct of_device_id ssbi_match_table[] = { { .compatible = "qcom,ssbi" }, {} }; +MODULE_DEVICE_TABLE(of, ssbi_match_table); static struct platform_driver ssbi_driver = { .probe = ssbi_probe, -- The Qualcomm Innovation Center, Inc. is a member of the Code Aurora Forum, hosted by The Linux Foundation ^ permalink raw reply related [flat|nested] 4+ messages in thread
* [PATCH 2/2] mfd: ssbi: Use devm_* to simplify code 2013-06-02 6:02 [PATCH 1/2] mfd: ssbi: Add MODULE_DEVICE_TABLE Stephen Boyd @ 2013-06-02 6:02 ` Stephen Boyd 2013-06-03 8:10 ` Lee Jones 0 siblings, 1 reply; 4+ messages in thread From: Stephen Boyd @ 2013-06-02 6:02 UTC (permalink / raw) To: Samuel Ortiz, Lee Jones; +Cc: linux-kernel, linux-arm-msm, David Brown Use devm_ioremap_resource and devm_kzalloc to simplify error paths and reduce lines of code. Cc: David Brown <davidb@codeaurora.org> Signed-off-by: Stephen Boyd <sboyd@codeaurora.org> --- drivers/mfd/ssbi.c | 69 +++++++++--------------------------------------------- 1 file changed, 11 insertions(+), 58 deletions(-) diff --git a/drivers/mfd/ssbi.c b/drivers/mfd/ssbi.c index e561d3b..102a2284 100644 --- a/drivers/mfd/ssbi.c +++ b/drivers/mfd/ssbi.c @@ -268,35 +268,23 @@ static int ssbi_probe(struct platform_device *pdev) struct device_node *np = pdev->dev.of_node; struct resource *mem_res; struct ssbi *ssbi; - int ret = 0; const char *type; - ssbi = kzalloc(sizeof(struct ssbi), GFP_KERNEL); - if (!ssbi) { - pr_err("can not allocate ssbi_data\n"); + ssbi = devm_kzalloc(&pdev->dev, sizeof(*ssbi), GFP_KERNEL); + if (!ssbi) return -ENOMEM; - } mem_res = platform_get_resource(pdev, IORESOURCE_MEM, 0); - if (!mem_res) { - pr_err("missing mem resource\n"); - ret = -EINVAL; - goto err_get_mem_res; - } + ssbi->base = devm_ioremap_resource(&pdev->dev, mem_res); + if (IS_ERR(ssbi->base)) + return PTR_ERR(ssbi->base); - ssbi->base = ioremap(mem_res->start, resource_size(mem_res)); - if (!ssbi->base) { - pr_err("ioremap of 0x%p failed\n", (void *)mem_res->start); - ret = -EINVAL; - goto err_ioremap; - } platform_set_drvdata(pdev, ssbi); type = of_get_property(np, "qcom,controller-type", NULL); if (type == NULL) { - pr_err("Missing qcom,controller-type property\n"); - ret = -EINVAL; - goto err_ssbi_controller; + dev_err(&pdev->dev, "Missing qcom,controller-type property\n"); + return -EINVAL; } dev_info(&pdev->dev, "SSBI controller type: '%s'\n", type); if (strcmp(type, "ssbi") == 0) @@ -306,9 +294,8 @@ static int ssbi_probe(struct platform_device *pdev) else if (strcmp(type, "pmic-arbiter") == 0) ssbi->controller_type = MSM_SBI_CTRL_PMIC_ARBITER; else { - pr_err("Unknown qcom,controller-type\n"); - ret = -EINVAL; - goto err_ssbi_controller; + dev_err(&pdev->dev, "Unknown qcom,controller-type\n"); + return -EINVAL; } if (ssbi->controller_type == MSM_SBI_CTRL_PMIC_ARBITER) { @@ -321,29 +308,7 @@ static int ssbi_probe(struct platform_device *pdev) spin_lock_init(&ssbi->lock); - ret = of_platform_populate(np, NULL, NULL, &pdev->dev); - if (ret) - goto err_ssbi_controller; - - return 0; - -err_ssbi_controller: - platform_set_drvdata(pdev, NULL); - iounmap(ssbi->base); -err_ioremap: -err_get_mem_res: - kfree(ssbi); - return ret; -} - -static int ssbi_remove(struct platform_device *pdev) -{ - struct ssbi *ssbi = platform_get_drvdata(pdev); - - platform_set_drvdata(pdev, NULL); - iounmap(ssbi->base); - kfree(ssbi); - return 0; + return of_platform_populate(np, NULL, NULL, &pdev->dev); } static struct of_device_id ssbi_match_table[] = { @@ -354,25 +319,13 @@ MODULE_DEVICE_TABLE(of, ssbi_match_table); static struct platform_driver ssbi_driver = { .probe = ssbi_probe, - .remove = ssbi_remove, .driver = { .name = "ssbi", .owner = THIS_MODULE, .of_match_table = ssbi_match_table, }, }; - -static int __init ssbi_init(void) -{ - return platform_driver_register(&ssbi_driver); -} -module_init(ssbi_init); - -static void __exit ssbi_exit(void) -{ - platform_driver_unregister(&ssbi_driver); -} -module_exit(ssbi_exit) +module_platform_driver(ssbi_driver); MODULE_LICENSE("GPL v2"); MODULE_VERSION("1.0"); -- The Qualcomm Innovation Center, Inc. is a member of the Code Aurora Forum, hosted by The Linux Foundation ^ permalink raw reply related [flat|nested] 4+ messages in thread
* Re: [PATCH 2/2] mfd: ssbi: Use devm_* to simplify code 2013-06-02 6:02 ` [PATCH 2/2] mfd: ssbi: Use devm_* to simplify code Stephen Boyd @ 2013-06-03 8:10 ` Lee Jones 2013-06-03 19:17 ` Stephen Boyd 0 siblings, 1 reply; 4+ messages in thread From: Lee Jones @ 2013-06-03 8:10 UTC (permalink / raw) To: Stephen Boyd; +Cc: Samuel Ortiz, linux-kernel, linux-arm-msm, David Brown > Use devm_ioremap_resource and devm_kzalloc to simplify error > paths and reduce lines of code. The code looks fine, but you're actually doing a great deal more than you describe in the commit message. Would you mind expanding? I.e: > + dev_err(&pdev->dev, "Unknown qcom,controller-type\n"); Switching to these 'cos they're more informative. > - platform_set_drvdata(pdev, NULL); Removing these because they're obsolete. > - .remove = ssbi_remove, Removing this 'cos it no longer does anything useful. > +module_platform_driver(ssbi_driver); Moving these because it's more succinct when init() and exit() routines are baron. None of the above have anything to do with devm_* managed resources. -- Lee Jones Linaro ST-Ericsson Landing Team Lead Linaro.org │ Open source software for ARM SoCs Follow Linaro: Facebook | Twitter | Blog ^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH 2/2] mfd: ssbi: Use devm_* to simplify code 2013-06-03 8:10 ` Lee Jones @ 2013-06-03 19:17 ` Stephen Boyd 0 siblings, 0 replies; 4+ messages in thread From: Stephen Boyd @ 2013-06-03 19:17 UTC (permalink / raw) To: Lee Jones; +Cc: Samuel Ortiz, linux-kernel, linux-arm-msm, David Brown On 06/03/13 01:10, Lee Jones wrote: >> Use devm_ioremap_resource and devm_kzalloc to simplify error >> paths and reduce lines of code. > The code looks fine, but you're actually doing a great deal more than > you describe in the commit message. Would you mind expanding? > > I.e: > >> + dev_err(&pdev->dev, "Unknown qcom,controller-type\n"); > Switching to these 'cos they're more informative. > >> - platform_set_drvdata(pdev, NULL); > Removing these because they're obsolete. > >> - .remove = ssbi_remove, > Removing this 'cos it no longer does anything useful. > >> +module_platform_driver(ssbi_driver); > Moving these because it's more succinct when init() and exit() > routines are baron. > > None of the above have anything to do with devm_* managed resources. > Ok I'll update the commit text and resend. Thanks for the review. -- Qualcomm Innovation Center, Inc. is a member of Code Aurora Forum, hosted by The Linux Foundation ^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2013-06-03 19:17 UTC | newest] Thread overview: 4+ messages (download: mbox.gz follow: Atom feed -- links below jump to the message on this page -- 2013-06-02 6:02 [PATCH 1/2] mfd: ssbi: Add MODULE_DEVICE_TABLE Stephen Boyd 2013-06-02 6:02 ` [PATCH 2/2] mfd: ssbi: Use devm_* to simplify code Stephen Boyd 2013-06-03 8:10 ` Lee Jones 2013-06-03 19:17 ` Stephen Boyd
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox; as well as URLs for NNTP newsgroup(s).