From: Stefano Babic <sbabic@denx.de>
To: u-boot@lists.denx.de
Subject: [U-Boot] [PATCH] mx53loco: Remove unneeded 'retval' variable
Date: Thu, 27 Dec 2012 12:05:51 +0100 [thread overview]
Message-ID: <50DC2B8F.2030709@denx.de> (raw)
In-Reply-To: <20121227103505.40769200F7A@gemini.denx.de>
On 27/12/2012 11:35, Wolfgang Denk wrote:
> Dear Fabio Estevam,
>
Hi Wolfgang,
> In message <1356604017-9699-1-git-send-email-festevam@gmail.com> you wrote:
>> From: Fabio Estevam <fabio.estevam@freescale.com>
>>
>> commit c73368150 (pmic: Extend PMIC framework to support multiple instances
>> of PMIC devices) introduced an extra 'retval' variable, but this is not
>> necessary since we have already the variable 'ret' in place.
>>
>> So use 'ret' to store the return values from the pmic related calls and remove
>> 'retval'.
>>
>> Signed-off-by: Fabio Estevam <fabio.estevam@freescale.com>
>
> Hm...
>
> I think the hole error code handling is borked in this function.
>
> Assume you enter this branch:
>
> 349
> 350 if (!i2c_probe(CONFIG_SYS_DIALOG_PMIC_I2C_ADDR)) {
>
> This will set "ret":
>
> 361 ret = pmic_reg_write(p, DA9053_BUCKCORE_REG, val);
> 362
> 363 ret |= pmic_reg_read(p, DA9053_SUPPLY_REG, &val);
> ...
> 365 ret |= pmic_reg_write(p, DA9053_SUPPLY_REG, val);
> ...
> 368 ret |= pmic_reg_write(p, DA9053_BUCKPRO_REG, 0x62);
> 369 ret |= pmic_reg_write(p, DA9053_SUPPLY_REG, 0x62);
> 370 }
>
> Assume any of these calls returns an error condition.
>
> Now we enter the second branch:
>
> 371
> 372 if (!i2c_probe(CONFIG_SYS_FSL_PMIC_I2C_ADDR)) {
> ...
>
I think it relies on the fact that only one of the two PMICs is mounted
on the board. There are versions of the board with the Dialog PMIC, and
other versions with Frescale's. Worse it is, there is no easy way to
detect which version of the board is running.
However, only one of the two branch can run, because i2c_probe() fails
if the PMIC is not found.
> But here we will unconditionally set "ret", no matter what it
> contained before:
>
> 384 ret = pmic_reg_write(p, REG_SW_0, val);
Agree, but physically not possible, until Freescale decides to mount
both PMICs on the mx53loco...(but this is a nonsense)
Best regards,
Stefano Babic
--
=====================================================================
DENX Software Engineering GmbH, MD: Wolfgang Denk & Detlev Zundel
HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany
Phone: +49-8142-66989-53 Fax: +49-8142-66989-80 Email: sbabic at denx.de
=====================================================================
next prev parent reply other threads:[~2012-12-27 11:05 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2012-12-27 10:26 [U-Boot] [PATCH] mx53loco: Remove unneeded 'retval' variable Fabio Estevam
2012-12-27 10:35 ` Wolfgang Denk
2012-12-27 11:05 ` Stefano Babic [this message]
2012-12-27 11:14 ` Fabio Estevam
2012-12-27 19:27 ` Wolfgang Denk
2012-12-27 19:14 ` Wolfgang Denk
2012-12-28 8:18 ` Stefano Babic
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=50DC2B8F.2030709@denx.de \
--to=sbabic@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