From mboxrd@z Thu Jan 1 00:00:00 1970 From: Hans de Goede Date: Wed, 14 Jan 2015 09:21:09 +0100 Subject: [U-Boot] [PATCH 01/17] sunxi: axp221: Protect axp221_init against multiple calls In-Reply-To: <1421174943.18322.0.camel@hellion.org.uk> References: <1421004895-10896-1-git-send-email-hdegoede@redhat.com> <1421004895-10896-2-git-send-email-hdegoede@redhat.com> <1421174943.18322.0.camel@hellion.org.uk> Message-ID: <54B626F5.4010605@redhat.com> List-Id: MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit To: u-boot@lists.denx.de Hi, On 13-01-15 19:49, Ian Campbell wrote: > On Sun, 2015-01-11 at 20:34 +0100, Hans de Goede wrote: >> The voltage setting code knows it needs to call axp221_init before calling >> the various voltage setting functions. >> >> But users of axp utility functions like axp221_get_sid() do not know this, >> so the utility functions always call axp221_init() to ensure that the >> p2wi / rsb setup magic has been done. >> >> Since doing this repeatedly is quite expensive, add a check to axp221_init >> so that it only does the initialization once. >> >> Signed-off-by: Hans de Goede > Acked-by: Ian Campbell Thanks for the reviews. I've queued up the first 5 patches of this series in u-boot-sunxi/next. I'll likely send a pull-req with everything we've in next later today. Regards, Hans > >> --- >> drivers/power/axp221.c | 6 ++++++ >> 1 file changed, 6 insertions(+) >> >> diff --git a/drivers/power/axp221.c b/drivers/power/axp221.c >> index 1fda19a..728727b 100644 >> --- a/drivers/power/axp221.c >> +++ b/drivers/power/axp221.c >> @@ -304,9 +304,14 @@ int axp221_set_aldo3(unsigned int mvolt) >> >> int axp221_init(void) >> { >> + /* This cannot be 0 because it is used in SPL before BSS is ready */ >> + static int needs_init = 1; >> u8 axp_chip_id; >> int ret; >> >> + if (!needs_init) >> + return 0; >> + >> ret = pmic_bus_init(); >> if (ret) >> return ret; >> @@ -318,6 +323,7 @@ int axp221_init(void) >> if (!(axp_chip_id == 0x6 || axp_chip_id == 0x7 || axp_chip_id == 0x17)) >> return -ENODEV; >> >> + needs_init = 0; >> return 0; >> } >> > >