Received: by 2002:a05:6a10:1a4d:0:0:0:0 with SMTP id nk13csp2218964pxb; Thu, 3 Feb 2022 01:51:25 -0800 (PST) X-Google-Smtp-Source: ABdhPJzZwKgXz/p3/XXB6aSCMtbXLfybYFFYsCG3lIGqQNHjSu0rBu7eb2jmooCnfVtCUEQeqBgc X-Received: by 2002:a17:906:99c1:: with SMTP id s1mr25217646ejn.298.1643881884795; Thu, 03 Feb 2022 01:51:24 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1643881884; cv=none; d=google.com; s=arc-20160816; b=i18DOL3ET+MmPmbLd/2EDl5dKo56w2YBizcxg1K/a7k44zuQLoJfzn8S1+LcUfpni7 pG/e9ThZDsccqSrozTvqikJj94f19BHvm/4MBo0KLXbhmN8Doa9Ox3PEVaLvNQ1jEoC6 3Y/0Y/N5of/79rDjhMO/7pqNASH3JrqRfs0BvIAgehtAS8mmXxQMHNHFqePDNRWlERh6 e8P0yliO6GNJaoxdB/do8ySbVBKEuRGORYU9+3yqES8t1YRUPD7MErMd9fAevIgsX9vY ljhrsGctpu/ssif+pK6bPqXlsut9MR5Azbs525UrhnLGFzJPzZiHIHyDtMuIL1zqn+r8 kGRw== 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=ahJp6eTHZ3fSx9Ky9bMySI7tvw7stlyKxNn2I6oxOgI=; b=rJ0ae/Tg63f67qONXkuiK7QCRcX7xJLqhuAlAjs5+BqsljndoxE3tZT1tAhwTdg6Ky bWhmY+lhwRLBBYgp8VIASSB0dJ9/u1WdrqwEfnQR0eC40/MxbRrpJovtzzrfqJLW8CwP Uwl0za5nX8wfMXgF2RoPCtEt/L/dlrD23R8mRaSeGI3FKUZXDIOn0tozLw4aI+RHsCiP vRDtnbo76pOzPKLjW7Nid1MD/wBzB+tO7oI6o9dN7+LuX764dr0gLafLVJ39EXfyh7C+ /MX4QEHkmLLnqu3QnqciSR2eVeq/lCyGI+aXsC2rjKnt4Bc/HCAsUleAHtdcyPjlMV8U ozsA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@walle.cc header.s=mail2016061301 header.b=sEjJGRI2; 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 Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id 3si12298542ejq.761.2022.02.03.01.51.00; Thu, 03 Feb 2022 01:51:24 -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=mail2016061301 header.b=sEjJGRI2; 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1345353AbiBBO7N (ORCPT + 99 others); Wed, 2 Feb 2022 09:59:13 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:48938 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1345241AbiBBO7D (ORCPT ); Wed, 2 Feb 2022 09:59:03 -0500 Received: from ssl.serverraum.org (ssl.serverraum.org [IPv6:2a01:4f8:151:8464::1:2]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 5BA1EC061714 for ; Wed, 2 Feb 2022 06:59:03 -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 ECDHE (P-384) server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by ssl.serverraum.org (Postfix) with ESMTPSA id 735F3223ED; Wed, 2 Feb 2022 15:59:01 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=walle.cc; s=mail2016061301; t=1643813941; 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=ahJp6eTHZ3fSx9Ky9bMySI7tvw7stlyKxNn2I6oxOgI=; b=sEjJGRI2Me9A3TTseN5rEfl2HGbzJN+/O/Gq4ycjxZDDq3k4wM95OZy4bfd8yh2OIbgAi+ vqYQa0suGBCYr/Nyc3QbMzaURXqxyrJwoykKMV2Db3pc3yx4m0t0aUGvj350lVFvdxy+CM 1cjv8XfuX+WJr2GlnWYH9uUoGViAAEI= From: Michael Walle To: linux-mtd@lists.infradead.org, linux-kernel@vger.kernel.org Cc: Tudor Ambarus , Pratyush Yadav , Miquel Raynal , Richard Weinberger , Vignesh Raghavendra , Michael Walle Subject: [PATCH v1 02/14] mtd: spi-nor: slightly refactor the spi_nor_setup() Date: Wed, 2 Feb 2022 15:58:41 +0100 Message-Id: <20220202145853.4187726-3-michael@walle.cc> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20220202145853.4187726-1-michael@walle.cc> References: <20220202145853.4187726-1-michael@walle.cc> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Instead of always using a function pointer (and initializing it to our default), just call the default function if the flash didn't set its own one. That will make the call flow easier to follow. Also mark the parameter as optional now. Signed-off-by: Michael Walle --- drivers/mtd/spi-nor/core.c | 10 +++++----- drivers/mtd/spi-nor/core.h | 8 ++++---- 2 files changed, 9 insertions(+), 9 deletions(-) diff --git a/drivers/mtd/spi-nor/core.c b/drivers/mtd/spi-nor/core.c index f05ece6018dc..c8cc906cf771 100644 --- a/drivers/mtd/spi-nor/core.c +++ b/drivers/mtd/spi-nor/core.c @@ -2532,11 +2532,12 @@ static int spi_nor_setup(struct spi_nor *nor, { int ret; - if (nor->params->setup) { + if (nor->params->setup) ret = nor->params->setup(nor, hwcaps); - if (ret) - return ret; - } + else + ret = spi_nor_default_setup(nor, hwcaps); + if (ret) + return ret; return spi_nor_set_addr_width(nor); } @@ -2786,7 +2787,6 @@ static void spi_nor_init_default_params(struct spi_nor *nor) params->quad_enable = spi_nor_sr2_bit1_quad_enable; params->set_4byte_addr_mode = spansion_set_4byte_addr_mode; - params->setup = spi_nor_default_setup; params->otp.org = &info->otp_org; /* Default to 16-bit Write Status (01h) Command */ diff --git a/drivers/mtd/spi-nor/core.h b/drivers/mtd/spi-nor/core.h index c6578d3f598b..10f478547dc2 100644 --- a/drivers/mtd/spi-nor/core.h +++ b/drivers/mtd/spi-nor/core.h @@ -257,10 +257,10 @@ struct spi_nor_otp { * @convert_addr: converts an absolute address into something the flash * will understand. Particularly useful when pagesize is * not a power-of-2. - * @setup: configures the SPI NOR memory. Useful for SPI NOR - * flashes that have peculiarities to the SPI NOR standard - * e.g. different opcodes, specific address calculation, - * page size, etc. + * @setup: (optional) configures the SPI NOR memory. Useful for + * SPI NOR flashes that have peculiarities to the SPI NOR + * standard e.g. different opcodes, specific address + * calculation, page size, etc. * @locking_ops: SPI NOR locking methods. */ struct spi_nor_flash_parameter { -- 2.30.2