From patchwork Mon Jun 29 06:50:02 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bartosz Golaszewski X-Patchwork-Id: 11632253 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 A5DB46C1 for ; Mon, 29 Jun 2020 20:50:00 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 8A9CD20720 for ; Mon, 29 Jun 2020 20:50:00 +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="MFHsR5ID" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728444AbgF2UuA (ORCPT ); Mon, 29 Jun 2020 16:50:00 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:43362 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1731480AbgF2TNj (ORCPT ); Mon, 29 Jun 2020 15:13:39 -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 31021C08EC11 for ; Sun, 28 Jun 2020 23:50:15 -0700 (PDT) Received: by mail-wr1-x444.google.com with SMTP id s10so15292390wrw.12 for ; Sun, 28 Jun 2020 23:50:15 -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=0FbmkW7UOcYY7LkyFQeYD+n43SXMQXYjstj7AfGPBFY=; b=MFHsR5IDjPY0E1cBnmOdDmaaexsDnuGaeCom8ugM6D2bx/csHHWIKc48ZfoIzQ1WnQ wH2T1DsKev7yAD8X37BfHZeGwcp165BuatzBqWpk9PKAHPFguntRaNcNM+9ylDmq1Njl NVuN0ckQWhi9I84VLdztbSBWb2IQ1+HBDHXb622lxqQpwfrwmNWd9Mkyxhm4TdXQF1a6 Qu7nv7GnKuaQtAdamC+YNXe2VGuqkZAdM7PXqkyxRPuNL0QCsk4OeEyOd44jJct2xsgz /DRypuk9B9Sua+ocxb2STpKn4HHeSpfcsjEMcVSUlGI2ghJFdvn2DzB6bgnCgXysJtma CCag== 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=0FbmkW7UOcYY7LkyFQeYD+n43SXMQXYjstj7AfGPBFY=; b=eSmQiqTha09wa9SXwtsot/uPh+aXQ0lnIM3cfZxRqMAkXmvTPJW+NiszIRrIx8y94z clc7/MnOMYoxB1mjVxnPsM78Fc1UT6IBlbMXBgNGF9aJ7APHYhYVj/7XJb3z2JnoRos2 OeATFSXvGibXBF6Q+gV1cmGf23BpHet6KPnuoEIqcgh4kVxg0PjGYBzE5pjHAOi0I/qN qPRPNIj+UVuHZzeoXjc/hSnPCmki96v2IZepB4Uo8KQmfe+qmDF3yVbp19ylLxFY439z 8FY6ik80LIfHg0F9XP7KVxZwnK4fYVqWfTxbQi8SLXUUhxhiL3tK/6WdpH7lbXHlfxLz Mh7g== X-Gm-Message-State: AOAM532FSA+sCItP0A8gf2IqPtvETBOXEYVYyw8p1AT7TV32veM+mNf8 SZ6OpLHqIYcnNaw49MCipuKbUw== X-Google-Smtp-Source: ABdhPJxSUzNN1zV4gXxXOT8r64Q07nF/D8nrR8lGdd7yU4bCgcU0Q04rNUK9eOM5Le0U05BUn4D0PA== X-Received: by 2002:a5d:4ec7:: with SMTP id s7mr15362311wrv.400.1593413413900; Sun, 28 Jun 2020 23:50:13 -0700 (PDT) Received: from localhost.localdomain (lfbn-nic-1-65-232.w2-15.abo.wanadoo.fr. [2.15.156.232]) by smtp.gmail.com with ESMTPSA id z25sm26400850wmk.28.2020.06.28.23.50.12 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 28 Jun 2020 23:50:13 -0700 (PDT) From: Bartosz Golaszewski To: Jonathan Corbet , Greg Kroah-Hartman , "Rafael J . Wysocki" , Guenter Roeck , Jean Delvare Cc: linux-doc@vger.kernel.org, linux-kernel@vger.kernel.org, linux-hwmon@vger.kernel.org, Bartosz Golaszewski Subject: [PATCH v2 0/6] devres: provide and use devm_krealloc() Date: Mon, 29 Jun 2020 08:50:02 +0200 Message-Id: <20200629065008.27620-1-brgl@bgdev.pl> X-Mailer: git-send-email 2.26.1 MIME-Version: 1.0 Sender: linux-hwmon-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-hwmon@vger.kernel.org From: Bartosz Golaszewski Regular krealloc() obviously can't work with managed memory. This series implements devm_krealloc() and adds the first user 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() Bartosz Golaszewski (6): devres: remove stray space from devm_kmalloc() definition devres: move the size check from alloc_dr() into a separate function device: remove 'extern' attribute from function prototypes in device.h devres: handle zero size in devm_kmalloc() devres: provide devm_krealloc() hwmon: pmbus: use more devres helpers .../driver-api/driver-model/devres.rst | 1 + drivers/base/devres.c | 75 +++++- drivers/hwmon/pmbus/pmbus_core.c | 28 +-- include/linux/device.h | 225 +++++++++--------- 4 files changed, 187 insertions(+), 142 deletions(-)