From: Linus Walleij <linus.walleij@linaro.org>
To: William Breathitt Gray <vilhelm.gray@gmail.com>
Cc: Alexandre Courbot <gnurou@gmail.com>,
"linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>,
"linux-gpio@vger.kernel.org" <linux-gpio@vger.kernel.org>
Subject: Re: [PATCH v9] gpio: Add GPIO support for the ACCES 104-IDIO-16
Date: Fri, 16 Oct 2015 17:03:00 +0200 [thread overview]
Message-ID: <CACRpkdYPBrgeqHL-dAMupGscht2US2WAAO7jojoTfSiXP8hDEA@mail.gmail.com> (raw)
In-Reply-To: <20151009225504.GA3050@sophia>
On Sat, Oct 10, 2015 at 12:55 AM, William Breathitt Gray
<vilhelm.gray@gmail.com> wrote:
> The ACCES 104-IDIO-16 family of PC/104 utility boards feature 16
> optically isolated inputs and 16 optically isolated FET solid state
> outputs. This driver provides GPIO support for these 32 channels of
> digital I/O. Change-of-State detection interrupts are not supported.
>
> GPIO 0-15 correspond to digital outputs 0-15, while GPIO 16-31
> correspond to digital inputs 0-15. The base port address for the device
> may be set via the a_104_idio_16_base module parameter.
>
> Signed-off-by: William Breathitt Gray <vilhelm.gray@gmail.com>
> ---
> Changes in v9:
> - Initialize GPIO device private data structure to 0 to prevent
> garbage data pollution
Getting there...
> +static unsigned a_104_idio_16_base;
> +module_param(a_104_idio_16_base, uint, 0);
> +MODULE_PARM_DESC(a_104_idio_16_base, "ACCES 104-IDIO-16 base address");
This is nice!
> +static int __init a_104_idio_16_probe(struct platform_device *pdev)
> +{
> + struct a_104_idio_16_gpio *const a104idio16gp = pdev->dev.platform_data;
No.
Why not just allocate zeroed it here in probe() like this:
struct a_104_idio_16_gpio *gp;
gp = devm_kzalloc(&pdev->dev, sizeof(*gp), GFP_KERNEL);
if (!gp)
return -ENOMEM;
You may want to rename "a_104_idio_16_gpio" to something more everyday.
This is hard to type.
> +static int __init a_104_idio_16_init(void)
> +{
> + int err;
> + const struct a_104_idio_16_gpio GP = { 0 };
This just works by chance. The keyword you're looking for is not "const"
but "static" if you want this to stay around. But do it as described above
instead.
> + a_104_idio_16_device = platform_device_register_data(NULL,
> + a_104_idio_16_driver.driver.name, -1, &GP, sizeof(GP));
> + if (IS_ERR(a_104_idio_16_device)) {
> + err = PTR_ERR(a_104_idio_16_device);
> + goto out_platform_device;
> + }
Skip all this. Use devm_kzalloc() in probe as described.
> +
> + dev_info(&a_104_idio_16_device->dev, "Initializing module\n");
> +
> + err = platform_driver_probe(&a_104_idio_16_driver, a_104_idio_16_probe);
> + if (err)
> + goto out_platform_driver;
> +
> + return 0;
> +
> +out_platform_driver:
> + platform_device_unregister(a_104_idio_16_device);
> +out_platform_device:
> + return err;
> +}
Then this can be just return platform_driver_probe(...);
Yours,
Linus Walleij
prev parent reply other threads:[~2015-10-16 15:03 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-10-09 22:55 [PATCH v9] gpio: Add GPIO support for the ACCES 104-IDIO-16 William Breathitt Gray
2015-10-16 15:03 ` Linus Walleij [this message]
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=CACRpkdYPBrgeqHL-dAMupGscht2US2WAAO7jojoTfSiXP8hDEA@mail.gmail.com \
--to=linus.walleij@linaro.org \
--cc=gnurou@gmail.com \
--cc=linux-gpio@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=vilhelm.gray@gmail.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).