All of lore.kernel.org
 help / color / mirror / Atom feed
From: Anton Vorontsov <avorontsov@ru.mvista.com>
To: Wolfram Sang <w.sang@pengutronix.de>
Cc: linuxppc-dev@ozlabs.org, devicetree-discuss@ozlabs.org,
	linux-i2c@vger.kernel.org
Subject: Re: [RFC] misc/at24: add experimental OF support for the generic eeprom driver
Date: Thu, 8 Oct 2009 18:33:01 +0400	[thread overview]
Message-ID: <20091008143301.GA6084@oksana.dev.rtsoft.ru> (raw)
In-Reply-To: <1255010672-21656-1-git-send-email-w.sang@pengutronix.de>

On Thu, Oct 08, 2009 at 04:04:32PM +0200, Wolfram Sang wrote:
> As Anton introduced archdata support, I wondered if this is a suitable way to
> handle the platform_data/devicetree_property-dualism (at least for some
> drivers).

Yes, we handle OF in a similar way for mmc_spi driver. Though,

[...]
> --- a/drivers/misc/eeprom/at24.c
> +++ b/drivers/misc/eeprom/at24.c
> @@ -22,6 +22,9 @@
[...]
> +#ifdef CONFIG_OF_I2C
> +#include <linux/of.h>
> +#endif
[..]
> +#ifdef CONFIG_OF_I2C
> +static void at24_get_ofdata(struct i2c_client *client, struct at24_platform_data *chip)
> +{
> +	const u32 *val;
> +	struct device_node *node = dev_archdata_get_node(&client->dev.archdata);
> +
> +	if (node) {
> +		if (of_get_property(node, "read-only", NULL))
> +			chip->flags |= AT24_FLAG_READONLY;
> +		val = of_get_property(node, "pagesize", NULL);
> +		if (val)
> +			chip->page_size = *val;
> +	}
> +}
> +#else
> +static void at24_get_ofdata(struct i2c_client *client, struct at24_platform_data *chip)
> +{ }
> +#endif

#ifdefs are ugly in .c files. I'd suggest to move the OF code
into a separate file. As an example, see

commit 9c43df57910bbba540a6cb5c9132302a9ea5f41a
Author: Anton Vorontsov <avorontsov@ru.mvista.com>
Date:   Tue Dec 30 18:15:28 2008 +0300

    mmc_spi: Add support for OpenFirmware bindings

Thanks,

-- 
Anton Vorontsov
email: cbouatmailru@gmail.com
irc://irc.freenode.net/bd2

  reply	other threads:[~2009-10-08 14:33 UTC|newest]

Thread overview: 38+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2009-10-08 14:04 [RFC] misc/at24: add experimental OF support for the generic eeprom driver Wolfram Sang
2009-10-08 14:33 ` Anton Vorontsov [this message]
     [not found]   ` <20091008143301.GA6084-wnGakbxT3iijyJ0x5qLZdcN33GVbZNy3@public.gmane.org>
2009-10-08 14:53     ` Grant Likely
2009-10-08 14:53       ` Grant Likely
2009-10-08 15:10       ` Anton Vorontsov
2009-10-08 15:48         ` Grant Likely
2009-10-08 15:48           ` Grant Likely
2009-10-08 15:48           ` Grant Likely
2009-10-08 20:27           ` Wolfram Sang
2009-10-08 20:27             ` Wolfram Sang
2009-10-09  5:14             ` Wolfram Sang
2009-10-09  5:14               ` Wolfram Sang
     [not found]               ` <20091009051409.GA2361-bIcnvbaLZ9MEGnE8C9+IrQ@public.gmane.org>
2009-10-09  5:40                 ` Grant Likely
2009-10-09  5:40                   ` Grant Likely
2009-10-09  5:40                   ` Grant Likely
2009-10-09 14:01                   ` Nate Case
2009-10-09 14:01                     ` Nate Case
2009-10-09 16:09                     ` Grant Likely
2009-10-09 16:09                       ` Grant Likely
2009-10-09 16:09                       ` Grant Likely
2009-10-09 16:20                     ` Wolfram Sang
2009-10-09 16:20                       ` Wolfram Sang
2009-10-09 13:43               ` Nate Case
2009-10-09 16:12                 ` Wolfram Sang
2009-10-09 16:12                   ` Wolfram Sang
2009-10-09 16:13                 ` Grant Likely
2009-10-09 16:13                   ` Grant Likely
2009-10-09 16:13                   ` Grant Likely
     [not found]           ` <fa686aa40910080848r459c47baob73fc70a95a08604-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
2009-10-08 22:20             ` Anton Vorontsov
2009-10-08 22:20               ` Anton Vorontsov
2009-10-09  6:37               ` Grant Likely
2009-10-09  6:37                 ` Grant Likely
2009-10-09  6:37                 ` Grant Likely
2009-10-08 14:37 ` Grant Likely
     [not found]   ` <fa686aa40910080737l5b21654cw9c8f7426f9faf7c3-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
2009-10-08 20:48     ` Wolfram Sang
2009-10-08 20:48       ` Wolfram Sang
     [not found]       ` <20091008204808.GB8116-bIcnvbaLZ9MEGnE8C9+IrQ@public.gmane.org>
2009-10-08 22:59         ` Grant Likely
2009-10-08 22:59           ` Grant Likely

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=20091008143301.GA6084@oksana.dev.rtsoft.ru \
    --to=avorontsov@ru.mvista.com \
    --cc=devicetree-discuss@ozlabs.org \
    --cc=linux-i2c@vger.kernel.org \
    --cc=linuxppc-dev@ozlabs.org \
    --cc=w.sang@pengutronix.de \
    /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.