|
@@ -43,7 +43,7 @@ static int _MCP7940_get_date_time(struct file *pf, struct tm *ptm)
|
|
|
int ret;
|
|
|
unsigned char rtc[7];
|
|
|
|
|
|
- if((ret = TivaCmdGetI2C(pf, _I2C_SLV_ADDR_MCP7940, 0, sizeof(rtc), rtc, sizeof(rtc))) > 0)
|
|
|
+ if(!(ret = TivaCmdGetI2C(pf, _I2C_SLV_ADDR_MCP7940, 0, sizeof(rtc), rtc, sizeof(rtc))))
|
|
|
{
|
|
|
if(_IS_MCP7940_OSC_RUN(rtc[3]))
|
|
|
{
|
|
@@ -117,7 +117,7 @@ static int _MCP7940_set_date_time(struct file *pf, const struct tm *ptm)
|
|
|
|
|
|
do
|
|
|
{
|
|
|
- if((ret = TivaCmdGetI2C(pf, _I2C_SLV_ADDR_MCP7940, 3, 1, ®, 1)) <= 0) // read register 3
|
|
|
+ if((ret = TivaCmdGetI2C(pf, _I2C_SLV_ADDR_MCP7940, 3, 1, ®, 1))) // read register 3
|
|
|
{
|
|
|
KALERT("%s: TivaCmdGetI2C failed (%d)\n", __FUNCTION__, ret);
|
|
|
return -EIO;
|
|
@@ -178,7 +178,7 @@ static int _MCP7940_test_i2c(struct file *pf)
|
|
|
return -EIO;
|
|
|
}
|
|
|
|
|
|
- if(!(ret = TivaCmdGetI2C(pf, _I2C_SLV_ADDR_MCP7940, _MCP7940_SRAM_ADDRESS, sizeof(read), read, sizeof(read))) <= 0)
|
|
|
+ if((ret = TivaCmdGetI2C(pf, _I2C_SLV_ADDR_MCP7940, _MCP7940_SRAM_ADDRESS, sizeof(read), read, sizeof(read))))
|
|
|
{
|
|
|
KALERT("%s: TivaCmdGetI2C failed (%d)\n", __FUNCTION__, ret);
|
|
|
return -EIO;
|
|
@@ -209,7 +209,7 @@ static int _DS3231_get_date_time(struct file *pf, struct tm *ptm)
|
|
|
int ret;
|
|
|
unsigned char rtc[16];
|
|
|
|
|
|
- if((ret = TivaCmdGetI2C(pf, _I2C_SLV_ADDR_DS3231, 0, sizeof(rtc), rtc, sizeof(rtc))) > 0)
|
|
|
+ if(!(ret = TivaCmdGetI2C(pf, _I2C_SLV_ADDR_DS3231, 0, sizeof(rtc), rtc, sizeof(rtc))))
|
|
|
{
|
|
|
if(_IS_DS3231_OSC_RUN(rtc[15]))
|
|
|
{
|
|
@@ -256,13 +256,13 @@ static int _DS3231_set_date_time(struct file *pf, const struct tm *ptm)
|
|
|
y = ptm->tm_year - 100;
|
|
|
m = ptm->tm_mon + 1;
|
|
|
|
|
|
- rtc[0] = _BIN2BCD(ptm->tm_sec); // seconds
|
|
|
- rtc[1] = _BIN2BCD(ptm->tm_min); // minutes
|
|
|
+ rtc[0] = _BIN2BCD(ptm->tm_sec); // seconds
|
|
|
+ rtc[1] = _BIN2BCD(ptm->tm_min); // minutes
|
|
|
rtc[2] = _BIN2BCD(ptm->tm_hour); // hour, uses 24h format
|
|
|
- rtc[3] = (ptm->tm_wday + 1); // DS3231 day of week is in range 1-7, struct tm is in range 0-6 (start with Sunday).
|
|
|
+ rtc[3] = (ptm->tm_wday + 1); // DS3231 day of week is in range 1-7, struct tm is in range 0-6 (start with Sunday).
|
|
|
rtc[4] = _BIN2BCD(ptm->tm_mday); // day
|
|
|
- rtc[5] = _BIN2BCD(m); // month
|
|
|
- rtc[6] = _BIN2BCD(y); // year
|
|
|
+ rtc[5] = _BIN2BCD(m); // month
|
|
|
+ rtc[6] = _BIN2BCD(y); // year
|
|
|
|
|
|
/////////////////////////////////////////////////////////////////////////
|
|
|
// write registers 0-6 (Seconds to Year)
|
|
@@ -271,14 +271,14 @@ static int _DS3231_set_date_time(struct file *pf, const struct tm *ptm)
|
|
|
|
|
|
if((ret = TivaCmdSetI2C(pf, _I2C_SLV_ADDR_DS3231, 0, rtc, sizeof(rtc))))
|
|
|
{
|
|
|
- KALERT("%s: TivaCmdSetI2C without failed (%d)\n", __FUNCTION__, ret);
|
|
|
+ KALERT("%s: TivaCmdSetI2C failed (%d)\n", __FUNCTION__, ret);
|
|
|
return -EIO;
|
|
|
}
|
|
|
|
|
|
/////////////////////////////////////////////////////////////////////////
|
|
|
// read/write register 15 (Status Register), to clear the OSF flag.
|
|
|
|
|
|
- if((ret = TivaCmdGetI2C(pf, _I2C_SLV_ADDR_DS3231, 15, 1, ®, 1)) > 0) // read register 15
|
|
|
+ if((ret = TivaCmdGetI2C(pf, _I2C_SLV_ADDR_DS3231, 15, 1, ®, 1))) // read register 15
|
|
|
{
|
|
|
reg &= 0x7F; // clear OSF bit.
|
|
|
|
|
@@ -312,7 +312,7 @@ int krtc_init(void)
|
|
|
{
|
|
|
unsigned char rtc[7];
|
|
|
|
|
|
- if((ret = TivaCmdGetI2C(pfSpiDev, _I2C_SLV_ADDR_MCP7940, 0, sizeof(rtc), rtc, sizeof(rtc))) > 0) // MCP7940
|
|
|
+ if(!(ret = TivaCmdGetI2C(pfSpiDev, _I2C_SLV_ADDR_MCP7940, 0, sizeof(rtc), rtc, sizeof(rtc)))) // MCP7940
|
|
|
{
|
|
|
for(i = 0; i < 7; ++i)
|
|
|
{
|
|
@@ -325,7 +325,7 @@ int krtc_init(void)
|
|
|
|
|
|
if(g_rtcType == RTCT_Unknown)
|
|
|
{
|
|
|
- if((ret = TivaCmdGetI2C(pfSpiDev, _I2C_SLV_ADDR_DS3231, 0, sizeof(rtc), rtc, sizeof(rtc))) > 0) // DS3231
|
|
|
+ if(!(ret = TivaCmdGetI2C(pfSpiDev, _I2C_SLV_ADDR_DS3231, 0, sizeof(rtc), rtc, sizeof(rtc)))) // DS3231
|
|
|
{
|
|
|
for(i = 0; i < 7; ++i)
|
|
|
{
|