From patchwork Mon Jul 13 14:59:31 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bartosz Golaszewski X-Patchwork-Id: 11660007 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 6A40A722 for ; Mon, 13 Jul 2020 14:59:49 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 520F820773 for ; Mon, 13 Jul 2020 14:59:49 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=bgdev-pl.20150623.gappssmtp.com header.i=@bgdev-pl.20150623.gappssmtp.com header.b="rSp1ckUH" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729919AbgGMO7s (ORCPT ); Mon, 13 Jul 2020 10:59:48 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:34352 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729649AbgGMO7s (ORCPT ); Mon, 13 Jul 2020 10:59:48 -0400 Received: from mail-wr1-x444.google.com (mail-wr1-x444.google.com [IPv6:2a00:1450:4864:20::444]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id E1DA5C061755 for ; Mon, 13 Jul 2020 07:59:47 -0700 (PDT) Received: by mail-wr1-x444.google.com with SMTP id k6so16900864wrn.3 for ; Mon, 13 Jul 2020 07:59:47 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bgdev-pl.20150623.gappssmtp.com; s=20150623; h=from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=hiVSo3xlj6ss4Z1I13IdfwQU+nfjMMT6+mU8Bg5YKmM=; b=rSp1ckUHPmHljClMQoIDDSw1ZCB7+ygalxtu5lHGTlN5T3q2RVoH60LPL6a4oxo/ty z0HQV95Z9mU86Vd/A/IUFtH/uJjLYmNuqYNKD2NYrejOVpNvFarZV+J0Ec+pnQT/Abgb HpclKpTNjEG/gl3XYssuh1rDjk5AjdDUrI8OuRabw5IccTvCHZGuWSTAi6tGsC2/FQVF nEBBDzZbPQXKqoIyz6Ltu3poOOlhxF3n8CguwS4Q8Xc0MSO0dHDE9sNxR/Y3ADBUUksn pu6EXZbVF4tml637IPR+2tIrGMvndreNuw6dnTpm28gZLa9qxm/+P+SfiwGENPndp3P4 AiNg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=hiVSo3xlj6ss4Z1I13IdfwQU+nfjMMT6+mU8Bg5YKmM=; b=HO8p90WuRCcqFMgH94r/+zxhbH89oHe9CNJKb9kemB0QgN7bi4Fgrayl8eRVIYd6N+ CDFjXDus3FR5+x6nkj4VUxseyvTasz/uPtf3H9l6WhK1Vb5qFRpkcRenLTjVt6+2AS32 d/2jAW66o0BlYwD8vRUzogLEUT68QjUGpyQtLzYIAbS1JSgm7fRqBkpX7usNH7OGCYGE OkzpVosBJj+eiswJXMvplzm1+PwISBHW2mWGYQJoVb/RtZAec9k3rlfZTKoJ8elnuJX7 o40Zv3KSzmxcfHsscppDyVLqMJNmUOsYgAshGUATQOUtohpTfFnJvG0ZUaLvCwTb/He8 cNIg== X-Gm-Message-State: AOAM533cEk/9zpZbJb0aqflAeFZTSsm80jaZSg39gO1ogNA1j46dodLZ N2aqZgk1bYqai+OQaPkGoc6g5Q== X-Google-Smtp-Source: ABdhPJzJvIhOZM1tW3JbhqV6XyxG2YJWfklQ1nvdDw0QVKBI2giA+0EpuZ7a9S9IT9ipoa2QgtDwsQ== X-Received: by 2002:a5d:4710:: with SMTP id y16mr82938978wrq.189.1594652385764; Mon, 13 Jul 2020 07:59:45 -0700 (PDT) Received: from debian-brgl.home (lfbn-nic-1-68-20.w2-15.abo.wanadoo.fr. [2.15.159.20]) by smtp.gmail.com with ESMTPSA id u20sm21991145wmm.15.2020.07.13.07.59.44 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 13 Jul 2020 07:59:45 -0700 (PDT) From: Bartosz Golaszewski To: Jonathan Cameron , Hartmut Knaack , Lars-Peter Clausen , Peter Meerwald-Stadler , Michal Simek , Greg Kroah-Hartman , Guenter Roeck , Andy Shevchenko Cc: linux-iio@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, Bartosz Golaszewski Subject: [PATCH v4 0/3] devres: provide and use devm_krealloc() Date: Mon, 13 Jul 2020 16:59:31 +0200 Message-Id: <20200713145934.18243-1-brgl@bgdev.pl> X-Mailer: git-send-email 2.26.1 MIME-Version: 1.0 Sender: linux-iio-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-iio@vger.kernel.org From: Bartosz Golaszewski Regular krealloc() obviously can't work with managed memory. This series implements devm_krealloc() and adds the first users with hope that this helper will be adopted by other drivers currently using non-managed krealloc(). Some additional changes to the code modified by main patches are included. 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 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 | 67 +++++++++++++++++++ drivers/hwmon/pmbus/pmbus_core.c | 28 +++----- drivers/iio/adc/xilinx-xadc-core.c | 16 ++--- include/linux/device.h | 2 + 5 files changed, 87 insertions(+), 27 deletions(-)