public inbox for u-boot@lists.denx.de
 help / color / mirror / Atom feed
From: Heiko Schocher <hs@denx.de>
To: u-boot@lists.denx.de
Subject: [U-Boot] [PATCH] cmd_i2c.c: added command to read to memory
Date: Mon, 22 Feb 2010 10:01:00 +0100	[thread overview]
Message-ID: <4B8247CC.5070508@denx.de> (raw)
In-Reply-To: <20100222083531.CB118A87D18@gemini.denx.de>

Hello Wolfgang,

Wolfgang Denk schrieb:
> In message <4B8231FF.1050605@denx.de> you wrote:
>>> That way it becomes possible to test against a value and
>>> use that to influence the boot process.
>> Ah, I see, but again, if you read from an eeprom, use the eeprom
>> command.
> 
> The intention is to be able to read from / write to any I2C device,
> not only EEPROMs. For example, assume to read a time from a RTC, or a
> temperature from a DTT.

Ah, Ok.

>>> +	/*
>>> +	 * memaddr is the address where to store things in memory
>>> +	 */
>>> +	memaddr = (u_char *)simple_strtoul(argv[4], NULL, 16);
>> Please add a check, if it is a valid address (not NULL).
> 
> No such check should be added.
> 
> Note that 0 _is_ a valid address in many systems (for example, on all
> Power Architecture systems, 0 is the begin of the system RAM and can
> be read and written without problems).

Ups, yes, you are right!

>>> +	if (i2c_read(chip, devaddr, alen, memaddr, length) != 0)
>>> +	{
> 
> BTW: incorrect brace style.
> 
>>> +		puts ("Error reading the chip.\n");
>>> +		return 1;
>>> +	}
>>> +	return 0;
>>> +}
>> Hmm... and what is, if you read from an eeprom, and you cross pages?
>> You don;t get what you expect!
> 
> We are not talking about EEPROMs here. If you want to access EEPROMs,
> you can use the EEPROM command. The "i2c" command set is for low-level
> access to I2C devices, and you are supposed to know what you are
> doing.

Then it is Ok for me.

>>>  #define DISP_LINE_LEN	16
>>> @@ -1249,15 +1306,17 @@ int do_i2c(cmd_tbl_t * cmdtp, int flag, int argc, char *argv[])
>>>  	argv++;
>>>  
>>>  #if defined(CONFIG_I2C_MUX)
>>> -	if (!strncmp(argv[0], "bu", 2))
>>> +	if (!strcmp(argv[0], "bus", 3))
>>>  		return do_i2c_add_bus(cmdtp, flag, argc, argv);
>> Why this?
>>
>>>  #endif  /* CONFIG_I2C_MUX */
>>> -	if (!strncmp(argv[0], "sp", 2))
>>> +	if (!strncmp(argv[0], "speed", 5))
>>>  		return do_i2c_bus_speed(cmdtp, flag, argc, argv);
>> and this ... and all other?
> 
> Agreed - these changes are bogus. As Detlev pointed out, the
> subcommand handling should be reworked.

Ack.

>> While writting here, and your code is just a copy from "i2c md"
>> maybe you can just modify the i2c md command, to something like that:
>>
>> "i2c md {i2c_chip} {addr}{.0, .1, .2} {len} {memaddr}"
>>
>> If there is a "memaddr", the i2c md command don;t print the values,
>> but it writes them to the memaddr ...
> 
> This seems unlogical to me. First, this would cover only reading, but
> we also want to add support for writing. Second, what would "md" store
> to memory? The raw content or an ASCII hex dump of it? From the
> command name, it should store a hex dump - which is not what we are
> looking for.

Yep you are right, that was no good idea. Also the "len" argument
in the "i2c md" command is optional!

bye
Heiko
-- 
DENX Software Engineering GmbH,     MD: Wolfgang Denk & Detlev Zundel
HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany

  reply	other threads:[~2010-02-22  9:01 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2010-02-20 11:14 [U-Boot] [PATCH] cmd_i2c.c: added command to read to memory Frans Meulenbroeks
2010-02-22  7:27 ` Heiko Schocher
2010-02-22  8:35   ` Wolfgang Denk
2010-02-22  9:01     ` Heiko Schocher [this message]
2010-02-22 11:05 ` Detlev Zundel

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=4B8247CC.5070508@denx.de \
    --to=hs@denx.de \
    --cc=u-boot@lists.denx.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox