From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-7.0 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI, SPF_HELO_NONE,SPF_PASS,USER_AGENT_GIT autolearn=no autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 2685EC433E0 for ; Sun, 2 Aug 2020 08:36:46 +0000 (UTC) Received: from merlin.infradead.org (merlin.infradead.org [205.233.59.134]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id E36EC20738 for ; Sun, 2 Aug 2020 08:36:45 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=lists.infradead.org header.i=@lists.infradead.org header.b="peLCJTwh"; dkim=fail reason="signature verification failed" (2048-bit key) header.d=bgdev-pl.20150623.gappssmtp.com header.i=@bgdev-pl.20150623.gappssmtp.com header.b="sJFO8/dN" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org E36EC20738 Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=bgdev.pl Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=merlin.20170209; h=Sender:Content-Transfer-Encoding: Content-Type:Cc:List-Subscribe:List-Help:List-Post:List-Archive: List-Unsubscribe:List-Id:MIME-Version:Message-Id:Date:Subject:To:From: Reply-To:Content-ID:Content-Description:Resent-Date:Resent-From:Resent-Sender :Resent-To:Resent-Cc:Resent-Message-ID:In-Reply-To:References:List-Owner; bh=aa6JgFt0p4tdLPinPiE6Gkcdl9UIHCkeGREtpCLD4Mc=; b=peLCJTwhJcCdk1BrGAPEaZHZ0c zCaUPDzGa4AVYwRdUpnlKSIZkGu84qNrkMyY+BD2ZnMQRYwuE5vJCKA3SuwbH9s9o3lhKQp9wmda2 WoPseaKxweF61uQ2JjgJGkSJmS3EPcMSD4ViFAu5NdFvuBhSZM2GX2eFeZD5ZZxDHlfopHjaVUJfd qeJGZywEX5yH0t/YGT7v4uIp5SvGB4/O05/Tx3fH0nwivjL1qtZsu0sGzmsxtjkEgny6xeaFoFDKw J/t05Vv3QbD2mLLUnqkHVs/Hm+p4BzpE7JDz1tMWnshekfpzh/TXkK83gCE6ChzxtarpyllZZJVai qnYGCrGA==; Received: from localhost ([::1] helo=merlin.infradead.org) by merlin.infradead.org with esmtp (Exim 4.92.3 #3 (Red Hat Linux)) id 1k29SX-000172-Tk; Sun, 02 Aug 2020 08:35:09 +0000 Received: from mail-wr1-x442.google.com ([2a00:1450:4864:20::442]) by merlin.infradead.org with esmtps (Exim 4.92.3 #3 (Red Hat Linux)) id 1k29SS-00015s-Qd for linux-arm-kernel@lists.infradead.org; Sun, 02 Aug 2020 08:35:05 +0000 Received: by mail-wr1-x442.google.com with SMTP id r2so26385089wrs.8 for ; Sun, 02 Aug 2020 01:35:02 -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=nwR0cSDRK1MacipoHZSBkL1yx2DzBEYBuItL8wnBzYY=; b=sJFO8/dNG2dGuiR/gT54hMqO6QnQtqhcCLkM5HmWg/NVzNUCWmPXvt4Bd510UemOzm GN/QfXIpMzu/oAX81Bv7GBpyPrJk4vph5MByjFxysIGgsnBGEVAG5jkaX8f/LCNpOQNQ Vaw0z/czRYrMJOgIcPbhpJEsaLTaG8fop7KNF7PqAsJ3ho3gBkUk5x0d3uiyNe8swLTq 2Lz70pmXu5+HB+9aa20R6jZ6/ViVkuAtWZnlgM1y7CcrwwtPis639LaCxdLFIXC6q9Uk b/SZz3MPXR0A24BbjHVD82xsyKT4FUSxzlVWYOlgICNrOMThzAgEtmASAbNgnv4Ut4W+ VQpQ== 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=nwR0cSDRK1MacipoHZSBkL1yx2DzBEYBuItL8wnBzYY=; b=s55cEEQGzAvQMAe4GZR/9c6rnKCpM9y5SHP74JGgXz/6rBmLF/eS32dZdukM3ivl7l ipkLd23bpLFT7n3yIPleZSinggPrqdZJcy3nHpKGlTL/bepmm2shep3YNX1Il5H3oVk0 UYSCIsDmYRth7WE5NV7fd/eUVcGAFfSl3rnW27CmRPW5FY9CZdlEjkuPJctr4z1Z3a55 CE6NXVcgKoQwgtzXA1B1Co0sveeZfo610zcrHOtSUh4ayaH2zOk2ensZidpLzSw5ifdy CMx1MXD/jgTuaPf85P57GkNq6+i55o3ovriP4iYHrsm2GdHAFrvEh8Aoy32tIKZkyhQH 43rw== X-Gm-Message-State: AOAM531D7RI0/BgsjGhijhyvid5eozGy7KqTN6Ed/gWo1EoAHCmoeYB8 QvAOORDvk4GE8ilgNJ4j1tMpCg== X-Google-Smtp-Source: ABdhPJysVYxzaXR2wk/8PBfHv2MvKUCCN0LllR0j3hUk2LNHkM3/+4zmSNtDZppkp6vg4/90vF9krA== X-Received: by 2002:adf:bbca:: with SMTP id z10mr9899567wrg.425.1596357302104; Sun, 02 Aug 2020 01:35:02 -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 d14sm19281466wre.44.2020.08.02.01.35.00 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 02 Aug 2020 01:35:01 -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 Subject: [PATCH v6 0/3] devres: provide and use devm_krealloc() Date: Sun, 2 Aug 2020 10:34:55 +0200 Message-Id: <20200802083458.24323-1-brgl@bgdev.pl> X-Mailer: git-send-email 2.26.1 MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20200802_043504_930774_204F2EE9 X-CRM114-Status: GOOD ( 15.88 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: linux-iio@vger.kernel.org, Bartosz Golaszewski , linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org From: Bartosz Golaszewski Hi Greg, Andy, this is a reworked version of devm_krealloc(). This time without the risk of sleeping with spinlock taken. I noticed that devres_lock is only there to protect the integrity of the devres list - we can assume users are sane enough to not devm_kfree() chunks that they devm_krealloc() at the same time so we only take the lock when manipulating the list now. I dropped Andy's review tag due to this change. === 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 v4 -> v5: - tweak the kerneldoc v5 -> v6: - tweak the devres_lock handling in devm_krealloc() 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 | 65 +++++++++++++++++++ drivers/hwmon/pmbus/pmbus_core.c | 28 +++----- drivers/iio/adc/xilinx-xadc-core.c | 16 ++--- include/linux/device.h | 2 + 5 files changed, 85 insertions(+), 27 deletions(-) -- 2.26.1 _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel