From: Wolfgang Denk Date: Mon, 02 May 2011 21:08:42 +0200 Subject: [U-Boot] [PATCH] sntp: fix problems at setting RTC at multi-bus I2C systems In-Reply-To: References: Message-ID: <20110502190842.936821518A8@gemini.denx.de> List-Id: MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit To: u-boot@lists.denx.de Dear =?iso-8859-1?Q?Tr=FCbenbach=2C_Ralf?=, In message you wrote: > Setting the RTC via SNTP did not work if the current I2C bus no. is > different from the bus no. the RTC is connected to. > > Signed-off-by: Ralf Tr=FCbenbach > --- > I don't like that I have to include the I2C things into sntp.c. Right, this is totally the wrong place. > But changing the rtc_set() function in 20 RTC drivers I don't > like, too. But that's where such code belongs - probably not into all of them, but into a single central locatioon. > index 76c10ec..7eee0db 100644 > --- a/net/sntp.c > +++ b/net/sntp.c > @@ -9,6 +9,9 @@ > #include > #include > #include > +#if defined(CONFIG_CMD_DATE) > +#include > +#endif This also makes little sense - what if the RTC is not I2C, but bus attached? > - * As the RTC's used in U-Boot sepport second resolution only > + * As the RTC's used in U-Boot support second resolution only Unrelated changes must be submitted separately. > #if defined(CONFIG_CMD_DATE) > + /* switch to correct I2C bus */ > + old_bus = I2C_GET_BUS(); > + I2C_SET_BUS(CONFIG_SYS_RTC_BUS_NUM); > + > rtc_set (&tm); > + > + /* switch back to original I2C bus */ > + I2C_SET_BUS(old_bus); > #endif Totally wrong: wrong place, wrong dependeny. NAK. Best regards, Wolfgang Denk -- DENX Software Engineering GmbH, MD: Wolfgang Denk & Detlev Zundel HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany Phone: (+49)-8142-66989-10 Fax: (+49)-8142-66989-80 Email: wd at denx.de I often quote myself; it adds spice to my conversation. - G. B. Shaw