diff options
Diffstat (limited to 'drivers/rtc/rtc-ds1305.c')
| -rw-r--r-- | drivers/rtc/rtc-ds1305.c | 43 |
1 files changed, 13 insertions, 30 deletions
diff --git a/drivers/rtc/rtc-ds1305.c b/drivers/rtc/rtc-ds1305.c index 077af1d7b9e..57fbcc149ba 100644 --- a/drivers/rtc/rtc-ds1305.c +++ b/drivers/rtc/rtc-ds1305.c | |||
| @@ -139,49 +139,32 @@ static u8 hour2bcd(bool hr12, int hour) | |||
| 139 | * Interface to RTC framework | 139 | * Interface to RTC framework |
| 140 | */ | 140 | */ |
| 141 | 141 | ||
| 142 | #ifdef CONFIG_RTC_INTF_DEV | 142 | static int ds1305_alarm_irq_enable(struct device *dev, unsigned int enabled) |
| 143 | |||
| 144 | /* | ||
| 145 | * Context: caller holds rtc->ops_lock (to protect ds1305->ctrl) | ||
| 146 | */ | ||
| 147 | static int ds1305_ioctl(struct device *dev, unsigned cmd, unsigned long arg) | ||
| 148 | { | 143 | { |
| 149 | struct ds1305 *ds1305 = dev_get_drvdata(dev); | 144 | struct ds1305 *ds1305 = dev_get_drvdata(dev); |
| 150 | u8 buf[2]; | 145 | u8 buf[2]; |
| 151 | int status = -ENOIOCTLCMD; | 146 | long err = -EINVAL; |
| 152 | 147 | ||
| 153 | buf[0] = DS1305_WRITE | DS1305_CONTROL; | 148 | buf[0] = DS1305_WRITE | DS1305_CONTROL; |
| 154 | buf[1] = ds1305->ctrl[0]; | 149 | buf[1] = ds1305->ctrl[0]; |
| 155 | 150 | ||
| 156 | switch (cmd) { | 151 | if (enabled) { |
| 157 | case RTC_AIE_OFF: | ||
| 158 | status = 0; | ||
| 159 | if (!(buf[1] & DS1305_AEI0)) | ||
| 160 | goto done; | ||
| 161 | buf[1] &= ~DS1305_AEI0; | ||
| 162 | break; | ||
| 163 | |||
| 164 | case RTC_AIE_ON: | ||
| 165 | status = 0; | ||
| 166 | if (ds1305->ctrl[0] & DS1305_AEI0) | 152 | if (ds1305->ctrl[0] & DS1305_AEI0) |
| 167 | goto done; | 153 | goto done; |
| 168 | buf[1] |= DS1305_AEI0; | 154 | buf[1] |= DS1305_AEI0; |
| 169 | break; | 155 | } else { |
| 170 | } | 156 | if (!(buf[1] & DS1305_AEI0)) |
| 171 | if (status == 0) { | 157 | goto done; |
| 172 | status = spi_write_then_read(ds1305->spi, buf, sizeof buf, | 158 | buf[1] &= ~DS1305_AEI0; |
| 173 | NULL, 0); | ||
| 174 | if (status >= 0) | ||
| 175 | ds1305->ctrl[0] = buf[1]; | ||
| 176 | } | 159 | } |
| 177 | 160 | err = spi_write_then_read(ds1305->spi, buf, sizeof buf, NULL, 0); | |
| 161 | if (err >= 0) | ||
| 162 | ds1305->ctrl[0] = buf[1]; | ||
| 178 | done: | 163 | done: |
| 179 | return status; | 164 | return err; |
| 165 | |||
| 180 | } | 166 | } |
| 181 | 167 | ||
| 182 | #else | ||
| 183 | #define ds1305_ioctl NULL | ||
| 184 | #endif | ||
| 185 | 168 | ||
| 186 | /* | 169 | /* |
| 187 | * Get/set of date and time is pretty normal. | 170 | * Get/set of date and time is pretty normal. |
| @@ -460,12 +443,12 @@ done: | |||
| 460 | #endif | 443 | #endif |
| 461 | 444 | ||
| 462 | static const struct rtc_class_ops ds1305_ops = { | 445 | static const struct rtc_class_ops ds1305_ops = { |
| 463 | .ioctl = ds1305_ioctl, | ||
| 464 | .read_time = ds1305_get_time, | 446 | .read_time = ds1305_get_time, |
| 465 | .set_time = ds1305_set_time, | 447 | .set_time = ds1305_set_time, |
| 466 | .read_alarm = ds1305_get_alarm, | 448 | .read_alarm = ds1305_get_alarm, |
| 467 | .set_alarm = ds1305_set_alarm, | 449 | .set_alarm = ds1305_set_alarm, |
| 468 | .proc = ds1305_proc, | 450 | .proc = ds1305_proc, |
| 451 | .alarm_irq_enable = ds1305_alarm_irq_enable, | ||
| 469 | }; | 452 | }; |
| 470 | 453 | ||
| 471 | static void ds1305_work(struct work_struct *work) | 454 | static void ds1305_work(struct work_struct *work) |
