From 8c3db42fea94cc360446602d3d1a4f50ae98af16 Mon Sep 17 00:00:00 2001 From: Felipe Balbi Date: Wed, 25 Jul 2012 15:05:27 +0300 Subject: w1: omap-hdq: add section annotation to remove trivial patch, no functional changes. Signed-off-by: Felipe Balbi Acked-by: Evgeniy Polyakov Signed-off-by: Andrew Morton Signed-off-by: Greg Kroah-Hartman --- drivers/w1/masters/omap_hdq.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'drivers/w1') diff --git a/drivers/w1/masters/omap_hdq.c b/drivers/w1/masters/omap_hdq.c index 4b0fcf3c2d03..38b0138ce74d 100644 --- a/drivers/w1/masters/omap_hdq.c +++ b/drivers/w1/masters/omap_hdq.c @@ -73,11 +73,11 @@ struct hdq_data { }; static int __devinit omap_hdq_probe(struct platform_device *pdev); -static int omap_hdq_remove(struct platform_device *pdev); +static int __devexit omap_hdq_remove(struct platform_device *pdev); static struct platform_driver omap_hdq_driver = { .probe = omap_hdq_probe, - .remove = omap_hdq_remove, + .remove = __devexit_p(omap_hdq_remove), .driver = { .name = "omap_hdq", }, @@ -628,7 +628,7 @@ err_kmalloc: } -static int omap_hdq_remove(struct platform_device *pdev) +static int __devexit omap_hdq_remove(struct platform_device *pdev) { struct hdq_data *hdq_data = platform_get_drvdata(pdev); -- cgit v1.2.3 From be6ec64a1bb04d6c54f77e8e445e83ea8f1e17e1 Mon Sep 17 00:00:00 2001 From: Felipe Balbi Date: Wed, 25 Jul 2012 15:05:28 +0300 Subject: w1: omap-hdq: don't hardcode resource size we have the helpful resource_size() macro to calculate the size of the memory resource for us, let's use it. Signed-off-by: Felipe Balbi Acked-by: Evgeniy Polyakov Signed-off-by: Andrew Morton Signed-off-by: Greg Kroah-Hartman --- drivers/w1/masters/omap_hdq.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'drivers/w1') diff --git a/drivers/w1/masters/omap_hdq.c b/drivers/w1/masters/omap_hdq.c index 38b0138ce74d..ee427975bd82 100644 --- a/drivers/w1/masters/omap_hdq.c +++ b/drivers/w1/masters/omap_hdq.c @@ -566,7 +566,7 @@ static int __devinit omap_hdq_probe(struct platform_device *pdev) goto err_resource; } - hdq_data->hdq_base = ioremap(res->start, SZ_4K); + hdq_data->hdq_base = ioremap(res->start, resource_size(res)); if (!hdq_data->hdq_base) { dev_dbg(&pdev->dev, "ioremap failed\n"); ret = -EINVAL; -- cgit v1.2.3 From 8650bbb58062f183ce5d983b6ba4ddd1e9b67f4a Mon Sep 17 00:00:00 2001 From: Felipe Balbi Date: Wed, 25 Jul 2012 15:05:29 +0300 Subject: w1: omap-hdq: convert to module_platform_driver trivial patch, no functional changes. Signed-off-by: Felipe Balbi Acked-by: Evgeniy Polyakov Signed-off-by: Andrew Morton Signed-off-by: Greg Kroah-Hartman --- drivers/w1/masters/omap_hdq.c | 14 +------------- 1 file changed, 1 insertion(+), 13 deletions(-) (limited to 'drivers/w1') diff --git a/drivers/w1/masters/omap_hdq.c b/drivers/w1/masters/omap_hdq.c index ee427975bd82..0427c2c60eab 100644 --- a/drivers/w1/masters/omap_hdq.c +++ b/drivers/w1/masters/omap_hdq.c @@ -652,19 +652,7 @@ static int __devexit omap_hdq_remove(struct platform_device *pdev) return 0; } -static int __init -omap_hdq_init(void) -{ - return platform_driver_register(&omap_hdq_driver); -} -module_init(omap_hdq_init); - -static void __exit -omap_hdq_exit(void) -{ - platform_driver_unregister(&omap_hdq_driver); -} -module_exit(omap_hdq_exit); +module_platform_driver(omap_hdq_driver); module_param(w1_id, int, S_IRUSR); MODULE_PARM_DESC(w1_id, "1-wire id for the slave detection"); -- cgit v1.2.3 From 19afea50f12b2dc5e2aaca488d1733188d06a619 Mon Sep 17 00:00:00 2001 From: Felipe Balbi Date: Wed, 25 Jul 2012 15:05:30 +0300 Subject: w1: omap-hdq: convert to devm_* functions this lets us remove a bit of boilerplate code. Signed-off-by: Felipe Balbi Acked-by: Evgeniy Polyakov Signed-off-by: Andrew Morton Signed-off-by: Greg Kroah-Hartman --- drivers/w1/masters/omap_hdq.c | 32 +++++++++----------------------- 1 file changed, 9 insertions(+), 23 deletions(-) (limited to 'drivers/w1') diff --git a/drivers/w1/masters/omap_hdq.c b/drivers/w1/masters/omap_hdq.c index 0427c2c60eab..5c13e7df9c69 100644 --- a/drivers/w1/masters/omap_hdq.c +++ b/drivers/w1/masters/omap_hdq.c @@ -544,33 +544,31 @@ static void omap_w1_write_byte(void *_hdq, u8 byte) static int __devinit omap_hdq_probe(struct platform_device *pdev) { + struct device *dev = &pdev->dev; struct hdq_data *hdq_data; struct resource *res; int ret, irq; u8 rev; - hdq_data = kmalloc(sizeof(*hdq_data), GFP_KERNEL); + hdq_data = devm_kzalloc(dev, sizeof(*hdq_data), GFP_KERNEL); if (!hdq_data) { dev_dbg(&pdev->dev, "unable to allocate memory\n"); - ret = -ENOMEM; - goto err_kmalloc; + return -ENOMEM; } - hdq_data->dev = &pdev->dev; + hdq_data->dev = dev; platform_set_drvdata(pdev, hdq_data); res = platform_get_resource(pdev, IORESOURCE_MEM, 0); if (!res) { dev_dbg(&pdev->dev, "unable to get resource\n"); - ret = -ENXIO; - goto err_resource; + return -ENXIO; } - hdq_data->hdq_base = ioremap(res->start, resource_size(res)); + hdq_data->hdq_base = devm_request_and_ioremap(dev, res); if (!hdq_data->hdq_base) { dev_dbg(&pdev->dev, "ioremap failed\n"); - ret = -EINVAL; - goto err_ioremap; + return -ENOMEM; } hdq_data->hdq_usecount = 0; @@ -591,7 +589,8 @@ static int __devinit omap_hdq_probe(struct platform_device *pdev) goto err_irq; } - ret = request_irq(irq, hdq_isr, IRQF_DISABLED, "omap_hdq", hdq_data); + ret = devm_request_irq(dev, irq, hdq_isr, IRQF_DISABLED, + "omap_hdq", hdq_data); if (ret < 0) { dev_dbg(&pdev->dev, "could not request irq\n"); goto err_irq; @@ -616,16 +615,7 @@ err_irq: err_w1: pm_runtime_disable(&pdev->dev); - iounmap(hdq_data->hdq_base); - -err_ioremap: -err_resource: - platform_set_drvdata(pdev, NULL); - kfree(hdq_data); - -err_kmalloc: return ret; - } static int __devexit omap_hdq_remove(struct platform_device *pdev) @@ -644,10 +634,6 @@ static int __devexit omap_hdq_remove(struct platform_device *pdev) /* remove module dependency */ pm_runtime_disable(&pdev->dev); - free_irq(INT_24XX_HDQ_IRQ, hdq_data); - platform_set_drvdata(pdev, NULL); - iounmap(hdq_data->hdq_base); - kfree(hdq_data); return 0; } -- cgit v1.2.3 From 042a713fa4369ffc2fcb2f93400bc862a04a1f0f Mon Sep 17 00:00:00 2001 From: Felipe Balbi Date: Wed, 25 Jul 2012 15:05:31 +0300 Subject: w1: omap-hdq: remove unnecessary return trivial patch, no functional changes. Signed-off-by: Felipe Balbi Acked-by: Evgeniy Polyakov Signed-off-by: Andrew Morton Signed-off-by: Greg Kroah-Hartman --- drivers/w1/masters/omap_hdq.c | 2 -- 1 file changed, 2 deletions(-) (limited to 'drivers/w1') diff --git a/drivers/w1/masters/omap_hdq.c b/drivers/w1/masters/omap_hdq.c index 5c13e7df9c69..c8a44642a5f1 100644 --- a/drivers/w1/masters/omap_hdq.c +++ b/drivers/w1/masters/omap_hdq.c @@ -538,8 +538,6 @@ static void omap_w1_write_byte(void *_hdq, u8 byte) hdq_data->init_trans = 0; mutex_unlock(&hdq_data->hdq_mutex); } - - return; } static int __devinit omap_hdq_probe(struct platform_device *pdev) -- cgit v1.2.3 From 73f2989d37a36614fe13f24891ebe1e44fe5887d Mon Sep 17 00:00:00 2001 From: Felipe Balbi Date: Wed, 25 Jul 2012 15:05:32 +0300 Subject: w1: omap-hdq: drop ARCH dependency Let the driver compile everywhere while also removing unnecessary headers. Signed-off-by: Felipe Balbi Acked-by: Evgeniy Polyakov Signed-off-by: Andrew Morton Signed-off-by: Greg Kroah-Hartman --- drivers/w1/masters/Kconfig | 1 - drivers/w1/masters/omap_hdq.c | 3 --- 2 files changed, 4 deletions(-) (limited to 'drivers/w1') diff --git a/drivers/w1/masters/Kconfig b/drivers/w1/masters/Kconfig index 5ceb1cd50195..7e984034a11b 100644 --- a/drivers/w1/masters/Kconfig +++ b/drivers/w1/masters/Kconfig @@ -60,7 +60,6 @@ config W1_MASTER_GPIO config HDQ_MASTER_OMAP tristate "OMAP HDQ driver" - depends on ARCH_OMAP2PLUS help Say Y here if you want support for the 1-wire or HDQ Interface on an OMAP processor. diff --git a/drivers/w1/masters/omap_hdq.c b/drivers/w1/masters/omap_hdq.c index c8a44642a5f1..ca8e60bb2f9c 100644 --- a/drivers/w1/masters/omap_hdq.c +++ b/drivers/w1/masters/omap_hdq.c @@ -18,9 +18,6 @@ #include #include -#include -#include - #include "../w1.h" #include "../w1_int.h" -- cgit v1.2.3 From 5f3d1382e3ca39a54032784414f0ad4e7078b37e Mon Sep 17 00:00:00 2001 From: Daniel Mack Date: Mon, 23 Jul 2012 16:36:35 +0200 Subject: onewire: w1-gpio: add DT bindings MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This patch add DT bindings to the w1-gpio driver, along with some documentation on how to use them. Signed-off-by: Daniel Mack Acked-by: Evgeniy Polyakov Acked-by: Ville Syrjälä Signed-off-by: Andrew Morton Signed-off-by: Greg Kroah-Hartman --- drivers/w1/masters/w1-gpio.c | 48 +++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 47 insertions(+), 1 deletion(-) (limited to 'drivers/w1') diff --git a/drivers/w1/masters/w1-gpio.c b/drivers/w1/masters/w1-gpio.c index df600d14974d..f01c336233da 100644 --- a/drivers/w1/masters/w1-gpio.c +++ b/drivers/w1/masters/w1-gpio.c @@ -14,6 +14,8 @@ #include #include #include +#include +#include #include "../w1.h" #include "../w1_int.h" @@ -42,12 +44,55 @@ static u8 w1_gpio_read_bit(void *data) return gpio_get_value(pdata->pin) ? 1 : 0; } +#ifdef CONFIG_OF +static struct of_device_id w1_gpio_dt_ids[] = { + { .compatible = "w1-gpio" }, + {} +}; +MODULE_DEVICE_TABLE(of, w1_gpio_dt_ids); + +static int w1_gpio_probe_dt(struct platform_device *pdev) +{ + struct w1_gpio_platform_data *pdata = pdev->dev.platform_data; + struct device_node *np = pdev->dev.of_node; + const struct of_device_id *of_id = + of_match_device(w1_gpio_dt_ids, &pdev->dev); + + if (!of_id) + return 0; + + pdata = devm_kzalloc(&pdev->dev, sizeof(*pdata), GFP_KERNEL); + if (!pdata) + return -ENOMEM; + + if (of_get_property(np, "linux,open-drain", NULL)) + pdata->is_open_drain = 1; + + pdata->pin = of_get_gpio(np, 0); + pdata->ext_pullup_enable_pin = of_get_gpio(np, 1); + pdev->dev.platform_data = pdata; + + return 0; +} +#else +static int w1_gpio_probe_dt(struct platform_device *pdev) +{ + return 0; +} +#endif + static int __init w1_gpio_probe(struct platform_device *pdev) { struct w1_bus_master *master; - struct w1_gpio_platform_data *pdata = pdev->dev.platform_data; + struct w1_gpio_platform_data *pdata; int err; + err = w1_gpio_probe_dt(pdev); + if (err < 0) + return err; + + pdata = pdev->dev.platform_data; + if (!pdata) return -ENXIO; @@ -135,6 +180,7 @@ static struct platform_driver w1_gpio_driver = { .driver = { .name = "w1-gpio", .owner = THIS_MODULE, + .of_match_table = of_match_ptr(w1_gpio_dt_ids), }, .remove = __exit_p(w1_gpio_remove), .suspend = w1_gpio_suspend, -- cgit v1.2.3 From d2323cf77308d6aa13a3a5287310ef93c4919d1e Mon Sep 17 00:00:00 2001 From: Daniel Mack Date: Wed, 25 Jul 2012 22:54:29 +0200 Subject: onewire: w1-gpio: add ext_pullup_enable pin in platform data MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit In the process of porting boards to devicetree implemenation, we should keep information about external circuitry where they belong - the individual drivers. This patch adds a way to specify a GPIO to drive the (optional) external pull-up logic, rather than using a function pointer for that. Signed-off-by: Daniel Mack Acked-by: Evgeniy Polyakov Acked-by: Ville Syrjälä Signed-off-by: Andrew Morton Signed-off-by: Greg Kroah-Hartman --- drivers/w1/masters/w1-gpio.c | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) (limited to 'drivers/w1') diff --git a/drivers/w1/masters/w1-gpio.c b/drivers/w1/masters/w1-gpio.c index f01c336233da..6012c4ea3206 100644 --- a/drivers/w1/masters/w1-gpio.c +++ b/drivers/w1/masters/w1-gpio.c @@ -104,6 +104,13 @@ static int __init w1_gpio_probe(struct platform_device *pdev) if (err) goto free_master; + if (gpio_is_valid(pdata->ext_pullup_enable_pin)) { + err = gpio_request_one(pdata->ext_pullup_enable_pin, + GPIOF_INIT_LOW, "w1 pullup"); + if (err < 0) + goto free_gpio; + } + master->data = pdata; master->read_bit = w1_gpio_read_bit; @@ -117,15 +124,21 @@ static int __init w1_gpio_probe(struct platform_device *pdev) err = w1_add_master_device(master); if (err) - goto free_gpio; + goto free_gpio_ext_pu; if (pdata->enable_external_pullup) pdata->enable_external_pullup(1); + if (gpio_is_valid(pdata->ext_pullup_enable_pin)) + gpio_set_value(pdata->ext_pullup_enable_pin, 1); + platform_set_drvdata(pdev, master); return 0; + free_gpio_ext_pu: + if (gpio_is_valid(pdata->ext_pullup_enable_pin)) + gpio_free(pdata->ext_pullup_enable_pin); free_gpio: gpio_free(pdata->pin); free_master: @@ -142,6 +155,9 @@ static int __exit w1_gpio_remove(struct platform_device *pdev) if (pdata->enable_external_pullup) pdata->enable_external_pullup(0); + if (gpio_is_valid(pdata->ext_pullup_enable_pin)) + gpio_set_value(pdata->ext_pullup_enable_pin, 0); + w1_remove_master_device(master); gpio_free(pdata->pin); kfree(master); -- cgit v1.2.3