From: vaibhav.hiremath@linaro.org (Vaibhav Hiremath)
To: linux-arm-kernel@lists.infradead.org
Subject: [PATCH 11/12] i2c:pxa: Use devm_ variants in probe function
Date: Sun, 31 May 2015 13:06:46 +0530 [thread overview]
Message-ID: <556ABA0E.7050205@linaro.org> (raw)
In-Reply-To: <878uc6xdsd.fsf@belgarion.home>
On Saturday 30 May 2015 09:23 PM, Robert Jarzmik wrote:
> Vaibhav Hiremath <vaibhav.hiremath@linaro.org> writes:
>
>> @@ -1270,10 +1270,17 @@ static int i2c_pxa_probe(struct platform_device *dev)
>> struct resource *res = NULL;
>> int ret, irq;
>>
>> - i2c = kzalloc(sizeof(struct pxa_i2c), GFP_KERNEL);
>> + i2c = devm_kzalloc(&dev->dev, sizeof(struct pxa_i2c), GFP_KERNEL);
>> if (!i2c) {
>> - ret = -ENOMEM;
>> - goto emalloc;
>> + dev_err(&dev->dev, "memory allocation failed\n");
>> + return -ENOMEM;
>> + }
>> +
>> + res = platform_get_resource(dev, IORESOURCE_MEM, 0);
>> + irq = platform_get_irq(dev, 0);
>> + if (res == NULL || irq < 0) {
>> + dev_err(&dev->dev, "no mem/irq resource\n");
>> + return -ENODEV;
> I'd like to have the error code here, as in other part of the driver.
> Ie. I'd want :
> dev_err(&dev->dev, "no mem/irq resource: %d\n", irq);
>
> Moreover, return -ENODEV if res == NULL, but return irq if irq < 0 (think of
> -EPROBE_DEFER).
>
Good point.
I will change it in next version.
>> + i2c->reg_base = devm_ioremap_resource(&dev->dev, res);
>> if (!i2c->reg_base) {
> if (IS_ERR(i2c->reg_base)) instead.
>
>> - ret = -EIO;
>> - goto eremap;
>> + dev_err(&dev->dev, "failed to map resource\n");
>> + return -EIO;
> Ditto, ie. include PTR_ERR(i2c->reg_base) in the dev_err(), and return
> PTR_ERR(i2c->reg_base);
>
Ok.
>> @@ -1361,11 +1356,13 @@ static int i2c_pxa_probe(struct platform_device *dev)
>> i2c->adap.algo = &i2c_pxa_pio_algorithm;
>> } else {
>> i2c->adap.algo = &i2c_pxa_algorithm;
>> - ret = request_irq(irq, i2c_pxa_handler,
>> + ret = devm_request_irq(&dev->dev, irq, i2c_pxa_handler,
>> IRQF_SHARED | IRQF_NO_SUSPEND,
>> dev_name(&dev->dev), i2c);
>> - if (ret)
>> + if (ret) {
>> + dev_err(&dev->dev, "failed to request irq\n");
> Ditto for the dev_err() and error code reporting.
>
>> @@ -1380,8 +1377,8 @@ static int i2c_pxa_probe(struct platform_device *dev)
>>
>> ret = i2c_add_numbered_adapter(&i2c->adap);
>> if (ret < 0) {
>> - printk(KERN_INFO "I2C: Failed to add bus\n");
>> - goto eadapt;
>> + dev_err(&dev->dev, "failed to add bus\n");
> Ditto.
>
>> @@ -1411,26 +1408,15 @@ static int i2c_pxa_probe(struct platform_device *dev)
>> }
>> }
>> #ifdef CONFIG_I2C_PXA_SLAVE
>> - printk(KERN_INFO "I2C: %s: PXA I2C adapter, slave address %d\n",
>> + pr_info("I2C: %s: PXA I2C adapter, slave address %d\n",
>> dev_name(&i2c->adap.dev), i2c->slave_addr);
> dev_info() maybe ?
>
>> #else
>> - printk(KERN_INFO "I2C: %s: PXA I2C adapter\n",
>> - dev_name(&i2c->adap.dev));
>> + pr_info("I2C: %s: PXA I2C adapter\n", dev_name(&i2c->adap.dev));
> Ditto.
>
Agreed to all your comments.
I will change the code in next version.
Thanks,
Vaibhav
next prev parent reply other threads:[~2015-05-31 7:36 UTC|newest]
Thread overview: 58+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-05-28 13:03 [PATCH 00/12] i2c: pxa: Fixes, cleanup and support for pxa910 family Vaibhav Hiremath
2015-05-28 13:03 ` [PATCH 01/12] i2c: pxa: keep i2c irq ON in suspend Vaibhav Hiremath
2015-05-28 13:03 ` [PATCH 02/12] i2c: pxa: No need to set slave addr for i2c master mode reset Vaibhav Hiremath
2015-05-29 19:21 ` Robert Jarzmik
2015-05-29 19:25 ` Vaibhav Hiremath
2015-05-28 13:03 ` [PATCH 03/12] i2c: pxa: Add reset operation when i2c bus busy Vaibhav Hiremath
2015-05-29 19:39 ` Robert Jarzmik
2015-05-29 20:20 ` Vaibhav Hiremath
2015-05-28 13:03 ` [PATCH 04/12] i2c: pxa: Add support for pxa910/988 & new configuration features Vaibhav Hiremath
2015-05-29 20:22 ` Robert Jarzmik
2015-05-29 20:33 ` Vaibhav Hiremath
2015-06-04 2:31 ` Yi Zhang
2015-06-04 5:46 ` Vaibhav Hiremath
2015-06-01 0:13 ` Wolfram Sang
2015-06-02 5:01 ` Vaibhav Hiremath
2015-05-28 13:03 ` [PATCH 05/12] i2c: pxa: Add bus reset functionality Vaibhav Hiremath
2015-05-29 13:59 ` Rob Herring
2015-05-29 15:40 ` Vaibhav Hiremath
2015-05-29 20:31 ` Robert Jarzmik
2015-06-02 13:12 ` Linus Walleij
2015-06-02 16:40 ` Vaibhav Hiremath
2015-06-03 19:16 ` Vaibhav Hiremath
2015-06-02 17:33 ` Wolfram Sang
2015-06-02 17:40 ` Vaibhav Hiremath
2015-06-02 17:48 ` Wolfram Sang
2015-06-02 17:57 ` Vaibhav Hiremath
2015-06-02 18:02 ` Wolfram Sang
2015-06-02 18:06 ` Vaibhav Hiremath
2015-06-02 18:24 ` Wolfram Sang
2015-06-02 18:46 ` Vaibhav Hiremath
2015-05-28 13:03 ` [PATCH 06/12] i2c: pxa: Return I2C_RETRY when timeout in pio mode Vaibhav Hiremath
2015-05-29 20:46 ` Robert Jarzmik
2015-05-29 21:23 ` Vaibhav Hiremath
2015-05-28 13:03 ` [PATCH 07/12] i2c: pxa: Reset i2c controller on timeout in interrupt and " Vaibhav Hiremath
2015-05-29 21:13 ` Robert Jarzmik
2015-05-29 21:19 ` Vaibhav Hiremath
2015-05-28 13:03 ` [PATCH 08/12] i2c: pxa: enable/disable irq across message xfer Vaibhav Hiremath
2015-05-28 13:17 ` Russell King - ARM Linux
2015-05-28 13:29 ` Vaibhav Hiremath
2015-05-28 13:03 ` [PATCH 09/12] i2c: pxa: Remove compile warnning in 64bit mode Vaibhav Hiremath
2015-05-29 21:28 ` Robert Jarzmik
2015-05-28 13:03 ` [PATCH 10/12] i2c: pxa: Update debug function to dump more info on error Vaibhav Hiremath
2015-05-29 21:42 ` Robert Jarzmik
2015-05-29 21:45 ` Vaibhav Hiremath
2015-05-28 13:03 ` [PATCH 11/12] i2c:pxa: Use devm_ variants in probe function Vaibhav Hiremath
2015-05-30 15:53 ` Robert Jarzmik
2015-05-31 7:36 ` Vaibhav Hiremath [this message]
2015-05-28 13:03 ` [PATCH 12/12] i2c: pxa: enable/disable i2c module across msg xfer Vaibhav Hiremath
2015-05-28 13:23 ` Russell King - ARM Linux
2015-06-02 16:52 ` Vaibhav Hiremath
2015-06-02 16:59 ` Vaibhav Hiremath
2015-06-03 10:56 ` Yi Zhang
2015-06-03 18:49 ` Vaibhav Hiremath
2015-06-04 6:29 ` Yi Zhang
2015-06-04 7:19 ` Vaibhav Hiremath
2015-06-04 7:58 ` Yi Zhang
2015-06-01 0:07 ` [PATCH 00/12] i2c: pxa: Fixes, cleanup and support for pxa910 family Wolfram Sang
2015-06-02 4:58 ` Vaibhav Hiremath
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=556ABA0E.7050205@linaro.org \
--to=vaibhav.hiremath@linaro.org \
--cc=linux-arm-kernel@lists.infradead.org \
/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).