.. | .. |
---|
16 | 16 | #include <linux/types.h> |
---|
17 | 17 | #include <linux/interrupt.h> |
---|
18 | 18 | #include <linux/nvmem-provider.h> |
---|
| 19 | +#include <linux/android_kabi.h> |
---|
19 | 20 | #include <uapi/linux/rtc.h> |
---|
20 | 21 | |
---|
21 | 22 | extern int rtc_month_days(unsigned int month, unsigned int year); |
---|
.. | .. |
---|
32 | 33 | static inline time64_t rtc_tm_sub(struct rtc_time *lhs, struct rtc_time *rhs) |
---|
33 | 34 | { |
---|
34 | 35 | return rtc_tm_to_time64(lhs) - rtc_tm_to_time64(rhs); |
---|
35 | | -} |
---|
36 | | - |
---|
37 | | -static inline void rtc_time_to_tm(unsigned long time, struct rtc_time *tm) |
---|
38 | | -{ |
---|
39 | | - rtc_time64_to_tm(time, tm); |
---|
40 | | -} |
---|
41 | | - |
---|
42 | | -static inline int rtc_tm_to_time(struct rtc_time *tm, unsigned long *time) |
---|
43 | | -{ |
---|
44 | | - *time = rtc_tm_to_time64(tm); |
---|
45 | | - |
---|
46 | | - return 0; |
---|
47 | 36 | } |
---|
48 | 37 | |
---|
49 | 38 | #include <linux/device.h> |
---|
.. | .. |
---|
67 | 56 | * |
---|
68 | 57 | * The (current) exceptions are mostly filesystem hooks: |
---|
69 | 58 | * - the proc() hook for procfs |
---|
70 | | - * - non-ioctl() chardev hooks: open(), release(), read_callback() |
---|
71 | | - * |
---|
72 | | - * REVISIT those periodic irq calls *do* have ops_lock when they're |
---|
73 | | - * issued through ioctl() ... |
---|
74 | 59 | */ |
---|
75 | 60 | struct rtc_class_ops { |
---|
76 | 61 | int (*ioctl)(struct device *, unsigned int, unsigned long); |
---|
.. | .. |
---|
79 | 64 | int (*read_alarm)(struct device *, struct rtc_wkalrm *); |
---|
80 | 65 | int (*set_alarm)(struct device *, struct rtc_wkalrm *); |
---|
81 | 66 | int (*proc)(struct device *, struct seq_file *); |
---|
82 | | - int (*set_mmss64)(struct device *, time64_t secs); |
---|
83 | | - int (*set_mmss)(struct device *, unsigned long secs); |
---|
84 | | - int (*read_callback)(struct device *, int data); |
---|
85 | 67 | int (*alarm_irq_enable)(struct device *, unsigned int enabled); |
---|
86 | 68 | int (*read_offset)(struct device *, long *offset); |
---|
87 | 69 | int (*set_offset)(struct device *, long offset); |
---|
| 70 | + |
---|
| 71 | + ANDROID_KABI_RESERVE(1); |
---|
88 | 72 | }; |
---|
| 73 | + |
---|
| 74 | +struct rtc_device; |
---|
89 | 75 | |
---|
90 | 76 | struct rtc_timer { |
---|
91 | 77 | struct timerqueue_node node; |
---|
92 | 78 | ktime_t period; |
---|
93 | | - void (*func)(void *private_data); |
---|
94 | | - void *private_data; |
---|
| 79 | + void (*func)(struct rtc_device *rtc); |
---|
| 80 | + struct rtc_device *rtc; |
---|
95 | 81 | int enabled; |
---|
96 | 82 | }; |
---|
97 | | - |
---|
98 | 83 | |
---|
99 | 84 | /* flags */ |
---|
100 | 85 | #define RTC_DEV_BUSY 0 |
---|
.. | .. |
---|
138 | 123 | |
---|
139 | 124 | bool registered; |
---|
140 | 125 | |
---|
141 | | - struct nvmem_device *nvmem; |
---|
142 | 126 | /* Old ABI support */ |
---|
143 | 127 | bool nvram_old_abi; |
---|
144 | 128 | struct bin_attribute *nvram; |
---|
.. | .. |
---|
159 | 143 | unsigned int uie_task_active:1; |
---|
160 | 144 | unsigned int uie_timer_active:1; |
---|
161 | 145 | #endif |
---|
| 146 | + |
---|
| 147 | + ANDROID_KABI_RESERVE(1); |
---|
162 | 148 | }; |
---|
163 | 149 | #define to_rtc_device(d) container_of(d, struct rtc_device, dev) |
---|
164 | 150 | |
---|
| 151 | +#define rtc_lock(d) mutex_lock(&d->ops_lock) |
---|
| 152 | +#define rtc_unlock(d) mutex_unlock(&d->ops_lock) |
---|
| 153 | + |
---|
165 | 154 | /* useful timestamps */ |
---|
| 155 | +#define RTC_TIMESTAMP_BEGIN_0000 -62167219200ULL /* 0000-01-01 00:00:00 */ |
---|
166 | 156 | #define RTC_TIMESTAMP_BEGIN_1900 -2208988800LL /* 1900-01-01 00:00:00 */ |
---|
167 | 157 | #define RTC_TIMESTAMP_BEGIN_2000 946684800LL /* 2000-01-01 00:00:00 */ |
---|
| 158 | +#define RTC_TIMESTAMP_END_2063 2966371199LL /* 2063-12-31 23:59:59 */ |
---|
| 159 | +#define RTC_TIMESTAMP_END_2079 3471292799LL /* 2079-12-31 23:59:59 */ |
---|
168 | 160 | #define RTC_TIMESTAMP_END_2099 4102444799LL /* 2099-12-31 23:59:59 */ |
---|
| 161 | +#define RTC_TIMESTAMP_END_2199 7258118399LL /* 2199-12-31 23:59:59 */ |
---|
| 162 | +#define RTC_TIMESTAMP_END_9999 253402300799LL /* 9999-12-31 23:59:59 */ |
---|
169 | 163 | |
---|
170 | | -extern struct rtc_device *rtc_device_register(const char *name, |
---|
171 | | - struct device *dev, |
---|
172 | | - const struct rtc_class_ops *ops, |
---|
173 | | - struct module *owner); |
---|
174 | 164 | extern struct rtc_device *devm_rtc_device_register(struct device *dev, |
---|
175 | 165 | const char *name, |
---|
176 | 166 | const struct rtc_class_ops *ops, |
---|
177 | 167 | struct module *owner); |
---|
178 | 168 | struct rtc_device *devm_rtc_allocate_device(struct device *dev); |
---|
179 | 169 | int __rtc_register_device(struct module *owner, struct rtc_device *rtc); |
---|
180 | | -extern void rtc_device_unregister(struct rtc_device *rtc); |
---|
181 | | -extern void devm_rtc_device_unregister(struct device *dev, |
---|
182 | | - struct rtc_device *rtc); |
---|
183 | 170 | |
---|
184 | 171 | extern int rtc_read_time(struct rtc_device *rtc, struct rtc_time *tm); |
---|
185 | 172 | extern int rtc_set_time(struct rtc_device *rtc, struct rtc_time *tm); |
---|
.. | .. |
---|
205 | 192 | unsigned int enabled); |
---|
206 | 193 | |
---|
207 | 194 | void rtc_handle_legacy_irq(struct rtc_device *rtc, int num, int mode); |
---|
208 | | -void rtc_aie_update_irq(void *private); |
---|
209 | | -void rtc_uie_update_irq(void *private); |
---|
| 195 | +void rtc_aie_update_irq(struct rtc_device *rtc); |
---|
| 196 | +void rtc_uie_update_irq(struct rtc_device *rtc); |
---|
210 | 197 | enum hrtimer_restart rtc_pie_update_irq(struct hrtimer *timer); |
---|
211 | 198 | |
---|
212 | | -void rtc_timer_init(struct rtc_timer *timer, void (*f)(void *p), void *data); |
---|
| 199 | +void rtc_timer_init(struct rtc_timer *timer, void (*f)(struct rtc_device *r), |
---|
| 200 | + struct rtc_device *rtc); |
---|
213 | 201 | int rtc_timer_start(struct rtc_device *rtc, struct rtc_timer *timer, |
---|
214 | 202 | ktime_t expires, ktime_t period); |
---|
215 | 203 | void rtc_timer_cancel(struct rtc_device *rtc, struct rtc_timer *timer); |
---|
.. | .. |
---|
277 | 265 | static inline void rtc_nvmem_unregister(struct rtc_device *rtc) {} |
---|
278 | 266 | #endif |
---|
279 | 267 | |
---|
| 268 | +#ifdef CONFIG_RTC_INTF_SYSFS |
---|
| 269 | +int rtc_add_group(struct rtc_device *rtc, const struct attribute_group *grp); |
---|
| 270 | +int rtc_add_groups(struct rtc_device *rtc, const struct attribute_group **grps); |
---|
| 271 | +#else |
---|
| 272 | +static inline |
---|
| 273 | +int rtc_add_group(struct rtc_device *rtc, const struct attribute_group *grp) |
---|
| 274 | +{ |
---|
| 275 | + return 0; |
---|
| 276 | +} |
---|
| 277 | + |
---|
| 278 | +static inline |
---|
| 279 | +int rtc_add_groups(struct rtc_device *rtc, const struct attribute_group **grps) |
---|
| 280 | +{ |
---|
| 281 | + return 0; |
---|
| 282 | +} |
---|
| 283 | +#endif |
---|
280 | 284 | #endif /* _LINUX_RTC_H_ */ |
---|