Commit graph

30 commits

Author SHA1 Message Date
Uwe Kleine-König
a0386bba70
spi: make remove callback a void function
The value returned by an spi driver's remove function is mostly ignored.
(Only an error message is printed if the value is non-zero that the
error is ignored.)

So change the prototype of the remove function to return no value. This
way driver authors are not tempted to assume that passing an error to
the upper layer is a good idea. All drivers are adapted accordingly.
There is no intended change of behaviour, all callbacks were prepared to
return 0 before.

Signed-off-by: Uwe Kleine-König <u.kleine-koenig@pengutronix.de>
Acked-by: Marc Kleine-Budde <mkl@pengutronix.de>
Acked-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Reviewed-by: Geert Uytterhoeven <geert+renesas@glider.be>
Acked-by: Jérôme Pouiller <jerome.pouiller@silabs.com>
Acked-by: Miquel Raynal <miquel.raynal@bootlin.com>
Acked-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
Acked-by: Claudius Heine <ch@denx.de>
Acked-by: Stefan Schmidt <stefan@datenfreihafen.org>
Acked-by: Alexandre Belloni <alexandre.belloni@bootlin.com>
Acked-by: Ulf Hansson <ulf.hansson@linaro.org> # For MMC
Acked-by: Marcus Folkesson <marcus.folkesson@gmail.com>
Acked-by: Łukasz Stelmach <l.stelmach@samsung.com>
Acked-by: Lee Jones <lee.jones@linaro.org>
Link: https://lore.kernel.org/r/20220123175201.34839-6-u.kleine-koenig@pengutronix.de
Signed-off-by: Mark Brown <broonie@kernel.org>
2022-02-09 13:00:45 +00:00
Bartosz Golaszewski
fdcfd85433 rtc: rework rtc_register_device() resource management
rtc_register_device() is a managed interface but it doesn't use devres
by itself - instead it marks an rtc_device as "registered" and the devres
callback for devm_rtc_allocate_device() takes care of resource release.

This doesn't correspond with the design behind devres where managed
structures should not be aware of being managed. The correct solution
here is to register a separate devres callback for unregistering the
device.

While at it: rename rtc_register_device() to devm_rtc_register_device()
and add it to the list of managed interfaces in devres.rst. This way we
can avoid any potential confusion of driver developers who may expect
there to exist a corresponding unregister function.

Signed-off-by: Bartosz Golaszewski <bgolaszewski@baylibre.com>
Signed-off-by: Alexandre Belloni <alexandre.belloni@bootlin.com>
Link: https://lore.kernel.org/r/20201109163409.24301-8-brgl@bgdev.pl
2020-11-19 12:50:12 +01:00
Bartosz Golaszewski
3a905c2d95 rtc: add devm_ prefix to rtc_nvmem_register()
rtc_nvmem_register() is a managed interface. It doesn't require any
release function to be called at driver detach. To avoid confusing
driver authors, let's rename it to devm_rtc_nvmem_register() and add it
to the list of managed interfaces in Documentation/.

Signed-off-by: Bartosz Golaszewski <bgolaszewski@baylibre.com>
Signed-off-by: Alexandre Belloni <alexandre.belloni@bootlin.com>
Link: https://lore.kernel.org/r/20201109163409.24301-6-brgl@bgdev.pl
2020-11-19 12:50:11 +01:00
Alexandre Belloni
25ece30561 rtc: nvmem: remove nvram ABI
The nvram sysfs attributes have been deprecated at least since v4.13, more
than 3 years ago and nobody ever complained about the deprecation warning.

Remove the sysfs attributes now.

[Bartosz: remove the declaration of rtc_nvmem_unregister()]

Signed-off-by: Alexandre Belloni <alexandre.belloni@bootlin.com>
Signed-off-by: Bartosz Golaszewski <bgolaszewski@baylibre.com>
Link: https://lore.kernel.org/r/20201109163409.24301-5-brgl@bgdev.pl
2020-11-19 12:50:11 +01:00
Nobuhiro Iwamatsu
d6e62e7f10 rtc: ds1343: Remove unused struct spi_device in struct ds1343_priv
struct spi_device in struct ds1343_priv is not used, remove it.

CC: Alessandro Zummo <a.zummo@towertech.it>
CC: Alexandre Belloni <alexandre.belloni@bootlin.com>
CC: Raghavendra Chandra Ganiga <ravi23ganiga@gmail.com>
CC: Ankur Srivastava <sankurece@gmail.com>
Signed-off-by: Nobuhiro Iwamatsu <iwamatsu@nigauri.org>
Link: https://lore.kernel.org/r/20191218081917.3308211-1-iwamatsu@nigauri.org
Signed-off-by: Alexandre Belloni <alexandre.belloni@bootlin.com>
2019-12-23 11:22:32 +01:00
Linus Walleij
3b52093dc9 rtc: ds1343: Do not hardcode SPI mode flags
The current use of mode flags to us SPI_MODE_3 and
SPI_CS_HIGH is fragile: it overwrites anything already
assigned by the SPI core. Change it thusly:

- Just |= the SPI_MODE_3 so we keep other flags
- Assign ^= SPI_CS_HIGH since we might be active high
  already, and that is usually the case with GPIOs used
  for chip select, even if they are in practice active low.

Add a comment clarifying why ^= SPI_CS_HIGH is the right
choice here.

Reported-by: Mark Brown <broonie@kernel.org>
Signed-off-by: Linus Walleij <linus.walleij@linaro.org>
Link: https://lore.kernel.org/r/20191204225731.20306-1-linus.walleij@linaro.org
Signed-off-by: Alexandre Belloni <alexandre.belloni@bootlin.com>
2019-12-10 17:47:16 +01:00
Alexandre Belloni
05df557285 rtc: ds1343: cleanup .remove
It is not necessary to call device_init_wakeup(dev, false) in .remove as
device_del will take care of that. It is also not necessary to
devm_free_irq. Finally, dev_pm_clear_wake_irq can be called
unconditionally.

Link: https://lore.kernel.org/r/20191019204941.6203-9-alexandre.belloni@bootlin.com
Signed-off-by: Alexandre Belloni <alexandre.belloni@bootlin.com>
2019-10-19 22:56:11 +02:00
Alexandre Belloni
0680a6cdab rtc: ds1343: rework interrupt handling
Rework the interrupt handling to avoid caching the values as the core is
already doing that. The core also always ensures the rtc_time passed for
the alarm is fully populated.

The only trick is in read_alarm where status needs to be read before the
alarm registers to ensure the potential irq is not cleared.

Link: https://lore.kernel.org/r/20191019204941.6203-8-alexandre.belloni@bootlin.com
Signed-off-by: Alexandre Belloni <alexandre.belloni@bootlin.com>
2019-10-19 22:56:09 +02:00
Alexandre Belloni
a986429095 rtc: ds1343: remove unnecessary mutex
Use rtc_lock and rtc_unlock to lock the rtc from the interrupt handler.
This removes the need for a driver specific lock.

Link: https://lore.kernel.org/r/20191019204941.6203-7-alexandre.belloni@bootlin.com
Signed-off-by: Alexandre Belloni <alexandre.belloni@bootlin.com>
2019-10-19 22:56:07 +02:00
Alexandre Belloni
ce0fd9db65 rtc: ds1343: check regmap_read return value
Check whether regmap_read fails before continuing in the sysfs .show
callbacks.

Link: https://lore.kernel.org/r/20191019204941.6203-6-alexandre.belloni@bootlin.com
Signed-off-by: Alexandre Belloni <alexandre.belloni@bootlin.com>
2019-10-19 22:56:05 +02:00
Alexandre Belloni
ac08888b25 rtc: ds1343: use regmap_update_bits for glitch filter
Use regmap_update_bits to update DS1343_CONTROL_REG in a race free manner
when setting the glitch filter.

Link: https://lore.kernel.org/r/20191019204941.6203-5-alexandre.belloni@bootlin.com
Signed-off-by: Alexandre Belloni <alexandre.belloni@bootlin.com>
2019-10-19 22:56:03 +02:00
Alexandre Belloni
580daaf43a rtc: ds1343: use rtc_add_group
Use rtc_add_group to add the sysfs group in a race free manner.
This has the side effect of moving the files to their proper location.

Link: https://lore.kernel.org/r/20191019204941.6203-4-alexandre.belloni@bootlin.com
Signed-off-by: Alexandre Belloni <alexandre.belloni@bootlin.com>
2019-10-19 22:56:01 +02:00
Alexandre Belloni
f308b68202 rtc: ds1343: use burst write to set time
To avoid possible race condition, use regmap_bulk_write to write all the
date/time registers at once instead of sequentially.

Link: https://lore.kernel.org/r/20191019204941.6203-3-alexandre.belloni@bootlin.com
Signed-off-by: Alexandre Belloni <alexandre.belloni@bootlin.com>
2019-10-19 22:56:00 +02:00
Alexandre Belloni
8c9a88fae2 rtc: ds1343: remove dead code
RTC_SET_CHARGE doesn't exist, the ioctl code is never used.

Link: https://lore.kernel.org/r/20191019204941.6203-2-alexandre.belloni@bootlin.com
Signed-off-by: Alexandre Belloni <alexandre.belloni@bootlin.com>
2019-10-19 22:55:58 +02:00
Alexandre Belloni
21783322fe rtc: ds1343: set range
This is a standard BCD rtc with a useless century bit (no leap year
correction after 2099).

Link: https://lore.kernel.org/r/20191019204941.6203-1-alexandre.belloni@bootlin.com
Signed-off-by: Alexandre Belloni <alexandre.belloni@bootlin.com>
2019-10-19 22:55:56 +02:00
Thomas Gleixner
d2912cb15b treewide: Replace GPLv2 boilerplate/reference with SPDX - rule 500
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 <tglx@linutronix.de>
Reviewed-by: Enrico Weigelt <info@metux.net>
Reviewed-by: Kate Stewart <kstewart@linuxfoundation.org>
Reviewed-by: Allison Randal <allison@lohutok.net>
Cc: linux-spdx@vger.kernel.org
Link: https://lkml.kernel.org/r/20190604081206.933168790@linutronix.de
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2019-06-19 17:09:55 +02:00
Alexandre Belloni
22652ba724 rtc: stop validating rtc_time in .read_time
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 <alexandre.belloni@bootlin.com>
2018-03-02 10:09:58 +01:00
Alexandre Belloni
d7501f7094 rtc: ds1343: use generic nvmem
Instead of adding a binary sysfs attribute from the driver (which suffers
from a race condition as the attribute appears after the device), use the
core to register an nvmem device.

Signed-off-by: Alexandre Belloni <alexandre.belloni@bootlin.com>
2018-03-01 10:49:25 +01:00
Alexandre Belloni
ab39286403 rtc: ds1343: remove undocumented and useless sysfs files
A documented ABI already exists to get information about the alarm. It is
the only one that is used.

Signed-off-by: Alexandre Belloni <alexandre.belloni@bootlin.com>
2018-03-01 10:49:25 +01:00
Alexandre Belloni
1536f6dc9d rtc: ds1343: switch to rtc_register_device
This allows for future improvement of the driver.

Signed-off-by: Alexandre Belloni <alexandre.belloni@bootlin.com>
2018-03-01 10:49:24 +01:00
Alexandre Belloni
b5086150a6 rtc: ds1343: simplify regmap initialization
Avoid using memset as gcc can properly initialize structures.

Signed-off-by: Alexandre Belloni <alexandre.belloni@bootlin.com>
2018-03-01 10:49:24 +01:00
Uwe Kleine-König
56d86a7e79 rtc: simplify implementations of read_alarm
Since commit d68778b80d ("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 <uwe@kleine-koenig.org>
Signed-off-by: Alexandre Belloni <alexandre.belloni@free-electrons.com>
2016-07-09 10:24:45 +02:00
Alexandre Belloni
fa5691131a rtc: remove useless DRV_VERSION
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 <alexandre.belloni@free-electrons.com>
2016-05-20 12:33:51 +02:00
Linus Torvalds
7d884710bb RTC for 4.4
Core:
  - Fix rtctest error path
 
 New drivers:
  - Microcrystal RV8803
 
 Subsystem wide cleanups:
  - remove misuse of IRQF_NO_SUSPEND flag
 
 Drivers:
  - at91rm9200: clear RTC alarm status flag prior to suspending
  - davinci: remove incorrect reference to probe function
  - ds1307: Fix alarm programming for mcp794xx
  - ds1390: trickle charger support, fix ds1390_get_reg
  - isl1208: Pass the IRQF_ONESHOT flag
  - opal: fix type of token
  - pcf2127: fix RTC_READ_VL, remove useless driver version
  - pcf85063: return an error when date is invalid
  - pcf8563: add CLKOUT to common clock framework
  - rx8025: remove unnecessary braces
  - s3c: Set year, month, day value for setting alarm
  - stmp3xxx: unify register access macros
  - License fixes: pcf2127, da9063
  - wakeup-source support for isl12057 and opal
 -----BEGIN PGP SIGNATURE-----
 Version: GnuPG v1
 
 iQIcBAABCAAGBQJWP0pTAAoJEKbNnwlvZCyzlt8P/0vtyp1BHNhgGphevBb5s3My
 fx84mvcGBj9EMAdoN7rn2YjdQDRn+Cmj3CjZ83XNKb8ulXSFU8NAKPSHL7aIVjKL
 2/ZhSKF1FBDzqD2aGaJsE8z9myHjttWEX+LXmpcKsIAlNKJ7RpXKc6CuN4I075Ef
 CUOWNcDdrbWr2ex2+jd+pRZP45ZSNstI66LTYCD/H6amq31nEeIuZCtRT4YkQ0eG
 zKV+I5M3NHmaExNy0Doj0cbCmekjrYNx2iXiucNEoyiIHzbZxg9i1MbYEUnkUn9J
 3bNS14yf1y6QSh12Muqjw3dYGJj+/aolqLAEABct2IsoH25YPDTX1ajkz5pk46B6
 1CS5xbFU99nVOIgr1luSUZAxsz2ZTWwxdaky5DT3iToBkPTNB9el+AOaoC0WosaU
 5SimYbwQ4taOREjKHnCwSpZwTMWISlYQmUM2q/95IS+S/zwj+Su79EOmFEldBof7
 L/Ni4ns3Lu+G+xfko63PZUOy4RbqJPW240ulp2B3IricT1bXd+6glrqp0c7OFWFr
 7bXlykVb7WVwHYSASi9nB7Gmp9XlafVbe5iJluUf5Xx+NHUKsTS9YkTHeDLLeyv+
 nhDd0rFq/O08sakASfBz9uF5GySkpJgg66RcadgvP/6qRms2SQCqypqSVEEtBgzL
 u7i9UuQ2UkIetJQKVhVu
 =sY2D
 -----END PGP SIGNATURE-----

Merge tag 'rtc-v4.4' of git://git.kernel.org/pub/scm/linux/kernel/git/abelloni/linux

Pull RTC updates from Alexandre Belloni:
 "Core:
   - Fix rtctest error path

  New drivers:
   - Microcrystal RV8803

  Subsystem wide cleanups:
   - remove misuse of IRQF_NO_SUSPEND flag

  Drivers:
   - at91rm9200: clear RTC alarm status flag prior to suspending
   - davinci: remove incorrect reference to probe function
   - ds1307: Fix alarm programming for mcp794xx
   - ds1390: trickle charger support, fix ds1390_get_reg
   - isl1208: Pass the IRQF_ONESHOT flag
   - opal: fix type of token
   - pcf2127: fix RTC_READ_VL, remove useless driver version
   - pcf85063: return an error when date is invalid
   - pcf8563: add CLKOUT to common clock framework
   - rx8025: remove unnecessary braces
   - s3c: Set year, month, day value for setting alarm
   - stmp3xxx: unify register access macros
   - License fixes: pcf2127, da9063
   - wakeup-source support for isl12057 and opal"

* tag 'rtc-v4.4' of git://git.kernel.org/pub/scm/linux/kernel/git/abelloni/linux: (23 commits)
  rtc: Add a driver for Micro Crystal RV8803
  rtc: s3c: Set year, month, day value for setting alarm
  rtc: ds1307: Fix alarm programming for mcp794xx
  rtc: isl12057: enable support for the standard "wakeup-source" property
  rtc: opal: enable support for the stardard "wakeup-source" property
  rtc: isl1208: Pass the IRQF_ONESHOT flag
  rtc: pcf8563: add CLKOUT to common clock framework
  rtc: davinci: remove incorrect reference to probe function
  rtc: at91rm9200: clear RTC alarm status flag prior to suspending
  rtc: pcf2127: remove useless driver version
  rtc: pcf2127: fix reading uninitialized value on RTC_READ_VL ioctl
  rtc: stmp3xxx: unify register access macros
  rtc: da9063: GPL copyright inconsistency fix
  rtc: pcf85063: return an error when date is invalid
  rtc: rx8025: remove unnecessary braces
  rtc: ds1343: remove misuse of IRQF_NO_SUSPEND flag
  rtc: ab8500: remove misuse of IRQF_NO_SUSPEND flag
  rtc: pl031: remove misuse of IRQF_NO_SUSPEND flag
  rtc: opal: fix type of token
  rtc: ds1390: Add trickle charger device tree binding
  ...
2015-11-10 10:01:21 -08:00
Sudeep Holla
caff0cc419 rtc: ds1343: remove misuse of IRQF_NO_SUSPEND flag
The IRQF_NO_SUSPEND flag is used to identify the interrupts that should
be left enabled so as to allow them to work as expected during the
suspend-resume cycle, but doesn't guarantee that it will wake the system
from a suspended state, enable_irq_wake is recommended to be used for
the wakeup.

This patch removes the use of IRQF_NO_SUSPEND flags and uses newly
introduce PM wakeup APIs dev_pm_{set,clear}_wake_irq.

Cc: Alessandro Zummo <a.zummo@towertech.it>
Cc: Alexandre Belloni <alexandre.belloni@free-electrons.com>
Cc: rtc-linux@googlegroups.com
Signed-off-by: Sudeep Holla <sudeep.holla@arm.com>
Signed-off-by: Alexandre Belloni <alexandre.belloni@free-electrons.com>
2015-11-08 14:12:25 +01:00
Andrew F. Davis
3821a065f5 spi: Drop owner assignment from spi_drivers
An spi_driver does not need to set an owner, it will be populated by the
driver core.

Signed-off-by: Andrew F. Davis <afd@ti.com>
Acked-by: Jonathan Cameron <jic23@kernel.org>
Signed-off-by: Mark Brown <broonie@kernel.org>
2015-10-28 10:30:17 +09:00
Vladimir Zapolskiy
f4843b19d2 rtc: ds1343: clean up ds1343_nvram_read()/ds1343_nvram_write()
The change removes redundant sysfs binary file boundary checks, since
this task is already done on caller side in fs/sysfs/file.c

Signed-off-by: Vladimir Zapolskiy <vz@mleia.com>
Signed-off-by: Alexandre Belloni <alexandre.belloni@free-electrons.com>
2015-09-05 13:19:10 +02:00
Raghavendra Ganiga
571eb88390 drivers/rtc/rtc-ds1343.c: add support of nvram for maxim dallas rtc ds1343
This is a patch to add support of nvram for maxim dallas rtc ds1343.

Signed-off-by: Raghavendra Chandra Ganiga <ravi23ganiga@gmail.com>
Cc: Alessandro Zummo <a.zummo@towertech.it>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
2014-08-08 15:57:19 -07:00
Raghavendra Ganiga
10b06b87b7 drivers/rtc/rtc-ds1343.c: fix potential race condition
Avoid the potential race condition by avoiding bailing out of driver in
probe after registering with rtc subsystem

Also the set_alarm , read_alarm and alarm_irq_enable returns error if irq
registration fails in probe.

Also the sysfs will not create entry for alarm if irq registration fails
in probe.

Signed-off-by: Raghavendra Chandra Ganiga <ravi23ganiga@gmail.com>
Acked-by: Alessandro Zummo <a.zummo@towertech.it>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
2014-06-06 16:08:08 -07:00
Raghavendra Ganiga
1d6316f56d drivers/rtc: add support for maxim dallas rtc ds1343 and ds1344
Signed-off-by: Raghavendra Chandra Ganiga <ravi23ganiga@gmail.com>
Cc: Alessandro Zummo <a.zummo@towertech.it>
Cc: Jingoo Han <jg1.han@samsung.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
2014-06-06 16:08:08 -07:00