linux-iio.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH v7 0/3] devres: provide and use devm_krealloc()
@ 2020-08-17 17:05 Bartosz Golaszewski
  2020-08-17 17:05 ` [PATCH v7 1/3] devres: provide devm_krealloc() Bartosz Golaszewski
                   ` (2 more replies)
  0 siblings, 3 replies; 11+ messages in thread
From: Bartosz Golaszewski @ 2020-08-17 17:05 UTC (permalink / raw)
  To: Jonathan Cameron, Hartmut Knaack, Lars-Peter Clausen,
	Peter Meerwald-Stadler, Michal Simek, Greg Kroah-Hartman,
	Guenter Roeck, Andy Shevchenko
  Cc: linux-iio, linux-arm-kernel, linux-kernel, Bartosz Golaszewski

From: Bartosz Golaszewski <bgolaszewski@baylibre.com>

Hi Greg, Andy,

this is another reworked version of devm_krealloc(). This time without the risk
of sleeping with spinlock taken but still with enough protection for the devres
list. We're using slab's ksize() to determine whether the new size is larger
than the current real size of the chunk and then either return the same pointer
or manually alloc a new, larger chunk outside of the spinlock.

===

Regular krealloc() obviously can't work with managed memory. This series
implements devm_krealloc() and adds two first users with hope that this
helper will be adopted by other drivers currently using non-managed
krealloc().

v1 -> v2:
- remove leftover call to hwmon_device_unregister() from pmbus_core.c
- add a patch extending devm_kmalloc() to handle zero size case
- use WARN_ON() instead of WARN_ONCE() in devm_krealloc() when passed
  a pointer to non-managed memory
- correctly handle the case when devm_krealloc() is passed a pointer to
  memory in .rodata (potentially returned by devm_kstrdup_const())
- correctly handle ZERO_SIZE_PTR passed as the ptr argument in devm_krealloc()

v2 -> v3:
- drop already applied patches
- collect Acks
- add an additional user in iio

v3 -> v4:
- add the kerneldoc for devm_krealloc()
- WARN() outside of spinlock
- rename local variable

v4 -> v5:
- tweak the kerneldoc

v5 -> v6:
- tweak the devres_lock handling in devm_krealloc()

v6 -> v7:
- rework devm_krealloc() to avoid calling krealloc() with spinlock taken

Bartosz Golaszewski (3):
  devres: provide devm_krealloc()
  hwmon: pmbus: use more devres helpers
  iio: adc: xilinx-xadc: use devm_krealloc()

 .../driver-api/driver-model/devres.rst        |  1 +
 drivers/base/devres.c                         | 93 +++++++++++++++++++
 drivers/hwmon/pmbus/pmbus_core.c              | 28 ++----
 drivers/iio/adc/xilinx-xadc-core.c            | 16 ++--
 include/linux/device.h                        |  2 +
 5 files changed, 113 insertions(+), 27 deletions(-)

-- 
2.26.1


^ permalink raw reply	[flat|nested] 11+ messages in thread

end of thread, other threads:[~2020-08-19  9:31 UTC | newest]

Thread overview: 11+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-08-17 17:05 [PATCH v7 0/3] devres: provide and use devm_krealloc() Bartosz Golaszewski
2020-08-17 17:05 ` [PATCH v7 1/3] devres: provide devm_krealloc() Bartosz Golaszewski
2020-08-17 17:39   ` Andy Shevchenko
2020-08-17 20:02     ` Bartosz Golaszewski
2020-08-18  8:25       ` Andy Shevchenko
2020-08-18 16:27         ` Bartosz Golaszewski
2020-08-18 17:10           ` Andy Shevchenko
2020-08-18 18:13             ` Bartosz Golaszewski
2020-08-19  9:14               ` Andy Shevchenko
2020-08-17 17:05 ` [PATCH v7 2/3] hwmon: pmbus: use more devres helpers Bartosz Golaszewski
2020-08-17 17:05 ` [PATCH v7 3/3] iio: adc: xilinx-xadc: use devm_krealloc() Bartosz Golaszewski

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).