When registering one RTC device, it will check to see if there is an
alarm already set in RTC hardware by reading RTC alarm, at this time
we should always read the normal alarm put in always-on region by
checking the rtc->registered flag.
Signed-off-by: Baolin Wang <[email protected]>
Signed-off-by: Alexandre Belloni <[email protected]>
The RTC interrupt enable register is not put in always-power-on region
supplied by VDDRTC, so we should check if we need enable the alarm
interrupt when system booting.
Signed-off-by: Baolin Wang <[email protected]>
Signed-off-by: Alexandre Belloni <[email protected]>
When registering one rtc device, it will check to see if there is an
alarm already set in rtc hardware by issuing __rtc_read_alarm(). So
we should not disable the RTC interrupts and clear the interrupts
status in probe() function.
Signed-off-by: Baolin Wang <[email protected]>
Signed-off-by: Alexandre Belloni <[email protected]>
We should clear the SPG value update interrupt status once the SPG value
is updated successfully, in case incorrect status validation for next time.
Signed-off-by: Baolin Wang <[email protected]>
Signed-off-by: Alexandre Belloni <[email protected]>
Set wakeup capability before registering rtc device, in case the alarmtimer
can find one available rtc device.
Signed-off-by: Baolin Wang <[email protected]>
Signed-off-by: Alexandre Belloni <[email protected]>
Clang warns:
drivers/rtc/rtc-s35390a.c:124:27: warning: implicit conversion from
'int' to 'char' changes value from 192 to -64 [-Wconstant-conversion]
buf = S35390A_FLAG_RESET | S35390A_FLAG_24H;
~ ~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~
1 warning generated.
Update buf to be an unsigned 8-bit integer, which matches the buf member
in struct i2c_msg.
https://github.com/ClangBuiltLinux/linux/issues/145
Signed-off-by: Nathan Chancellor <[email protected]>
Signed-off-by: Alexandre Belloni <[email protected]>
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]>
In preparation to enabling -Wimplicit-fallthrough, mark switch cases
where we are expecting to fall through.
Notice that in this particular case, I replaced "Fall" with a proper
"Fall through" comment.
Addresses-Coverity-ID: 1373875 ("Missing break in switch")
Signed-off-by: Gustavo A. R. Silva <[email protected]>
Signed-off-by: Alexandre Belloni <[email protected]>
Instead of confusingly returning -EBUSY on failure to obtain an
interrupt, propagate the real error code. While at it, let the user know
why the interrupt could not be acquired.
Signed-off-by: Thierry Reding <[email protected]>
Signed-off-by: Alexandre Belloni <[email protected]>
Fix a problem with commit 311ee9c151 ("rtc: cmos: allow using ACPI for
RTC alarm instead of HPET") defining `use_acpi_alarm' module parameter
even for non-ACPI platforms, which ignore it. Wrap the definition into
#ifdef CONFIG_ACPI and use a static inline wrapper function, hardcoded
to return 0 and consequently optimized away for !ACPI, following the
existing pattern with HPET handling functions.
Signed-off-by: Maciej W. Rozycki <[email protected]>
Fixes: 311ee9c151 ("rtc: cmos: allow using ACPI for RTC alarm instead of HPET")
Cc: [email protected] # 4.18+
Signed-off-by: Alexandre Belloni <[email protected]>
Fix a commit 311ee9c151 ("rtc: cmos: allow using ACPI for RTC alarm
instead of HPET") `rtc-cmos' regression causing a link error:
drivers/rtc/rtc-cmos.o: In function `cmos_platform_probe':
rtc-cmos.c:(.init.text+0x33c): undefined reference to `hpet_rtc_interrupt'
rtc-cmos.c:(.init.text+0x3f4): undefined reference to `hpet_rtc_interrupt'
with non-ACPI platforms using this driver. The cause is the change of
the condition guarding the use of `hpet_rtc_interrupt'.
Previously it was a call to `is_hpet_enabled'. That function is static
inline and has a hardcoded 0 result for non-ACPI platforms, which imply
!HPET_EMULATE_RTC. Consequently the compiler optimized the whole block
away including the reference to `hpet_rtc_interrupt', which never made
it to the link stage.
Now the guarding condition is a call to `use_hpet_alarm', which is not
static inline and therefore the compiler may not be able to prove that
it actually always returns 0 for non-ACPI platforms. Consequently the
build breaks with an unsatisfied reference, because `hpet_rtc_interrupt'
is nowhere defined at link time.
Fix the problem by marking `use_hpet_alarm' inline. As the `inline'
keyword serves as an optimization hint rather than a requirement the
compiler is still free to choose whether inlining will be beneficial or
not for ACPI platforms.
Signed-off-by: Maciej W. Rozycki <[email protected]>
Fixes: 311ee9c151 ("rtc: cmos: allow using ACPI for RTC alarm instead of HPET")
Cc: [email protected] # 4.18+
Signed-off-by: Alexandre Belloni <[email protected]>
Instead of lying to the core when the alarm is invalid, let it handle that
by returning the error.
Signed-off-by: Alexandre Belloni <[email protected]>
Tested-by: Gregory CLEMENT <[email protected]> (on Armada 375 DB)
Signed-off-by: Alexandre Belloni <[email protected]>
Call the 64bit versions of rtc_time_to_tm now that the range is enforced by
the core.
Also remove the open coded rtc_tm_to_time64.
Signed-off-by: Alexandre Belloni <[email protected]>
rtc_time_to_tm always rturns a valid tm, there is no need to validate it.
Signed-off-by: Alexandre Belloni <[email protected]>
Acked-by: Linus Walleij <[email protected]>
Signed-off-by: Alexandre Belloni <[email protected]>
Let the core handle offsetting and windowing the RTC range.
The RTC has a 24 bit counter for minutes plus a seconds counter.
Keep the epoch at the beginning of 2000.
Signed-off-by: Alexandre Belloni <[email protected]>
Acked-by: Linus Walleij <[email protected]>
Signed-off-by: Alexandre Belloni <[email protected]>
Use rtc_add_group to add the sysfs group in a race free manner.
Signed-off-by: Alexandre Belloni <[email protected]>
Reviewed-by: Linus Walleij <[email protected]>
Signed-off-by: Alexandre Belloni <[email protected]>
Instead of resetting the RTC to an bogus valid time, let userspace know
that the time is invalid when XSTP is set. Reset XSTP when setting the time
again.
Signed-off-by: Alexandre Belloni <[email protected]>
The name passed to devm_rtc_device_register is now unused. anyway, switch
to devm_rtc_allocate_device to avoid forward declaring rs5c348_driver.
Signed-off-by: Alexandre Belloni <[email protected]>
Call the 64bit versions of rtc_time_to_tm and rtc_tm_to_time now that the
range is enforced by the core.
Signed-off-by: Alexandre Belloni <[email protected]>
The IRQ is requested before the struct rtc is allocated and registered, but
this struct is used in the IRQ handler. This may lead to a NULL pointer
dereference.
Switch to devm_rtc_allocate_device/rtc_register_device to allocate the rtc
before requesting the IRQ.
Signed-off-by: Alexandre Belloni <[email protected]>
Register frequency test using rtc_add_group to avoid a possible race
condition and simplify the code.
This also moves the attribute to its proper location under the rtc device
instead of the i2c parent device.
Signed-off-by: Alexandre Belloni <[email protected]>
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]>
/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]>
The license text is specifying GPL v2 only but the MODULE_LICENSE is set to
GPL which means GNU Public License v2 or later. When MODULE_LICENSE and
boiler plate does not match, go for boiler plate license.
Signed-off-by: Alexandre Belloni <[email protected]>
The core header file is reserved for the core, stop including it.
Also reorder includes alphabetically.
Signed-off-by: Alexandre Belloni <[email protected]>
On m41txx you can enable open-drain OUT pin to check if offset is ok.
Enabling OUT pin with frequency_test_enable attribute, OUT pin will tick
512 times faster than 1s tick base.
Enable or Disable FT bit on CONTROL register if freq_test is 1 or 0.
Signed-off-by: Giulio Benetti <[email protected]>
Signed-off-by: Alexandre Belloni <[email protected]>
m41txx chips can hold a calibration value to get correct clock bias.
Add offset handling (ranging between -63ppm and 126ppm) via sysfs.
Signed-off-by: Giulio Benetti <[email protected]>
Signed-off-by: Alexandre Belloni <[email protected]>
Use rtc_add_group to add the common sysfs group to avoid a possible race
condition.
[[email protected]: use to_i2c_client(dev->parent)]
Signed-off-by: Denis Osterland <[email protected]>
Signed-off-by: Alexandre Belloni <[email protected]>
The move of atrim, dtrim usr sysfs properties from i2c device
to rtc device require to access them via dev->parent.
This patch also aligns timestamp0.
Stale mentions of irq_task are left in the kerneldoc after its removal.
Remove them.
There is still one indirect mention left but commit 3c8bb90efb ("rtc: Fix
hrtimer deadlock") can probably be reverted now.
Reported-by: Linus Torvalds <[email protected]>
Signed-off-by: Alexandre Belloni <[email protected]>
Ensure the non managed version of the un/registration functions is not used
anymore. No driver is using it anymore and they should not be necessary.
Signed-off-by: Alexandre Belloni <[email protected]>
The abx804 and abx805 chips have support for a simple watchdog
function that can trigger an external reset.
Signed-off-by: Jeremy Gebben <[email protected]>
Reviewed-by: Guenter Roeck <[email protected]>
Signed-off-by: Alexandre Belloni <[email protected]>
This will allow additional data to be tracked, for future
improvements.
Signed-off-by: Jeremy Gebben <[email protected]>
Signed-off-by: Alexandre Belloni <[email protected]>
The IRQ is requested before the struct rtc is allocated and registered, but
this struct is used in the IRQ handler. This may lead to a NULL pointer
dereference.
Switch to devm_rtc_allocate_device/rtc_register_device to allocate the rtc
before requesting the IRQ.
Signed-off-by: Alexandre Belloni <[email protected]>
The IRQ is requested before the struct rtc is allocated and registered, but
this struct is used in the IRQ handler. This may lead to a NULL pointer
dereference.
Switch to devm_rtc_allocate_device/rtc_register_device to allocate the rtc
before requesting the IRQ.
Acked-by: Eddie Huang <[email protected]>
Signed-off-by: Alexandre Belloni <[email protected]>
Fixes gcc '-Wunused-but-set-variable' warning:
drivers/rtc/rtc-mrst.c: In function 'mrst_procfs':
drivers/rtc/rtc-mrst.c:264:29: warning:
variable 'valid' set but not used [-Wunused-but-set-variable]
unsigned char rtc_control, valid;
Signed-off-by: YueHaibing <[email protected]>
Signed-off-by: Alexandre Belloni <[email protected]>
The Epson rx8803 is mostly similar to the Microcrystal RV8803 but the size
of the offset register is 4 bits vs 6 bits but it has a configurable
temperature compensation.
Signed-off-by: Alexandre Belloni <[email protected]>
devm_kcalloc() returns NULL, it never returns error pointers. In the
current code we would return PTR_ERR(NULL) which is success, instead of
returning the -ENOMEM error code.
Fixes: a0a1a1ba30 ("rtc: sysfs: facilitate attribute add to rtc device")
Signed-off-by: Dan Carpenter <[email protected]>
Signed-off-by: Alexandre Belloni <[email protected]>
One of the more common cases of allocation size calculations is finding
the size of a structure that has a zero-sized array at the end, along
with memory for some number of elements for that array. For example:
struct foo {
int stuff;
void *entry[];
};
instance = kzalloc(sizeof(struct foo) + sizeof(void *) * count, GFP_KERNEL);
Instead of leaving these open-coded and prone to type mistakes, we can
now use the new struct_size() helper:
instance = kzalloc(struct_size(instance, entry, count), GFP_KERNEL);
Signed-off-by: Gustavo A. R. Silva <[email protected]>
Reviewed-by: Kees Cook <[email protected]>
Signed-off-by: Alexandre Belloni <[email protected]>
Depending on MACH_INGENIC prevent us from creating a generic kernel that
works on more than one MIPS board. Instead, we just depend on MIPS being
set.
Signed-off-by: Paul Cercueil <[email protected]>
Signed-off-by: Alexandre Belloni <[email protected]>