aboutsummaryrefslogtreecommitdiff
path: root/drivers/rtc/rtc-ds1685.c
AgeCommit message (Collapse)AuthorFilesLines
2020-09-15rtc: ds1685: Fix bank switching to avoid endless loopThomas Bogendoerfer1-4/+4
ds1685_rtc_begin_data_access() tried to access an extended register before enabling access to it by switching to bank 1. Depending on content in NVRAM this could lead to an endless loop. While at it fix also switch back to bank 0 in ds1685_rtc_end_data_access(). Signed-off-by: Thomas Bogendoerfer <[email protected]> Signed-off-by: Alexandre Belloni <[email protected]> Acked-by: Joshua Kinard <[email protected]> Link: https://lore.kernel.org/r/[email protected]
2019-11-27rtc: ds1685: fix build error with make W=1Alexandre Belloni1-3/+3
Fix the following parsing errors when building with W=1: drivers/rtc/rtc-ds1685.c:1053: error: Cannot parse struct or union! drivers/rtc/rtc-ds1685.c:1062: error: Cannot parse struct or union! drivers/rtc/rtc-ds1685.c:1363: warning: cannot understand function prototype: 'struct platform_driver ds1685_rtc_driver = ' Cc: Joshua Kinard <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Alexandre Belloni <[email protected]>
2019-11-27rtc: ds1685: remove set but unused variablesAlexandre Belloni1-4/+2
Fix the following warnings: drivers/rtc/rtc-ds1685.c: In function ‘ds1685_rtc_read_time’: drivers/rtc/rtc-ds1685.c:264:5: warning: variable ‘ctrlb’ set but not used [-Wunused-but-set-variable] 264 | u8 ctrlb, century; | ^~~~~ drivers/rtc/rtc-ds1685.c: In function ‘ds1685_rtc_proc’: drivers/rtc/rtc-ds1685.c:758:19: warning: variable ‘ctrlc’ set but not used [-Wunused-but-set-variable] 758 | u8 ctrla, ctrlb, ctrlc, ctrld, ctrl4a, ctrl4b, ssn[8]; | ^~~~~ Cc: Joshua Kinard <[email protected]> Acked-By: Joshua Kinard <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Alexandre Belloni <[email protected]>
2019-10-16rtc: ds1685: add indirect access method and remove plat_read/plat_writeThomas Bogendoerfer1-26/+52
SGI Octane (IP30) doesn't have RTC register directly mapped into CPU address space, but accesses RTC registers with an address and data register. This is now supported by additional access functions, which are selected by a new field in platform data. Removed plat_read/plat_write since there is no user and their usage could introduce lifetime issue, when functions are placed in different modules. Signed-off-by: Thomas Bogendoerfer <[email protected]> Acked-by: Joshua Kinard <[email protected]> Reviewed-by: Joshua Kinard <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Alexandre Belloni <[email protected]>
2019-10-14rtc: ds1685: use devm_platform_ioremap_resource helperThomas Bogendoerfer1-20/+3
Simplify ioremapping of registers by using devm_platform_ioremap_resource. Signed-off-by: Thomas Bogendoerfer <[email protected]> Acked-by: Joshua Kinard <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Alexandre Belloni <[email protected]>
2019-10-14rts: ds1685: remove not needed fields from private structThomas Bogendoerfer1-3/+0
A few of the fields in struct ds1685_priv aren't needed at all, so we can remove it. Signed-off-by: Thomas Bogendoerfer <[email protected]> Acked-by: Joshua Kinard <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Alexandre Belloni <[email protected]>
2019-06-19treewide: Replace GPLv2 boilerplate/reference with SPDX - rule 500Thomas Gleixner1-4/+1
Based on 2 normalized pattern(s): this program is free software you can redistribute it and or modify it under the terms of the gnu general public license version 2 as published by the free software foundation this program is free software you can redistribute it and or modify it under the terms of the gnu general public license version 2 as published by the free software foundation # extracted by the scancode license scanner the SPDX license identifier GPL-2.0-only has been chosen to replace the boilerplate/reference in 4122 file(s). Signed-off-by: Thomas Gleixner <[email protected]> Reviewed-by: Enrico Weigelt <[email protected]> Reviewed-by: Kate Stewart <[email protected]> Reviewed-by: Allison Randal <[email protected]> Cc: [email protected] Link: https://lkml.kernel.org/r/[email protected] Signed-off-by: Greg Kroah-Hartman <[email protected]>
2019-04-16rtc: ds1685: use threaded interruptThomas Bogendoerfer1-116/+104
Handling of extended interrupts (kickstart, wake-up, ram-clear) was moved off to a work queue, but the interrupts aren't acknowledged in the interrupt handler. This leads to a deadlock, if driver is used with interrupts. To fix this we use a threaded interrupt, get rid of the work queue and do locking with just the rtc mutex lock. Fixes: aaaf5fbf56f1 ("rtc: add driver for DS1685 family of real time clocks") Signed-off-by: Thomas Bogendoerfer <[email protected]> Signed-off-by: Alexandre Belloni <[email protected]>
2019-04-16rtc: ds1685: remove dead codeThomas Bogendoerfer1-36/+0
ds1685_rtc_begin_ctrl_access/ds1685_rtc_end_ctrl_access aren't used, so get rid of it. Signed-off-by: Thomas Bogendoerfer <[email protected]> Signed-off-by: Alexandre Belloni <[email protected]>
2019-04-12rtc: ds1685: fix crash caused by referencing wrong device structThomas Bogendoerfer1-3/+3
sysfs entries added by rtc_add_group are called with the rtc device as argument and not the underlying device. Fixed by using the dev->parent Fixes: cfb74916e2ec ("rtc: ds1685: use rtc_add_group") Signed-off-by: Thomas Bogendoerfer <[email protected]> Signed-off-by: Alexandre Belloni <[email protected]>
2018-10-22rtc: ds1685: simplify getting .driver_dataWolfram Sang1-2/+1
We should get 'driver_data' from 'struct device' directly. Going via platform_device is an unneeded step back and forth. Signed-off-by: Wolfram Sang <[email protected]> Signed-off-by: Alexandre Belloni <[email protected]>
2018-09-28rtc: ds1685: use rtc_add_groupAlexandre Belloni1-39/+1
Use rtc_add_group to add the sysfs group in a race free manner. Signed-off-by: Alexandre Belloni <[email protected]>
2018-09-28rtc: ds1685: use generic nvmemAlexandre Belloni1-67/+25
Instead of adding a binary sysfs attribute from the driver, use the core to register an nvmem device. Signed-off-by: Alexandre Belloni <[email protected]>
2018-09-28rtc: ds1685: drop RTC_DS1685_PROC_REGSAlexandre Belloni1-61/+0
/proc is not the correct ABI to display debugging info. Remove RTC_DS1685_PROC_REGS as the driver hasn't seen any real development since it was included. Signed-off-by: Alexandre Belloni <[email protected]>
2018-06-20rtc: ds1685: remove sysfs access to control registersAlexandre Belloni1-369/+0
Access to the control registers is mostly not needed and can cause runtime issues (like missed interrupts). Remove this debugging interface. Signed-off-by: Alexandre Belloni <[email protected]>
2018-06-20rtc: ds1685: remove improper datetime access ABIAlexandre Belloni1-221/+0
The driver exposes an undocumented ABI to access the date and time registers. It is not actually used by any userspace tools. Remove it. Signed-off-by: Alexandre Belloni <[email protected]>
2018-05-31rtc: ds1685: Add rangeAlexandre Belloni1-0/+4
Useful range is 2000-2099 because leap year fails on centuries. Signed-off-by: Alexandre Belloni <[email protected]>
2018-05-31rtc: ds1685: fix possible race conditionAlexandre Belloni1-23/+18
The IRQ is requested before the struct rtc is allocated and registered, but this struct is used in the IRQ handler. Switch to devm_rtc_allocate_device/rtc_register_device to allocate the rtc before requesting the IRQ. Signed-off-by: Alexandre Belloni <[email protected]>
2018-05-03rtc: simplify getting .drvdataWolfram Sang1-14/+7
We should get drvdata from struct device directly. Going via platform_device is an unneeded step back and forth. Signed-off-by: Wolfram Sang <[email protected]> Acked-by: Michal Simek <[email protected]> (for zynqmp) Signed-off-by: Alexandre Belloni <[email protected]>
2018-03-02rtc: stop validating rtc_time in .read_timeAlexandre Belloni1-1/+1
The RTC core is always calling rtc_valid_tm after the read_time callback. It is not necessary to call it just before returning from the callback. Signed-off-by: Alexandre Belloni <[email protected]>
2016-07-09rtc: simplify implementations of read_alarmUwe Kleine-König1-15/+4
Since commit d68778b80dd7 ("rtc: initialize output parameter for read alarm to "uninitialized"") there is no need to explicitly set unsupported members to -1. So drop the respective assignments from drivers. Signed-off-by: Uwe Kleine-König <[email protected]> Signed-off-by: Alexandre Belloni <[email protected]>
2016-06-04rtc: ds1685: correct day of month checkingHeinrich Schuchardt1-5/+29
The day of month is checked in ds1685_rtc_read_alarm and ds1685_rtc_set_alarm. Multiple errors exist in the day of month check. Operator ! has a higher priority than &&. (!(mday >= 1) && (mday <= 31)) is false for mday == 32. When verifying the day of month the binary and the BCD mode have to be considered. Signed-off-by: Heinrich Schuchardt <[email protected]> Signed-off-by: Alexandre Belloni <[email protected]>
2016-05-20rtc: ds1685: actually spin forever in poweroff pathJosh Poimboeuf1-0/+1
objtool reports the following warning: drivers/rtc/rtc-ds1685.o: warning: objtool: ds1685_rtc_poweroff() falls through to next function ds1685_rtc_work_queue() Similar to commit 361c6ed6b153 ("rtc: ds1685: actually spin forever in poweroff error path"), there's another unreachable() annotation which is actually reachable, which we missed the first time. Actually spin forever to be consistent with the comment and to make the unreachable() annotation guaranteed to be unreachable. Reported-by: kbuild test robot <[email protected]> Signed-off-by: Josh Poimboeuf <[email protected]> Signed-off-by: Alexandre Belloni <[email protected]>
2016-05-20rtc: remove useless DRV_VERSIONAlexandre Belloni1-3/+0
Many drivers are defining a DRV_VERSION. This is often only used for MODULE_VERSION and sometimes to print an info message at probe time. This is kind of pointless as they are all versionned with the kernel anyway. Also the core will print a message when a new rtc is found. Signed-off-by: Alexandre Belloni <[email protected]>
2016-03-14rtc: ds1685: actually spin forever in poweroff error pathJosh Poimboeuf1-0/+1
objtool reports the following warnings: drivers/rtc/rtc-ds1685.o: warning: objtool: ds1685_rtc_work_queue()+0x0: duplicate frame pointer save drivers/rtc/rtc-ds1685.o: warning: objtool: ds1685_rtc_work_queue()+0x3: duplicate frame pointer setup drivers/rtc/rtc-ds1685.o: warning: objtool: ds1685_rtc_work_queue()+0x0: frame pointer state mismatch The warning message needs to be improved, but what it really means in this case is that ds1685_rtc_poweroff() has a possible code path where it can actually fall through to the next function in the object code, ds1685_rtc_work_queue(). The bug is caused by the use of the unreachable() macro in a place which is actually reachable. That causes gcc to assume that the printk() immediately before the unreachable() macro never returns, when in fact it does. So gcc places the printk() at the very end of the function's object code. When the printk() returns, the next function starts executing. The surrounding comment and printk message state that the code should spin forever, which explains the unreachable() statement. However the actual spin code is missing. Reported-by: kbuild test robot <[email protected]> Signed-off-by: Josh Poimboeuf <[email protected]> Signed-off-by: Alexandre Belloni <[email protected]>
2016-03-14rtc: ds1685: passing bogus values to irq_restoreDan Carpenter1-4/+4
We call spin_lock_irqrestore with "flags" set to zero instead of to the value from spin_lock_irqsave(). Fixes: aaaf5fbf56f1 ('rtc: add driver for DS1685 family of real time clocks') Signed-off-by: Dan Carpenter <[email protected]> Signed-off-by: Alexandre Belloni <[email protected]>
2016-01-11rtc: ds1685: don't try to micromanage sysfs output sizeRasmus Villemoes1-7/+5
...and don't do it wrong. "not ok or N/A" has length 13. Add the trailing newline, and the snprintf return value will be 14. However, we lied to snprintf and told it that only 13 bytes were available. Hence snprintf has only written "not ok or N/" and a trailing '\0' to the buffer. Next we continue lying, this time to the upper sysfs layer, claiming that we wrote 14 meaningful bytes to the buffer. That'll make the upper layer copy "not ok or N/" plus two nul bytes to user space (one nul byte from snprintf, the other since sysfs takes care to clear the buffer before giving it to the ->show method). In the other cases, the claimed buffer size is closer to sufficient, but we'll still get a nul byte instead of a newline written to user space. There's absolutely no reason to try to predict the output size, and there's plenty of room in the buffer, so just use sprintf. Signed-off-by: Rasmus Villemoes <[email protected]> Signed-off-by: Alexandre Belloni <[email protected]>
2016-01-11rtc: use %ph for short hex dumpsRasmus Villemoes1-7/+5
This makes the generated code slightly smaller. Signed-off-by: Rasmus Villemoes <[email protected]> Signed-off-by: Alexandre Belloni <[email protected]>
2015-09-05rtc: ds1685: Use module_platform_driverVaishali Thakkar1-21/+1
Use module_platform_driver for drivers whose init and exit functions only register and unregister, respectively. A simplified version of the Coccinelle semantic patch that performs this transformation is as follows: @a@ identifier f, x; @@ -static f(...) { return platform_driver_register(&x); } @b depends on a@ identifier e, a.x; @@ -static e(...) { platform_driver_unregister(&x); } @c depends on a && b@ identifier a.f; declarer name module_init; @@ -module_init(f); @d depends on a && b && c@ identifier b.e, a.x; declarer name module_exit; declarer name module_platform_driver; @@ -module_exit(e); +module_platform_driver(x); Signed-off-by: Vaishali Thakkar <[email protected]> Signed-off-by: Alexandre Belloni <[email protected]>
2015-04-17rtc: use more standard kernel logging stylesJoe Perches1-1/+3
Neaten the logging a bit by adding #define pr_fmt Miscellanea: o Remove __FILE__/__func__ uses o Coalesce formats adding missing spaces o Align arguments o (rtc-cmos) Integrated 2 consecutive messages Signed-off-by: Joe Perches <[email protected]> Acked-by: Alexandre Belloni <[email protected]> Cc: Alessandro Zummo <[email protected]> Cc: Joshua Kinard <[email protected]> Cc: Chanwoo Choi <[email protected]> Reviewed-by: Krzysztof Kozlowski <[email protected]> Tested-by: Krzysztof Kozlowski <[email protected]> Cc: Aaro Koskinen <[email protected]> Signed-off-by: Andrew Morton <[email protected]> Signed-off-by: Linus Torvalds <[email protected]>
2015-04-17drivers/rtc/rtc-ds1685.c: fix sparse warningsJoshua Kinard1-2/+2
Fix two minor sparse warnings: CHECK drivers/rtc/rtc-ds1685.c drivers/rtc/rtc-ds1685.c:2178:1: warning: function 'ds1685_rtc_poweroff' with external linkage has definition drivers/rtc/rtc-ds1685.c:802:23: warning: Using plain integer as NULL pointer Fixes: aaaf5fbf56f1 ("rtc: add driver for DS1685 family of real time clocks") Signed-off-by: Joshua Kinard <[email protected]> Signed-off-by: Andrew Morton <[email protected]> Signed-off-by: Linus Torvalds <[email protected]>
2015-04-17drivers/rtc/rtc-ds1685.c: remove .owner assignment from platform_driverJoshua Kinard1-1/+0
The rtc driver core now sets the platform_driver 'owner' property, so remove the assignment from the DS1685 driver. Fixes: aaaf5fbf56f1: "rtc: add driver for DS1685 family of real time clocks" Signed-off-by: Joshua Kinard <[email protected]> Reported-by: kbuild test robot <[email protected]> Signed-off-by: Andrew Morton <[email protected]> Signed-off-by: Linus Torvalds <[email protected]>
2015-02-28drivers/rtc/rtc-ds1685.c: fix conditional in ↵Joshua Kinard1-2/+2
ds1685_rtc_sysfs_time_regs_{show,store} Fix a conditional statement checking for NULL in both ds1685_rtc_sysfs_time_regs_show and ds1685_rtc_sysfs_time_regs_store that was using a logical AND when it should be using a logical OR so that we fail out of the function properly if the condition ever evaluates to true. Fixes: aaaf5fbf56f1 ("rtc: add driver for DS1685 family of real time clocks") Signed-off-by: Joshua Kinard <[email protected]> Reported-by: Dan Carpenter <[email protected]> Signed-off-by: Andrew Morton <[email protected]> Signed-off-by: Linus Torvalds <[email protected]>
2015-02-28rtc: ds1685: remove superfluous checks for out-of-range u8 valuesGeert Uytterhoeven1-6/+6
drivers/rtc/rtc-ds1685.c: In function `ds1685_rtc_read_alarm': drivers/rtc/rtc-ds1685.c:402: warning: comparison is always true due to limited range of data type drivers/rtc/rtc-ds1685.c:409: warning: comparison is always true due to limited range of data type drivers/rtc/rtc-ds1685.c:416: warning: comparison is always true due to limited range of data type drivers/rtc/rtc-ds1685.c: In function `ds1685_rtc_set_alarm': drivers/rtc/rtc-ds1685.c:475: warning: comparison is always true due to limited range of data type drivers/rtc/rtc-ds1685.c:478: warning: comparison is always true due to limited range of data type drivers/rtc/rtc-ds1685.c:481: warning: comparison is always true due to limited range of data type u8 cannot contain a value larger than 0xff, hence drop the checks. Wrapping the checks in unlikely() indicated some sense of humor, though ;-) Signed-off-by: Geert Uytterhoeven <[email protected]> Acked-by: Joshua Kinard <[email protected]> Cc: Alessandro Zummo <[email protected]> Signed-off-by: Andrew Morton <[email protected]> Signed-off-by: Linus Torvalds <[email protected]>
2015-02-28rtc: ds1685: fix ds1685_rtc_alarm_irq_enable build errorArnd Bergmann1-2/+0
The newly added ds1685 driver causes a build error when enabled without CONFIG_RTC_INTF_DEV: drivers/rtc/rtc-ds1685.c:919:22: error: 'ds1685_rtc_alarm_irq_enable' undeclared here (not in a function) .alarm_irq_enable = ds1685_rtc_alarm_irq_enable, Apparently the driver was incorrectly changed to reflect the interface change from 16380c153a69c ("RTC: Convert rtc drivers to use the alarm_irq_enable method"), which removed the respective #ifdef from all other rtc drivers. This does the same change that was merged for the other drivers before and removes the #ifdef, allowing the interrupts to be enabled through the in-kernel rtc interface independent of the existence of /dev/rtc. Fixes: aaaf5fbf56f ("rtc: add driver for DS1685 family of real time clocks") Signed-off-by: Arnd Bergmann <[email protected]> Acked-by: Joshua Kinard <[email protected]> Cc: Ralf Baechle <[email protected]> Cc: Alessandro Zummo <[email protected]> Signed-off-by: Andrew Morton <[email protected]> Signed-off-by: Linus Torvalds <[email protected]>
2015-02-16rtc: add driver for DS1685 family of real time clocksJoshua Kinard1-0/+2252
This adds a driver for the Dallas/Maxim DS1685-family of RTC chips. It supports the DS1685/DS1687, DS1688/DS1691, DS1689/DS1693, DS17285/DS17287, DS17485/DS17487, and DS17885/DS17887 RTC chips. These chips are commonly found in SGI O2 and SGI Octane systems. It was originally derived from a driver patch submitted by Matthias Fuchs many years ago for use in EPPC-405-UC modules, which also used these RTCs. In addition to the time-keeping functions, this RTC also handles the shutdown mechanism of the O2 and Octane and acts as a partial NVRAM for the boot PROMS in these systems. Verified on both an SGI O2 and an SGI Octane. Signed-off-by: Joshua Kinard <[email protected]> Cc: Ralf Baechle <[email protected]> Cc: Alessandro Zummo <[email protected]> Signed-off-by: Andrew Morton <[email protected]> Signed-off-by: Linus Torvalds <[email protected]>