mail archive of the barebox mailing list
 help / color / mirror / Atom feed
From: Sascha Hauer <s.hauer@pengutronix.de>
To: Marc Reilly <marc@cpdesign.com.au>
Cc: barebox@lists.infradead.org
Subject: Re: [PATCH 4/5] at24: add I2C eeprom for 24cl02
Date: Mon, 16 Jul 2012 09:49:37 +0200	[thread overview]
Message-ID: <20120716074937.GA30009@pengutronix.de> (raw)
In-Reply-To: <1342400699-6753-5-git-send-email-marc@cpdesign.com.au>

On Mon, Jul 16, 2012 at 11:04:58AM +1000, Marc Reilly wrote:
> This series adds a driver for at24 eeproms. Much of the guts of the code
> is taken from the at24 driver in the linux kernel.
> 
> Signed-off-by: Marc Reilly <marc@cpdesign.com.au>
> ---
>  drivers/eeprom/Kconfig  |    7 +++
>  drivers/eeprom/Makefile |    1 +
>  drivers/eeprom/at24.c   |  134 +++++++++++++++++++++++++++++++++++++++++++++++
>  3 files changed, 142 insertions(+), 0 deletions(-)
>  create mode 100644 drivers/eeprom/at24.c
> 
> diff --git a/drivers/eeprom/Kconfig b/drivers/eeprom/Kconfig
> index a0b5489..56dfd1a 100644
> --- a/drivers/eeprom/Kconfig
> +++ b/drivers/eeprom/Kconfig
> @@ -8,4 +8,11 @@ config EEPROM_AT25
>  	  after you configure the board init code to know about each eeprom
>  	  on your target board.
>  
> +config EEPROM_AT24
> +	bool "at24 based eeprom"
> +	depends on I2C
> +	help
> +	  Provides read/write for the at24 family of I2C EEPROMS.
> +	  Currently only the 2K bit versions are supported.
> +	  

Trailing whitespace here.

> +{
> +	struct at24 *priv = to_at24(cdev);
> +	const u8 *buf = _buf;
> +	const int maxwrite = 8;
> +	int numtowrite;
> +	ssize_t numwritten = 0;
> +
> +	while (count) {
> +		int ret;
> +
> +		numtowrite = count;
> +		if (numtowrite > maxwrite)
> +			numtowrite = maxwrite;
> +
> +		ret = i2c_write_reg(priv->client, offset, buf, numtowrite);
> +		if (ret < 0)
> +			return (ssize_t)ret;
> +
> +		mdelay(10);

Do we need this? This makes the driver veeery slow. If we could poll
this somehow it would be much better.

> +
> +static int at24_init(void)
> +{
> +	register_driver(&at24_driver);
> +	return 0;

We can safely return the result of register_driver here. There was a
time when barebox paniced on a failed initcall, but this is not the case
anymore. Instead we have some debug output for failed initcalls which
seems more useful

Sascha


-- 
Pengutronix e.K.                           |                             |
Industrial Linux Solutions                 | http://www.pengutronix.de/  |
Peiner Str. 6-8, 31137 Hildesheim, Germany | Phone: +49-5121-206917-0    |
Amtsgericht Hildesheim, HRA 2686           | Fax:   +49-5121-206917-5555 |

_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox

  reply	other threads:[~2012-07-16  7:50 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-07-16  1:04 Various patches for imx35, fec, at24 driver and misc Marc Reilly
2012-07-16  1:04 ` [PATCH 1/5] imx_fec: Allow driver clients to supply MAC address Marc Reilly
2012-07-16  7:43   ` Sascha Hauer
2012-07-16  1:04 ` [PATCH 2/5] imx35: 6-bit divider helper Marc Reilly
2012-07-16  1:04 ` [PATCH 3/5] imx35: mmc clock has 6 bit divider, not 3_3 Marc Reilly
2012-07-16  1:04 ` [PATCH 4/5] at24: add I2C eeprom for 24cl02 Marc Reilly
2012-07-16  7:49   ` Sascha Hauer [this message]
2012-07-16  1:04 ` [PATCH 5/5] misc: new driver: isl22316 digital potentiometer Marc Reilly

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=20120716074937.GA30009@pengutronix.de \
    --to=s.hauer@pengutronix.de \
    --cc=barebox@lists.infradead.org \
    --cc=marc@cpdesign.com.au \
    /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