Message ID | 20221118185118.1190044-7-michael@walle.cc |
---|---|
State | New |
Headers |
Return-Path: <linux-kernel-owner@vger.kernel.org> Delivered-To: ouuuleilei@gmail.com Received: by 2002:adf:f944:0:0:0:0:0 with SMTP id q4csp356257wrr; Fri, 18 Nov 2022 10:54:33 -0800 (PST) X-Google-Smtp-Source: AA0mqf77kgWYTXHhiAFyYgGq6ErUlpQjwmHztK/VCp+YUe75HPOtY+GNWPoV+NFsrHetlOBvvPE+ X-Received: by 2002:aa7:c54c:0:b0:469:10c6:19d2 with SMTP id s12-20020aa7c54c000000b0046910c619d2mr3417476edr.243.1668797673568; Fri, 18 Nov 2022 10:54:33 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1668797673; cv=none; d=google.com; s=arc-20160816; b=KD85cFt2SeMWfGDw+YhJVfO9u4E5VxMOX58aB0Xq2iuErUDfxozhYUcKpKrANB9ODB 1DepxwL0UH6fC7lObWHMi96sqvAZBDcHVr/vayHSJBEJu2WWvJHkDOD7AUYrn+9k9xrs kL9WtYp8r262c87WrdYT61ffdigZFNn45QWPPaaPtvHCLjkOKZxQiE1bjzgeJkWBLe4E S4NG8h4emtD4z/h/2M6BMANM/UXNF8T8d9dlNenP0lM85ES91eBS344frBQulDYwZESy Bqa9KwO0NemvujlEbRFr2uee6IGaS0CZsaa4GEYVeIesAzMUOgWK7NjBD1O8fvBkkqPI ObwA== 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=YDoaHvyBqWrvft0gXJEgSIKrah/C9bAdp2KK5WyaSuo=; b=TSPv+JiAJ6Tp93GHF90+IDqk8UO7JxGysbWSePrnI2v5qpkTiV9R2hiVVRHnYDpsUO J1QKHgP3dUZwtq/gEfjel/Vg/VGc6c2is8fFzRMTo+NSrtvZyYAq8rw3Xne8tBfhq8mi hBCJjKyTWdzNN5ubFPfMLyzXm/Nw9H4rDnD2p0qz/q6xQlniqtohU3fd1TNmRV0/cIRs 8YJcRRzlidl1f6CoLRRSds/mzAsGoHTc0Dj944+aXhvrd6EXt4nRCKrZajjhCNBvMnJB VnCPIF1VgIlS3eqjkIYmtJwMcoZQdcjLkpmZc0fhD7gAMPh2Rwv6F/BOwVFpMSRSHrjd DpjA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@walle.cc header.s=mail2022082101 header.b=K0nxA0n3; 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 wz12-20020a170906fe4c00b0078e54eda758si3260699ejb.611.2022.11.18.10.54.06; Fri, 18 Nov 2022 10:54:33 -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=K0nxA0n3; 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 S242856AbiKRSwd (ORCPT <rfc822;kkmonlee@gmail.com> + 99 others); Fri, 18 Nov 2022 13:52:33 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:52006 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S242842AbiKRSvx (ORCPT <rfc822;linux-kernel@vger.kernel.org>); Fri, 18 Nov 2022 13:51:53 -0500 Received: from mail.3ffe.de (0001.3ffe.de [IPv6:2a01:4f8:c0c:9d57::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 1505F8FE6C; Fri, 18 Nov 2022 10:51:43 -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 39AE72425; Fri, 18 Nov 2022 19:51:28 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=walle.cc; s=mail2022082101; t=1668797488; 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=YDoaHvyBqWrvft0gXJEgSIKrah/C9bAdp2KK5WyaSuo=; b=K0nxA0n3Dcsx4aBa3WKEFfgTjORaDsc+tBpmqcqFQm5KQEnA5lshxVjDAz47RlHJ4UkEt9 Ej73nTaKXeid1cdQT6+7/vLk10c8chS82RNAjE8H9IBNk5QT1zOmPfeaMYp5RupENvySx8 bsCw/nJo5md2u+I2IHSNbdSBMWc7G4HzA4S5+/6fnJwFFiTlDRrMrFwGIXkQ5USDw3UYHG Y2pmNJVplPAS0QUvPQdwFQAkrVGymLPe8EtTXmto/I8YeXtgFu4Z2VFFvrJCkSX1OvThTz 0OEnMq9ahyrKUAFOlS9zCtCVsXNu5UEllBjHwPdLK7a0B+1T6PyYqBu7lvgp7w== From: Michael Walle <michael@walle.cc> To: Jonathan Corbet <corbet@lwn.net>, Srinivas Kandagatla <srinivas.kandagatla@linaro.org>, Miquel Raynal <miquel.raynal@bootlin.com>, Rob Herring <robh+dt@kernel.org>, Frank Rowand <frowand.list@gmail.com> Cc: linux-doc@vger.kernel.org, linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org, devicetree@vger.kernel.org, Michael Walle <michael@walle.cc> Subject: [PATCH v3 06/18] nvmem: core: drop the removal of the cells in nvmem_add_cells() Date: Fri, 18 Nov 2022 19:51:06 +0100 Message-Id: <20221118185118.1190044-7-michael@walle.cc> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20221118185118.1190044-1-michael@walle.cc> References: <20221118185118.1190044-1-michael@walle.cc> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit 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: <linux-kernel.vger.kernel.org> X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1749861189703810245?= X-GMAIL-MSGID: =?utf-8?q?1749861189703810245?= |
Series |
nvmem: core: introduce NVMEM layouts
|
|
Commit Message
Michael Walle
Nov. 18, 2022, 6:51 p.m. UTC
If nvmem_add_cells() fails, the whole nvmem_register() will fail
and the cells will then be removed anyway. This is a prepartion
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 <michael@walle.cc>
---
changes since v2:
- none
changes since v1:
- none
drivers/nvmem/core.c | 14 ++++----------
1 file changed, 4 insertions(+), 10 deletions(-)
Comments
On Fri, Nov 18, 2022 at 07:51:06PM +0100, Michael Walle wrote: > If nvmem_add_cells() fails, the whole nvmem_register() will fail > and the cells will then be removed anyway. This is a prepartion s/prepartion/preparation/ Sascha
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; }