From patchwork Tue Dec 6 20:07:27 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Michael Walle X-Patchwork-Id: 30497 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:adf:f944:0:0:0:0:0 with SMTP id q4csp3027289wrr; Tue, 6 Dec 2022 12:10:03 -0800 (PST) X-Google-Smtp-Source: AA0mqf7gjWDX6CJ0lYsWIEaUTbw8HJ4N92oNJouTfxvUTzSKsR5xAenVW8BlO82A28EiJbFucZ48 X-Received: by 2002:a63:4605:0:b0:478:80f8:66a6 with SMTP id t5-20020a634605000000b0047880f866a6mr20488668pga.222.1670357403527; Tue, 06 Dec 2022 12:10:03 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1670357403; cv=none; d=google.com; s=arc-20160816; b=iR3v/BT9h3l3cQmqI+0nQ8wdc4EU5NU6su6AiNxbMHWQ3W7pmVE7D5+9KSqh6CY3q0 WZBB/mrxITNvZ65rls5Je84M16HiCXsXKnOp9Yjz1FcbzlcjuVZc2GeCyu46c6w2GBxw Ag+POjlC3I+TXgTN9ouDV4cxGZXdLv7syXav8XB0WvRN9/XRpBeYYbbsoeoA7BGXutgx 2gqnvVmHR7e+rM77+eFRhq839vVOTFiClfD+QYLLONer1JuUXMw5pybgzDtx8Q9Zmn37 532V4h/bFaqXlEYtdkNn+CPThB4R4dhA33K59vLEkc8fqKxdGjqOYf1myftNHLiHEj6v C64w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=XjEsutPxJcw9ycuwtn1DnBCaMeP1tVgn6MXPS4VZA6I=; b=WElqacir0REFsxG5nx4IWU33I1qlI13mriLWdNk/HtnyKdFM5ArOA190D+M4eRBCvO HDAkxoDfrYzNvsSEeS5WfhUTQ8+QjTPFC/JLYdIXP0jhBeW6Ich0wBNLmgK8om6v7vJF aj2TmPAYyhVR2PlkMInHzGFnnmUyu5D3rlqETNBx/pj2nQWky/rjrJ4cE5CjUJUeJ7Vq Cc/tzmdOhJI23XWZcy53B35WvqAI/8rMEzsPKmSeKoEV9PBFyhWgax5ccIFLfZMJeoDq eaZNYPdRysgQgJUtkg1TkvshmOPtlFTN6uxkFDY/PKiwMXA1Heil39w1+JY/qpwjzPhp 7XPQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@walle.cc header.s=mail2022082101 header.b=QHHe21qR; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=walle.cc Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id h14-20020a056a001a4e00b0056b81818621si19896908pfv.157.2022.12.06.12.09.50; Tue, 06 Dec 2022 12:10:03 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@walle.cc header.s=mail2022082101 header.b=QHHe21qR; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=walle.cc Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229818AbiLFUIO (ORCPT + 99 others); Tue, 6 Dec 2022 15:08:14 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:44972 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229619AbiLFUHy (ORCPT ); Tue, 6 Dec 2022 15:07:54 -0500 Received: from mail.3ffe.de (0001.3ffe.de [159.69.201.130]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id BB6EA165B6; Tue, 6 Dec 2022 12:07:51 -0800 (PST) Received: from mwalle01.kontron.local. (unknown [213.135.10.150]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mail.3ffe.de (Postfix) with ESMTPSA id 110A43B37; Tue, 6 Dec 2022 21:07:50 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=walle.cc; s=mail2022082101; t=1670357270; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=XjEsutPxJcw9ycuwtn1DnBCaMeP1tVgn6MXPS4VZA6I=; b=QHHe21qRSQ4K/jwvw4jcKRSJB8BvJsT+adygn6kWzVp2w0U1HAI0N+2uWwdy5XqCOa59Y9 vTlZZQi5qVkrT/fHfoQa4OPQ+cuiLs5u/ilrxbn5pxtDbkoBRKvsUYPzdBAmib750BBmiM un+nXH6ib5oA9WbkeW82amZuCZt7dzk4QuDr5hQ+R2JeN8qvObxdVvHZpDN83IGqRcISDj j13yv0ejM+RriBdzQiWl3GWrFJ+o5p3cWP1x7ddUDseKNcLG7McJ8zyaWeBKjtgF361vqD 3X3ZloyXqjWzlP+T2W/P08VcbpKNkmAPfTtHrPtJbuz08wT0CrbuNuBFAA6DEg== From: Michael Walle To: Jonathan Corbet , Srinivas Kandagatla , Miquel Raynal , Rob Herring , Frank Rowand , Sascha Hauer Cc: linux-doc@vger.kernel.org, linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org, devicetree@vger.kernel.org, Michael Walle , Dan Carpenter Subject: [PATCH v5 08/21] nvmem: core: drop the removal of the cells in nvmem_add_cells() Date: Tue, 6 Dec 2022 21:07:27 +0100 Message-Id: <20221206200740.3567551-9-michael@walle.cc> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20221206200740.3567551-1-michael@walle.cc> References: <20221206200740.3567551-1-michael@walle.cc> MIME-Version: 1.0 X-Spam: Yes X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1751496684687649876?= X-GMAIL-MSGID: =?utf-8?q?1751496684687649876?= If nvmem_add_cells() fails, the whole nvmem_register() will fail and the cells will then be removed anyway. This is a preparation to introduce a nvmem_add_one_cell() which can then be used by nvmem_add_cells(). This is then the same to what nvmem_add_cells_from_table() and nvmem_add_cells_from_of() do. Signed-off-by: Michael Walle --- changes since v4: - none changes since v3: - fix typo, s/prepartion/preparation/ changes since v2: - none changes since v1: - none drivers/nvmem/core.c | 14 ++++---------- 1 file changed, 4 insertions(+), 10 deletions(-) diff --git a/drivers/nvmem/core.c b/drivers/nvmem/core.c index 24573e63e5a9..7c76e0e0072e 100644 --- a/drivers/nvmem/core.c +++ b/drivers/nvmem/core.c @@ -515,7 +515,7 @@ static int nvmem_add_cells(struct nvmem_device *nvmem, int ncells) { struct nvmem_cell_entry **cells; - int i, rval; + int i, rval = 0; cells = kcalloc(ncells, sizeof(*cells), GFP_KERNEL); if (!cells) @@ -525,28 +525,22 @@ static int nvmem_add_cells(struct nvmem_device *nvmem, cells[i] = kzalloc(sizeof(**cells), GFP_KERNEL); if (!cells[i]) { rval = -ENOMEM; - goto err; + goto out; } rval = nvmem_cell_info_to_nvmem_cell_entry(nvmem, &info[i], cells[i]); if (rval) { kfree(cells[i]); - goto err; + goto out; } nvmem_cell_entry_add(cells[i]); } +out: /* remove tmp array */ kfree(cells); - return 0; -err: - while (i--) - nvmem_cell_entry_drop(cells[i]); - - kfree(cells); - return rval; }