Received: by 2002:a05:6a10:7420:0:0:0:0 with SMTP id hk32csp4415227pxb; Mon, 21 Feb 2022 20:53:31 -0800 (PST) X-Google-Smtp-Source: ABdhPJzCd2ZNwEbsEf7otPanqYqiEV+akAW5x08DtQ+y6kerNVUrzl/fHGXYQL9BLh9LTYnd3r5Q X-Received: by 2002:a17:903:1c2:b0:14d:ad07:2f97 with SMTP id e2-20020a17090301c200b0014dad072f97mr21962363plh.132.1645505611401; Mon, 21 Feb 2022 20:53:31 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1645505611; cv=none; d=google.com; s=arc-20160816; b=oexi5s/dasGPNo8jPshPlBiDRiAl9+1oGhi3Adf+BbrIDYWLRaz8Kz4PW6MBrd0HnD no98Ygz2vhZLOfpRJbFmAdtib6ZXVnQXkYuA4WmTebMuPWEesQSGBBsYbAY/z6U4wR8p Qyw9S192L06wuF/Y0bJtrcyGA+I6ri/Xo5aeSp3HwDYWAmMvaeRHCVfJFCKXeqIQ66ej dfZPNIotQKfoY8vOqQsZC8F+nRsYTV0WTGQp9VJqZKJZHMR2oleQEwFW1ZLwlVUmCH7K bGHFy8cKg/eLn8ALR9IlD61r0xiroFiWOJ1hxwQTobpw4Tz0ydAnuQxTYlRnBoWDHFM7 dOEA== 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=paJhNg7eqEirB8dn54YN+QUmZw8Qy4jGNQS7MyQZtwuQJJx6Pr90cf/+KLQM05jJca 0FQNVXvEa0Dgc4rmClSqVsn8DFGcU/jqZZbJpJDR0Fd7f2zWd/mlt3PSCIsHUeEwuZrP syWELzKN0wzM4rzEPehOyVPuyKoNY6xh9A6LV01Zp3esFjnS/0g/6ncdfahou2KcQ77C HcS9p5vt0b47h2XqvqcnLbLe5YQSfYuA7EMFe1ZMgw1vNLqBQhOv3x949RhYQyPyePzI z4oBps6hWpYhM93GAVn4+nofemc4bihldagWXpLKu0YVtqGIWd2wqzhORKYDv7XfPk7H Pp0A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@walle.cc header.s=mail2016061301 header.b="I0Du+d/9"; spf=softfail (google.com: domain of transitioning linux-kernel-owner@vger.kernel.org does not designate 23.128.96.19 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from lindbergh.monkeyblade.net (lindbergh.monkeyblade.net. [23.128.96.19]) by mx.google.com with ESMTPS id l22si11994828pfc.103.2022.02.21.20.53.31 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 21 Feb 2022 20:53:31 -0800 (PST) Received-SPF: softfail (google.com: domain of transitioning linux-kernel-owner@vger.kernel.org does not designate 23.128.96.19 as permitted sender) client-ip=23.128.96.19; Authentication-Results: mx.google.com; dkim=pass header.i=@walle.cc header.s=mail2016061301 header.b="I0Du+d/9"; spf=softfail (google.com: domain of transitioning linux-kernel-owner@vger.kernel.org does not designate 23.128.96.19 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 154CCB3E76; Mon, 21 Feb 2022 20:32:21 -0800 (PST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1346266AbiBUIzn (ORCPT + 99 others); Mon, 21 Feb 2022 03:55:43 -0500 Received: from mxb-00190b01.gslb.pphosted.com ([23.128.96.19]:46938 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1345753AbiBUIxn (ORCPT ); Mon, 21 Feb 2022 03:53:43 -0500 Received: from ssl.serverraum.org (ssl.serverraum.org [IPv6:2a01:4f8:151:8464::1:2]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 787C31EEDB for ; Mon, 21 Feb 2022 00:52:58 -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 82533223F7; Mon, 21 Feb 2022 09:52:56 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=walle.cc; s=mail2016061301; t=1645433576; 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=I0Du+d/9S66NNNRZ30yQncUrmCAwO2XS28J9sRjG8uXUfY+jXZx8uswIuHChclIOqE/Hp1 LTirK/MXfIy39iqU0+ToyfjNwRiTHhyjbI9bjxF4D4Dps/JtoRIyOMRJS1m4qb37lXPLrg H1Gbhs73E9pzVTe1MXyDh+icga8REW4= 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 v3 17/32] mtd: spi-nor: slightly refactor the spi_nor_setup() Date: Mon, 21 Feb 2022 09:52:21 +0100 Message-Id: <20220221085236.1452024-18-michael@walle.cc> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20220221085236.1452024-1-michael@walle.cc> References: <20220221085236.1452024-1-michael@walle.cc> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-2.0 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,RDNS_NONE,SPF_HELO_NONE,T_SCC_BODY_TEXT_LINE autolearn=no 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