Re: [rtc-linux] [PATCH] rtc: add support for Maxim rtc max6916 v3.0

2016-05-13 Thread Krzysztof Kozlowski
On Fri, May 13, 2016 at 8:14 AM,   wrote:
> From: venkat-prashanth 
>
> This is a patch to add support
> for Maxim rtc max6916

Please fix line wrapping (around 72 characters).

Also please follow patch submission rules. Look at other patches with
versions - how "v4" is added (not to title) and prefix for driver,
after 'rtc'.

> Signed-off-by: Venkat Prashanth B U 

>From name does not match Signed-off-by.

> ---
>
>#Change Log: from v2.0 to v3.0
>
>  - fixed the out-of-tree Makefile and suitably added
>the modifications in the Makefile
>
>  - fixed the bad indented Kconfig file
>
>  -used a define instead of 0x1B as follows
 > #define MAX6916_REG_MAP_ADDRESS 0x1B
>
>  -moved and placed the test at the begining of the 
> function
>   after the range is properly enforced
>if (dt->tm_year < 100 || dt->tm_year > 199) {
>   dev_err(>dev,"Year must be between 2000 and 2099.
>   It's %d.\n", dt->tm_year + 1900);
>   return -EINVAL;
>   }
>
>  - A magic number is a direct usage of a number
>in the code,instead has been refactored in  the
>current version v3.0 which use defines as follows:-
>  -max6916_read_reg(>dev,
>   int MAX6916_CONTROL_REG = 0x08, );
>  -max6916_write_reg(>dev,
>   int MAX6916_CONTROL_REG= 0x08, data);
>  -max6916_write_reg(>dev,
>   int MAX6916_STATUS_REG = 0x0C, data);
>  -max6916_read_reg(>dev,
>   int MAX6916_CONTROL_REG = 0x08, );
>-max6916_read_reg(>dev,
>   int MAX6916_STATUS_REG  = 0X0C,  );
>  -Unnecessary test function if(dt->tm_year >= 100)
>   dt->tm_year -= 100;
>   is deleted after the range is properly enforced.
>  -seperated logical code sections with an empty line
>   and used indentation after if-statements.

Indentation and line wrapping created unreadable piece of changelog.

> ---
> ---
>  Kconfig   |   9 
>  Makefile  |   1 +
>  rtc-max6916.c | 162 
> ++

This looks wrong.

>  3 files changed, 172 insertions(+)
>
> diff --git a/driver/rtc/Kconfig b/driver/rtc/Kconfig
> index fcf87da..5321e8f 100644
> --- a/driver/rtc/Kconfig
> +++ b/driver/rtc/Kconfig
> @@ -699,6 +699,15 @@
>
>This driver can also be built as a module. If so, the module
>will be called rtc-max6902.
> +config RTC_DRV_MAX6916
> +tristate "Maxim MAX6916"
> +help
> +  If you say yes here you will get support for the
> +  Maxim MAX6916 SPI RTC chip.
> +
> +  This driver can also be built as a module. If so, the module
> +  will be called rtc-max6916.
> +
>
>  config RTC_DRV_R9701
>  tristate "Epson RTC-9701JE"
> diff --git a/driver/rtc/Makefile b/driver/rtc/Makefile
> index 9421959..0b3fded 100644
> --- a/driver/rtc/Makefile
> +++ b/driver/rtc/Makefile
> @@ -85,6 +85,7 @@
>  obj-$(CONFIG_RTC_DRV_M48T86)+= rtc-m48t86.o
>  obj-$(CONFIG_RTC_DRV_MAX6900)   += rtc-max6900.o
>  obj-$(CONFIG_RTC_DRV_MAX6902)   += rtc-max6902.o
> +obj-$(CONFIG_RTC_DRV_MAX6916)   += rtc-max6916.o
>  obj-$(CONFIG_RTC_DRV_MAX77686)  += rtc-max77686.o
>  obj-$(CONFIG_RTC_DRV_MAX77802)  += rtc-max77802.o
>  obj-$(CONFIG_RTC_DRV_MAX8907)   += rtc-max8907.o
> diff --git a/driver/rtc/rtc-max6916.c b/driver/rtc/rtc-max6916.c
> index e69de29..ced341a 100644
> --- a/driver/rtc/rtc-max6916.c
> +++ b/driver/rtc/rtc-max6916.c
> @@ -0,0 +1,162 @@
> +#include 
> +#include 
> +#include 
> +#include 
> +#include 
> +#include 
> +#include 
> +
> +/* Registers in max6916 rtc */
> +
> +#define MAX6916_SECONDS_REG  0x01
> +#define MAX6916_MINUTES_REG  0x02
> +#define MAX6916_HOURS_REG0x03
> +#define MAX6916_DATE_REG 0x04
> +#define MAX6916_MONTH_REG0x05
> +#define MAX6916_DAY_REG  0x06
> +#define MAX6916_YEAR_REG 0x07
> +#define MAX6916_CONTROL_REG  0x08
> +#define MAX6916_STATUS_REG   0x0C
> +#define MAX6916_CLOCK_BURST  0x3F
> +#define MAX6916_REG_MAP_ADDRESS  0x1B

Align the value with tabs. Make it readable.

> +
> +static int max6916_read_reg(struct device *dev, unsigned char address, 
> unsigned char *data)
> +
> +{
> +   

Re: [rtc-linux] [PATCH] rtc: add support for Maxim rtc max6916 v3.0

2016-05-13 Thread Krzysztof Kozlowski
On Fri, May 13, 2016 at 8:14 AM,   wrote:
> From: venkat-prashanth 
>
> This is a patch to add support
> for Maxim rtc max6916

Please fix line wrapping (around 72 characters).

Also please follow patch submission rules. Look at other patches with
versions - how "v4" is added (not to title) and prefix for driver,
after 'rtc'.

> Signed-off-by: Venkat Prashanth B U 

>From name does not match Signed-off-by.

> ---
>
>#Change Log: from v2.0 to v3.0
>
>  - fixed the out-of-tree Makefile and suitably added
>the modifications in the Makefile
>
>  - fixed the bad indented Kconfig file
>
>  -used a define instead of 0x1B as follows
 > #define MAX6916_REG_MAP_ADDRESS 0x1B
>
>  -moved and placed the test at the begining of the 
> function
>   after the range is properly enforced
>if (dt->tm_year < 100 || dt->tm_year > 199) {
>   dev_err(>dev,"Year must be between 2000 and 2099.
>   It's %d.\n", dt->tm_year + 1900);
>   return -EINVAL;
>   }
>
>  - A magic number is a direct usage of a number
>in the code,instead has been refactored in  the
>current version v3.0 which use defines as follows:-
>  -max6916_read_reg(>dev,
>   int MAX6916_CONTROL_REG = 0x08, );
>  -max6916_write_reg(>dev,
>   int MAX6916_CONTROL_REG= 0x08, data);
>  -max6916_write_reg(>dev,
>   int MAX6916_STATUS_REG = 0x0C, data);
>  -max6916_read_reg(>dev,
>   int MAX6916_CONTROL_REG = 0x08, );
>-max6916_read_reg(>dev,
>   int MAX6916_STATUS_REG  = 0X0C,  );
>  -Unnecessary test function if(dt->tm_year >= 100)
>   dt->tm_year -= 100;
>   is deleted after the range is properly enforced.
>  -seperated logical code sections with an empty line
>   and used indentation after if-statements.

Indentation and line wrapping created unreadable piece of changelog.

> ---
> ---
>  Kconfig   |   9 
>  Makefile  |   1 +
>  rtc-max6916.c | 162 
> ++

This looks wrong.

>  3 files changed, 172 insertions(+)
>
> diff --git a/driver/rtc/Kconfig b/driver/rtc/Kconfig
> index fcf87da..5321e8f 100644
> --- a/driver/rtc/Kconfig
> +++ b/driver/rtc/Kconfig
> @@ -699,6 +699,15 @@
>
>This driver can also be built as a module. If so, the module
>will be called rtc-max6902.
> +config RTC_DRV_MAX6916
> +tristate "Maxim MAX6916"
> +help
> +  If you say yes here you will get support for the
> +  Maxim MAX6916 SPI RTC chip.
> +
> +  This driver can also be built as a module. If so, the module
> +  will be called rtc-max6916.
> +
>
>  config RTC_DRV_R9701
>  tristate "Epson RTC-9701JE"
> diff --git a/driver/rtc/Makefile b/driver/rtc/Makefile
> index 9421959..0b3fded 100644
> --- a/driver/rtc/Makefile
> +++ b/driver/rtc/Makefile
> @@ -85,6 +85,7 @@
>  obj-$(CONFIG_RTC_DRV_M48T86)+= rtc-m48t86.o
>  obj-$(CONFIG_RTC_DRV_MAX6900)   += rtc-max6900.o
>  obj-$(CONFIG_RTC_DRV_MAX6902)   += rtc-max6902.o
> +obj-$(CONFIG_RTC_DRV_MAX6916)   += rtc-max6916.o
>  obj-$(CONFIG_RTC_DRV_MAX77686)  += rtc-max77686.o
>  obj-$(CONFIG_RTC_DRV_MAX77802)  += rtc-max77802.o
>  obj-$(CONFIG_RTC_DRV_MAX8907)   += rtc-max8907.o
> diff --git a/driver/rtc/rtc-max6916.c b/driver/rtc/rtc-max6916.c
> index e69de29..ced341a 100644
> --- a/driver/rtc/rtc-max6916.c
> +++ b/driver/rtc/rtc-max6916.c
> @@ -0,0 +1,162 @@
> +#include 
> +#include 
> +#include 
> +#include 
> +#include 
> +#include 
> +#include 
> +
> +/* Registers in max6916 rtc */
> +
> +#define MAX6916_SECONDS_REG  0x01
> +#define MAX6916_MINUTES_REG  0x02
> +#define MAX6916_HOURS_REG0x03
> +#define MAX6916_DATE_REG 0x04
> +#define MAX6916_MONTH_REG0x05
> +#define MAX6916_DAY_REG  0x06
> +#define MAX6916_YEAR_REG 0x07
> +#define MAX6916_CONTROL_REG  0x08
> +#define MAX6916_STATUS_REG   0x0C
> +#define MAX6916_CLOCK_BURST  0x3F
> +#define MAX6916_REG_MAP_ADDRESS  0x1B

Align the value with tabs. Make it readable.

> +
> +static int max6916_read_reg(struct device *dev, unsigned char address, 
> unsigned char *data)
> +
> +{
> +   struct spi_device *spi = to_spi_device(dev);

All of these indentations look wrong.

Have you run 

[PATCH] rtc: add support for Maxim rtc max6916 v3.0

2016-05-13 Thread venkat . prashanth2498
From: venkat-prashanth 

This is a patch to add support 
for Maxim rtc max6916

Signed-off-by: Venkat Prashanth B U 
---

   #Change Log: from v2.0 to v3.0

 - fixed the out-of-tree Makefile and suitably added
   the modifications in the Makefile

 - fixed the bad indented Kconfig file

 -used a define instead of 0x1B as follows
#define MAX6916_REG_MAP_ADDRESS 0x1B

 -moved and placed the test at the begining of the function
  after the range is properly enforced
   if (dt->tm_year < 100 || dt->tm_year > 199) {
  dev_err(>dev,"Year must be between 2000 and 2099.
  It's %d.\n", dt->tm_year + 1900);
  return -EINVAL;
  }

 - A magic number is a direct usage of a number
   in the code,instead has been refactored in  the
   current version v3.0 which use defines as follows:-
 -max6916_read_reg(>dev,
  int MAX6916_CONTROL_REG = 0x08, );
 -max6916_write_reg(>dev,
  int MAX6916_CONTROL_REG= 0x08, data);
 -max6916_write_reg(>dev,
  int MAX6916_STATUS_REG = 0x0C, data);
 -max6916_read_reg(>dev,
  int MAX6916_CONTROL_REG = 0x08, );
   -max6916_read_reg(>dev,
  int MAX6916_STATUS_REG  = 0X0C,  );
 -Unnecessary test function if(dt->tm_year >= 100)
  dt->tm_year -= 100;
  is deleted after the range is properly enforced.
 -seperated logical code sections with an empty line
  and used indentation after if-statements.
---
---
 Kconfig   |   9 
 Makefile  |   1 +
 rtc-max6916.c | 162 ++
 3 files changed, 172 insertions(+)

diff --git a/driver/rtc/Kconfig b/driver/rtc/Kconfig
index fcf87da..5321e8f 100644
--- a/driver/rtc/Kconfig
+++ b/driver/rtc/Kconfig
@@ -699,6 +699,15 @@
  
   This driver can also be built as a module. If so, the module
   will be called rtc-max6902.
+config RTC_DRV_MAX6916
+tristate "Maxim MAX6916"
+help
+  If you say yes here you will get support for the
+  Maxim MAX6916 SPI RTC chip.
+
+  This driver can also be built as a module. If so, the module
+  will be called rtc-max6916.
+
  
 config RTC_DRV_R9701
 tristate "Epson RTC-9701JE"
diff --git a/driver/rtc/Makefile b/driver/rtc/Makefile
index 9421959..0b3fded 100644
--- a/driver/rtc/Makefile
+++ b/driver/rtc/Makefile
@@ -85,6 +85,7 @@
 obj-$(CONFIG_RTC_DRV_M48T86)+= rtc-m48t86.o
 obj-$(CONFIG_RTC_DRV_MAX6900)   += rtc-max6900.o
 obj-$(CONFIG_RTC_DRV_MAX6902)   += rtc-max6902.o
+obj-$(CONFIG_RTC_DRV_MAX6916)   += rtc-max6916.o
 obj-$(CONFIG_RTC_DRV_MAX77686)  += rtc-max77686.o
 obj-$(CONFIG_RTC_DRV_MAX77802)  += rtc-max77802.o
 obj-$(CONFIG_RTC_DRV_MAX8907)   += rtc-max8907.o
diff --git a/driver/rtc/rtc-max6916.c b/driver/rtc/rtc-max6916.c
index e69de29..ced341a 100644
--- a/driver/rtc/rtc-max6916.c
+++ b/driver/rtc/rtc-max6916.c
@@ -0,0 +1,162 @@
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+
+/* Registers in max6916 rtc */
+
+#define MAX6916_SECONDS_REG  0x01
+#define MAX6916_MINUTES_REG  0x02
+#define MAX6916_HOURS_REG0x03
+#define MAX6916_DATE_REG 0x04
+#define MAX6916_MONTH_REG0x05
+#define MAX6916_DAY_REG  0x06
+#define MAX6916_YEAR_REG 0x07
+#define MAX6916_CONTROL_REG  0x08
+#define MAX6916_STATUS_REG   0x0C
+#define MAX6916_CLOCK_BURST  0x3F
+#define MAX6916_REG_MAP_ADDRESS  0x1B
+
+static int max6916_read_reg(struct device *dev, unsigned char address, 
unsigned char *data)
+
+{
+   struct spi_device *spi = to_spi_device(dev);
+
+   *data = address | 0x80;
+
+   return spi_write_then_read(spi, data, 1, data, 1);
+}
+
+static int max6916_write_reg(struct device *dev, unsigned char address, 
unsigned char data)
+
+{
+   struct spi_device *spi = to_spi_device(dev);
+   unsigned char buf[2];
+
+   buf[0] = address&0x7F;
+   buf[1] = data;
+
+   return spi_write_then_read(spi, buf, 2, NULL, 0);
+}
+
+static int max6916_read_time(struct device *dev, struct rtc_time *dt)
+{
+   struct spi_device *spi 

[PATCH] rtc: add support for Maxim rtc max6916 v3.0

2016-05-13 Thread venkat . prashanth2498
From: venkat-prashanth 

This is a patch to add support 
for Maxim rtc max6916

Signed-off-by: Venkat Prashanth B U 
---

   #Change Log: from v2.0 to v3.0

 - fixed the out-of-tree Makefile and suitably added
   the modifications in the Makefile

 - fixed the bad indented Kconfig file

 -used a define instead of 0x1B as follows
#define MAX6916_REG_MAP_ADDRESS 0x1B

 -moved and placed the test at the begining of the function
  after the range is properly enforced
   if (dt->tm_year < 100 || dt->tm_year > 199) {
  dev_err(>dev,"Year must be between 2000 and 2099.
  It's %d.\n", dt->tm_year + 1900);
  return -EINVAL;
  }

 - A magic number is a direct usage of a number
   in the code,instead has been refactored in  the
   current version v3.0 which use defines as follows:-
 -max6916_read_reg(>dev,
  int MAX6916_CONTROL_REG = 0x08, );
 -max6916_write_reg(>dev,
  int MAX6916_CONTROL_REG= 0x08, data);
 -max6916_write_reg(>dev,
  int MAX6916_STATUS_REG = 0x0C, data);
 -max6916_read_reg(>dev,
  int MAX6916_CONTROL_REG = 0x08, );
   -max6916_read_reg(>dev,
  int MAX6916_STATUS_REG  = 0X0C,  );
 -Unnecessary test function if(dt->tm_year >= 100)
  dt->tm_year -= 100;
  is deleted after the range is properly enforced.
 -seperated logical code sections with an empty line
  and used indentation after if-statements.
---
---
 Kconfig   |   9 
 Makefile  |   1 +
 rtc-max6916.c | 162 ++
 3 files changed, 172 insertions(+)

diff --git a/driver/rtc/Kconfig b/driver/rtc/Kconfig
index fcf87da..5321e8f 100644
--- a/driver/rtc/Kconfig
+++ b/driver/rtc/Kconfig
@@ -699,6 +699,15 @@
  
   This driver can also be built as a module. If so, the module
   will be called rtc-max6902.
+config RTC_DRV_MAX6916
+tristate "Maxim MAX6916"
+help
+  If you say yes here you will get support for the
+  Maxim MAX6916 SPI RTC chip.
+
+  This driver can also be built as a module. If so, the module
+  will be called rtc-max6916.
+
  
 config RTC_DRV_R9701
 tristate "Epson RTC-9701JE"
diff --git a/driver/rtc/Makefile b/driver/rtc/Makefile
index 9421959..0b3fded 100644
--- a/driver/rtc/Makefile
+++ b/driver/rtc/Makefile
@@ -85,6 +85,7 @@
 obj-$(CONFIG_RTC_DRV_M48T86)+= rtc-m48t86.o
 obj-$(CONFIG_RTC_DRV_MAX6900)   += rtc-max6900.o
 obj-$(CONFIG_RTC_DRV_MAX6902)   += rtc-max6902.o
+obj-$(CONFIG_RTC_DRV_MAX6916)   += rtc-max6916.o
 obj-$(CONFIG_RTC_DRV_MAX77686)  += rtc-max77686.o
 obj-$(CONFIG_RTC_DRV_MAX77802)  += rtc-max77802.o
 obj-$(CONFIG_RTC_DRV_MAX8907)   += rtc-max8907.o
diff --git a/driver/rtc/rtc-max6916.c b/driver/rtc/rtc-max6916.c
index e69de29..ced341a 100644
--- a/driver/rtc/rtc-max6916.c
+++ b/driver/rtc/rtc-max6916.c
@@ -0,0 +1,162 @@
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+
+/* Registers in max6916 rtc */
+
+#define MAX6916_SECONDS_REG  0x01
+#define MAX6916_MINUTES_REG  0x02
+#define MAX6916_HOURS_REG0x03
+#define MAX6916_DATE_REG 0x04
+#define MAX6916_MONTH_REG0x05
+#define MAX6916_DAY_REG  0x06
+#define MAX6916_YEAR_REG 0x07
+#define MAX6916_CONTROL_REG  0x08
+#define MAX6916_STATUS_REG   0x0C
+#define MAX6916_CLOCK_BURST  0x3F
+#define MAX6916_REG_MAP_ADDRESS  0x1B
+
+static int max6916_read_reg(struct device *dev, unsigned char address, 
unsigned char *data)
+
+{
+   struct spi_device *spi = to_spi_device(dev);
+
+   *data = address | 0x80;
+
+   return spi_write_then_read(spi, data, 1, data, 1);
+}
+
+static int max6916_write_reg(struct device *dev, unsigned char address, 
unsigned char data)
+
+{
+   struct spi_device *spi = to_spi_device(dev);
+   unsigned char buf[2];
+
+   buf[0] = address&0x7F;
+   buf[1] = data;
+
+   return spi_write_then_read(spi, buf, 2, NULL, 0);
+}
+
+static int max6916_read_time(struct device *dev, struct rtc_time *dt)
+{
+   struct spi_device *spi = to_spi_device(dev);
+   int err;
+

[PATCH] rtc: add support for Maxim rtc max6916 v3.0

2016-05-13 Thread venkat . prashanth2498
From: venkat-prashanth 

 [PATCH] rtc: add support to maxim rtc max6916

 #Change Log: from v2.0 to v3.0

 - fixed the out-of-tree Makefile and suitably added
   the modifications in the Makefile

 - fixed the bad indented Kconfig file

 -used a define instead of 0x1B as follows
#define MAX6916_REG_MAP_ADDRESS 0x1B

 -moved and placed the test at the begining of the function
  after the range is properly enforced
   if (dt->tm_year < 100 || dt->tm_year > 199) {
  dev_err(>dev,"Year must be between 2000 and 2099.
  It's %d.\n", dt->tm_year + 1900);
  return -EINVAL;
  }

 - A magic number is a direct usage of a number
   in the code,instead has been refactored in  the
   current version v3.0 which use defines as follows:-
 -max6916_read_reg(>dev,
  int MAX6916_CONTROL_REG = 0x08, );
 -max6916_write_reg(>dev,
  int MAX6916_CONTROL_REG= 0x08, data);
 -max6916_write_reg(>dev,
  int MAX6916_STATUS_REG = 0x0C, data);
 -max6916_read_reg(>dev,
  int MAX6916_CONTROL_REG = 0x08, );
   -max6916_read_reg(>dev,
  int MAX6916_STATUS_REG  = 0X0C,  );
 -Unnecessary test function if(dt->tm_year >= 100)
  dt->tm_year -= 100;
  is deleted after the range is properly enforced.
 -seperated logical code sections with an empty line
  and used indentation after if-statements.
---
---
 Kconfig   |   9 
 Makefile  |   1 +
 rtc-max6916.c | 162 ++
 3 files changed, 172 insertions(+)

diff --git a/driver/rtc/Kconfig b/driver/rtc/Kconfig
index fcf87da..5321e8f 100644
--- a/driver/rtc/Kconfig
+++ b/driver/rtc/Kconfig
@@ -699,6 +699,15 @@
  
   This driver can also be built as a module. If so, the module
   will be called rtc-max6902.
+config RTC_DRV_MAX6916
+tristate "Maxim MAX6916"
+help
+  If you say yes here you will get support for the
+  Maxim MAX6916 SPI RTC chip.
+
+  This driver can also be built as a module. If so, the module
+  will be called rtc-max6916.
+
  
 config RTC_DRV_R9701
 tristate "Epson RTC-9701JE"
diff --git a/driver/rtc/Makefile b/driver/rtc/Makefile
index 9421959..0b3fded 100644
--- a/driver/rtc/Makefile
+++ b/driver/rtc/Makefile
@@ -85,6 +85,7 @@
 obj-$(CONFIG_RTC_DRV_M48T86)+= rtc-m48t86.o
 obj-$(CONFIG_RTC_DRV_MAX6900)   += rtc-max6900.o
 obj-$(CONFIG_RTC_DRV_MAX6902)   += rtc-max6902.o
+obj-$(CONFIG_RTC_DRV_MAX6916)   += rtc-max6916.o
 obj-$(CONFIG_RTC_DRV_MAX77686)  += rtc-max77686.o
 obj-$(CONFIG_RTC_DRV_MAX77802)  += rtc-max77802.o
 obj-$(CONFIG_RTC_DRV_MAX8907)   += rtc-max8907.o
diff --git a/driver/rtc/rtc-max6916.c b/driver/rtc/rtc-max6916.c
index e69de29..ced341a 100644
--- a/driver/rtc/rtc-max6916.c
+++ b/driver/rtc/rtc-max6916.c
@@ -0,0 +1,162 @@
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+
+/* Registers in max6916 rtc */
+
+#define MAX6916_SECONDS_REG  0x01
+#define MAX6916_MINUTES_REG  0x02
+#define MAX6916_HOURS_REG0x03
+#define MAX6916_DATE_REG 0x04
+#define MAX6916_MONTH_REG0x05
+#define MAX6916_DAY_REG  0x06
+#define MAX6916_YEAR_REG 0x07
+#define MAX6916_CONTROL_REG  0x08
+#define MAX6916_STATUS_REG   0x0C
+#define MAX6916_CLOCK_BURST  0x3F
+#define MAX6916_REG_MAP_ADDRESS  0x1B
+
+static int max6916_read_reg(struct device *dev, unsigned char address, 
unsigned char *data)
+
+{
+   struct spi_device *spi = to_spi_device(dev);
+
+   *data = address | 0x80;
+
+   return spi_write_then_read(spi, data, 1, data, 1);
+}
+
+static int max6916_write_reg(struct device *dev, unsigned char address, 
unsigned char data)
+
+{
+   struct spi_device *spi = to_spi_device(dev);
+   unsigned char buf[2];
+
+   buf[0] = address&0x7F;
+   buf[1] = data;
+
+   return spi_write_then_read(spi, buf, 2, NULL, 0);
+}
+
+static int max6916_read_time(struct device *dev, struct rtc_time *dt)
+{
+   struct spi_device *spi = to_spi_device(dev);
+   int err;
+   

[PATCH] rtc: add support for Maxim rtc max6916 v3.0

2016-05-13 Thread venkat . prashanth2498
From: venkat-prashanth 

 [PATCH] rtc: add support to maxim rtc max6916

 #Change Log: from v2.0 to v3.0

 - fixed the out-of-tree Makefile and suitably added
   the modifications in the Makefile

 - fixed the bad indented Kconfig file

 -used a define instead of 0x1B as follows
#define MAX6916_REG_MAP_ADDRESS 0x1B

 -moved and placed the test at the begining of the function
  after the range is properly enforced
   if (dt->tm_year < 100 || dt->tm_year > 199) {
  dev_err(>dev,"Year must be between 2000 and 2099.
  It's %d.\n", dt->tm_year + 1900);
  return -EINVAL;
  }

 - A magic number is a direct usage of a number
   in the code,instead has been refactored in  the
   current version v3.0 which use defines as follows:-
 -max6916_read_reg(>dev,
  int MAX6916_CONTROL_REG = 0x08, );
 -max6916_write_reg(>dev,
  int MAX6916_CONTROL_REG= 0x08, data);
 -max6916_write_reg(>dev,
  int MAX6916_STATUS_REG = 0x0C, data);
 -max6916_read_reg(>dev,
  int MAX6916_CONTROL_REG = 0x08, );
   -max6916_read_reg(>dev,
  int MAX6916_STATUS_REG  = 0X0C,  );
 -Unnecessary test function if(dt->tm_year >= 100)
  dt->tm_year -= 100;
  is deleted after the range is properly enforced.
 -seperated logical code sections with an empty line
  and used indentation after if-statements.
---
---
 Kconfig   |   9 
 Makefile  |   1 +
 rtc-max6916.c | 162 ++
 3 files changed, 172 insertions(+)

diff --git a/driver/rtc/Kconfig b/driver/rtc/Kconfig
index fcf87da..5321e8f 100644
--- a/driver/rtc/Kconfig
+++ b/driver/rtc/Kconfig
@@ -699,6 +699,15 @@
  
   This driver can also be built as a module. If so, the module
   will be called rtc-max6902.
+config RTC_DRV_MAX6916
+tristate "Maxim MAX6916"
+help
+  If you say yes here you will get support for the
+  Maxim MAX6916 SPI RTC chip.
+
+  This driver can also be built as a module. If so, the module
+  will be called rtc-max6916.
+
  
 config RTC_DRV_R9701
 tristate "Epson RTC-9701JE"
diff --git a/driver/rtc/Makefile b/driver/rtc/Makefile
index 9421959..0b3fded 100644
--- a/driver/rtc/Makefile
+++ b/driver/rtc/Makefile
@@ -85,6 +85,7 @@
 obj-$(CONFIG_RTC_DRV_M48T86)+= rtc-m48t86.o
 obj-$(CONFIG_RTC_DRV_MAX6900)   += rtc-max6900.o
 obj-$(CONFIG_RTC_DRV_MAX6902)   += rtc-max6902.o
+obj-$(CONFIG_RTC_DRV_MAX6916)   += rtc-max6916.o
 obj-$(CONFIG_RTC_DRV_MAX77686)  += rtc-max77686.o
 obj-$(CONFIG_RTC_DRV_MAX77802)  += rtc-max77802.o
 obj-$(CONFIG_RTC_DRV_MAX8907)   += rtc-max8907.o
diff --git a/driver/rtc/rtc-max6916.c b/driver/rtc/rtc-max6916.c
index e69de29..ced341a 100644
--- a/driver/rtc/rtc-max6916.c
+++ b/driver/rtc/rtc-max6916.c
@@ -0,0 +1,162 @@
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+
+/* Registers in max6916 rtc */
+
+#define MAX6916_SECONDS_REG  0x01
+#define MAX6916_MINUTES_REG  0x02
+#define MAX6916_HOURS_REG0x03
+#define MAX6916_DATE_REG 0x04
+#define MAX6916_MONTH_REG0x05
+#define MAX6916_DAY_REG  0x06
+#define MAX6916_YEAR_REG 0x07
+#define MAX6916_CONTROL_REG  0x08
+#define MAX6916_STATUS_REG   0x0C
+#define MAX6916_CLOCK_BURST  0x3F
+#define MAX6916_REG_MAP_ADDRESS  0x1B
+
+static int max6916_read_reg(struct device *dev, unsigned char address, 
unsigned char *data)
+
+{
+   struct spi_device *spi = to_spi_device(dev);
+
+   *data = address | 0x80;
+
+   return spi_write_then_read(spi, data, 1, data, 1);
+}
+
+static int max6916_write_reg(struct device *dev, unsigned char address, 
unsigned char data)
+
+{
+   struct spi_device *spi = to_spi_device(dev);
+   unsigned char buf[2];
+
+   buf[0] = address&0x7F;
+   buf[1] = data;
+
+   return spi_write_then_read(spi, buf, 2, NULL, 0);
+}
+
+static int max6916_read_time(struct device *dev, struct rtc_time *dt)
+{
+   struct spi_device *spi = to_spi_device(dev);
+   int err;
+   unsigned char 

[PATCH] rtc: add support for Maxim rtc max6916 v3.0

2016-05-12 Thread venkat . prashanth2498
From: venkat-prashanth 

 #Change Log: from v2.0 to v3.0

 - fixed the out-of-tree Makefile and suitably added
   the modifications in the Makefile

 - fixed the bad indented Kconfig file

 -used a define instead of 0x1B as follows
#define MAX6916_REG_MAP_ADDRESS 0x1B

 -moved and placed the test at the begining of the function
  after the range is properly enforced
   if (dt->tm_year < 100 || dt->tm_year > 199) {
  dev_err(>dev,"Year must be between 2000 and 2099.
  It's %d.\n", dt->tm_year + 1900);
  return -EINVAL;
  }

 - A magic number is a direct usage of a number
   in the code,instead has been refactored in  the
   current version v3.0 which use defines as follows:-
 -max6916_read_reg(>dev,
  int MAX6916_CONTROL_REG = 0x08, );
 -max6916_write_reg(>dev,
  int MAX6916_CONTROL_REG= 0x08, data);
 -max6916_write_reg(>dev,
  int MAX6916_STATUS_REG = 0x0C, data);
 -max6916_read_reg(>dev,
  int MAX6916_CONTROL_REG = 0x08, );
   -max6916_read_reg(>dev,
  int MAX6916_STATUS_REG  = 0X0C,  );
 -Unnecessary test function if(dt->tm_year >= 100)
  dt->tm_year -= 100;
  is deleted after the range is properly enforced.
 -seperated logical code sections with an empty line
  and used indentation after if-statements.
---
---
 Kconfig   |   9 
 Makefile  |   1 +
 rtc-max6916.c | 162 ++
 3 files changed, 172 insertions(+)

diff --git a/driver/rtc/Kconfig b/driver/rtc/Kconfig
index fcf87da..5321e8f 100644
--- a/driver/rtc/Kconfig
+++ b/driver/rtc/Kconfig
@@ -699,6 +699,15 @@
  
   This driver can also be built as a module. If so, the module
   will be called rtc-max6902.
+config RTC_DRV_MAX6916
+tristate "Maxim MAX6916"
+help
+  If you say yes here you will get support for the
+  Maxim MAX6916 SPI RTC chip.
+
+  This driver can also be built as a module. If so, the module
+  will be called rtc-max6916.
+
  
 config RTC_DRV_R9701
 tristate "Epson RTC-9701JE"
diff --git a/driver/rtc/Makefile b/driver/rtc/Makefile
index 9421959..0b3fded 100644
--- a/driver/rtc/Makefile
+++ b/driver/rtc/Makefile
@@ -85,6 +85,7 @@
 obj-$(CONFIG_RTC_DRV_M48T86)+= rtc-m48t86.o
 obj-$(CONFIG_RTC_DRV_MAX6900)   += rtc-max6900.o
 obj-$(CONFIG_RTC_DRV_MAX6902)   += rtc-max6902.o
+obj-$(CONFIG_RTC_DRV_MAX6916)   += rtc-max6916.o
 obj-$(CONFIG_RTC_DRV_MAX77686)  += rtc-max77686.o
 obj-$(CONFIG_RTC_DRV_MAX77802)  += rtc-max77802.o
 obj-$(CONFIG_RTC_DRV_MAX8907)   += rtc-max8907.o
diff --git a/driver/rtc/rtc-max6916.c b/driver/rtc/rtc-max6916.c
index e69de29..ced341a 100644
--- a/driver/rtc/rtc-max6916.c
+++ b/driver/rtc/rtc-max6916.c
@@ -0,0 +1,162 @@
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+
+/* Registers in max6916 rtc */
+
+#define MAX6916_SECONDS_REG  0x01
+#define MAX6916_MINUTES_REG  0x02
+#define MAX6916_HOURS_REG0x03
+#define MAX6916_DATE_REG 0x04
+#define MAX6916_MONTH_REG0x05
+#define MAX6916_DAY_REG  0x06
+#define MAX6916_YEAR_REG 0x07
+#define MAX6916_CONTROL_REG  0x08
+#define MAX6916_STATUS_REG   0x0C
+#define MAX6916_CLOCK_BURST  0x3F
+#define MAX6916_REG_MAP_ADDRESS  0x1B
+
+static int max6916_read_reg(struct device *dev, unsigned char address, 
unsigned char *data)
+
+{
+   struct spi_device *spi = to_spi_device(dev);
+
+   *data = address | 0x80;
+
+   return spi_write_then_read(spi, data, 1, data, 1);
+}
+
+static int max6916_write_reg(struct device *dev, unsigned char address, 
unsigned char data)
+
+{
+   struct spi_device *spi = to_spi_device(dev);
+   unsigned char buf[2];
+
+   buf[0] = address&0x7F;
+   buf[1] = data;
+
+   return spi_write_then_read(spi, buf, 2, NULL, 0);
+}
+
+static int max6916_read_time(struct device *dev, struct rtc_time *dt)
+{
+   struct spi_device *spi = to_spi_device(dev);
+   int err;
+   unsigned char buf[8];
+
+   

[PATCH] rtc: add support for Maxim rtc max6916 v3.0

2016-05-12 Thread venkat . prashanth2498
From: venkat-prashanth 

 #Change Log: from v2.0 to v3.0

 - fixed the out-of-tree Makefile and suitably added
   the modifications in the Makefile

 - fixed the bad indented Kconfig file

 -used a define instead of 0x1B as follows
#define MAX6916_REG_MAP_ADDRESS 0x1B

 -moved and placed the test at the begining of the function
  after the range is properly enforced
   if (dt->tm_year < 100 || dt->tm_year > 199) {
  dev_err(>dev,"Year must be between 2000 and 2099.
  It's %d.\n", dt->tm_year + 1900);
  return -EINVAL;
  }

 - A magic number is a direct usage of a number
   in the code,instead has been refactored in  the
   current version v3.0 which use defines as follows:-
 -max6916_read_reg(>dev,
  int MAX6916_CONTROL_REG = 0x08, );
 -max6916_write_reg(>dev,
  int MAX6916_CONTROL_REG= 0x08, data);
 -max6916_write_reg(>dev,
  int MAX6916_STATUS_REG = 0x0C, data);
 -max6916_read_reg(>dev,
  int MAX6916_CONTROL_REG = 0x08, );
   -max6916_read_reg(>dev,
  int MAX6916_STATUS_REG  = 0X0C,  );
 -Unnecessary test function if(dt->tm_year >= 100)
  dt->tm_year -= 100;
  is deleted after the range is properly enforced.
 -seperated logical code sections with an empty line
  and used indentation after if-statements.
---
---
 Kconfig   |   9 
 Makefile  |   1 +
 rtc-max6916.c | 162 ++
 3 files changed, 172 insertions(+)

diff --git a/driver/rtc/Kconfig b/driver/rtc/Kconfig
index fcf87da..5321e8f 100644
--- a/driver/rtc/Kconfig
+++ b/driver/rtc/Kconfig
@@ -699,6 +699,15 @@
  
   This driver can also be built as a module. If so, the module
   will be called rtc-max6902.
+config RTC_DRV_MAX6916
+tristate "Maxim MAX6916"
+help
+  If you say yes here you will get support for the
+  Maxim MAX6916 SPI RTC chip.
+
+  This driver can also be built as a module. If so, the module
+  will be called rtc-max6916.
+
  
 config RTC_DRV_R9701
 tristate "Epson RTC-9701JE"
diff --git a/driver/rtc/Makefile b/driver/rtc/Makefile
index 9421959..0b3fded 100644
--- a/driver/rtc/Makefile
+++ b/driver/rtc/Makefile
@@ -85,6 +85,7 @@
 obj-$(CONFIG_RTC_DRV_M48T86)+= rtc-m48t86.o
 obj-$(CONFIG_RTC_DRV_MAX6900)   += rtc-max6900.o
 obj-$(CONFIG_RTC_DRV_MAX6902)   += rtc-max6902.o
+obj-$(CONFIG_RTC_DRV_MAX6916)   += rtc-max6916.o
 obj-$(CONFIG_RTC_DRV_MAX77686)  += rtc-max77686.o
 obj-$(CONFIG_RTC_DRV_MAX77802)  += rtc-max77802.o
 obj-$(CONFIG_RTC_DRV_MAX8907)   += rtc-max8907.o
diff --git a/driver/rtc/rtc-max6916.c b/driver/rtc/rtc-max6916.c
index e69de29..ced341a 100644
--- a/driver/rtc/rtc-max6916.c
+++ b/driver/rtc/rtc-max6916.c
@@ -0,0 +1,162 @@
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+
+/* Registers in max6916 rtc */
+
+#define MAX6916_SECONDS_REG  0x01
+#define MAX6916_MINUTES_REG  0x02
+#define MAX6916_HOURS_REG0x03
+#define MAX6916_DATE_REG 0x04
+#define MAX6916_MONTH_REG0x05
+#define MAX6916_DAY_REG  0x06
+#define MAX6916_YEAR_REG 0x07
+#define MAX6916_CONTROL_REG  0x08
+#define MAX6916_STATUS_REG   0x0C
+#define MAX6916_CLOCK_BURST  0x3F
+#define MAX6916_REG_MAP_ADDRESS  0x1B
+
+static int max6916_read_reg(struct device *dev, unsigned char address, 
unsigned char *data)
+
+{
+   struct spi_device *spi = to_spi_device(dev);
+
+   *data = address | 0x80;
+
+   return spi_write_then_read(spi, data, 1, data, 1);
+}
+
+static int max6916_write_reg(struct device *dev, unsigned char address, 
unsigned char data)
+
+{
+   struct spi_device *spi = to_spi_device(dev);
+   unsigned char buf[2];
+
+   buf[0] = address&0x7F;
+   buf[1] = data;
+
+   return spi_write_then_read(spi, buf, 2, NULL, 0);
+}
+
+static int max6916_read_time(struct device *dev, struct rtc_time *dt)
+{
+   struct spi_device *spi = to_spi_device(dev);
+   int err;
+   unsigned char buf[8];
+
+   buf[0] = MAX6916_CLOCK_BURST |