diff options
Diffstat (limited to 'drivers/rtc')
-rw-r--r-- | drivers/rtc/Kconfig | 5 | ||||
-rw-r--r-- | drivers/rtc/rtc-at91rm9200.c | 12 | ||||
-rw-r--r-- | drivers/rtc/rtc-at91sam9.c | 2 | ||||
-rw-r--r-- | drivers/rtc/rtc-bfin.c | 2 | ||||
-rw-r--r-- | drivers/rtc/rtc-ds1302.c | 2 | ||||
-rw-r--r-- | drivers/rtc/rtc-ds1511.c | 6 | ||||
-rw-r--r-- | drivers/rtc/rtc-ds1672.c | 14 | ||||
-rw-r--r-- | drivers/rtc/rtc-isl1208.c | 357 | ||||
-rw-r--r-- | drivers/rtc/rtc-max6900.c | 6 | ||||
-rw-r--r-- | drivers/rtc/rtc-max6902.c | 4 | ||||
-rw-r--r-- | drivers/rtc/rtc-pcf8563.c | 126 | ||||
-rw-r--r-- | drivers/rtc/rtc-pcf8583.c | 2 | ||||
-rw-r--r-- | drivers/rtc/rtc-proc.c | 8 | ||||
-rw-r--r-- | drivers/rtc/rtc-rs5c313.c | 4 | ||||
-rw-r--r-- | drivers/rtc/rtc-rs5c372.c | 18 | ||||
-rw-r--r-- | drivers/rtc/rtc-s3c.c | 6 | ||||
-rw-r--r-- | drivers/rtc/rtc-sh.c | 2 | ||||
-rw-r--r-- | drivers/rtc/rtc-sysfs.c | 12 | ||||
-rw-r--r-- | drivers/rtc/rtc-test.c | 8 | ||||
-rw-r--r-- | drivers/rtc/rtc-v3020.c | 4 | ||||
-rw-r--r-- | drivers/rtc/rtc-x1205.c | 170 |
21 files changed, 334 insertions, 436 deletions
diff --git a/drivers/rtc/Kconfig b/drivers/rtc/Kconfig index 02a4c8c..6cc2c03 100644 --- a/drivers/rtc/Kconfig +++ b/drivers/rtc/Kconfig @@ -20,10 +20,6 @@ menuconfig RTC_CLASS if RTC_CLASS -if GEN_RTC || RTC -comment "Conflicting RTC option has been selected, check GEN_RTC and RTC" -endif - config RTC_HCTOSYS bool "Set system time from RTC on startup and resume" depends on RTC_CLASS = y @@ -304,6 +300,7 @@ comment "Platform RTC drivers" config RTC_DRV_CMOS tristate "PC-style 'CMOS'" depends on X86 || ALPHA || ARM || M32R || ATARI || PPC || MIPS + default y if X86 help Say "yes" here to get direct support for the real time clock found in every PC or ACPI-based system, and some other boards. diff --git a/drivers/rtc/rtc-at91rm9200.c b/drivers/rtc/rtc-at91rm9200.c index 52abffc8..39e64ab 100644 --- a/drivers/rtc/rtc-at91rm9200.c +++ b/drivers/rtc/rtc-at91rm9200.c @@ -83,7 +83,7 @@ static int at91_rtc_readtime(struct device *dev, struct rtc_time *tm) tm->tm_yday = rtc_year_days(tm->tm_mday, tm->tm_mon, tm->tm_year); tm->tm_year = tm->tm_year - 1900; - pr_debug("%s(): %4d-%02d-%02d %02d:%02d:%02d\n", __FUNCTION__, + pr_debug("%s(): %4d-%02d-%02d %02d:%02d:%02d\n", __func__, 1900 + tm->tm_year, tm->tm_mon, tm->tm_mday, tm->tm_hour, tm->tm_min, tm->tm_sec); @@ -97,7 +97,7 @@ static int at91_rtc_settime(struct device *dev, struct rtc_time *tm) { unsigned long cr; - pr_debug("%s(): %4d-%02d-%02d %02d:%02d:%02d\n", __FUNCTION__, + pr_debug("%s(): %4d-%02d-%02d %02d:%02d:%02d\n", __func__, 1900 + tm->tm_year, tm->tm_mon, tm->tm_mday, tm->tm_hour, tm->tm_min, tm->tm_sec); @@ -142,7 +142,7 @@ static int at91_rtc_readalarm(struct device *dev, struct rtc_wkalrm *alrm) alrm->enabled = (at91_sys_read(AT91_RTC_IMR) & AT91_RTC_ALARM) ? 1 : 0; - pr_debug("%s(): %4d-%02d-%02d %02d:%02d:%02d\n", __FUNCTION__, + pr_debug("%s(): %4d-%02d-%02d %02d:%02d:%02d\n", __func__, 1900 + tm->tm_year, tm->tm_mon, tm->tm_mday, tm->tm_hour, tm->tm_min, tm->tm_sec); @@ -178,7 +178,7 @@ static int at91_rtc_setalarm(struct device *dev, struct rtc_wkalrm *alrm) if (alrm->enabled) at91_sys_write(AT91_RTC_IER, AT91_RTC_ALARM); - pr_debug("%s(): %4d-%02d-%02d %02d:%02d:%02d\n", __FUNCTION__, + pr_debug("%s(): %4d-%02d-%02d %02d:%02d:%02d\n", __func__, at91_alarm_year, tm.tm_mon, tm.tm_mday, tm.tm_hour, tm.tm_min, tm.tm_sec); @@ -193,7 +193,7 @@ static int at91_rtc_ioctl(struct device *dev, unsigned int cmd, { int ret = 0; - pr_debug("%s(): cmd=%08x, arg=%08lx.\n", __FUNCTION__, cmd, arg); + pr_debug("%s(): cmd=%08x, arg=%08lx.\n", __func__, cmd, arg); switch (cmd) { case RTC_AIE_OFF: /* alarm off */ @@ -265,7 +265,7 @@ static irqreturn_t at91_rtc_interrupt(int irq, void *dev_id) rtc_update_irq(rtc, 1, events); - pr_debug("%s(): num=%ld, events=0x%02lx\n", __FUNCTION__, + pr_debug("%s(): num=%ld, events=0x%02lx\n", __func__, events >> 8, events & 0x000000FF); return IRQ_HANDLED; diff --git a/drivers/rtc/rtc-at91sam9.c b/drivers/rtc/rtc-at91sam9.c index 56728a2..38d8742 100644 --- a/drivers/rtc/rtc-at91sam9.c +++ b/drivers/rtc/rtc-at91sam9.c @@ -288,7 +288,7 @@ static irqreturn_t at91_rtc_interrupt(int irq, void *_rtc) rtc_update_irq(rtc->rtcdev, 1, events); - pr_debug("%s: num=%ld, events=0x%02lx\n", __FUNCTION__, + pr_debug("%s: num=%ld, events=0x%02lx\n", __func__, events >> 8, events & 0x000000FF); return IRQ_HANDLED; diff --git a/drivers/rtc/rtc-bfin.c b/drivers/rtc/rtc-bfin.c index 4f28045..8624f55 100644 --- a/drivers/rtc/rtc-bfin.c +++ b/drivers/rtc/rtc-bfin.c @@ -419,7 +419,7 @@ static int __devinit bfin_rtc_probe(struct platform_device *pdev) return -ENOMEM; rtc->rtc_dev = rtc_device_register(pdev->name, &pdev->dev, &bfin_rtc_ops, THIS_MODULE); - if (unlikely(IS_ERR(rtc))) { + if (IS_ERR(rtc)) { ret = PTR_ERR(rtc->rtc_dev); goto err; } diff --git a/drivers/rtc/rtc-ds1302.c b/drivers/rtc/rtc-ds1302.c index 7b002ce..b939781 100644 --- a/drivers/rtc/rtc-ds1302.c +++ b/drivers/rtc/rtc-ds1302.c @@ -122,7 +122,7 @@ static int ds1302_rtc_read_time(struct device *dev, struct rtc_time *tm) dev_dbg(dev, "%s: tm is secs=%d, mins=%d, hours=%d, " "mday=%d, mon=%d, year=%d, wday=%d\n", - __FUNCTION__, + __func__, tm->tm_sec, tm->tm_min, tm->tm_hour, tm->tm_mday, tm->tm_mon + 1, tm->tm_year, tm->tm_wday); diff --git a/drivers/rtc/rtc-ds1511.c b/drivers/rtc/rtc-ds1511.c index d08912f..a83a40b 100644 --- a/drivers/rtc/rtc-ds1511.c +++ b/drivers/rtc/rtc-ds1511.c @@ -181,8 +181,7 @@ ds1511_wdog_disable(void) * stupidly, some callers call with year unmolested; * and some call with year = year - 1900. thanks. */ - int -ds1511_rtc_set_time(struct device *dev, struct rtc_time *rtc_tm) +static int ds1511_rtc_set_time(struct device *dev, struct rtc_time *rtc_tm) { u8 mon, day, dow, hrs, min, sec, yrs, cen; unsigned int flags; @@ -245,8 +244,7 @@ ds1511_rtc_set_time(struct device *dev, struct rtc_time *rtc_tm) return 0; } - int -ds1511_rtc_read_time(struct device *dev, struct rtc_time *rtc_tm) +static int ds1511_rtc_read_time(struct device *dev, struct rtc_time *rtc_tm) { unsigned int century; unsigned int flags; diff --git a/drivers/rtc/rtc-ds1672.c b/drivers/rtc/rtc-ds1672.c index e0900ca..6fa4556 100644 --- a/drivers/rtc/rtc-ds1672.c +++ b/drivers/rtc/rtc-ds1672.c @@ -50,13 +50,13 @@ static int ds1672_get_datetime(struct i2c_client *client, struct rtc_time *tm) /* read date registers */ if ((i2c_transfer(client->adapter, &msgs[0], 2)) != 2) { - dev_err(&client->dev, "%s: read error\n", __FUNCTION__); + dev_err(&client->dev, "%s: read error\n", __func__); return -EIO; } dev_dbg(&client->dev, "%s: raw read data - counters=%02x,%02x,%02x,%02x\n", - __FUNCTION__, buf[0], buf[1], buf[2], buf[3]); + __func__, buf[0], buf[1], buf[2], buf[3]); time = (buf[3] << 24) | (buf[2] << 16) | (buf[1] << 8) | buf[0]; @@ -64,7 +64,7 @@ static int ds1672_get_datetime(struct i2c_client *client, struct rtc_time *tm) dev_dbg(&client->dev, "%s: tm is secs=%d, mins=%d, hours=%d, " "mday=%d, mon=%d, year=%d, wday=%d\n", - __FUNCTION__, tm->tm_sec, tm->tm_min, tm->tm_hour, + __func__, tm->tm_sec, tm->tm_min, tm->tm_hour, tm->tm_mday, tm->tm_mon, tm->tm_year, tm->tm_wday); return 0; @@ -84,7 +84,7 @@ static int ds1672_set_mmss(struct i2c_client *client, unsigned long secs) xfer = i2c_master_send(client, buf, 6); if (xfer != 6) { - dev_err(&client->dev, "%s: send: %d\n", __FUNCTION__, xfer); + dev_err(&client->dev, "%s: send: %d\n", __func__, xfer); return -EIO; } @@ -98,7 +98,7 @@ static int ds1672_set_datetime(struct i2c_client *client, struct rtc_time *tm) dev_dbg(&client->dev, "%s: secs=%d, mins=%d, hours=%d, " "mday=%d, mon=%d, year=%d, wday=%d\n", - __FUNCTION__, + __func__, tm->tm_sec, tm->tm_min, tm->tm_hour, tm->tm_mday, tm->tm_mon, tm->tm_year, tm->tm_wday); @@ -133,7 +133,7 @@ static int ds1672_get_control(struct i2c_client *client, u8 *status) /* read control register */ if ((i2c_transfer(client->adapter, &msgs[0], 2)) != 2) { - dev_err(&client->dev, "%s: read error\n", __FUNCTION__); + dev_err(&client->dev, "%s: read error\n", __func__); return -EIO; } @@ -199,7 +199,7 @@ static int ds1672_probe(struct i2c_adapter *adapter, int address, int kind) struct i2c_client *client; struct rtc_device *rtc; - dev_dbg(&adapter->dev, "%s\n", __FUNCTION__); + dev_dbg(&adapter->dev, "%s\n", __func__); if (!i2c_check_functionality(adapter, I2C_FUNC_I2C)) { err = -ENODEV; diff --git a/drivers/rtc/rtc-isl1208.c b/drivers/rtc/rtc-isl1208.c index 725b0c7..fb15e3f 100644 --- a/drivers/rtc/rtc-isl1208.c +++ b/drivers/rtc/rtc-isl1208.c @@ -15,16 +15,15 @@ #include <linux/bcd.h> #include <linux/rtc.h> -#define DRV_NAME "isl1208" -#define DRV_VERSION "0.2" +#define DRV_VERSION "0.3" /* Register map */ /* rtc section */ #define ISL1208_REG_SC 0x00 #define ISL1208_REG_MN 0x01 #define ISL1208_REG_HR 0x02 -#define ISL1208_REG_HR_MIL (1<<7) /* 24h/12h mode */ -#define ISL1208_REG_HR_PM (1<<5) /* PM/AM bit in 12h mode */ +#define ISL1208_REG_HR_MIL (1<<7) /* 24h/12h mode */ +#define ISL1208_REG_HR_PM (1<<5) /* PM/AM bit in 12h mode */ #define ISL1208_REG_DT 0x03 #define ISL1208_REG_MO 0x04 #define ISL1208_REG_YR 0x05 @@ -33,14 +32,14 @@ /* control/status section */ #define ISL1208_REG_SR 0x07 -#define ISL1208_REG_SR_ARST (1<<7) /* auto reset */ -#define ISL1208_REG_SR_XTOSCB (1<<6) /* crystal oscillator */ -#define ISL1208_REG_SR_WRTC (1<<4) /* write rtc */ -#define ISL1208_REG_SR_ALM (1<<2) /* alarm */ -#define ISL1208_REG_SR_BAT (1<<1) /* battery */ -#define ISL1208_REG_SR_RTCF (1<<0) /* rtc fail */ +#define ISL1208_REG_SR_ARST (1<<7) /* auto reset */ +#define ISL1208_REG_SR_XTOSCB (1<<6) /* crystal oscillator */ +#define ISL1208_REG_SR_WRTC (1<<4) /* write rtc */ +#define ISL1208_REG_SR_ALM (1<<2) /* alarm */ +#define ISL1208_REG_SR_BAT (1<<1) /* battery */ +#define ISL1208_REG_SR_RTCF (1<<0) /* rtc fail */ #define ISL1208_REG_INT 0x08 -#define ISL1208_REG_09 0x09 /* reserved */ +#define ISL1208_REG_09 0x09 /* reserved */ #define ISL1208_REG_ATR 0x0a #define ISL1208_REG_DTR 0x0b @@ -58,39 +57,21 @@ #define ISL1208_REG_USR2 0x13 #define ISL1208_USR_SECTION_LEN 2 -/* i2c configuration */ -#define ISL1208_I2C_ADDR 0xde - -static const unsigned short normal_i2c[] = { - ISL1208_I2C_ADDR>>1, I2C_CLIENT_END -}; -I2C_CLIENT_INSMOD; /* defines addr_data */ - -static int isl1208_attach_adapter(struct i2c_adapter *adapter); -static int isl1208_detach_client(struct i2c_client *client); - -static struct i2c_driver isl1208_driver = { - .driver = { - .name = DRV_NAME, - }, - .id = I2C_DRIVERID_ISL1208, - .attach_adapter = &isl1208_attach_adapter, - .detach_client = &isl1208_detach_client, -}; +static struct i2c_driver isl1208_driver; /* block read */ static int isl1208_i2c_read_regs(struct i2c_client *client, u8 reg, u8 buf[], - unsigned len) + unsigned len) { u8 reg_addr[1] = { reg }; struct i2c_msg msgs[2] = { - { client->addr, client->flags, sizeof(reg_addr), reg_addr }, - { client->addr, client->flags | I2C_M_RD, len, buf } + {client->addr, 0, sizeof(reg_addr), reg_addr} + , + {client->addr, I2C_M_RD, len, buf} }; int ret; - BUG_ON(len == 0); BUG_ON(reg > ISL1208_REG_USR2); BUG_ON(reg + len > ISL1208_REG_USR2 + 1); @@ -103,15 +84,14 @@ isl1208_i2c_read_regs(struct i2c_client *client, u8 reg, u8 buf[], /* block write */ static int isl1208_i2c_set_regs(struct i2c_client *client, u8 reg, u8 const buf[], - unsigned len) + unsigned len) { u8 i2c_buf[ISL1208_REG_USR2 + 2]; struct i2c_msg msgs[1] = { - { client->addr, client->flags, len + 1, i2c_buf } + {client->addr, 0, len + 1, i2c_buf} }; int ret; - BUG_ON(len == 0); BUG_ON(reg > ISL1208_REG_USR2); BUG_ON(reg + len > ISL1208_REG_USR2 + 1); @@ -125,7 +105,8 @@ isl1208_i2c_set_regs(struct i2c_client *client, u8 reg, u8 const buf[], } /* simple check to see wether we have a isl1208 */ -static int isl1208_i2c_validate_client(struct i2c_client *client) +static int +isl1208_i2c_validate_client(struct i2c_client *client) { u8 regs[ISL1208_RTC_SECTION_LEN] = { 0, }; u8 zero_mask[ISL1208_RTC_SECTION_LEN] = { @@ -139,24 +120,29 @@ static int isl1208_i2c_validate_client(struct i2c_client *client) return ret; for (i = 0; i < ISL1208_RTC_SECTION_LEN; ++i) { - if (regs[i] & zero_mask[i]) /* check if bits are cleared */ + if (regs[i] & zero_mask[i]) /* check if bits are cleared */ return -ENODEV; } return 0; } -static int isl1208_i2c_get_sr(struct i2c_client *client) +static int +isl1208_i2c_get_sr(struct i2c_client *client) { - return i2c_smbus_read_byte_data(client, ISL1208_REG_SR) == -1 ? -EIO:0; + int sr = i2c_smbus_read_byte_data(client, ISL1208_REG_SR); + if (sr < 0) + return -EIO; + + return sr; } -static int isl1208_i2c_get_atr(struct i2c_client *client) +static int +isl1208_i2c_get_atr(struct i2c_client *client) { int atr = i2c_smbus_read_byte_data(client, ISL1208_REG_ATR); - if (atr < 0) - return -EIO; + return atr; /* The 6bit value in the ATR register controls the load * capacitance C_load * in steps of 0.25pF @@ -169,51 +155,54 @@ static int isl1208_i2c_get_atr(struct i2c_client *client) * */ - atr &= 0x3f; /* mask out lsb */ - atr ^= 1<<5; /* invert 6th bit */ - atr += 2*9; /* add offset of 4.5pF; unit[atr] = 0.25pF */ + atr &= 0x3f; /* mask out lsb */ + atr ^= 1 << 5; /* invert 6th bit */ + atr += 2 * 9; /* add offset of 4.5pF; unit[atr] = 0.25pF */ return atr; } -static int isl1208_i2c_get_dtr(struct i2c_client *client) +static int +isl1208_i2c_get_dtr(struct i2c_client *client) { int dtr = i2c_smbus_read_byte_data(client, ISL1208_REG_DTR); - if (dtr < 0) return -EIO; /* dtr encodes adjustments of {-60,-40,-20,0,20,40,60} ppm */ - dtr = ((dtr & 0x3) * 20) * (dtr & (1<<2) ? -1 : 1); + dtr = ((dtr & 0x3) * 20) * (dtr & (1 << 2) ? -1 : 1); return dtr; } -static int isl1208_i2c_get_usr(struct i2c_client *client) +static int +isl1208_i2c_get_usr(struct i2c_client *client) { u8 buf[ISL1208_USR_SECTION_LEN] = { 0, }; int ret; - ret = isl1208_i2c_read_regs (client, ISL1208_REG_USR1, buf, - ISL1208_USR_SECTION_LEN); + ret = isl1208_i2c_read_regs(client, ISL1208_REG_USR1, buf, + ISL1208_USR_SECTION_LEN); if (ret < 0) return ret; return (buf[1] << 8) | buf[0]; } -static int isl1208_i2c_set_usr(struct i2c_client *client, u16 usr) +static int +isl1208_i2c_set_usr(struct i2c_client *client, u16 usr) { u8 buf[ISL1208_USR_SECTION_LEN]; buf[0] = usr & 0xff; buf[1] = (usr >> 8) & 0xff; - return isl1208_i2c_set_regs (client, ISL1208_REG_USR1, buf, - ISL1208_USR_SECTION_LEN); + return isl1208_i2c_set_regs(client, ISL1208_REG_USR1, buf, + ISL1208_USR_SECTION_LEN); } -static int isl1208_rtc_proc(struct device *dev, struct seq_file *seq) +static int +isl1208_rtc_proc(struct device *dev, struct seq_file *seq) { struct i2c_client *const client = to_i2c_client(dev); int sr, dtr, atr, usr; @@ -230,20 +219,19 @@ static int isl1208_rtc_proc(struct device *dev, struct seq_file *seq) (sr & ISL1208_REG_SR_ALM) ? " ALM" : "", (sr & ISL1208_REG_SR_WRTC) ? " WRTC" : "", (sr & ISL1208_REG_SR_XTOSCB) ? " XTOSCB" : "", - (sr & ISL1208_REG_SR_ARST) ? " ARST" : "", - sr); + (sr & ISL1208_REG_SR_ARST) ? " ARST" : "", sr); seq_printf(seq, "batt_status\t: %s\n", (sr & ISL1208_REG_SR_RTCF) ? "bad" : "okay"); dtr = isl1208_i2c_get_dtr(client); - if (dtr >= 0 -1) + if (dtr >= 0 - 1) seq_printf(seq, "digital_trim\t: %d ppm\n", dtr); atr = isl1208_i2c_get_atr(client); if (atr >= 0) seq_printf(seq, "analog_trim\t: %d.%.2d pF\n", - atr>>2, (atr&0x3)*25); + atr >> 2, (atr & 0x3) * 25); usr = isl1208_i2c_get_usr(client); if (usr >= 0) @@ -252,9 +240,8 @@ static int isl1208_rtc_proc(struct device *dev, struct seq_file *seq) return 0; } - -static int isl1208_i2c_read_time(struct i2c_client *client, - struct rtc_time *tm) +static int +isl1208_i2c_read_time(struct i2c_client *client, struct rtc_time *tm) { int sr; u8 regs[ISL1208_RTC_SECTION_LEN] = { 0, }; @@ -274,27 +261,30 @@ static int isl1208_i2c_read_time(struct i2c_client *client, tm->tm_sec = BCD2BIN(regs[ISL1208_REG_SC]); tm->tm_min = BCD2BIN(regs[ISL1208_REG_MN]); - { /* HR field has a more complex interpretation */ + + /* HR field has a more complex interpretation */ + { const u8 _hr = regs[ISL1208_REG_HR]; - if (_hr & ISL1208_REG_HR_MIL) /* 24h format */ + if (_hr & ISL1208_REG_HR_MIL) /* 24h format */ tm->tm_hour = BCD2BIN(_hr & 0x3f); - else { // 12h format + else { + /* 12h format */ tm->tm_hour = BCD2BIN(_hr & 0x1f); - if (_hr & ISL1208_REG_HR_PM) /* PM flag set */ + if (_hr & ISL1208_REG_HR_PM) /* PM flag set */ tm->tm_hour += 12; } } tm->tm_mday = BCD2BIN(regs[ISL1208_REG_DT]); - tm->tm_mon = BCD2BIN(regs[ISL1208_REG_MO]) - 1; /* rtc starts at 1 */ + tm->tm_mon = BCD2BIN(regs[ISL1208_REG_MO]) - 1; /* rtc starts at 1 */ tm->tm_year = BCD2BIN(regs[ISL1208_REG_YR]) + 100; tm->tm_wday = BCD2BIN(regs[ISL1208_REG_DW]); return 0; } -static int isl1208_i2c_read_alarm(struct i2c_client *client, - struct rtc_wkalrm *alarm) +static int +isl1208_i2c_read_alarm(struct i2c_client *client, struct rtc_wkalrm *alarm) { struct rtc_time *const tm = &alarm->time; u8 regs[ISL1208_ALARM_SECTION_LEN] = { 0, }; @@ -307,7 +297,7 @@ static int isl1208_i2c_read_alarm(struct i2c_client *client, } sr = isl1208_i2c_read_regs(client, ISL1208_REG_SCA, regs, - ISL1208_ALARM_SECTION_LEN); + ISL1208_ALARM_SECTION_LEN); if (sr < 0) { dev_err(&client->dev, "%s: reading alarm section failed\n", __func__); @@ -315,23 +305,25 @@ static int isl1208_i2c_read_alarm(struct i2c_client *client, } /* MSB of each alarm register is an enable bit */ - tm->tm_sec = BCD2BIN(regs[ISL1208_REG_SCA-ISL1208_REG_SCA] & 0x7f); - tm->tm_min = BCD2BIN(regs[ISL1208_REG_MNA-ISL1208_REG_SCA] & 0x7f); - tm->tm_hour = BCD2BIN(regs[ISL1208_REG_HRA-ISL1208_REG_SCA] & 0x3f); - tm->tm_mday = BCD2BIN(regs[ISL1208_REG_DTA-ISL1208_REG_SCA] & 0x3f); - tm->tm_mon = BCD2BIN(regs[ISL1208_REG_MOA-ISL1208_REG_SCA] & 0x1f)-1; - tm->tm_wday = BCD2BIN(regs[ISL1208_REG_DWA-ISL1208_REG_SCA] & 0x03); + tm->tm_sec = BCD2BIN(regs[ISL1208_REG_SCA - ISL1208_REG_SCA] & 0x7f); + tm->tm_min = BCD2BIN(regs[ISL1208_REG_MNA - ISL1208_REG_SCA] & 0x7f); + tm->tm_hour = BCD2BIN(regs[ISL1208_REG_HRA - ISL1208_REG_SCA] & 0x3f); + tm->tm_mday = BCD2BIN(regs[ISL1208_REG_DTA - ISL1208_REG_SCA] & 0x3f); + tm->tm_mon = + BCD2BIN(regs[ISL1208_REG_MOA - ISL1208_REG_SCA] & 0x1f) - 1; + tm->tm_wday = BCD2BIN(regs[ISL1208_REG_DWA - ISL1208_REG_SCA] & 0x03); return 0; } -static int isl1208_rtc_read_time(struct device *dev, struct rtc_time *tm) +static int +isl1208_rtc_read_time(struct device *dev, struct rtc_time *tm) { return isl1208_i2c_read_time(to_i2c_client(dev), tm); } -static int isl1208_i2c_set_time(struct i2c_client *client, - struct rtc_time const *tm) +static int +isl1208_i2c_set_time(struct i2c_client *client, struct rtc_time const *tm) { int sr; u8 regs[ISL1208_RTC_SECTION_LEN] = { 0, }; @@ -353,7 +345,7 @@ static int isl1208_i2c_set_time(struct i2c_client *client, } /* set WRTC */ - sr = i2c_smbus_write_byte_data (client, ISL1208_REG_SR, + sr = i2c_smbus_write_byte_data(client, ISL1208_REG_SR, sr | ISL1208_REG_SR_WRTC); if (sr < 0) { dev_err(&client->dev, "%s: writing SR failed\n", __func__); @@ -369,7 +361,7 @@ static int isl1208_i2c_set_time(struct i2c_client *client, } /* clear WRTC again */ - sr = i2c_smbus_write_byte_data (client, ISL1208_REG_SR, + sr = i2c_smbus_write_byte_data(client, ISL1208_REG_SR, sr & ~ISL1208_REG_SR_WRTC); if (sr < 0) { dev_err(&client->dev, "%s: writing SR failed\n", __func__); @@ -380,70 +372,69 @@ static int isl1208_i2c_set_time(struct i2c_client *client, } -static int isl1208_rtc_set_time(struct device *dev, struct rtc_time *tm) +static int +isl1208_rtc_set_time(struct device *dev, struct rtc_time *tm) { return isl1208_i2c_set_time(to_i2c_client(dev), tm); } -static int isl1208_rtc_read_alarm(struct device *dev, struct rtc_wkalrm *alarm) +static int +isl1208_rtc_read_alarm(struct device *dev, struct rtc_wkalrm *alarm) { return isl1208_i2c_read_alarm(to_i2c_client(dev), alarm); } static const struct rtc_class_ops isl1208_rtc_ops = { - .proc = isl1208_rtc_proc, - .read_time = isl1208_rtc_read_time, - .set_time = isl1208_rtc_set_time, - .read_alarm = isl1208_rtc_read_alarm, - //.set_alarm = isl1208_rtc_set_alarm, + .proc = isl1208_rtc_proc, + .read_time = isl1208_rtc_read_time, + .set_time = isl1208_rtc_set_time, + .read_alarm = isl1208_rtc_read_alarm, + /*.set_alarm = isl1208_rtc_set_alarm, */ }; /* sysfs interface */ -static ssize_t isl1208_sysfs_show_atrim(struct device *dev, - struct device_attribute *attr, - char *buf) +static ssize_t +isl1208_sysfs_show_atrim(struct device *dev, + struct device_attribute *attr, char *buf) { - int atr; - - atr = isl1208_i2c_get_atr(to_i2c_client(dev)); + int atr = isl1208_i2c_get_atr(to_i2c_client(dev)); if (atr < 0) return atr; - return sprintf(buf, "%d.%.2d pF\n", atr>>2, (atr&0x3)*25); + return sprintf(buf, "%d.%.2d pF\n", atr >> 2, (atr & 0x3) * 25); } + static DEVICE_ATTR(atrim, S_IRUGO, isl1208_sysfs_show_atrim, NULL); -static ssize_t isl1208_sysfs_show_dtrim(struct device *dev, - struct device_attribute *attr, - char *buf) +static ssize_t +isl1208_sysfs_show_dtrim(struct device *dev, + struct device_attribute *attr, char *buf) { - int dtr; - - dtr = isl1208_i2c_get_dtr(to_i2c_client(dev)); + int dtr = isl1208_i2c_get_dtr(to_i2c_client(dev)); if (dtr < 0) return dtr; return sprintf(buf, "%d ppm\n", dtr); } + static DEVICE_ATTR(dtrim, S_IRUGO, isl1208_sysfs_show_dtrim, NULL); -static ssize_t isl1208_sysfs_show_usr(struct device *dev, - struct device_attribute *attr, - char *buf) +static ssize_t +isl1208_sysfs_show_usr(struct device *dev, + struct device_attribute *attr, char *buf) { - int usr; - - usr = isl1208_i2c_get_usr(to_i2c_client(dev)); + int usr = isl1208_i2c_get_usr(to_i2c_client(dev)); if (usr < 0) return usr; return sprintf(buf, "0x%.4x\n", usr); } -static ssize_t isl1208_sysfs_store_usr(struct device *dev, - struct device_attribute *attr, - const char *buf, size_t count) +static ssize_t +isl1208_sysfs_store_usr(struct device *dev, + struct device_attribute *attr, + const char *buf, size_t count) { int usr = -1; @@ -460,124 +451,116 @@ static ssize_t isl1208_sysfs_store_usr(struct device *dev, return isl1208_i2c_set_usr(to_i2c_client(dev), usr) ? -EIO : count; } + static DEVICE_ATTR(usr, S_IRUGO | S_IWUSR, isl1208_sysfs_show_usr, isl1208_sysfs_store_usr); static int -isl1208_probe(struct i2c_adapter *adapter, int addr, int kind) +isl1208_sysfs_register(struct device *dev) { - int rc = 0; - struct i2c_client *new_client = NULL; - struct rtc_device *rtc = NULL; + int err; + + err = device_create_file(dev, &dev_attr_atrim); + if (err) + return err; - if (!i2c_check_functionality(adapter, I2C_FUNC_I2C)) { - rc = -ENODEV; - goto failout; + err = device_create_file(dev, &dev_attr_dtrim); + if (err) { + device_remove_file(dev, &dev_attr_atrim); + return err; } - new_client = kzalloc(sizeof(struct i2c_client), GFP_KERNEL); - if (new_client == NULL) { - rc = -ENOMEM; - goto failout; + err = device_create_file(dev, &dev_attr_usr); + if (err) { + device_remove_file(dev, &dev_attr_atrim); + device_remove_file(dev, &dev_attr_dtrim); } - new_client->addr = addr; - new_client->adapter = adapter; - new_client->driver = &isl1208_driver; - new_client->flags = 0; - strcpy(new_client->name, DRV_NAME); + return 0; +} - if (kind < 0) { - rc = isl1208_i2c_validate_client(new_client); - if (rc < 0) - goto failout; - } +static int +isl1208_sysfs_unregister(struct device *dev) +{ + device_remove_file(dev, &dev_attr_atrim); + device_remove_file(dev, &dev_attr_atrim); + device_remove_file(dev, &dev_attr_usr); + + return 0; +} + +static int +isl1208_probe(struct i2c_client *client) +{ + int rc = 0; + struct rtc_device *rtc; - rc = i2c_attach_client(new_client); - if (rc < 0) - goto failout; + if (!i2c_check_functionality(client->adapter, I2C_FUNC_I2C)) + return -ENODEV; - dev_info(&new_client->dev, + if (isl1208_i2c_validate_client(client) < 0) + return -ENODEV; + + dev_info(&client->dev, "chip found, driver version " DRV_VERSION "\n"); rtc = rtc_device_register(isl1208_driver.driver.name, - &new_client->dev, - &isl1208_rtc_ops, THIS_MODULE); - - if (IS_ERR(rtc)) { - rc = PTR_ERR(rtc); - goto failout_detach; - } + &client->dev, &isl1208_rtc_ops, + THIS_MODULE); + if (IS_ERR(rtc)) + return PTR_ERR(rtc); - i2c_set_clientdata(new_client, rtc); + i2c_set_clientdata(client, rtc); - rc = isl1208_i2c_get_sr(new_client); + rc = isl1208_i2c_get_sr(client); if (rc < 0) { - dev_err(&new_client->dev, "reading status failed\n"); - goto failout_unregister; + dev_err(&client->dev, "reading status failed\n"); + goto exit_unregister; } if (rc & ISL1208_REG_SR_RTCF) - dev_warn(&new_client->dev, "rtc power failure detected, " + dev_warn(&client->dev, "rtc power failure detected, " "please set clock.\n"); - rc = device_create_file(&new_client->dev, &dev_attr_atrim); - if (rc < 0) - goto failout_unregister; - rc = device_create_file(&new_client->dev, &dev_attr_dtrim); - if (rc < 0) - goto failout_atrim; - rc = device_create_file(&new_client->dev, &dev_attr_usr); - if (rc < 0) - goto failout_dtrim; + rc = isl1208_sysfs_register(&client->dev); + if (rc) + goto exit_unregister; return 0; - failout_dtrim: - device_remove_file(&new_client->dev, &dev_attr_dtrim); - failout_atrim: - device_remove_file(&new_client->dev, &dev_attr_atrim); - failout_unregister: +exit_unregister: rtc_device_unregister(rtc); - failout_detach: - i2c_detach_client(new_client); - failout: - kfree(new_client); - return rc; -} -static int -isl1208_attach_adapter (struct i2c_adapter *adapter) -{ - return i2c_probe(adapter, &addr_data, isl1208_probe); + return rc; } static int -isl1208_detach_client(struct i2c_client *client) +isl1208_remove(struct i2c_client *client) { - int rc; - struct rtc_device *const rtc = i2c_get_clientdata(client); - - if (rtc) - rtc_device_unregister(rtc); /* do we need to kfree? */ - - rc = i2c_detach_client(client); - if (rc) - return rc; + struct rtc_device *rtc = i2c_get_clientdata(client); - kfree(client); + isl1208_sysfs_unregister(&client->dev); + rtc_device_unregister(rtc); return 0; } -/* module management */ +static struct i2c_driver isl1208_driver = { + .driver = { + .name = "rtc-isl1208", + }, + .probe = isl1208_probe, + .remove = isl1208_remove, +}; -static int __init isl1208_init(void) +static int __init +isl1208_init(void) { return i2c_add_driver(&isl1208_driver); } -static void __exit isl1208_exit(void) +static void __exit +isl1208_exit(void) { i2c_del_driver(&isl1208_driver); } diff --git a/drivers/rtc/rtc-max6900.c b/drivers/rtc/rtc-max6900.c index 7683412..ded3c0a 100644 --- a/drivers/rtc/rtc-max6900.c +++ b/drivers/rtc/rtc-max6900.c @@ -98,7 +98,7 @@ static int max6900_i2c_read_regs(struct i2c_client *client, u8 *buf) rc = i2c_transfer(client->adapter, msgs, ARRAY_SIZE(msgs)); if (rc != ARRAY_SIZE(msgs)) { dev_err(&client->dev, "%s: register read failed\n", - __FUNCTION__); + __func__); return -EIO; } return 0; @@ -150,7 +150,7 @@ static int max6900_i2c_write_regs(struct i2c_client *client, u8 const *buf) write_failed: dev_err(&client->dev, "%s: register write failed\n", - __FUNCTION__); + __func__); return -EIO; } @@ -214,7 +214,7 @@ static int max6900_i2c_clear_write_protect(struct i2c_client *client) rc = i2c_smbus_write_byte_data (client, MAX6900_REG_CONTROL_WRITE, 0); if (rc < 0) { dev_err(&client->dev, "%s: control register write failed\n", - __FUNCTION__); + __func__); return -EIO; } return 0; diff --git a/drivers/rtc/rtc-max6902.c b/drivers/rtc/rtc-max6902.c index 1f956dc..12f0310 100644 --- a/drivers/rtc/rtc-max6902.c +++ b/drivers/rtc/rtc-max6902.c @@ -140,7 +140,7 @@ static int max6902_get_datetime(struct device *dev, struct rtc_time *dt) dt->tm_year -= 1900; #ifdef MAX6902_DEBUG - printk("\n%s : Read RTC values\n",__FUNCTION__); + printk("\n%s : Read RTC values\n",__func__); printk("tm_hour: %i\n",dt->tm_hour); printk("tm_min : %i\n",dt->tm_min); printk("tm_sec : %i\n",dt->tm_sec); @@ -158,7 +158,7 @@ static int max6902_set_datetime(struct device *dev, struct rtc_time *dt) dt->tm_year = dt->tm_year+1900; #ifdef MAX6902_DEBUG - printk("\n%s : Setting RTC values\n",__FUNCTION__); + printk("\n%s : Setting RTC values\n",__func__); printk("tm_sec : %i\n",dt->tm_sec); printk("tm_min : %i\n",dt->tm_min); printk("tm_hour: %i\n",dt->tm_hour); diff --git a/drivers/rtc/rtc-pcf8563.c b/drivers/rtc/rtc-pcf8563.c index b3317fc..a41681d 100644 --- a/drivers/rtc/rtc-pcf8563.c +++ b/drivers/rtc/rtc-pcf8563.c @@ -18,17 +18,7 @@ #include <linux/bcd.h> #include <linux/rtc.h> -#define DRV_VERSION "0.4.2" - -/* Addresses to scan: none - * This chip cannot be reliably autodetected. An empty eeprom - * located at 0x51 will pass the validation routine due to - * the way the registers are implemented. - */ -static const unsigned short normal_i2c[] = { I2C_CLIENT_END }; - -/* Module parameters */ -I2C_CLIENT_INSMOD; +#define DRV_VERSION "0.4.3" #define PCF8563_REG_ST1 0x00 /* status */ #define PCF8563_REG_ST2 0x01 @@ -53,8 +43,10 @@ I2C_CLIENT_INSMOD; #define PCF8563_SC_LV 0x80 /* low voltage */ #define PCF8563_MO_C 0x80 /* century */ +static struct i2c_driver pcf8563_driver; + struct pcf8563 { - struct i2c_client client; + struct rtc_device *rtc; /* * The meaning of MO_C bit varies by the chip type. * From PCF8563 datasheet: this bit is toggled when the years @@ -72,16 +64,13 @@ struct pcf8563 { int c_polarity; /* 0: MO_C=1 means 19xx, otherwise MO_C=1 means 20xx */ }; -static int pcf8563_probe(struct i2c_adapter *adapter, int address, int kind); -static int pcf8563_detach(struct i2c_client *client); - /* * In the routines that deal directly with the pcf8563 hardware, we use * rtc_time -- month 0-11, hour 0-23, yr = calendar year-epoch. */ static int pcf8563_get_datetime(struct i2c_client *client, struct rtc_time *tm) { - struct pcf8563 *pcf8563 = container_of(client, struct pcf8563, client); + struct pcf8563 *pcf8563 = i2c_get_clientdata(client); unsigned char buf[13] = { PCF8563_REG_ST1 }; struct i2c_msg msgs[] = { @@ -91,7 +80,7 @@ static int pcf8563_get_datetime(struct i2c_client *client, struct rtc_time *tm) /* read registers */ if ((i2c_transfer(client->adapter, msgs, 2)) != 2) { - dev_err(&client->dev, "%s: read error\n", __FUNCTION__); + dev_err(&client->dev, "%s: read error\n", __func__); return -EIO; } @@ -102,7 +91,7 @@ static int pcf8563_get_datetime(struct i2c_client *client, struct rtc_time *tm) dev_dbg(&client->dev, "%s: raw data is st1=%02x, st2=%02x, sec=%02x, min=%02x, hr=%02x, " "mday=%02x, wday=%02x, mon=%02x, year=%02x\n", - __FUNCTION__, + __func__, buf[0], buf[1], buf[2], buf[3], buf[4], buf[5], buf[6], buf[7], buf[8]); @@ -123,7 +112,7 @@ static int pcf8563_get_datetime(struct i2c_client *client, struct rtc_time *tm) dev_dbg(&client->dev, "%s: tm is secs=%d, mins=%d, hours=%d, " "mday=%d, mon=%d, year=%d, wday=%d\n", - __FUNCTION__, + __func__, tm->tm_sec, tm->tm_min, tm->tm_hour, tm->tm_mday, tm->tm_mon, tm->tm_year, tm->tm_wday); @@ -138,13 +127,13 @@ static int pcf8563_get_datetime(struct i2c_client *client, struct rtc_time *tm) static int pcf8563_set_datetime(struct i2c_client *client, struct rtc_time *tm) { - struct pcf8563 *pcf8563 = container_of(client, struct pcf8563, client); + struct pcf8563 *pcf8563 = i2c_get_clientdata(client); int i, err; unsigned char buf[9]; dev_dbg(&client->dev, "%s: secs=%d, mins=%d, hours=%d, " "mday=%d, mon=%d, year=%d, wday=%d\n", - __FUNCTION__, + __func__, tm->tm_sec, tm->tm_min, tm->tm_hour, tm->tm_mday, tm->tm_mon, tm->tm_year, tm->tm_wday); @@ -174,7 +163,7 @@ static int pcf8563_set_datetime(struct i2c_client *client, struct rtc_time *tm) if (err != sizeof(data)) { dev_err(&client->dev, "%s: err=%d addr=%02x, data=%02x\n", - __FUNCTION__, err, data[0], data[1]); + __func__, err, data[0], data[1]); return -EIO; } }; @@ -219,7 +208,7 @@ static int pcf8563_validate_client(struct i2c_client *client) if (xfer != ARRAY_SIZE(msgs)) { dev_err(&client->dev, "%s: could not read register 0x%02X\n", - __FUNCTION__, pattern[i].reg); + __func__, pattern[i].reg); return -EIO; } @@ -231,7 +220,7 @@ static int pcf8563_validate_client(struct i2c_client *client) dev_dbg(&client->dev, "%s: pattern=%d, reg=%x, mask=0x%02x, min=%d, " "max=%d, value=%d, raw=0x%02X\n", - __FUNCTION__, i, pattern[i].reg, pattern[i].mask, + __func__, i, pattern[i].reg, pattern[i].mask, pattern[i].min, pattern[i].max, value, buf); @@ -257,100 +246,67 @@ static const struct rtc_class_ops pcf8563_rtc_ops = { .set_time = pcf8563_rtc_set_time, }; -static int pcf8563_attach(struct i2c_adapter *adapter) -{ - return i2c_probe(adapter, &addr_data, pcf8563_probe); -} - -static struct i2c_driver pcf8563_driver = { - .driver = { - .name = "pcf8563", - }, - .id = I2C_DRIVERID_PCF8563, - .attach_adapter = &pcf8563_attach, - .detach_client = &pcf8563_detach, -}; - -static int pcf8563_probe(struct i2c_adapter *adapter, int address, int kind) +static int pcf8563_probe(struct i2c_client *client) { struct pcf8563 *pcf8563; - struct i2c_client *client; - struct rtc_device *rtc; int err = 0; - dev_dbg(&adapter->dev, "%s\n", __FUNCTION__); + dev_dbg(&client->dev, "%s\n", __func__); - if (!i2c_check_functionality(adapter, I2C_FUNC_I2C)) { - err = -ENODEV; - goto exit; - } + if (!i2c_check_functionality(client->adapter, I2C_FUNC_I2C)) + return -ENODEV; - if (!(pcf8563 = kzalloc(sizeof(struct pcf8563), GFP_KERNEL))) { - err = -ENOMEM; - goto exit; - } - - client = &pcf8563->client; - client->addr = address; - client->driver = &pcf8563_driver; - client->adapter = adapter; - - strlcpy(client->name, pcf8563_driver.driver.name, I2C_NAME_SIZE); + pcf8563 = kzalloc(sizeof(struct pcf8563), GFP_KERNEL); + if (!pcf8563) + return -ENOMEM; /* Verify the chip is really an PCF8563 */ - if (kind < 0) { - if (pcf8563_validate_client(client) < 0) { - err = -ENODEV; - goto exit_kfree; - } - } - - /* Inform the i2c layer */ - if ((err = i2c_attach_client(client))) + if (pcf8563_validate_client(client) < 0) { + err = -ENODEV; goto exit_kfree; + } dev_info(&client->dev, "chip found, driver version " DRV_VERSION "\n"); - rtc = rtc_device_register(pcf8563_driver.driver.name, &client->dev, - &pcf8563_rtc_ops, THIS_MODULE); + pcf8563->rtc = rtc_device_register(pcf8563_driver.driver.name, + &client->dev, &pcf8563_rtc_ops, THIS_MODULE); - if (IS_ERR(rtc)) { - err = PTR_ERR(rtc); - goto exit_detach; + if (IS_ERR(pcf8563->rtc)) { + err = PTR_ERR(pcf8563->rtc); + goto exit_kfree; } - i2c_set_clientdata(client, rtc); + i2c_set_clientdata(client, pcf8563); return 0; -exit_detach: - i2c_detach_client(client); - exit_kfree: kfree(pcf8563); -exit: return err; } -static int pcf8563_detach(struct i2c_client *client) +static int pcf8563_remove(struct i2c_client *client) { - struct pcf8563 *pcf8563 = container_of(client, struct pcf8563, client); - int err; - struct rtc_device *rtc = i2c_get_clientdata(client); + struct pcf8563 *pcf8563 = i2c_get_clientdata(client); - if (rtc) - rtc_device_unregister(rtc); - - if ((err = i2c_detach_client(client))) - return err; + if (pcf8563->rtc) + rtc_device_unregister(pcf8563->rtc); kfree(pcf8563); return 0; } +static struct i2c_driver pcf8563_driver = { + .driver = { + .name = "rtc-pcf8563", + }, + .probe = pcf8563_probe, + .remove = pcf8563_remove, +}; + static int __init pcf8563_init(void) { return i2c_add_driver(&pcf8563_driver); diff --git a/drivers/rtc/rtc-pcf8583.c b/drivers/rtc/rtc-pcf8583.c index 8b39970..3d09d8f 100644 --- a/drivers/rtc/rtc-pcf8583.c +++ b/drivers/rtc/rtc-pcf8583.c @@ -15,7 +15,7 @@ #include <linux/i2c.h> #include <linux/slab.h> #include <linux/string.h> -#include <linux/mc146818rtc.h> +#include <linux/rtc.h> #include <linux/init.h> #include <linux/errno.h> #include <linux/bcd.h> diff --git a/drivers/rtc/rtc-proc.c b/drivers/rtc/rtc-proc.c index 8d300e6..0c6257a 100644 --- a/drivers/rtc/rtc-proc.c +++ b/drivers/rtc/rtc-proc.c @@ -108,12 +108,10 @@ void rtc_proc_add_device(struct rtc_device *rtc) if (rtc->id == 0) { struct proc_dir_entry *ent; - ent = create_proc_entry("driver/rtc", 0, NULL); - if (ent) { - ent->proc_fops = &rtc_proc_fops; + ent = proc_create_data("driver/rtc", 0, NULL, + &rtc_proc_fops, rtc); + if (ent) ent->owner = rtc->owner; - ent->data = rtc; - } } } diff --git a/drivers/rtc/rtc-rs5c313.c b/drivers/rtc/rtc-rs5c313.c index 664e89a..1c14d44 100644 --- a/drivers/rtc/rtc-rs5c313.c +++ b/drivers/rtc/rtc-rs5c313.c @@ -228,7 +228,7 @@ static int rs5c313_rtc_read_time(struct device *dev, struct rtc_time *tm) ndelay(700); /* CE:L */ if (cnt++ > 100) { - dev_err(dev, "%s: timeout error\n", __FUNCTION__); + dev_err(dev, "%s: timeout error\n", __func__); return -EIO; } } @@ -289,7 +289,7 @@ static int rs5c313_rtc_set_time(struct device *dev, struct rtc_time *tm) ndelay(700); /* CE:L */ if (cnt++ > 100) { - dev_err(dev, "%s: timeout error\n", __FUNCTION__); + dev_err(dev, "%s: timeout error\n", __func__); return -EIO; } } diff --git a/drivers/rtc/rtc-rs5c372.c b/drivers/rtc/rtc-rs5c372.c index 6b67b50..7e63074 100644 --- a/drivers/rtc/rtc-rs5c372.c +++ b/drivers/rtc/rtc-rs5c372.c @@ -99,7 +99,7 @@ static int rs5c_get_regs(struct rs5c372 *rs5c) * least 80219 chips; this works around that bug. */ if ((i2c_transfer(client->adapter, msgs, 1)) != 1) { - pr_debug("%s: can't read registers\n", rs5c->rtc->name); + dev_warn(&client->dev, "can't read registers\n"); return -EIO; } @@ -166,7 +166,7 @@ static int rs5c372_get_datetime(struct i2c_client *client, struct rtc_time *tm) dev_dbg(&client->dev, "%s: tm is secs=%d, mins=%d, hours=%d, " "mday=%d, mon=%d, year=%d, wday=%d\n", - __FUNCTION__, + __func__, tm->tm_sec, tm->tm_min, tm->tm_hour, tm->tm_mday, tm->tm_mon, tm->tm_year, tm->tm_wday); @@ -181,7 +181,7 @@ static int rs5c372_set_datetime(struct i2c_client *client, struct rtc_time *tm) dev_dbg(&client->dev, "%s: tm is secs=%d, mins=%d, hours=%d " "mday=%d, mon=%d, year=%d, wday=%d\n", - __FUNCTION__, + __func__, tm->tm_sec, tm->tm_min, tm->tm_hour, tm->tm_mday, tm->tm_mon, tm->tm_year, tm->tm_wday); @@ -195,7 +195,7 @@ static int rs5c372_set_datetime(struct i2c_client *client, struct rtc_time *tm) buf[7] = BIN2BCD(tm->tm_year - 100); if ((i2c_master_send(client, buf, 8)) != 8) { - dev_err(&client->dev, "%s: write error\n", __FUNCTION__); + dev_err(&client->dev, "%s: write error\n", __func__); return -EIO; } @@ -220,7 +220,7 @@ static int rs5c372_get_trim(struct i2c_client *client, int *osc, int *trim) *osc = (tmp & RS5C372_TRIM_XSL) ? 32000 : 32768; if (trim) { - dev_dbg(&client->dev, "%s: raw trim=%x\n", __FUNCTION__, tmp); + dev_dbg(&client->dev, "%s: raw trim=%x\n", __func__, tmp); tmp &= RS5C372_TRIM_MASK; if (tmp & 0x3e) { int t = tmp & 0x3f; @@ -500,7 +500,7 @@ static int rs5c372_probe(struct i2c_client *client) struct rs5c372 *rs5c372; struct rtc_time tm; - dev_dbg(&client->dev, "%s\n", __FUNCTION__); + dev_dbg(&client->dev, "%s\n", __func__); if (!i2c_check_functionality(client->adapter, I2C_FUNC_I2C)) { err = -ENODEV; @@ -512,12 +512,12 @@ static int rs5c372_probe(struct i2c_client *client) goto exit; } - /* we read registers 0x0f then 0x00-0x0f; skip the first one */ - rs5c372->regs=&rs5c372->buf[1]; - rs5c372->client = client; i2c_set_clientdata(client, rs5c372); + /* we read registers 0x0f then 0x00-0x0f; skip the first one */ + rs5c372->regs = &rs5c372->buf[1]; + err = rs5c_get_regs(rs5c372); if (err < 0) goto exit_kfree; diff --git a/drivers/rtc/rtc-s3c.c b/drivers/rtc/rtc-s3c.c index 9f4d512..f26e0ca 100644 --- a/drivers/rtc/rtc-s3c.c +++ b/drivers/rtc/rtc-s3c.c @@ -68,7 +68,7 @@ static void s3c_rtc_setaie(int to) { unsigned int tmp; - pr_debug("%s: aie=%d\n", __FUNCTION__, to); + pr_debug("%s: aie=%d\n", __func__, to); tmp = readb(s3c_rtc_base + S3C2410_RTCALM) & ~S3C2410_RTCALM_ALMEN; @@ -82,7 +82,7 @@ static void s3c_rtc_setpie(int to) { unsigned int tmp; - pr_debug("%s: pie=%d\n", __FUNCTION__, to); + pr_debug("%s: pie=%d\n", __func__, to); spin_lock_irq(&s3c_rtc_pie_lock); tmp = readb(s3c_rtc_base + S3C2410_TICNT) & ~S3C2410_TICNT_ENABLE; @@ -457,7 +457,7 @@ static int s3c_rtc_probe(struct platform_device *pdev) struct resource *res; int ret; - pr_debug("%s: probe=%p\n", __FUNCTION__, pdev); + pr_debug("%s: probe=%p\n", __func__, pdev); /* find the IRQs */ diff --git a/drivers/rtc/rtc-sh.c b/drivers/rtc/rtc-sh.c index c594b34..110699b 100644 --- a/drivers/rtc/rtc-sh.c +++ b/drivers/rtc/rtc-sh.c @@ -361,7 +361,7 @@ static int sh_rtc_read_time(struct device *dev, struct rtc_time *tm) dev_dbg(dev, "%s: tm is secs=%d, mins=%d, hours=%d, " "mday=%d, mon=%d, year=%d, wday=%d\n", - __FUNCTION__, + __func__, tm->tm_sec, tm->tm_min, tm->tm_hour, tm->tm_mday, tm->tm_mon + 1, tm->tm_year, tm->tm_wday); diff --git a/drivers/rtc/rtc-sysfs.c b/drivers/rtc/rtc-sysfs.c index 4d27ccc..2531ce4 100644 --- a/drivers/rtc/rtc-sysfs.c +++ b/drivers/rtc/rtc-sysfs.c @@ -145,6 +145,8 @@ rtc_sysfs_set_wakealarm(struct device *dev, struct device_attribute *attr, unsigned long now, alarm; struct rtc_wkalrm alm; struct rtc_device *rtc = to_rtc_device(dev); + char *buf_ptr; + int adjust = 0; /* Only request alarms that trigger in the future. Disable them * by writing another time, e.g. 0 meaning Jan 1 1970 UTC. @@ -154,7 +156,15 @@ rtc_sysfs_set_wakealarm(struct device *dev, struct device_attribute *attr, return retval; rtc_tm_to_time(&alm.time, &now); - alarm = simple_strtoul(buf, NULL, 0); + buf_ptr = (char *)buf; + if (*buf_ptr == '+') { + buf_ptr++; + adjust = 1; + } + alarm = simple_strtoul(buf_ptr, NULL, 0); + if (adjust) { + alarm += now; + } if (alarm > now) { /* Avoid accidentally clobbering active alarms; we can't * entirely prevent that here, without even the minimal diff --git a/drivers/rtc/rtc-test.c b/drivers/rtc/rtc-test.c index 254c9fc..bc93002 100644 --- a/drivers/rtc/rtc-test.c +++ b/drivers/rtc/rtc-test.c @@ -147,7 +147,7 @@ static int __devexit test_remove(struct platform_device *plat_dev) return 0; } -static struct platform_driver test_drv = { +static struct platform_driver test_driver = { .probe = test_probe, .remove = __devexit_p(test_remove), .driver = { @@ -160,7 +160,7 @@ static int __init test_init(void) { int err; - if ((err = platform_driver_register(&test_drv))) + if ((err = platform_driver_register(&test_driver))) return err; if ((test0 = platform_device_alloc("rtc-test", 0)) == NULL) { @@ -191,7 +191,7 @@ exit_free_test0: platform_device_put(test0); exit_driver_unregister: - platform_driver_unregister(&test_drv); + platform_driver_unregister(&test_driver); return err; } @@ -199,7 +199,7 @@ static void __exit test_exit(void) { platform_device_unregister(test0); platform_device_unregister(test1); - platform_driver_unregister(&test_drv); + platform_driver_unregister(&test_driver); } MODULE_AUTHOR("Alessandro Zummo <a.zummo@towertech.it>"); diff --git a/drivers/rtc/rtc-v3020.c b/drivers/rtc/rtc-v3020.c index 24203a0..10025d8 100644 --- a/drivers/rtc/rtc-v3020.c +++ b/drivers/rtc/rtc-v3020.c @@ -107,7 +107,7 @@ static int v3020_read_time(struct device *dev, struct rtc_time *dt) dt->tm_year = BCD2BIN(tmp)+100; #ifdef DEBUG - printk("\n%s : Read RTC values\n",__FUNCTION__); + printk("\n%s : Read RTC values\n",__func__); printk("tm_hour: %i\n",dt->tm_hour); printk("tm_min : %i\n",dt->tm_min); printk("tm_sec : %i\n",dt->tm_sec); @@ -126,7 +126,7 @@ static int v3020_set_time(struct device *dev, struct rtc_time *dt) struct v3020 *chip = dev_get_drvdata(dev); #ifdef DEBUG - printk("\n%s : Setting RTC values\n",__FUNCTION__); + printk("\n%s : Setting RTC values\n",__func__); printk("tm_sec : %i\n",dt->tm_sec); printk("tm_min : %i\n",dt->tm_min); printk("tm_hour: %i\n",dt->tm_hour); diff --git a/drivers/rtc/rtc-x1205.c b/drivers/rtc/rtc-x1205.c index b90fb18..095282f 100644 --- a/drivers/rtc/rtc-x1205.c +++ b/drivers/rtc/rtc-x1205.c @@ -22,20 +22,7 @@ #include <linux/rtc.h> #include <linux/delay.h> -#define DRV_VERSION "1.0.7" - -/* Addresses to scan: none. This chip is located at - * 0x6f and uses a two bytes register addressing. - * Two bytes need to be written to read a single register, - * while most other chips just require one and take the second - * one as the data to be written. To prevent corrupting - * unknown chips, the user must explicitly set the probe parameter. - */ - -static const unsigned short normal_i2c[] = { I2C_CLIENT_END }; - -/* Insmod parameters */ -I2C_CLIENT_INSMOD; +#define DRV_VERSION "1.0.8" /* offsets into CCR area */ @@ -91,19 +78,7 @@ I2C_CLIENT_INSMOD; #define X1205_HR_MIL 0x80 /* Set in ccr.hour for 24 hr mode */ -/* Prototypes */ -static int x1205_attach(struct i2c_adapter *adapter); -static int x1205_detach(struct i2c_client *client); -static int x1205_probe(struct i2c_adapter *adapter, int address, int kind); - -static struct i2c_driver x1205_driver = { - .driver = { - .name = "x1205", - }, - .id = I2C_DRIVERID_X1205, - .attach_adapter = &x1205_attach, - .detach_client = &x1205_detach, -}; +static struct i2c_driver x1205_driver; /* * In the routines that deal directly with the x1205 hardware, we use @@ -124,14 +99,14 @@ static int x1205_get_datetime(struct i2c_client *client, struct rtc_time *tm, /* read date registers */ if ((i2c_transfer(client->adapter, &msgs[0], 2)) != 2) { - dev_err(&client->dev, "%s: read error\n", __FUNCTION__); + dev_err(&client->dev, "%s: read error\n", __func__); return -EIO; } dev_dbg(&client->dev, "%s: raw read data - sec=%02x, min=%02x, hr=%02x, " "mday=%02x, mon=%02x, year=%02x, wday=%02x, y2k=%02x\n", - __FUNCTION__, + __func__, buf[0], buf[1], buf[2], buf[3], buf[4], buf[5], buf[6], buf[7]); @@ -146,7 +121,7 @@ static int x1205_get_datetime(struct i2c_client *client, struct rtc_time *tm, dev_dbg(&client->dev, "%s: tm is secs=%d, mins=%d, hours=%d, " "mday=%d, mon=%d, year=%d, wday=%d\n", - __FUNCTION__, + __func__, tm->tm_sec, tm->tm_min, tm->tm_hour, tm->tm_mday, tm->tm_mon, tm->tm_year, tm->tm_wday); @@ -164,7 +139,7 @@ static int x1205_get_status(struct i2c_client *client, unsigned char *sr) /* read status register */ if ((i2c_transfer(client->adapter, &msgs[0], 2)) != 2) { - dev_err(&client->dev, "%s: read error\n", __FUNCTION__); + dev_err(&client->dev, "%s: read error\n", __func__); return -EIO; } @@ -187,7 +162,7 @@ static int x1205_set_datetime(struct i2c_client *client, struct rtc_time *tm, dev_dbg(&client->dev, "%s: secs=%d, mins=%d, hours=%d\n", - __FUNCTION__, + __func__, tm->tm_sec, tm->tm_min, tm->tm_hour); buf[CCR_SEC] = BIN2BCD(tm->tm_sec); @@ -200,7 +175,7 @@ static int x1205_set_datetime(struct i2c_client *client, struct rtc_time *tm, if (datetoo) { dev_dbg(&client->dev, "%s: mday=%d, mon=%d, year=%d, wday=%d\n", - __FUNCTION__, + __func__, tm->tm_mday, tm->tm_mon, tm->tm_year, tm->tm_wday); buf[CCR_MDAY] = BIN2BCD(tm->tm_mday); @@ -216,12 +191,12 @@ static int x1205_set_datetime(struct i2c_client *client, struct rtc_time *tm, /* this sequence is required to unlock the chip */ if ((xfer = i2c_master_send(client, wel, 3)) != 3) { - dev_err(&client->dev, "%s: wel - %d\n", __FUNCTION__, xfer); + dev_err(&client->dev, "%s: wel - %d\n", __func__, xfer); return -EIO; } if ((xfer = i2c_master_send(client, rwel, 3)) != 3) { - dev_err(&client->dev, "%s: rwel - %d\n", __FUNCTION__, xfer); + dev_err(&client->dev, "%s: rwel - %d\n", __func__, xfer); return -EIO; } @@ -233,7 +208,7 @@ static int x1205_set_datetime(struct i2c_client *client, struct rtc_time *tm, if (xfer != 3) { dev_err(&client->dev, "%s: xfer=%d addr=%02x, data=%02x\n", - __FUNCTION__, + __func__, xfer, rdata[1], rdata[2]); return -EIO; } @@ -241,7 +216,7 @@ static int x1205_set_datetime(struct i2c_client *client, struct rtc_time *tm, /* disable further writes */ if ((xfer = i2c_master_send(client, diswe, 3)) != 3) { - dev_err(&client->dev, "%s: diswe - %d\n", __FUNCTION__, xfer); + dev_err(&client->dev, "%s: diswe - %d\n", __func__, xfer); return -EIO; } @@ -274,11 +249,11 @@ static int x1205_get_dtrim(struct i2c_client *client, int *trim) /* read dtr register */ if ((i2c_transfer(client->adapter, &msgs[0], 2)) != 2) { - dev_err(&client->dev, "%s: read error\n", __FUNCTION__); + dev_err(&client->dev, "%s: read error\n", __func__); return -EIO; } - dev_dbg(&client->dev, "%s: raw dtr=%x\n", __FUNCTION__, dtr); + dev_dbg(&client->dev, "%s: raw dtr=%x\n", __func__, dtr); *trim = 0; @@ -306,11 +281,11 @@ static int x1205_get_atrim(struct i2c_client *client, int *trim) /* read atr register */ if ((i2c_transfer(client->adapter, &msgs[0], 2)) != 2) { - dev_err(&client->dev, "%s: read error\n", __FUNCTION__); + dev_err(&client->dev, "%s: read error\n", __func__); return -EIO; } - dev_dbg(&client->dev, "%s: raw atr=%x\n", __FUNCTION__, atr); + dev_dbg(&client->dev, "%s: raw atr=%x\n", __func__, atr); /* atr is a two's complement value on 6 bits, * perform sign extension. The formula is @@ -319,11 +294,11 @@ static int x1205_get_atrim(struct i2c_client *client, int *trim) if (atr & 0x20) atr |= 0xC0; - dev_dbg(&client->dev, "%s: raw atr=%x (%d)\n", __FUNCTION__, atr, atr); + dev_dbg(&client->dev, "%s: raw atr=%x (%d)\n", __func__, atr, atr); *trim = (atr * 250) + 11000; - dev_dbg(&client->dev, "%s: real=%d\n", __FUNCTION__, *trim); + dev_dbg(&client->dev, "%s: real=%d\n", __func__, *trim); return 0; } @@ -377,7 +352,7 @@ static int x1205_validate_client(struct i2c_client *client) if ((xfer = i2c_transfer(client->adapter, msgs, 2)) != 2) { dev_err(&client->dev, "%s: could not read register %x\n", - __FUNCTION__, probe_zero_pattern[i]); + __func__, probe_zero_pattern[i]); return -EIO; } @@ -385,7 +360,7 @@ static int x1205_validate_client(struct i2c_client *client) if ((buf & probe_zero_pattern[i+1]) != 0) { dev_err(&client->dev, "%s: register=%02x, zero pattern=%d, value=%x\n", - __FUNCTION__, probe_zero_pattern[i], i, buf); + __func__, probe_zero_pattern[i], i, buf); return -ENODEV; } @@ -405,7 +380,7 @@ static int x1205_validate_client(struct i2c_client *client) if ((xfer = i2c_transfer(client->adapter, msgs, 2)) != 2) { dev_err(&client->dev, "%s: could not read register %x\n", - __FUNCTION__, probe_limits_pattern[i].reg); + __func__, probe_limits_pattern[i].reg); return -EIO; } @@ -416,7 +391,7 @@ static int x1205_validate_client(struct i2c_client *client) value < probe_limits_pattern[i].min) { dev_dbg(&client->dev, "%s: register=%x, lim pattern=%d, value=%d\n", - __FUNCTION__, probe_limits_pattern[i].reg, + __func__, probe_limits_pattern[i].reg, i, value); return -ENODEV; @@ -497,58 +472,49 @@ static ssize_t x1205_sysfs_show_dtrim(struct device *dev, } static DEVICE_ATTR(dtrim, S_IRUGO, x1205_sysfs_show_dtrim, NULL); -static int x1205_attach(struct i2c_adapter *adapter) +static int x1205_sysfs_register(struct device *dev) +{ + int err; + + err = device_create_file(dev, &dev_attr_atrim); + if (err) + return err; + + err = device_create_file(dev, &dev_attr_dtrim); + if (err) + device_remove_file(dev, &dev_attr_atrim); + + return err; +} + +static void x1205_sysfs_unregister(struct device *dev) { - return i2c_probe(adapter, &addr_data, x1205_probe); + device_remove_file(dev, &dev_attr_atrim); + device_remove_file(dev, &dev_attr_dtrim); } -static int x1205_probe(struct i2c_adapter *adapter, int address, int kind) + +static int x1205_probe(struct i2c_client *client) { int err = 0; unsigned char sr; - struct i2c_client *client; struct rtc_device *rtc; - dev_dbg(&adapter->dev, "%s\n", __FUNCTION__); - - if (!i2c_check_functionality(adapter, I2C_FUNC_I2C)) { - err = -ENODEV; - goto exit; - } - - if (!(client = kzalloc(sizeof(struct i2c_client), GFP_KERNEL))) { - err = -ENOMEM; - goto exit; - } - - /* I2C client */ - client->addr = address; - client->driver = &x1205_driver; - client->adapter = adapter; + dev_dbg(&client->dev, "%s\n", __func__); - strlcpy(client->name, x1205_driver.driver.name, I2C_NAME_SIZE); - - /* Verify the chip is really an X1205 */ - if (kind < 0) { - if (x1205_validate_client(client) < 0) { - err = -ENODEV; - goto exit_kfree; - } - } + if (!i2c_check_functionality(client->adapter, I2C_FUNC_I2C)) + return -ENODEV; - /* Inform the i2c layer */ - if ((err = i2c_attach_client(client))) - goto exit_kfree; + if (x1205_validate_client(client) < 0) + return -ENODEV; dev_info(&client->dev, "chip found, driver version " DRV_VERSION "\n"); rtc = rtc_device_register(x1205_driver.driver.name, &client->dev, &x1205_rtc_ops, THIS_MODULE); - if (IS_ERR(rtc)) { - err = PTR_ERR(rtc); - goto exit_detach; - } + if (IS_ERR(rtc)) + return PTR_ERR(rtc); i2c_set_clientdata(client, rtc); @@ -565,45 +531,35 @@ static int x1205_probe(struct i2c_adapter *adapter, int address, int kind) else dev_err(&client->dev, "couldn't read status\n"); - err = device_create_file(&client->dev, &dev_attr_atrim); - if (err) goto exit_devreg; - err = device_create_file(&client->dev, &dev_attr_dtrim); - if (err) goto exit_atrim; + err = x1205_sysfs_register(&client->dev); + if (err) + goto exit_devreg; return 0; -exit_atrim: - device_remove_file(&client->dev, &dev_attr_atrim); - exit_devreg: rtc_device_unregister(rtc); -exit_detach: - i2c_detach_client(client); - -exit_kfree: - kfree(client); - -exit: return err; } -static int x1205_detach(struct i2c_client *client) +static int x1205_remove(struct i2c_client *client) { - int err; struct rtc_device *rtc = i2c_get_clientdata(client); - if (rtc) - rtc_device_unregister(rtc); - - if ((err = i2c_detach_client(client))) - return err; - - kfree(client); - + rtc_device_unregister(rtc); + x1205_sysfs_unregister(&client->dev); return 0; } +static struct i2c_driver x1205_driver = { + .driver = { + .name = "rtc-x1205", + }, + .probe = x1205_probe, + .remove = x1205_remove, +}; + static int __init x1205_init(void) { return i2c_add_driver(&x1205_driver); |