rtc-ds1374.c (4ba24fef3eb3b142197135223b90ced2f319cd53) rtc-ds1374.c (a737e835e5769ef22897179ed7f82b1fc50bfa58)
1/*
2 * RTC client/driver for the Maxim/Dallas DS1374 Real-Time Clock over I2C
3 *
4 * Based on code by Randy Vinson <rvinson@mvista.com>,
5 * which was based on the m41t00.c by Mark Greer <mgreer@mvista.com>.
6 *
7 * Copyright (C) 2014 Rose Technology
8 * Copyright (C) 2006-2007 Freescale Semiconductor

--- 4 unchanged lines hidden (view full) ---

13 * or implied.
14 */
15/*
16 * It would be more efficient to use i2c msgs/i2c_transfer directly but, as
17 * recommened in .../Documentation/i2c/writing-clients section
18 * "Sending and receiving", using SMBus level communication is preferred.
19 */
20
1/*
2 * RTC client/driver for the Maxim/Dallas DS1374 Real-Time Clock over I2C
3 *
4 * Based on code by Randy Vinson <rvinson@mvista.com>,
5 * which was based on the m41t00.c by Mark Greer <mgreer@mvista.com>.
6 *
7 * Copyright (C) 2014 Rose Technology
8 * Copyright (C) 2006-2007 Freescale Semiconductor

--- 4 unchanged lines hidden (view full) ---

13 * or implied.
14 */
15/*
16 * It would be more efficient to use i2c msgs/i2c_transfer directly but, as
17 * recommened in .../Documentation/i2c/writing-clients section
18 * "Sending and receiving", using SMBus level communication is preferred.
19 */
20
21#define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
22
21#include <linux/kernel.h>
22#include <linux/module.h>
23#include <linux/interrupt.h>
24#include <linux/i2c.h>
25#include <linux/rtc.h>
26#include <linux/bcd.h>
27#include <linux/workqueue.h>
28#include <linux/slab.h>

--- 372 unchanged lines hidden (view full) ---

401
402 ret = i2c_smbus_write_byte_data(save_client, DS1374_REG_CR, cr);
403 if (ret < 0)
404 goto out;
405
406 /* Set new watchdog time */
407 ret = ds1374_write_rtc(save_client, timeout, DS1374_REG_WDALM0, 3);
408 if (ret) {
23#include <linux/kernel.h>
24#include <linux/module.h>
25#include <linux/interrupt.h>
26#include <linux/i2c.h>
27#include <linux/rtc.h>
28#include <linux/bcd.h>
29#include <linux/workqueue.h>
30#include <linux/slab.h>

--- 372 unchanged lines hidden (view full) ---

403
404 ret = i2c_smbus_write_byte_data(save_client, DS1374_REG_CR, cr);
405 if (ret < 0)
406 goto out;
407
408 /* Set new watchdog time */
409 ret = ds1374_write_rtc(save_client, timeout, DS1374_REG_WDALM0, 3);
410 if (ret) {
409 pr_info("rtc-ds1374 - couldn't set new watchdog time\n");
411 pr_info("couldn't set new watchdog time\n");
410 goto out;
411 }
412
413 /* Enable watchdog timer */
414 cr |= DS1374_REG_CR_WACE | DS1374_REG_CR_WDALM;
415 cr &= ~DS1374_REG_CR_AIE;
416
417 ret = i2c_smbus_write_byte_data(save_client, DS1374_REG_CR, cr);

--- 116 unchanged lines hidden (view full) ---

534 /* fallthrough */
535 case WDIOC_GETTIMEOUT:
536 return put_user(wdt_margin, (int __user *)arg);
537 case WDIOC_SETOPTIONS:
538 if (copy_from_user(&options, (int __user *)arg, sizeof(int)))
539 return -EFAULT;
540
541 if (options & WDIOS_DISABLECARD) {
412 goto out;
413 }
414
415 /* Enable watchdog timer */
416 cr |= DS1374_REG_CR_WACE | DS1374_REG_CR_WDALM;
417 cr &= ~DS1374_REG_CR_AIE;
418
419 ret = i2c_smbus_write_byte_data(save_client, DS1374_REG_CR, cr);

--- 116 unchanged lines hidden (view full) ---

536 /* fallthrough */
537 case WDIOC_GETTIMEOUT:
538 return put_user(wdt_margin, (int __user *)arg);
539 case WDIOC_SETOPTIONS:
540 if (copy_from_user(&options, (int __user *)arg, sizeof(int)))
541 return -EFAULT;
542
543 if (options & WDIOS_DISABLECARD) {
542 pr_info("rtc-ds1374: disable watchdog\n");
544 pr_info("disable watchdog\n");
543 ds1374_wdt_disable();
544 }
545
546 if (options & WDIOS_ENABLECARD) {
545 ds1374_wdt_disable();
546 }
547
548 if (options & WDIOS_ENABLECARD) {
547 pr_info("rtc-ds1374: enable watchdog\n");
549 pr_info("enable watchdog\n");
548 ds1374_wdt_settimeout(wdt_margin);
549 ds1374_wdt_ping();
550 }
551
552 return -EINVAL;
553 }
554 return -ENOTTY;
555}

--- 167 unchanged lines hidden ---
550 ds1374_wdt_settimeout(wdt_margin);
551 ds1374_wdt_ping();
552 }
553
554 return -EINVAL;
555 }
556 return -ENOTTY;
557}

--- 167 unchanged lines hidden ---