From: arnd@arndb.de (Arnd Bergmann)
To: linux-arm-kernel@lists.infradead.org
Subject: [PATCH 4/8] i2c: pxa: add OF support
Date: Thu, 1 Mar 2012 10:01:00 +0000 [thread overview]
Message-ID: <201203011001.00289.arnd@arndb.de> (raw)
In-Reply-To: <1330582228-12424-5-git-send-email-haojian.zhuang@marvell.com>
On Thursday 01 March 2012, Haojian Zhuang wrote:
> +#ifdef CONFIG_OF
> +static int i2c_pxa_probe_dt(struct platform_device *pdev, struct pxa_i2c *i2c,
> + enum pxa_i2c_types *i2c_types)
> {
> + struct device_node *np = pdev->dev.of_node;
> + const struct of_device_id *of_id =
> + of_match_device(i2c_pxa_dt_ids, &pdev->dev);
> + const char *status;
> + int len;
> +
> + if (of_get_property(np, "mrvl,i2c-polling", NULL))
> + i2c->use_pio = 1;
> + status = of_get_property(np, "mrvl,i2c-mode", &len);
> + if (status && len > 0)
> + if (!strcmp(status, "fast"))
> + i2c->fast_mode = 1;
This would be easier if you made it an empty "mrvl,i2c-fast-mode"
property to get rid of the strcmp.
> + *i2c_types = ((u32)(of_id->data) - (u32)&pxa_reg_layout[0])
> + / sizeof(struct pxa_reg_layout);
This looks unnecessarily complicated. Just put the enum into of_id->data
instead of the pointer, with a cast to unsigned long.
> + return 0;
> +}
> +#else
> +static int i2c_pxa_probe_dt(struct platform_device *pdev, struct pxa_i2c *i2c,
> + enum pxa_i2c_types *i2c_types)
> +{
> + return 1;
> +}
> +#endif
Again, no need for the #ifdef. Just add in the beginning
if (!of_id)
return 1;
And the rest will be optimized out without CONFIG_OF.
Arnd
WARNING: multiple messages have this Message-ID (diff)
From: Arnd Bergmann <arnd-r2nGTMty4D4@public.gmane.org>
To: Haojian Zhuang <haojian.zhuang-eYqpPyKDWXRBDgjK7y7TUQ@public.gmane.org>
Cc: eric.y.miao-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org,
devicetree-discuss-uLR06cmDAlY/bJ5BZ2RsiQ@public.gmane.org,
linux-lFZ/pmaqli7XmaaqVzeoHQ@public.gmane.org,
linux-arm-kernel-IAPFreCvJWM7uuMidbF8XUB+6BGkLq7r@public.gmane.org
Subject: Re: [PATCH 4/8] i2c: pxa: add OF support
Date: Thu, 1 Mar 2012 10:01:00 +0000 [thread overview]
Message-ID: <201203011001.00289.arnd@arndb.de> (raw)
In-Reply-To: <1330582228-12424-5-git-send-email-haojian.zhuang-eYqpPyKDWXRBDgjK7y7TUQ@public.gmane.org>
On Thursday 01 March 2012, Haojian Zhuang wrote:
> +#ifdef CONFIG_OF
> +static int i2c_pxa_probe_dt(struct platform_device *pdev, struct pxa_i2c *i2c,
> + enum pxa_i2c_types *i2c_types)
> {
> + struct device_node *np = pdev->dev.of_node;
> + const struct of_device_id *of_id =
> + of_match_device(i2c_pxa_dt_ids, &pdev->dev);
> + const char *status;
> + int len;
> +
> + if (of_get_property(np, "mrvl,i2c-polling", NULL))
> + i2c->use_pio = 1;
> + status = of_get_property(np, "mrvl,i2c-mode", &len);
> + if (status && len > 0)
> + if (!strcmp(status, "fast"))
> + i2c->fast_mode = 1;
This would be easier if you made it an empty "mrvl,i2c-fast-mode"
property to get rid of the strcmp.
> + *i2c_types = ((u32)(of_id->data) - (u32)&pxa_reg_layout[0])
> + / sizeof(struct pxa_reg_layout);
This looks unnecessarily complicated. Just put the enum into of_id->data
instead of the pointer, with a cast to unsigned long.
> + return 0;
> +}
> +#else
> +static int i2c_pxa_probe_dt(struct platform_device *pdev, struct pxa_i2c *i2c,
> + enum pxa_i2c_types *i2c_types)
> +{
> + return 1;
> +}
> +#endif
Again, no need for the #ifdef. Just add in the beginning
if (!of_id)
return 1;
And the rest will be optimized out without CONFIG_OF.
Arnd
next prev parent reply other threads:[~2012-03-01 10:01 UTC|newest]
Thread overview: 34+ messages / expand[flat|nested] mbox.gz Atom feed top
2012-03-01 6:10 [PATCH 0/8] ARM: mmp: support OF on pxa168 Haojian Zhuang
2012-03-01 6:10 ` Haojian Zhuang
2012-03-01 6:10 ` [PATCH 1/8] gpio: pxa: add OF support Haojian Zhuang
2012-03-01 6:10 ` Haojian Zhuang
2012-03-01 9:40 ` Arnd Bergmann
2012-03-01 9:40 ` Arnd Bergmann
2012-03-01 9:51 ` Arnd Bergmann
2012-03-01 9:51 ` Arnd Bergmann
2012-03-01 6:10 ` [PATCH 2/8] serial: " Haojian Zhuang
2012-03-01 6:10 ` Haojian Zhuang
2012-03-01 9:47 ` Arnd Bergmann
2012-03-01 9:47 ` Arnd Bergmann
2012-03-01 9:48 ` Russell King - ARM Linux
2012-03-01 9:48 ` Russell King - ARM Linux
2012-03-01 12:55 ` Haojian Zhuang
2012-03-01 12:55 ` Haojian Zhuang
2012-03-01 6:10 ` [PATCH 3/8] rtc: sa1100: " Haojian Zhuang
2012-03-01 6:10 ` Haojian Zhuang
2012-03-01 9:51 ` Arnd Bergmann
2012-03-01 9:51 ` Arnd Bergmann
2012-03-01 12:52 ` Haojian Zhuang
2012-03-01 12:52 ` Haojian Zhuang
2012-03-01 6:10 ` [PATCH 4/8] i2c: pxa: " Haojian Zhuang
2012-03-01 6:10 ` Haojian Zhuang
2012-03-01 10:01 ` Arnd Bergmann [this message]
2012-03-01 10:01 ` Arnd Bergmann
2012-03-01 6:10 ` [PATCH 5/8] ARM: mmp: enable rtc clk in pxa168 Haojian Zhuang
2012-03-01 6:10 ` Haojian Zhuang
2012-03-01 6:10 ` [PATCH 6/8] ARM: mmp: append OF support on pxa168 Haojian Zhuang
2012-03-01 6:10 ` Haojian Zhuang
2012-03-01 6:10 ` [PATCH 7/8] ARM: dts: append DTS file of pxa168 Haojian Zhuang
2012-03-01 6:10 ` Haojian Zhuang
2012-03-01 6:10 ` [PATCH 8/8] Document: devicetree: add OF documents for arch-mmp Haojian Zhuang
2012-03-01 6:10 ` Haojian Zhuang
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=201203011001.00289.arnd@arndb.de \
--to=arnd@arndb.de \
--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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.