From patchwork Fri Dec 7 09:26:17 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Boris Brezillon X-Patchwork-Id: 1009264 X-Patchwork-Delegate: tudor.ambarus@gmail.com Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=none (mailfrom) smtp.mailfrom=lists.infradead.org (client-ip=2607:7c80:54:e::133; helo=bombadil.infradead.org; envelope-from=linux-mtd-bounces+incoming=patchwork.ozlabs.org@lists.infradead.org; receiver=) Authentication-Results: ozlabs.org; dmarc=none (p=none dis=none) header.from=bootlin.com Authentication-Results: ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=lists.infradead.org header.i=@lists.infradead.org header.b="tzgGxlkg"; dkim-atps=neutral Received: from bombadil.infradead.org (bombadil.infradead.org [IPv6:2607:7c80:54:e::133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 43B6bD0ZHdz9s3q for ; Fri, 7 Dec 2018 20:28:24 +1100 (AEDT) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20170209; h=Sender: Content-Transfer-Encoding:Content-Type:MIME-Version:Cc:List-Subscribe: List-Help:List-Post:List-Archive:List-Unsubscribe:List-Id:References: In-Reply-To:Message-Id:Date:Subject:To:From:Reply-To:Content-ID: Content-Description:Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc :Resent-Message-ID:List-Owner; bh=2TxuU1igHpwGBtcsBMyfXyEOETBnGsihMwhuGuZ8zO0=; b=tzgGxlkgsn6nN0rp7Ov8aJSe52 cP+WuRXW/039mqMC3w/g41qymWDi9mKqiFd5PEX3euxZZGzt5eV2E42+LAxYlDjJo/Pl42wv15N2V WjDPy4TG7ByotqA5/T/LsInJLlw8hNPGIEkCwV0dzZa11r5zqASQ1DxEyhp9hd7Hq3F10hQBChsDN 9MRmagbGjmlr1yiw54ThEvNIPRZToVUrf/wfAWy+2BfmMkFVP27PeVplpBVFcPtZh7ijJ+EYipl9R UbR5rEhXe6hfg4tx9z4Uo8ECkcW46k+BI2JUBiplmqrJi86X4/KBKoOmDboZDKV3HMnqsJsSq4dqU rSlQYXiQ==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.90_1 #2 (Red Hat Linux)) id 1gVCQk-0002P9-Tz; Fri, 07 Dec 2018 09:28:18 +0000 Received: from mail.bootlin.com ([62.4.15.54]) by bombadil.infradead.org with esmtp (Exim 4.90_1 #2 (Red Hat Linux)) id 1gVCPf-00010C-Br for linux-mtd@lists.infradead.org; Fri, 07 Dec 2018 09:27:21 +0000 Received: by mail.bootlin.com (Postfix, from userid 110) id 542B320DDA; Fri, 7 Dec 2018 10:26:51 +0100 (CET) X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on mail.bootlin.com X-Spam-Level: X-Spam-Status: No, score=-1.0 required=5.0 tests=ALL_TRUSTED,SHORTCIRCUIT, URIBL_BLOCKED shortcircuit=ham autolearn=disabled version=3.4.2 Received: from localhost.localdomain (aaubervilliers-681-1-79-44.w90-88.abo.wanadoo.fr [90.88.21.44]) by mail.bootlin.com (Postfix) with ESMTPSA id A698420E1F; Fri, 7 Dec 2018 10:26:40 +0100 (CET) From: Boris Brezillon To: Tudor Ambarus , Marek Vasut Subject: [RFC PATCH 14/34] mtd: spi-nor: Stop prefixing generic functions with a manufacturer name Date: Fri, 7 Dec 2018 10:26:17 +0100 Message-Id: <20181207092637.18687-15-boris.brezillon@bootlin.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20181207092637.18687-1-boris.brezillon@bootlin.com> References: <20181207092637.18687-1-boris.brezillon@bootlin.com> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20181207_012712_486440_604C4BD5 X-CRM114-Status: GOOD ( 18.25 ) X-Spam-Score: -0.0 (/) X-Spam-Report: SpamAssassin version 3.4.2 on bombadil.infradead.org summary: Content analysis details: (-0.0 points) pts rule name description ---- ---------------------- -------------------------------------------------- -0.0 SPF_PASS SPF: sender matches SPF record X-BeenThere: linux-mtd@lists.infradead.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: Linux MTD discussion mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Yogesh Narayan Gaur , Vignesh R , Richard Weinberger , Boris Brezillon , linux-mtd@lists.infradead.org, Miquel Raynal , Brian Norris , David Woodhouse MIME-Version: 1.0 Sender: "linux-mtd" Errors-To: linux-mtd-bounces+incoming=patchwork.ozlabs.org@lists.infradead.org Most quad_enable, set_4byte() and locking functions are manufacturer agnostic. Replace the manufacturer prefix by something describing more precisely what those functions do. Signed-off-by: Boris Brezillon --- drivers/mtd/spi-nor/core.c | 104 ++++++++++++++++++------------------- 1 file changed, 51 insertions(+), 53 deletions(-) diff --git a/drivers/mtd/spi-nor/core.c b/drivers/mtd/spi-nor/core.c index 8efd0490d2a0..f3c8e4ac1158 100644 --- a/drivers/mtd/spi-nor/core.c +++ b/drivers/mtd/spi-nor/core.c @@ -220,7 +220,7 @@ static int set_4byte(struct spi_nor *nor, bool enable) return nor->write_reg(nor, SPINOR_OP_BRWR, nor->cmd_buf, 1); } -static int s3an_sr_ready(struct spi_nor *nor) +static int spi_nor_xsr_ready(struct spi_nor *nor) { int ret; u8 val; @@ -281,7 +281,7 @@ static int spi_nor_ready(struct spi_nor *nor) int sr, fsr; if (nor->flags & SNOR_F_READY_XSR_RDY) - sr = s3an_sr_ready(nor); + sr = spi_nor_xsr_ready(nor); else sr = spi_nor_sr_ready(nor); if (sr < 0) @@ -797,8 +797,8 @@ static int write_sr_and_check(struct spi_nor *nor, u8 status_new, u8 mask) return ((ret & mask) != (status_new & mask)) ? -EIO : 0; } -static void stm_get_locked_range(struct spi_nor *nor, u8 sr, loff_t *ofs, - uint64_t *len) +static void get_locked_range_sr(struct spi_nor *nor, u8 sr, loff_t *ofs, + uint64_t *len) { struct mtd_info *mtd = &nor->mtd; u8 mask = SR_BP2 | SR_BP1 | SR_BP0; @@ -823,8 +823,8 @@ static void stm_get_locked_range(struct spi_nor *nor, u8 sr, loff_t *ofs, * Return 1 if the entire region is locked (if @locked is true) or unlocked (if * @locked is false); 0 otherwise */ -static int stm_check_lock_status_sr(struct spi_nor *nor, loff_t ofs, uint64_t len, - u8 sr, bool locked) +static int check_lock_status_sr(struct spi_nor *nor, loff_t ofs, uint64_t len, + u8 sr, bool locked) { loff_t lock_offs; uint64_t lock_len; @@ -832,7 +832,7 @@ static int stm_check_lock_status_sr(struct spi_nor *nor, loff_t ofs, uint64_t le if (!len) return 1; - stm_get_locked_range(nor, sr, &lock_offs, &lock_len); + get_locked_range_sr(nor, sr, &lock_offs, &lock_len); if (locked) /* Requested range is a sub-range of locked range */ @@ -842,16 +842,14 @@ static int stm_check_lock_status_sr(struct spi_nor *nor, loff_t ofs, uint64_t le return (ofs >= lock_offs + lock_len) || (ofs + len <= lock_offs); } -static int stm_is_locked_sr(struct spi_nor *nor, loff_t ofs, uint64_t len, - u8 sr) +static int is_locked_sr(struct spi_nor *nor, loff_t ofs, uint64_t len, u8 sr) { - return stm_check_lock_status_sr(nor, ofs, len, sr, true); + return check_lock_status_sr(nor, ofs, len, sr, true); } -static int stm_is_unlocked_sr(struct spi_nor *nor, loff_t ofs, uint64_t len, - u8 sr) +static int is_unlocked_sr(struct spi_nor *nor, loff_t ofs, uint64_t len, u8 sr) { - return stm_check_lock_status_sr(nor, ofs, len, sr, false); + return check_lock_status_sr(nor, ofs, len, sr, false); } /* @@ -886,7 +884,7 @@ static int stm_is_unlocked_sr(struct spi_nor *nor, loff_t ofs, uint64_t len, * * Returns negative on errors, 0 on success. */ -static int stm_lock(struct spi_nor *nor, loff_t ofs, uint64_t len) +static int sr_lock(struct spi_nor *nor, loff_t ofs, uint64_t len) { struct mtd_info *mtd = &nor->mtd; int status_old, status_new; @@ -901,16 +899,16 @@ static int stm_lock(struct spi_nor *nor, loff_t ofs, uint64_t len) return status_old; /* If nothing in our range is unlocked, we don't need to do anything */ - if (stm_is_locked_sr(nor, ofs, len, status_old)) + if (is_locked_sr(nor, ofs, len, status_old)) return 0; /* If anything below us is unlocked, we can't use 'bottom' protection */ - if (!stm_is_locked_sr(nor, 0, ofs, status_old)) + if (!is_locked_sr(nor, 0, ofs, status_old)) can_be_bottom = false; /* If anything above us is unlocked, we can't use 'top' protection */ - if (!stm_is_locked_sr(nor, ofs + len, mtd->size - (ofs + len), - status_old)) + if (!is_locked_sr(nor, ofs + len, mtd->size - (ofs + len), + status_old)) can_be_top = false; if (!can_be_bottom && !can_be_top) @@ -962,11 +960,11 @@ static int stm_lock(struct spi_nor *nor, loff_t ofs, uint64_t len) } /* - * Unlock a region of the flash. See stm_lock() for more info + * Unlock a region of the flash. See sr_lock() for more info * * Returns negative on errors, 0 on success. */ -static int stm_unlock(struct spi_nor *nor, loff_t ofs, uint64_t len) +static int sr_unlock(struct spi_nor *nor, loff_t ofs, uint64_t len) { struct mtd_info *mtd = &nor->mtd; int status_old, status_new; @@ -981,16 +979,16 @@ static int stm_unlock(struct spi_nor *nor, loff_t ofs, uint64_t len) return status_old; /* If nothing in our range is locked, we don't need to do anything */ - if (stm_is_unlocked_sr(nor, ofs, len, status_old)) + if (is_unlocked_sr(nor, ofs, len, status_old)) return 0; /* If anything below us is locked, we can't use 'top' protection */ - if (!stm_is_unlocked_sr(nor, 0, ofs, status_old)) + if (!is_unlocked_sr(nor, 0, ofs, status_old)) can_be_top = false; /* If anything above us is locked, we can't use 'bottom' protection */ - if (!stm_is_unlocked_sr(nor, ofs + len, mtd->size - (ofs + len), - status_old)) + if (!is_unlocked_sr(nor, ofs + len, mtd->size - (ofs + len), + status_old)) can_be_bottom = false; if (!can_be_bottom && !can_be_top) @@ -1045,13 +1043,13 @@ static int stm_unlock(struct spi_nor *nor, loff_t ofs, uint64_t len) } /* - * Check if a region of the flash is (completely) locked. See stm_lock() for + * Check if a region of the flash is (completely) locked. See sr_lock() for * more info. * * Returns 1 if entire region is locked, 0 if any portion is unlocked, and * negative on errors. */ -static int stm_is_locked(struct spi_nor *nor, loff_t ofs, uint64_t len) +static int sr_is_locked(struct spi_nor *nor, loff_t ofs, uint64_t len) { int status; @@ -1059,13 +1057,13 @@ static int stm_is_locked(struct spi_nor *nor, loff_t ofs, uint64_t len) if (status < 0) return status; - return stm_is_locked_sr(nor, ofs, len, status); + return is_locked_sr(nor, ofs, len, status); } -static const struct spi_nor_locking_ops stm_locking_ops = { - .lock = stm_lock, - .unlock = stm_unlock, - .is_locked = stm_is_locked, +static const struct spi_nor_locking_ops sr_locking_ops = { + .lock = sr_lock, + .unlock = sr_unlock, + .is_locked = sr_is_locked, }; static int spi_nor_lock(struct mtd_info *mtd, loff_t ofs, uint64_t len) @@ -1148,7 +1146,7 @@ static int no_quad_enable(struct spi_nor *nor) } /** - * macronix_quad_enable() - set QE bit in Status Register. + * sr1_bit6_quad_enable() - set QE bit in Status Register. * @nor: pointer to a 'struct spi_nor' * * Set the Quad Enable (QE) bit in the Status Register. @@ -1157,7 +1155,7 @@ static int no_quad_enable(struct spi_nor *nor) * * Return: 0 on success, -errno otherwise. */ -static int macronix_quad_enable(struct spi_nor *nor) +static int sr1_bit6_quad_enable(struct spi_nor *nor) { int ret, val; @@ -1177,7 +1175,7 @@ static int macronix_quad_enable(struct spi_nor *nor) ret = read_sr(nor); if (!(ret > 0 && (ret & SR_QUAD_EN_MX))) { - dev_err(nor->dev, "Macronix Quad bit not set\n"); + dev_err(nor->dev, "QE bit not set\n"); return -EINVAL; } @@ -1185,7 +1183,7 @@ static int macronix_quad_enable(struct spi_nor *nor) } /** - * spansion_quad_enable() - set QE bit in Configuraiton Register. + * legacy_quad_enable() - set QE bit in Configuraiton Register. * @nor: pointer to a 'struct spi_nor' * * Set the Quad Enable (QE) bit in the Configuration Register. @@ -1207,7 +1205,7 @@ static int macronix_quad_enable(struct spi_nor *nor) * * Return: 0 on success, -errno otherwise. */ -static int spansion_quad_enable(struct spi_nor *nor) +static int legacy_quad_enable(struct spi_nor *nor) { u8 sr_cr[2] = {0, CR_QUAD_EN_SPAN}; int ret; @@ -1227,7 +1225,7 @@ static int spansion_quad_enable(struct spi_nor *nor) } /** - * spansion_no_read_cr_quad_enable() - set QE bit in Configuration Register. + * sr2_bit1_no_read_quad_enable() - set QE bit in Configuration Register. * @nor: pointer to a 'struct spi_nor' * * Set the Quad Enable (QE) bit in the Configuration Register. @@ -1239,7 +1237,7 @@ static int spansion_quad_enable(struct spi_nor *nor) * * Return: 0 on success, -errno otherwise. */ -static int spansion_no_read_cr_quad_enable(struct spi_nor *nor) +static int sr2_bit1_no_read_quad_enable(struct spi_nor *nor) { u8 sr_cr[2]; int ret; @@ -1257,7 +1255,7 @@ static int spansion_no_read_cr_quad_enable(struct spi_nor *nor) } /** - * spansion_read_cr_quad_enable() - set QE bit in Configuration Register. + * sr2_bit1_read_quad_enable() - set QE bit in Configuration Register. * @nor: pointer to a 'struct spi_nor' * * Set the Quad Enable (QE) bit in the Configuration Register. @@ -1269,7 +1267,7 @@ static int spansion_no_read_cr_quad_enable(struct spi_nor *nor) * * Return: 0 on success, -errno otherwise. */ -static int spansion_read_cr_quad_enable(struct spi_nor *nor) +static int sr2_bit1_read_quad_enable(struct spi_nor *nor) { struct device *dev = nor->dev; u8 sr_cr[2]; @@ -1363,7 +1361,7 @@ static int sr2_bit7_quad_enable(struct spi_nor *nor) static int gd25q256_post_sfdp_fixups(struct spi_nor *nor, struct spi_nor_flash_parameter *params) { - params->quad_enable = macronix_quad_enable; + params->quad_enable = sr1_bit6_quad_enable; return 0; } @@ -2548,11 +2546,11 @@ static int spi_nor_parse_bfpt(struct spi_nor *nor, case BFPT_DWORD15_QER_SR2_BIT1_BUGGY: case BFPT_DWORD15_QER_SR2_BIT1_NO_RD: - params->quad_enable = spansion_no_read_cr_quad_enable; + params->quad_enable = sr2_bit1_no_read_quad_enable; break; case BFPT_DWORD15_QER_SR1_BIT6: - params->quad_enable = macronix_quad_enable; + params->quad_enable = sr1_bit6_quad_enable; break; case BFPT_DWORD15_QER_SR2_BIT7: @@ -2560,7 +2558,7 @@ static int spi_nor_parse_bfpt(struct spi_nor *nor, break; case BFPT_DWORD15_QER_SR2_BIT1: - params->quad_enable = spansion_read_cr_quad_enable; + params->quad_enable = sr2_bit1_read_quad_enable; break; default: @@ -3326,18 +3324,18 @@ void spi_nor_restore(struct spi_nor *nor) } EXPORT_SYMBOL_GPL(spi_nor_restore); -static int macronix_set_4byte(struct spi_nor *nor, bool enable) +static int en4_ex4_set_4byte(struct spi_nor *nor, bool enable) { return nor->write_reg(nor, enable ? SPINOR_OP_EN4B : SPINOR_OP_EX4B, NULL, 0); } -static int st_micron_set_4byte(struct spi_nor *nor, bool enable) +static int en4_ex4_wen_set_4byte(struct spi_nor *nor, bool enable) { int ret; write_enable(nor); - ret = macronix_set_4byte(nor, enable); + ret = en4_ex4_set_4byte(nor, enable); write_disable(nor); return ret; @@ -3347,7 +3345,7 @@ static int winbond_set_4byte(struct spi_nor *nor, bool enable) { int ret; - ret = macronix_set_4byte(nor, enable); + ret = en4_ex4_set_4byte(nor, enable); if (ret || enable) return ret; @@ -3369,14 +3367,14 @@ static void st_micron_post_sfdp_fixups(struct spi_nor *nor) { /* All ST/Micron NORs support the unlock/lock operations. */ nor->flags |= SNOR_F_HAS_LOCK; - nor->set_4byte = st_micron_set_4byte; + nor->set_4byte = en4_ex4_wen_set_4byte; nor->quad_enable = no_quad_enable; } static void macronix_post_sfdp_fixups(struct spi_nor *nor) { - nor->set_4byte = macronix_set_4byte; - nor->quad_enable = macronix_quad_enable; + nor->set_4byte = en4_ex4_set_4byte; + nor->quad_enable = sr1_bit6_quad_enable; } static void winbond_post_sfdp_fixups(struct spi_nor *nor) @@ -3669,7 +3667,7 @@ int spi_nor_scan(struct spi_nor *nor, const char *name, nor->flags |= SNOR_F_HAS_LOCK; /* Kept only for backward compatibility purpose. */ - nor->quad_enable = spansion_quad_enable; + nor->quad_enable = legacy_quad_enable; /* * Post SFDP fixups. Has to be called before spi_nor_setup() because @@ -3688,7 +3686,7 @@ int spi_nor_scan(struct spi_nor *nor, const char *name, * pick the default ones. */ if (nor->flags & SNOR_F_HAS_LOCK && !nor->locking_ops) - nor->locking_ops = &stm_locking_ops; + nor->locking_ops = &sr_locking_ops; if (nor->locking_ops) { mtd->_lock = spi_nor_lock;