archive mirror
 help / color / mirror / Atom feed
From: Bartosz Golaszewski <>
To: Jonathan Cameron <>,
	Hartmut Knaack <>,
	Lars-Peter Clausen <>,
	Peter Meerwald-Stadler <>,
	Michal Simek <>,
	Greg Kroah-Hartman <>,
	Guenter Roeck <>,
	Andy Shevchenko <>
	Bartosz Golaszewski <>
Subject: [PATCH v9 0/3] devres: provide and use devm_krealloc()
Date: Mon, 24 Aug 2020 19:38:56 +0200	[thread overview]
Message-ID: <> (raw)

From: Bartosz Golaszewski <>

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

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(-)


             reply	other threads:[~2020-08-24 17:39 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-08-24 17:38 Bartosz Golaszewski [this message]
2020-08-24 17:38 ` [PATCH v9 1/3] devres: provide devm_krealloc() Bartosz Golaszewski
2020-08-24 17:38 ` [PATCH v9 2/3] hwmon: pmbus: use more devres helpers Bartosz Golaszewski
2020-08-24 17:38 ` [PATCH v9 3/3] iio: adc: xilinx-xadc: use devm_krealloc() Bartosz Golaszewski

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \ \ \ \ \ \ \ \ \ \ \ \ \ \ \
    --subject='Re: [PATCH v9 0/3] devres: provide and use devm_krealloc()' \

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link

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).