From: Sebastian Reichel <sre@ring0.de>
To: Pavel Machek <pavel@ucw.cz>
Cc: "Marcel Holtmann" <marcel@holtmann.org>,
"Pali Rohár" <pali.rohar@gmail.com>,
"Ивайло Димитров" <freemangordon@abv.bg>,
"Gustavo F. Padovan" <gustavo@padovan.org>,
"Johan Hedberg" <johan.hedberg@gmail.com>,
linux-kernel <linux-kernel@vger.kernel.org>,
"linux-bluetooth@vger.kernel.org development"
<linux-bluetooth@vger.kernel.org>,
"Ville Tervo" <ville.tervo@nokia.com>
Subject: Re: [PATCH v4] Bluetooth: Add hci_h4p driver
Date: Fri, 10 Jan 2014 14:44:26 +0100 [thread overview]
Message-ID: <20140110134426.GA7235@earth.universe> (raw)
In-Reply-To: <20140110121805.GA21117@amd.pavel.ucw.cz>
[-- Attachment #1: Type: text/plain, Size: 6143 bytes --]
Hi Pavel,
You have missed some things. See inline comments below.
On Fri, Jan 10, 2014 at 01:18:05PM +0100, Pavel Machek wrote:
> diff --git a/drivers/bluetooth/nokia_core.c b/drivers/bluetooth/nokia_core.c
> index 5c7acad..d6b0701 100644
> --- a/drivers/bluetooth/nokia_core.c
> v+++ b/drivers/bluetooth/nokia_core.c
> @@ -39,6 +39,7 @@
> #include <linux/gpio.h>
> #include <linux/timer.h>
> #include <linux/kthread.h>
> +#include <linux/io.h>
>
> #include <net/bluetooth/bluetooth.h>
> #include <net/bluetooth/hci_core.h>
> @@ -1079,7 +1080,7 @@ static int hci_h4p_probe(struct platform_device *pdev)
> int err;
>
> dev_info(&pdev->dev, "Registering HCI H4P device\n");
> - info = kzalloc(sizeof(struct hci_h4p_info), GFP_KERNEL);
> + info = devm_kzalloc(&pdev->dev, sizeof(struct hci_h4p_info), GFP_KERNEL);
> if (!info)
> return -ENOMEM;
>
> @@ -1092,7 +1093,6 @@ static int hci_h4p_probe(struct platform_device *pdev)
>
> if (pdev->dev.platform_data == NULL) {
> dev_err(&pdev->dev, "Could not get Bluetooth config data\n");
> - kfree(info);
> return -ENODATA;
> }
>
> @@ -1113,67 +1113,59 @@ static int hci_h4p_probe(struct platform_device *pdev)
> complete_all(&info->test_completion);
>
> if (!info->reset_gpio_shared) {
> - err = gpio_request(info->reset_gpio, "bt_reset");
> + err = devm_gpio_request_one(&pdev->dev, info->reset_gpio,
> + GPIOF_OUT_INIT_LOW, "bt_reset");
> if (err < 0) {
> dev_err(&pdev->dev, "Cannot get GPIO line %d\n",
> info->reset_gpio);
> - goto cleanup_setup;
> + return err;
> }
> }
>
> - err = gpio_request(info->bt_wakeup_gpio, "bt_wakeup");
> + err = devm_gpio_request_one(&pdev->dev, info->bt_wakeup_gpio,
> + GPIOF_OUT_INIT_LOW, "bt_wakeup");
> +
> if (err < 0) {
> dev_err(info->dev, "Cannot get GPIO line 0x%d",
> info->bt_wakeup_gpio);
> - if (!info->reset_gpio_shared)
> - gpio_free(info->reset_gpio);
> - goto cleanup_setup;
> + return err;
> }
>
> - err = gpio_request(info->host_wakeup_gpio, "host_wakeup");
> + err = devm_gpio_request_one(&pdev->dev, info->host_wakeup_gpio,
> + GPIOF_DIR_IN, "host_wakeup");
> if (err < 0) {
> dev_err(info->dev, "Cannot get GPIO line %d",
> info->host_wakeup_gpio);
> - if (!info->reset_gpio_shared)
> - gpio_free(info->reset_gpio);
> - gpio_free(info->bt_wakeup_gpio);
> - goto cleanup_setup;
> + return err;
> }
>
> - gpio_direction_output(info->reset_gpio, 0);
> - gpio_direction_output(info->bt_wakeup_gpio, 0);
> - gpio_direction_input(info->host_wakeup_gpio);
> -
> info->irq = bt_plat_data->uart_irq;
> - info->uart_base = ioremap(bt_plat_data->uart_base, SZ_2K);
> - info->uart_iclk = clk_get(NULL, bt_plat_data->uart_iclk);
> - info->uart_fclk = clk_get(NULL, bt_plat_data->uart_fclk);
> + info->uart_base = devm_ioremap(&pdev->dev, bt_plat_data->uart_base, SZ_2K);
> + info->uart_iclk = devm_clk_get(&pdev->dev, bt_plat_data->uart_iclk);
> + info->uart_fclk = devm_clk_get(&pdev->dev, bt_plat_data->uart_fclk);
>
> err = request_irq(info->irq, hci_h4p_interrupt, IRQF_DISABLED, "hci_h4p",
> info);
This one should also use devm_request_irq(). Especially since you
removed the cleanup in the probe function already ;)
> if (err < 0) {
> dev_err(info->dev, "hci_h4p: unable to get IRQ %d\n", info->irq);
> - goto cleanup;
> + return err;
> }
>
> - err = request_irq(gpio_to_irq(info->host_wakeup_gpio),
> + err = devm_request_irq(&pdev->dev, gpio_to_irq(info->host_wakeup_gpio),
> hci_h4p_wakeup_interrupt, IRQF_TRIGGER_FALLING |
> IRQF_TRIGGER_RISING | IRQF_DISABLED,
> "hci_h4p_wkup", info);
> if (err < 0) {
> dev_err(info->dev, "hci_h4p: unable to get wakeup IRQ %d\n",
> gpio_to_irq(info->host_wakeup_gpio));
> - free_irq(info->irq, info);
> - goto cleanup;
> + return err;
> }
>
> err = irq_set_irq_wake(gpio_to_irq(info->host_wakeup_gpio), 1);
> if (err < 0) {
> dev_err(info->dev, "hci_h4p: unable to set wakeup for IRQ %d\n",
> gpio_to_irq(info->host_wakeup_gpio));
> - free_irq(info->irq, info);
> - free_irq(gpio_to_irq(info->host_wakeup_gpio), info);
> - goto cleanup;
> + return err;
> }
>
> init_timer_deferrable(&info->lazy_release);
> @@ -1182,7 +1174,7 @@ static int hci_h4p_probe(struct platform_device *pdev)
> hci_h4p_set_clk(info, &info->tx_clocks_en, 1);
> err = hci_h4p_reset_uart(info);
> if (err < 0)
> - goto cleanup_irq;
> + return err;
> gpio_set_value(info->reset_gpio, 0);
> hci_h4p_set_clk(info, &info->tx_clocks_en, 0);
>
> @@ -1190,23 +1182,10 @@ static int hci_h4p_probe(struct platform_device *pdev)
>
> if (hci_h4p_register_hdev(info) < 0) {
> dev_err(info->dev, "failed to register hci_h4p hci device\n");
> - goto cleanup_irq;
> + return -EINVAL;
> }
>
> return 0;
> -
> -cleanup_irq:
> - free_irq(info->irq, (void *)info);
> - free_irq(gpio_to_irq(info->host_wakeup_gpio), info);
> -cleanup:
> - gpio_set_value(info->reset_gpio, 0);
> - if (!info->reset_gpio_shared)
> - gpio_free(info->reset_gpio);
> - gpio_free(info->bt_wakeup_gpio);
> - gpio_free(info->host_wakeup_gpio);
> -cleanup_setup:
> - kfree(info);
> - return err;
> }
>
> static int hci_h4p_remove(struct platform_device *pdev)
> @@ -1217,15 +1196,11 @@ static int hci_h4p_remove(struct platform_device *pdev)
>
> hci_h4p_sysfs_remove_files(info->dev);
> hci_h4p_hci_close(info->hdev);
> - free_irq(gpio_to_irq(info->host_wakeup_gpio), info);
> hci_unregister_dev(info->hdev);
> hci_free_dev(info->hdev);
> - if (!info->reset_gpio_shared)
> - gpio_free(info->reset_gpio);
> gpio_free(info->bt_wakeup_gpio);
> gpio_free(info->host_wakeup_gpio);
those two gpios are also managed. No need to free them manually.
> free_irq(info->irq, (void *) info);
Once this irq is also requested using managed resources you can also
drop this line.
> - kfree(info);
>
> return 0;
> }
> [...]
-- Sebastian
[-- Attachment #2: Digital signature --]
[-- Type: application/pgp-signature, Size: 836 bytes --]
next prev parent reply other threads:[~2014-01-10 13:44 UTC|newest]
Thread overview: 53+ messages / expand[flat|nested] mbox.gz Atom feed top
2013-09-20 19:01 [PATCH] Bluetooth: Add hci_h4p driver Pali Rohár
2013-10-17 20:25 ` Pali Rohár
2013-10-17 22:11 ` Marcel Holtmann
2013-10-18 10:30 ` Pali Rohár
2013-10-24 16:41 ` Pali Rohár
2013-10-24 18:41 ` Joe Perches
2013-10-26 19:28 ` Pali Rohár
2013-12-27 11:02 ` [PATCH v2] " Pali Rohár
2013-12-27 11:34 ` Pali Rohár
2013-12-28 1:21 ` Marcel Holtmann
2013-12-30 12:13 ` Pavel Machek
2013-12-30 12:25 ` Pavel Machek
2013-12-30 13:19 ` Sebastian Reichel
2013-12-30 14:04 ` Pali Rohár
2013-12-30 13:54 ` Pali Rohár
2013-12-30 12:23 ` Pavel Machek
2013-12-30 14:31 ` Pali Rohár
2013-12-30 14:52 ` Sebastian Reichel
2013-12-30 23:42 ` Sebastian Reichel
2014-01-08 21:36 ` Pali Rohár
2014-02-13 15:33 ` Pali Rohár
2014-02-14 17:28 ` Sebastian Reichel
2014-02-15 22:30 ` Pavel Machek
2014-02-19 1:12 ` Ben Hutchings
2013-12-30 22:18 ` Pavel Machek
2013-12-30 22:19 ` [PATCH] wilink: mention name of module in help text Pavel Machek
2013-12-30 22:28 ` [PATCH v2] Bluetooth: Add hci_h4p driver Pavel Machek
2013-12-30 22:48 ` Pavel Machek
2013-12-31 22:12 ` Pavel Machek
2013-12-31 23:23 ` Marcel Holtmann
2014-01-01 20:09 ` Pavel Machek
2014-01-02 16:18 ` [PATCH v3] " Pavel Machek
2014-01-02 16:34 ` Marcel Holtmann
2014-01-03 0:17 ` [PATCH v4] " Pavel Machek
2014-01-03 1:05 ` Sebastian Reichel
2014-01-05 22:32 ` Pavel Machek
2014-01-05 23:01 ` Sebastian Reichel
2014-01-06 0:27 ` Pavel Machek
2014-01-03 1:36 ` Sebastian Reichel
2014-01-09 23:38 ` Pavel Machek
2014-01-10 0:32 ` Sebastian Reichel
2014-01-10 12:18 ` Pavel Machek
2014-01-10 13:44 ` Sebastian Reichel [this message]
2014-01-10 14:49 ` Pavel Machek
2014-01-10 14:52 ` [PATCH v5] " Pavel Machek
2014-01-10 17:33 ` Joe Perches
2014-01-11 0:19 ` Pavel Machek
2014-01-11 0:28 ` [PATCH v6] " Pavel Machek
2014-01-16 0:22 ` Pavel Machek
2014-01-16 3:01 ` Marcel Holtmann
2014-01-17 12:14 ` Pavel Machek
2014-01-17 13:29 ` [PATCH v7] staging/bluetooth: " Pavel Machek
2014-01-17 13:34 ` [PATCH] Bluetooth: add module name for btwilink Pavel Machek
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20140110134426.GA7235@earth.universe \
--to=sre@ring0.de \
--cc=freemangordon@abv.bg \
--cc=gustavo@padovan.org \
--cc=johan.hedberg@gmail.com \
--cc=linux-bluetooth@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=marcel@holtmann.org \
--cc=pali.rohar@gmail.com \
--cc=pavel@ucw.cz \
--cc=ville.tervo@nokia.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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).