Received: by 2002:a05:6a10:7420:0:0:0:0 with SMTP id hk32csp3828271pxb; Mon, 21 Feb 2022 06:32:25 -0800 (PST) X-Google-Smtp-Source: ABdhPJzHjlgXxKe0wZyr5PtXOCneP2Iby+3KHyL4VJGTITNhZ7RvBl1FAVajpK8k4piogQh5wVyx X-Received: by 2002:a17:902:e84e:b0:14d:8c9b:c6f6 with SMTP id t14-20020a170902e84e00b0014d8c9bc6f6mr19404115plg.96.1645453945183; Mon, 21 Feb 2022 06:32:25 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1645453945; cv=none; d=google.com; s=arc-20160816; b=NKllaDDHA8M81u32npRXUJJGMYes87LZi8RV4Wimntt6ULB8Me9vsOMH+bBMWLMqEF 1NPINJxP0L31tbyeJ8vXHLq9KdOIJ0GCcm/kya945VzvviOcST/PraqlPB42qrb3RNZV CP3sxCD4teOWsQv21X/13kGQ5keLFF/imVTx7rwXE3aGp1K5mqNqh8imCxxPvv9iHtrD pt6ecfSNKo+APL26DOGBOiJtUwZQ206OEpXsVs3mxaReAtO51eLVyEIu7dB1qV6TEuri mQU/aydPuY6Rvm24Vd8Jq2vT82uNqOIDl10+3uvdY7bG8TWCUbwVOpTbLUC0JaneH+zZ I+mQ== 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=FPwyUqw9bIye7MTeMw3+l2+GgFM/jhis7VAg9kKcJLA=; b=n5Gmd2v8fe9PRUBTKyiknAilUAit7BI2qUELT3NXNsuhJTxmiB+w5ACwE1sBEL4V6e LfpB7jjZboEEfLX4a0WY6RV2I31QIgns7kx4tGvc4UQelG20Mbl607OKSx2o6dI6bV4i FKWUwDOmTspu68EpfWiRrIP6PONp0JfOB6Jb5Jk9pxqzx2Gvb4xLN64HUWPIWYGzruHb vFA/W2C0I8SjrhrCCpy9irgQanxYrA39HPVoKz/MewGvM6LqCDArctUBNqIzuQecateq YTZ9Ymyqo7AqN6S4ZKJe5FXGWQVYYlhqFjOprGDkuxdJuoifr7rO0f1esWx+h80iqA+D x1DQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@walle.cc header.s=mail2016061301 header.b=Cx1SDM6d; 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 ij18si4476932plb.526.2022.02.21.06.32.08; Mon, 21 Feb 2022 06:32:25 -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=Cx1SDM6d; 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 S1357423AbiBUMKK (ORCPT + 99 others); Mon, 21 Feb 2022 07:10:10 -0500 Received: from mxb-00190b01.gslb.pphosted.com ([23.128.96.19]:40838 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1357322AbiBUMIv (ORCPT ); Mon, 21 Feb 2022 07:08:51 -0500 Received: from ssl.serverraum.org (ssl.serverraum.org [176.9.125.105]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 4C359201B9 for ; Mon, 21 Feb 2022 04:08:28 -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 460ED223ED; Mon, 21 Feb 2022 13:08:26 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=walle.cc; s=mail2016061301; t=1645445306; 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=FPwyUqw9bIye7MTeMw3+l2+GgFM/jhis7VAg9kKcJLA=; b=Cx1SDM6drLPnBQgdsBPDO11W9D4ga9wyeZOOBXXsbIh0DpqPa/t+GhoancUsSMZ0xhhAsH KFcl7+RqLwL/KqF1dHiTT9JhjPw646jqq/lQuBsGHTa5UIySEIXWwpnJySEvzQwDIvcgdA EMim0/Dm7+cSq+s0/hD3/rg0aQiGLbU= 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 , yaliang.wang@windriver.com, Michael Walle Subject: [PATCH v4 17/32] mtd: spi-nor: slightly refactor the spi_nor_setup() Date: Mon, 21 Feb 2022 13:07:54 +0100 Message-Id: <20220221120809.1531502-18-michael@walle.cc> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20220221120809.1531502-1-michael@walle.cc> References: <20220221120809.1531502-1-michael@walle.cc> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-4.4 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_MED,SPF_HELO_NONE, SPF_PASS,T_SCC_BODY_TEXT_LINE 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 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 Reviewed-by: Tudor Ambarus Reviewed-by: Pratyush Yadav --- 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 04ea180118e3..4d2036cdce42 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 2afb610853a9..4fe16b5aa3f5 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