From: Maxime Ripard <maxime.ripard-wi1+55ScJUtKEb57/3fJTNBPR1lH4CV8@public.gmane.org>
To: Tomasz Figa <tomasz.figa-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
Cc: linux-arm-kernel-IAPFreCvJWM7uuMidbF8XUB+6BGkLq7r@public.gmane.org,
Wolfram Sang <wsa-z923LK4zBo2bacvFa/9K2g@public.gmane.org>,
Emilio Lopez <emilio-0Z03zUJReD5OxF6Tv1QG9Q@public.gmane.org>,
linux-sunxi-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org,
linux-i2c-u79uwXL29TY76Z2rM5mHXA@public.gmane.org,
sunny-0TFLnhJekD6UEPyfVivIlAC/G2K4zDHf@public.gmane.org,
shuge-0TFLnhJekD6UEPyfVivIlAC/G2K4zDHf@public.gmane.org,
kevin-0TFLnhJekD6UEPyfVivIlAC/G2K4zDHf@public.gmane.org
Subject: Re: [PATCHv2 1/6] i2c: sunxi: Add Allwinner A1X i2c driver
Date: Sun, 26 May 2013 19:00:11 +0200 [thread overview]
Message-ID: <20130526170011.GK17847@lukather> (raw)
In-Reply-To: <24460034.7lWPC5EJAp@flatron>
On Sun, May 26, 2013 at 04:38:19PM +0200, Tomasz Figa wrote:
> On Sunday 26 of May 2013 12:20:37 Maxime Ripard wrote:
> > + /*
> > + * Address + Read bit have been transmitted, ACK has not been
> > + * received. If we don't care about the NAKs, we just treat
> > + * this case as if an ACK would have been received, and fall
> > + * through to the next case.
> > + */
> > + case SUNXI_I2C_STA_MASTER_RADDR_NAK:
> > + if (!(i2c_dev->msg_cur->flags & I2C_M_IGNORE_NAK)) {
> > + i2c_dev->msg_err = SUNXI_I2C_NAK;
> > + goto out;
> > + }
>
> I meant something more like:
>
> +
> + /* Intentional fall through. */
>
> This is enough to let the reader know that there is no break missing here
> and you can keep those nice short state descriptions from v1.
Ok, I'll do it that way
[..]
> > +static int sunxi_i2c_probe(struct platform_device *pdev)
> > +{
> > + struct sunxi_i2c_dev *i2c_dev;
> > + struct device_node *np;
> > + u32 freq, div_m, div_n;
> > + struct resource res;
>
> struct resource *res;
>
> and then...
>
> > + int ret;
> > +
> > + np = pdev->dev.of_node;
> > + if (!np)
> > + return -EINVAL;
> > +
> > + i2c_dev = devm_kzalloc(&pdev->dev, sizeof(*i2c_dev), GFP_KERNEL);
> > + if (!i2c_dev)
> > + return -ENOMEM;
> > + platform_set_drvdata(pdev, i2c_dev);
> > + i2c_dev->dev = &pdev->dev;
> > +
> > + init_completion(&i2c_dev->completion);
> > +
> > + ret = of_address_to_resource(np, 0, &res);
> > + if (ret) {
> > + dev_err(&pdev->dev, "could not get IO memory\n");
> > + return ret;
> > + }
> > +
> > + i2c_dev->membase = devm_ioremap_resource(&pdev->dev, &res);
>
> res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
> i2c_dev->membase = devm_ioremap_resource(&pdev->dev, res);
>
> This way you can save yourself from parsing device tree again, one error
> check and few lines of code. Remember that of_platform_populate() creates
> all the resources of platform_devices based on reg and interrupts
> properties, so there is no point in wasting this effort in drivers by
> parsing them manually again.
Ah, right, I didn't thought about the double dt parsing. I'll switch to
platform_get_resource and platform_get_irq as you suggested.
Thanks!
Maxime
--
Maxime Ripard, Free Electrons
Embedded Linux, Kernel and Android engineering
http://free-electrons.com
next prev parent reply other threads:[~2013-05-26 17:00 UTC|newest]
Thread overview: 15+ messages / expand[flat|nested] mbox.gz Atom feed top
2013-05-26 10:20 [PATCHv2 0/6] Add I2C support for Allwinner SoCs Maxime Ripard
[not found] ` <1369563642-4390-1-git-send-email-maxime.ripard-wi1+55ScJUtKEb57/3fJTNBPR1lH4CV8@public.gmane.org>
2013-05-26 10:20 ` [PATCHv2 1/6] i2c: sunxi: Add Allwinner A1X i2c driver Maxime Ripard
[not found] ` <1369563642-4390-2-git-send-email-maxime.ripard-wi1+55ScJUtKEb57/3fJTNBPR1lH4CV8@public.gmane.org>
2013-05-26 10:53 ` Oliver Schinagl
[not found] ` <51A1E9AA.4000008-dxLnbx3+1qmEVqv0pETR8A@public.gmane.org>
2013-05-26 13:21 ` [linux-sunxi] " Maxime Ripard
2013-05-26 19:01 ` Oliver Schinagl
[not found] ` <51A25C21.2060700-dxLnbx3+1qmEVqv0pETR8A@public.gmane.org>
2013-05-27 10:04 ` Maxime Ripard
2013-05-26 14:44 ` [linux-sunxi] " Tomasz Figa
2013-05-26 19:05 ` Oliver Schinagl
2013-05-26 14:38 ` Tomasz Figa
2013-05-26 17:00 ` Maxime Ripard [this message]
2013-05-26 10:20 ` [PATCHv2 2/6] ARM: sunxi: dt: Add i2c controller nodes to the DTSI Maxime Ripard
2013-05-26 10:20 ` [PATCHv2 3/6] ARM: sun4i: dt: Add i2c muxing options Maxime Ripard
2013-05-26 10:20 ` [PATCHv2 4/6] ARM: sun5i: " Maxime Ripard
2013-05-26 10:20 ` [PATCHv2 5/6] ARM: sun5i: olinuxino: Enable the i2c controllers Maxime Ripard
2013-05-26 10:20 ` [PATCHv2 6/6] ARM: sun4i: cubieboard: " Maxime Ripard
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=20130526170011.GK17847@lukather \
--to=maxime.ripard-wi1+55scjutkeb57/3fjtnbpr1lh4cv8@public.gmane.org \
--cc=emilio-0Z03zUJReD5OxF6Tv1QG9Q@public.gmane.org \
--cc=kevin-0TFLnhJekD6UEPyfVivIlAC/G2K4zDHf@public.gmane.org \
--cc=linux-arm-kernel-IAPFreCvJWM7uuMidbF8XUB+6BGkLq7r@public.gmane.org \
--cc=linux-i2c-u79uwXL29TY76Z2rM5mHXA@public.gmane.org \
--cc=linux-sunxi-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org \
--cc=shuge-0TFLnhJekD6UEPyfVivIlAC/G2K4zDHf@public.gmane.org \
--cc=sunny-0TFLnhJekD6UEPyfVivIlAC/G2K4zDHf@public.gmane.org \
--cc=tomasz.figa-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org \
--cc=wsa-z923LK4zBo2bacvFa/9K2g@public.gmane.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).