diff options
author | H Hartley Sweeten <hsweeten@visionengravers.com> | 2017-02-10 13:11:55 -0500 |
---|---|---|
committer | Alexandre Belloni <alexandre.belloni@free-electrons.com> | 2017-02-11 19:06:35 -0500 |
commit | 68b54f477fae4f50a4010a1b5019bd185d452fa7 (patch) | |
tree | fb5c8f45857f98720a3d7a89d56b885c2a605234 | |
parent | 6db6bd479d4c41de98c6c4f740fbc39e179e4b5f (diff) |
rtc: m48t86: shorten register name defines
For aesthetics. Shorten all the register names by removing '_REG' from all
of them.
This helps fix all the checkpatch.pl issues.
Signed-off-by: H Hartley Sweeten <hsweeten@visionengravers.com>
Signed-off-by: Alexandre Belloni <alexandre.belloni@free-electrons.com>
-rw-r--r-- | drivers/rtc/rtc-m48t86.c | 127 |
1 files changed, 63 insertions, 64 deletions
diff --git a/drivers/rtc/rtc-m48t86.c b/drivers/rtc/rtc-m48t86.c index 0eeb5714c00f..30648ea9e8e0 100644 --- a/drivers/rtc/rtc-m48t86.c +++ b/drivers/rtc/rtc-m48t86.c | |||
@@ -19,25 +19,24 @@ | |||
19 | #include <linux/platform_data/rtc-m48t86.h> | 19 | #include <linux/platform_data/rtc-m48t86.h> |
20 | #include <linux/bcd.h> | 20 | #include <linux/bcd.h> |
21 | 21 | ||
22 | #define M48T86_REG_SEC 0x00 | 22 | #define M48T86_SEC 0x00 |
23 | #define M48T86_REG_SECALRM 0x01 | 23 | #define M48T86_SECALRM 0x01 |
24 | #define M48T86_REG_MIN 0x02 | 24 | #define M48T86_MIN 0x02 |
25 | #define M48T86_REG_MINALRM 0x03 | 25 | #define M48T86_MINALRM 0x03 |
26 | #define M48T86_REG_HOUR 0x04 | 26 | #define M48T86_HOUR 0x04 |
27 | #define M48T86_REG_HOURALRM 0x05 | 27 | #define M48T86_HOURALRM 0x05 |
28 | #define M48T86_REG_DOW 0x06 /* 1 = sunday */ | 28 | #define M48T86_DOW 0x06 /* 1 = sunday */ |
29 | #define M48T86_REG_DOM 0x07 | 29 | #define M48T86_DOM 0x07 |
30 | #define M48T86_REG_MONTH 0x08 /* 1 - 12 */ | 30 | #define M48T86_MONTH 0x08 /* 1 - 12 */ |
31 | #define M48T86_REG_YEAR 0x09 /* 0 - 99 */ | 31 | #define M48T86_YEAR 0x09 /* 0 - 99 */ |
32 | #define M48T86_REG_A 0x0A | 32 | #define M48T86_A 0x0a |
33 | #define M48T86_REG_B 0x0B | 33 | #define M48T86_B 0x0b |
34 | #define M48T86_REG_C 0x0C | 34 | #define M48T86_B_SET BIT(7) |
35 | #define M48T86_REG_D 0x0D | 35 | #define M48T86_B_DM BIT(2) |
36 | 36 | #define M48T86_B_H24 BIT(1) | |
37 | #define M48T86_REG_B_H24 (1 << 1) | 37 | #define M48T86_C 0x0c |
38 | #define M48T86_REG_B_DM (1 << 2) | 38 | #define M48T86_D 0x0d |
39 | #define M48T86_REG_B_SET (1 << 7) | 39 | #define M48T86_D_VRT BIT(7) |
40 | #define M48T86_REG_D_VRT (1 << 7) | ||
41 | 40 | ||
42 | static int m48t86_rtc_read_time(struct device *dev, struct rtc_time *tm) | 41 | static int m48t86_rtc_read_time(struct device *dev, struct rtc_time *tm) |
43 | { | 42 | { |
@@ -45,33 +44,33 @@ static int m48t86_rtc_read_time(struct device *dev, struct rtc_time *tm) | |||
45 | struct platform_device *pdev = to_platform_device(dev); | 44 | struct platform_device *pdev = to_platform_device(dev); |
46 | struct m48t86_ops *ops = dev_get_platdata(&pdev->dev); | 45 | struct m48t86_ops *ops = dev_get_platdata(&pdev->dev); |
47 | 46 | ||
48 | reg = ops->readbyte(M48T86_REG_B); | 47 | reg = ops->readbyte(M48T86_B); |
49 | 48 | ||
50 | if (reg & M48T86_REG_B_DM) { | 49 | if (reg & M48T86_B_DM) { |
51 | /* data (binary) mode */ | 50 | /* data (binary) mode */ |
52 | tm->tm_sec = ops->readbyte(M48T86_REG_SEC); | 51 | tm->tm_sec = ops->readbyte(M48T86_SEC); |
53 | tm->tm_min = ops->readbyte(M48T86_REG_MIN); | 52 | tm->tm_min = ops->readbyte(M48T86_MIN); |
54 | tm->tm_hour = ops->readbyte(M48T86_REG_HOUR) & 0x3F; | 53 | tm->tm_hour = ops->readbyte(M48T86_HOUR) & 0x3f; |
55 | tm->tm_mday = ops->readbyte(M48T86_REG_DOM); | 54 | tm->tm_mday = ops->readbyte(M48T86_DOM); |
56 | /* tm_mon is 0-11 */ | 55 | /* tm_mon is 0-11 */ |
57 | tm->tm_mon = ops->readbyte(M48T86_REG_MONTH) - 1; | 56 | tm->tm_mon = ops->readbyte(M48T86_MONTH) - 1; |
58 | tm->tm_year = ops->readbyte(M48T86_REG_YEAR) + 100; | 57 | tm->tm_year = ops->readbyte(M48T86_YEAR) + 100; |
59 | tm->tm_wday = ops->readbyte(M48T86_REG_DOW); | 58 | tm->tm_wday = ops->readbyte(M48T86_DOW); |
60 | } else { | 59 | } else { |
61 | /* bcd mode */ | 60 | /* bcd mode */ |
62 | tm->tm_sec = bcd2bin(ops->readbyte(M48T86_REG_SEC)); | 61 | tm->tm_sec = bcd2bin(ops->readbyte(M48T86_SEC)); |
63 | tm->tm_min = bcd2bin(ops->readbyte(M48T86_REG_MIN)); | 62 | tm->tm_min = bcd2bin(ops->readbyte(M48T86_MIN)); |
64 | tm->tm_hour = bcd2bin(ops->readbyte(M48T86_REG_HOUR) & 0x3F); | 63 | tm->tm_hour = bcd2bin(ops->readbyte(M48T86_HOUR) & 0x3f); |
65 | tm->tm_mday = bcd2bin(ops->readbyte(M48T86_REG_DOM)); | 64 | tm->tm_mday = bcd2bin(ops->readbyte(M48T86_DOM)); |
66 | /* tm_mon is 0-11 */ | 65 | /* tm_mon is 0-11 */ |
67 | tm->tm_mon = bcd2bin(ops->readbyte(M48T86_REG_MONTH)) - 1; | 66 | tm->tm_mon = bcd2bin(ops->readbyte(M48T86_MONTH)) - 1; |
68 | tm->tm_year = bcd2bin(ops->readbyte(M48T86_REG_YEAR)) + 100; | 67 | tm->tm_year = bcd2bin(ops->readbyte(M48T86_YEAR)) + 100; |
69 | tm->tm_wday = bcd2bin(ops->readbyte(M48T86_REG_DOW)); | 68 | tm->tm_wday = bcd2bin(ops->readbyte(M48T86_DOW)); |
70 | } | 69 | } |
71 | 70 | ||
72 | /* correct the hour if the clock is in 12h mode */ | 71 | /* correct the hour if the clock is in 12h mode */ |
73 | if (!(reg & M48T86_REG_B_H24)) | 72 | if (!(reg & M48T86_B_H24)) |
74 | if (ops->readbyte(M48T86_REG_HOUR) & 0x80) | 73 | if (ops->readbyte(M48T86_HOUR) & 0x80) |
75 | tm->tm_hour += 12; | 74 | tm->tm_hour += 12; |
76 | 75 | ||
77 | return rtc_valid_tm(tm); | 76 | return rtc_valid_tm(tm); |
@@ -83,35 +82,35 @@ static int m48t86_rtc_set_time(struct device *dev, struct rtc_time *tm) | |||
83 | struct platform_device *pdev = to_platform_device(dev); | 82 | struct platform_device *pdev = to_platform_device(dev); |
84 | struct m48t86_ops *ops = dev_get_platdata(&pdev->dev); | 83 | struct m48t86_ops *ops = dev_get_platdata(&pdev->dev); |
85 | 84 | ||
86 | reg = ops->readbyte(M48T86_REG_B); | 85 | reg = ops->readbyte(M48T86_B); |
87 | 86 | ||
88 | /* update flag and 24h mode */ | 87 | /* update flag and 24h mode */ |
89 | reg |= M48T86_REG_B_SET | M48T86_REG_B_H24; | 88 | reg |= M48T86_B_SET | M48T86_B_H24; |
90 | ops->writebyte(reg, M48T86_REG_B); | 89 | ops->writebyte(reg, M48T86_B); |
91 | 90 | ||
92 | if (reg & M48T86_REG_B_DM) { | 91 | if (reg & M48T86_B_DM) { |
93 | /* data (binary) mode */ | 92 | /* data (binary) mode */ |
94 | ops->writebyte(tm->tm_sec, M48T86_REG_SEC); | 93 | ops->writebyte(tm->tm_sec, M48T86_SEC); |
95 | ops->writebyte(tm->tm_min, M48T86_REG_MIN); | 94 | ops->writebyte(tm->tm_min, M48T86_MIN); |
96 | ops->writebyte(tm->tm_hour, M48T86_REG_HOUR); | 95 | ops->writebyte(tm->tm_hour, M48T86_HOUR); |
97 | ops->writebyte(tm->tm_mday, M48T86_REG_DOM); | 96 | ops->writebyte(tm->tm_mday, M48T86_DOM); |
98 | ops->writebyte(tm->tm_mon + 1, M48T86_REG_MONTH); | 97 | ops->writebyte(tm->tm_mon + 1, M48T86_MONTH); |
99 | ops->writebyte(tm->tm_year % 100, M48T86_REG_YEAR); | 98 | ops->writebyte(tm->tm_year % 100, M48T86_YEAR); |
100 | ops->writebyte(tm->tm_wday, M48T86_REG_DOW); | 99 | ops->writebyte(tm->tm_wday, M48T86_DOW); |
101 | } else { | 100 | } else { |
102 | /* bcd mode */ | 101 | /* bcd mode */ |
103 | ops->writebyte(bin2bcd(tm->tm_sec), M48T86_REG_SEC); | 102 | ops->writebyte(bin2bcd(tm->tm_sec), M48T86_SEC); |
104 | ops->writebyte(bin2bcd(tm->tm_min), M48T86_REG_MIN); | 103 | ops->writebyte(bin2bcd(tm->tm_min), M48T86_MIN); |
105 | ops->writebyte(bin2bcd(tm->tm_hour), M48T86_REG_HOUR); | 104 | ops->writebyte(bin2bcd(tm->tm_hour), M48T86_HOUR); |
106 | ops->writebyte(bin2bcd(tm->tm_mday), M48T86_REG_DOM); | 105 | ops->writebyte(bin2bcd(tm->tm_mday), M48T86_DOM); |
107 | ops->writebyte(bin2bcd(tm->tm_mon + 1), M48T86_REG_MONTH); | 106 | ops->writebyte(bin2bcd(tm->tm_mon + 1), M48T86_MONTH); |
108 | ops->writebyte(bin2bcd(tm->tm_year % 100), M48T86_REG_YEAR); | 107 | ops->writebyte(bin2bcd(tm->tm_year % 100), M48T86_YEAR); |
109 | ops->writebyte(bin2bcd(tm->tm_wday), M48T86_REG_DOW); | 108 | ops->writebyte(bin2bcd(tm->tm_wday), M48T86_DOW); |
110 | } | 109 | } |
111 | 110 | ||
112 | /* update ended */ | 111 | /* update ended */ |
113 | reg &= ~M48T86_REG_B_SET; | 112 | reg &= ~M48T86_B_SET; |
114 | ops->writebyte(reg, M48T86_REG_B); | 113 | ops->writebyte(reg, M48T86_B); |
115 | 114 | ||
116 | return 0; | 115 | return 0; |
117 | } | 116 | } |
@@ -122,15 +121,15 @@ static int m48t86_rtc_proc(struct device *dev, struct seq_file *seq) | |||
122 | struct platform_device *pdev = to_platform_device(dev); | 121 | struct platform_device *pdev = to_platform_device(dev); |
123 | struct m48t86_ops *ops = dev_get_platdata(&pdev->dev); | 122 | struct m48t86_ops *ops = dev_get_platdata(&pdev->dev); |
124 | 123 | ||
125 | reg = ops->readbyte(M48T86_REG_B); | 124 | reg = ops->readbyte(M48T86_B); |
126 | 125 | ||
127 | seq_printf(seq, "mode\t\t: %s\n", | 126 | seq_printf(seq, "mode\t\t: %s\n", |
128 | (reg & M48T86_REG_B_DM) ? "binary" : "bcd"); | 127 | (reg & M48T86_B_DM) ? "binary" : "bcd"); |
129 | 128 | ||
130 | reg = ops->readbyte(M48T86_REG_D); | 129 | reg = ops->readbyte(M48T86_D); |
131 | 130 | ||
132 | seq_printf(seq, "battery\t\t: %s\n", | 131 | seq_printf(seq, "battery\t\t: %s\n", |
133 | (reg & M48T86_REG_D_VRT) ? "ok" : "exhausted"); | 132 | (reg & M48T86_D_VRT) ? "ok" : "exhausted"); |
134 | 133 | ||
135 | return 0; | 134 | return 0; |
136 | } | 135 | } |
@@ -148,7 +147,7 @@ static int m48t86_rtc_probe(struct platform_device *dev) | |||
148 | struct rtc_device *rtc; | 147 | struct rtc_device *rtc; |
149 | 148 | ||
150 | rtc = devm_rtc_device_register(&dev->dev, "m48t86", | 149 | rtc = devm_rtc_device_register(&dev->dev, "m48t86", |
151 | &m48t86_rtc_ops, THIS_MODULE); | 150 | &m48t86_rtc_ops, THIS_MODULE); |
152 | 151 | ||
153 | if (IS_ERR(rtc)) | 152 | if (IS_ERR(rtc)) |
154 | return PTR_ERR(rtc); | 153 | return PTR_ERR(rtc); |
@@ -156,9 +155,9 @@ static int m48t86_rtc_probe(struct platform_device *dev) | |||
156 | platform_set_drvdata(dev, rtc); | 155 | platform_set_drvdata(dev, rtc); |
157 | 156 | ||
158 | /* read battery status */ | 157 | /* read battery status */ |
159 | reg = ops->readbyte(M48T86_REG_D); | 158 | reg = ops->readbyte(M48T86_D); |
160 | dev_info(&dev->dev, "battery %s\n", | 159 | dev_info(&dev->dev, "battery %s\n", |
161 | (reg & M48T86_REG_D_VRT) ? "ok" : "exhausted"); | 160 | (reg & M48T86_D_VRT) ? "ok" : "exhausted"); |
162 | 161 | ||
163 | return 0; | 162 | return 0; |
164 | } | 163 | } |