Skip to content

devres: provide and use devm_krealloc()

Bartosz Golaszewski linux-arm-kernel linux-iio lkml 9 versions – New

Get series with b4
b4 am [email protected]

Versions newest first · linked by author and title

  1. v9 Latest3 patches 0 repliesNew
  2. v83 patches 6 repliesSuperseded
  3. v73 patches 7 repliesSuperseded
Earlier versions · 6
VersionPostedPatchesRepliesStatus
v63 patches2 repliesSuperseded
v53 patches3 repliesSuperseded
v43 patches2 repliesSuperseded
v33 patches2 repliesSuperseded
v26 patches17 repliesSuperseded
v15 patches1 replySuperseded

Changes in v9 from the cover letter

- use container_of() and offsetoff() instead of manual offset calculations
- use kfree() instead of devres_free() in error path as the latter expects the pointer to devres data, not devres node

Patches in v9 No applies recorded yet

#Subject and filesSizeRepliesApplied
1/3devres: provide devm_krealloc()Documentation/driver-api/driver-model/devres.rst drivers/base/devres.c include/linux/device.h+108 -00 replies
2/3hwmon: pmbus: use more devres helpersdrivers/hwmon/pmbus/pmbus_core.c+9 -190 replies
3/3iio: adc: xilinx-xadc: use devm_krealloc()drivers/iio/adc/xilinx-xadc-core.c+8 -80 replies

Reviews trailers per patch

All 3 patches have a Reviewed-by or Acked-by.

PatchAndy ShevchenkoGuenter RoeckJonathan Cameron
1/3R-b
2/3A-b
3/3A-b

Trailers given in replies are filled; those carried in the patches from earlier versions are outlined with dashes. Scroll the table sideways for all 3 reviewers.

Read the v9 thread

Cover letter [PATCH v9 0/3] devres: provide and use devm_krealloc()

From: Bartosz Golaszewski <[email protected]>

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

v7 -> v8:
- drop unnecessary explicit pointer casting in to_devres()
- check the return value of ksize() to make sure the pointer actually points to a dynamically allocated chunk
- add more comments to explain the locking strategy and resource handling

v8 -> v9:
- use container_of() and offsetoff() instead of manual offset calculations
- use kfree() instead of devres_free() in error path as the latter expects the pointer to devres data, not devres node

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                         | 105 ++++++++++++++++++
 drivers/hwmon/pmbus/pmbus_core.c              |  28 ++---
 drivers/iio/adc/xilinx-xadc-core.c            |  16 +--
 include/linux/device.h                        |   2 +
 5 files changed, 125 insertions(+), 27 deletions(-)
Signature · 1 line
2.26.1