From patchwork Wed Nov 23 18:01:39 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Michael Walle X-Patchwork-Id: 25110 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:adf:f944:0:0:0:0:0 with SMTP id q4csp2942131wrr; Wed, 23 Nov 2022 10:05:20 -0800 (PST) X-Google-Smtp-Source: AA0mqf58uBoJO35SNSH1ukZ+531QDxzNzX/xTCx8/qbJj6/U+WVnSN5vcsdejt+S4CMmOMxjkUx4 X-Received: by 2002:a2e:b816:0:b0:277:461b:41d5 with SMTP id u22-20020a2eb816000000b00277461b41d5mr4396849ljo.40.1669226720611; Wed, 23 Nov 2022 10:05:20 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1669226720; cv=none; d=google.com; s=arc-20160816; b=mJlTKjgSY4xestQBGiUMgDjbpxWLp1xLYGLHiwCZOGUWbueuOQyXwgAwNkDfqbDQb4 4rm0/W25PRCIWg5hKyQakcVYWRsK2f0zxBctPDDyIM3WJbgxEMkrzOgqXGRDJvI0bpJn VZW3uUokCQWLBe0NOTKOhfTsZNbmM+7QHH/2AwmiaiFXJ2ttja3V4Gg5LVFTuQeupNGi bPR87th4fvqoPX7jRmW2EIWR4he4Es7wp0mI0EYyqDXNSHBQJ8Gti/VtVjiTnhipU2OR 77i9dOIfABJFSoxKIUJYperAdhfuClz5geiGHbs5HZxa0kZPCrI8yfqaKAVqDEJl6mva aHFA== 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=dbqJAngAnCItu/kQhrmwoKdD13Z1Ky8qwmXbY0PTXSA=; b=JPSIjBZHPD6qo01NW9620UdCl7SQtKhQ5g5ksxsS+EMQnOcZSLV2NbZruX8nmcaQw0 L11bkTGvIUdFAsyHqP1jLUAOaX0L/7AySgcUpo7tShdYBzKF/M96W2XS3s6ann3nuL9y a+Yqfu4azVyrUvFZDgUZtEcgGtZIGWAT3Kj+elNsA7naHr2PS8TeW/dw/V2YWJpgXoeh 1QF6ihLKQVuUjG6tX+1SgDN7w67AzMqsE3CwD3pJyNvkCzOSj/Iphx/ZCdfNN5MRSSoc LubIaqXMyXuH/q9BFCjIdPzhCsbYnb0gUuoJPYWg/sHZOpGNGt2H2VI8UoRJIeuzit5S M+kw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@walle.cc header.s=mail2022082101 header.b="v/5RSiS+"; 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 js5-20020a17090797c500b007ad8bd5b636si15480577ejc.377.2022.11.23.10.04.47; Wed, 23 Nov 2022 10:05:20 -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="v/5RSiS+"; 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 S239092AbiKWSDu (ORCPT + 99 others); Wed, 23 Nov 2022 13:03:50 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:53704 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S239227AbiKWSCZ (ORCPT ); Wed, 23 Nov 2022 13:02:25 -0500 Received: from mail.3ffe.de (0001.3ffe.de [IPv6:2a01:4f8:c0c:9d57::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id C3ECF8C7AC; Wed, 23 Nov 2022 10:02:23 -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 0CFBA3B1D; Wed, 23 Nov 2022 19:02:22 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=walle.cc; s=mail2022082101; t=1669226542; 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=dbqJAngAnCItu/kQhrmwoKdD13Z1Ky8qwmXbY0PTXSA=; b=v/5RSiS+j5rt3w7kJZACxzGmYamX7vbD6+QyoLb9F0wfekJVPshLPUfL8jQ7PVLYQx4/1j djfiU2DV47D29uxfvw4BMdtCxpcuiuaDkAPIIYfayKTlmghBR8FxRP/cUQPu9+B9PXeg96 4vQueLE3pnYbPuvjAMbutoxAFzXu8FWnZQ4MRgeJWBxE7coja3R20STwIJwE09zG9C91I4 0WfBZiPn3jpbhY2dotC5oW/O4WuagisAZgsCShQYbwHYM9fJZf1FNhNuQHdOuhFE0bz7kv iKaENYpuqLt4rB4kxYCjNAQUzOipujW49nGSSwvjv18izu7vZpJR38I3idkWkg== 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 Subject: [PATCH v4 08/20] nvmem: core: drop the removal of the cells in nvmem_add_cells() Date: Wed, 23 Nov 2022 19:01:39 +0100 Message-Id: <20221123180151.2160033-9-michael@walle.cc> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20221123180151.2160033-1-michael@walle.cc> References: <20221123180151.2160033-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?1750311077661261440?= X-GMAIL-MSGID: =?utf-8?q?1750311077661261440?= 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 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; }