* [PATCH 1/8] mtd: rawnand: qcom: make check_flash_errors() more generic
2026-09-24 20:04 [PATCH 0/8] mtd: rawnand: qcom: share more common code Gabor Juhos
@ 2026-09-24 20:04 ` Gabor Juhos
2026-09-24 20:09 ` sashiko-bot
2026-09-24 20:04 ` [PATCH 2/8] mtd: rawnand: qcom: make config_nand_page_read() " Gabor Juhos
` (6 subsequent siblings)
7 siblings, 1 reply; 16+ messages in thread
From: Gabor Juhos @ 2026-09-24 20:04 UTC (permalink / raw)
To: Manivannan Sadhasivam, Miquel Raynal, Richard Weinberger,
Vignesh Raghavendra
Cc: Md Sadre Alam, linux-mtd, linux-arm-msm, linux-kernel, Gabor Juhos
The function gets a 'qcom_nand_host' pointer as a parameter but it is
only used to extract the nand controller's private structure from that.
In order to make the function more generic, change the declaration to
get a 'qcom_nandc_controller' pointer directly, and update the callers
accordingly.
While at it, also change the function name to use a 'qpic_nandc' prefix.
No functional changes. This is in preparation of moving the function
into the 'qpic_common' code to allow reusing it from the 'spi-qpic-snand'
driver.
Signed-off-by: Gabor Juhos <j4g8y7@gmail.com>
---
drivers/mtd/nand/raw/qcom_nandc.c | 9 ++++-----
1 file changed, 4 insertions(+), 5 deletions(-)
diff --git a/drivers/mtd/nand/raw/qcom_nandc.c b/drivers/mtd/nand/raw/qcom_nandc.c
index d7642db2e2df..12bfb14cd9a3 100644
--- a/drivers/mtd/nand/raw/qcom_nandc.c
+++ b/drivers/mtd/nand/raw/qcom_nandc.c
@@ -449,10 +449,9 @@ struct read_stats {
};
/* reads back FLASH_STATUS register set by the controller */
-static int check_flash_errors(struct qcom_nand_host *host, int cw_cnt)
+static int qcom_nandc_check_flash_errors(struct qcom_nand_controller *nandc,
+ int cw_cnt)
{
- struct nand_chip *chip = &host->chip;
- struct qcom_nand_controller *nandc = get_qcom_nand_controller(chip);
int i;
qcom_nandc_dev_to_mem(nandc, true);
@@ -538,7 +537,7 @@ qcom_nandc_read_cw_raw(struct mtd_info *mtd, struct nand_chip *chip,
return ret;
}
- return check_flash_errors(host, 1);
+ return qcom_nandc_check_flash_errors(nandc, 1);
}
/*
@@ -1181,7 +1180,7 @@ static int qcom_nandc_block_bad(struct nand_chip *chip, loff_t ofs)
if (ret)
goto err;
- if (check_flash_errors(host, 1)) {
+ if (qcom_nandc_check_flash_errors(nandc, 1)) {
dev_warn(nandc->dev, "error when trying to read BBM\n");
goto err;
}
--
2.55.0
^ permalink raw reply [flat|nested] 16+ messages in thread* Re: [PATCH 1/8] mtd: rawnand: qcom: make check_flash_errors() more generic
2026-09-24 20:04 ` [PATCH 1/8] mtd: rawnand: qcom: make check_flash_errors() more generic Gabor Juhos
@ 2026-09-24 20:09 ` sashiko-bot
2026-09-24 20:22 ` Gabor Juhos
0 siblings, 1 reply; 16+ messages in thread
From: sashiko-bot @ 2026-09-24 20:09 UTC (permalink / raw)
To: Vignesh Raghavendra, Manivannan Sadhasivam, Gabor Juhos,
Miquel Raynal, Richard Weinberger
Cc: linux-kernel, Md Sadre Alam, linux-arm-msm, linux-mtd
Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:
- [Medium] mtd: rawnand: qcom: mismatch between commit message and function prefix
--
commit a83607e63ec53429dc425262093eef9dee3bfd4e
Author: Gabor Juhos <j4g8y7@gmail.com>
mtd: rawnand: qcom: make check_flash_errors() more generic
The function gets a qcom_nand_host pointer as a parameter but it is
only used to extract the nand controller's private structure from that.
In order to make the function more generic, change the declaration to
get a qcom_nandc_controller pointer directly, and update the callers
accordingly.
> diff --git a/drivers/mtd/nand/raw/qcom_nandc.c b/drivers/mtd/nand/raw/qcom_nandc.c
> index d7642db2e2df1..12bfb14cd9a37 100644
> --- a/drivers/mtd/nand/raw/qcom_nandc.c
> +++ b/drivers/mtd/nand/raw/qcom_nandc.c
> @@ -449,10 +449,9 @@ struct read_stats {
> };
>
> /* reads back FLASH_STATUS register set by the controller */
> -static int check_flash_errors(struct qcom_nand_host *host, int cw_cnt)
> +static int qcom_nandc_check_flash_errors(struct qcom_nand_controller *nandc,
> + int cw_cnt)
> {
[Severity: Medium]
This isn't a bug, but there is a mismatch between the commit message and
the actual function renaming.
The commit message states the function will use the "qpic_nandc" prefix:
"While at it, also change the function name to use a 'qpic_nandc' prefix."
However, the code changes the name to qcom_nandc_check_flash_errors, using
the "qcom_nandc" prefix instead.
Could the commit message be updated to match the code, or should the
function be named qpic_nandc_check_flash_errors?
--
Sashiko AI review · https://sashiko.dev/#/patchset/20260924-qcom_nandc-share-more-code-v1-0-f3012199b161@gmail.com?part=1
^ permalink raw reply [flat|nested] 16+ messages in thread* Re: [PATCH 1/8] mtd: rawnand: qcom: make check_flash_errors() more generic
2026-09-24 20:09 ` sashiko-bot
@ 2026-09-24 20:22 ` Gabor Juhos
0 siblings, 0 replies; 16+ messages in thread
From: Gabor Juhos @ 2026-09-24 20:22 UTC (permalink / raw)
To: sashiko-reviews, Vignesh Raghavendra, Manivannan Sadhasivam,
Miquel Raynal, Richard Weinberger
Cc: linux-kernel, Md Sadre Alam, linux-arm-msm, linux-mtd
2026. 09. 24. 22:09 keltezéssel, sashiko-bot@kernel.org írta:
> Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:
> - [Medium] mtd: rawnand: qcom: mismatch between commit message and function prefix
> --
>
> commit a83607e63ec53429dc425262093eef9dee3bfd4e
> Author: Gabor Juhos <j4g8y7@gmail.com>
>
> mtd: rawnand: qcom: make check_flash_errors() more generic
>
> The function gets a qcom_nand_host pointer as a parameter but it is
> only used to extract the nand controller's private structure from that.
> In order to make the function more generic, change the declaration to
> get a qcom_nandc_controller pointer directly, and update the callers
> accordingly.
>
>> diff --git a/drivers/mtd/nand/raw/qcom_nandc.c b/drivers/mtd/nand/raw/qcom_nandc.c
>> index d7642db2e2df1..12bfb14cd9a37 100644
>> --- a/drivers/mtd/nand/raw/qcom_nandc.c
>> +++ b/drivers/mtd/nand/raw/qcom_nandc.c
>> @@ -449,10 +449,9 @@ struct read_stats {
>> };
>>
>> /* reads back FLASH_STATUS register set by the controller */
>> -static int check_flash_errors(struct qcom_nand_host *host, int cw_cnt)
>> +static int qcom_nandc_check_flash_errors(struct qcom_nand_controller *nandc,
>> + int cw_cnt)
>> {
>
> [Severity: Medium]
> This isn't a bug, but there is a mismatch between the commit message and
> the actual function renaming.
>
> The commit message states the function will use the "qpic_nandc" prefix:
> "While at it, also change the function name to use a 'qpic_nandc' prefix."
>
> However, the code changes the name to qcom_nandc_check_flash_errors, using
> the "qcom_nandc" prefix instead.
>
> Could the commit message be updated to match the code, or should the
> function be named qpic_nandc_check_flash_errors?
>
May bad, the commit message is wrong of course. I will fix it in the next
version, also in the the other patches.
-Gabor
^ permalink raw reply [flat|nested] 16+ messages in thread
* [PATCH 2/8] mtd: rawnand: qcom: make config_nand_page_read() more generic
2026-09-24 20:04 [PATCH 0/8] mtd: rawnand: qcom: share more common code Gabor Juhos
2026-09-24 20:04 ` [PATCH 1/8] mtd: rawnand: qcom: make check_flash_errors() more generic Gabor Juhos
@ 2026-09-24 20:04 ` Gabor Juhos
2026-09-24 20:10 ` sashiko-bot
2026-09-24 20:04 ` [PATCH 3/8] mtd: rawnand: qcom: make config_nand_page_write() " Gabor Juhos
` (5 subsequent siblings)
7 siblings, 1 reply; 16+ messages in thread
From: Gabor Juhos @ 2026-09-24 20:04 UTC (permalink / raw)
To: Manivannan Sadhasivam, Miquel Raynal, Richard Weinberger,
Vignesh Raghavendra
Cc: Md Sadre Alam, linux-mtd, linux-arm-msm, linux-kernel, Gabor Juhos
The function gets a 'nand_chip' pointer as a parameter but it is
only used to extract a pointer to the nand controller's private
structure from that.
In order to make the function more generic, change the declaration
to get a 'qcom_nandc_controller' pointer directly, and update the
callers accordingly. While at it, also change the function name to
use a 'qpic_nandc' prefix.
No functional changes intended. This is in preparation of moving
the function into the 'qpic_common' code to allow reusing it from
the 'spi-qpic-snand' driver.
Signed-off-by: Gabor Juhos <j4g8y7@gmail.com>
---
drivers/mtd/nand/raw/qcom_nandc.c | 12 ++++++------
1 file changed, 6 insertions(+), 6 deletions(-)
diff --git a/drivers/mtd/nand/raw/qcom_nandc.c b/drivers/mtd/nand/raw/qcom_nandc.c
index 12bfb14cd9a3..c65a8416c3f5 100644
--- a/drivers/mtd/nand/raw/qcom_nandc.c
+++ b/drivers/mtd/nand/raw/qcom_nandc.c
@@ -305,10 +305,8 @@ static void update_rw_regs(struct qcom_nand_host *host, int num_cw, bool read, i
* Helper to prepare DMA descriptors for configuring registers
* before reading a NAND page.
*/
-static void config_nand_page_read(struct nand_chip *chip)
+static void qcom_nandc_config_page_read(struct qcom_nand_controller *nandc)
{
- struct qcom_nand_controller *nandc = get_qcom_nand_controller(chip);
-
qcom_write_reg_dma(nandc, &nandc->regs->addr0, NAND_ADDR0, 2, 0);
qcom_write_reg_dma(nandc, &nandc->regs->cfg0, NAND_DEV0_CFG0, 3, 0);
if (!nandc->props->qpic_version2)
@@ -357,7 +355,9 @@ static void
config_nand_single_cw_page_read(struct nand_chip *chip,
bool use_ecc, int cw)
{
- config_nand_page_read(chip);
+ struct qcom_nand_controller *nandc = get_qcom_nand_controller(chip);
+
+ qcom_nandc_config_page_read(nandc);
config_nand_cw_read(chip, use_ecc, cw);
}
@@ -490,7 +490,7 @@ qcom_nandc_read_cw_raw(struct mtd_info *mtd, struct nand_chip *chip,
qcom_clear_bam_transaction(nandc);
set_address(host, host->cw_size * cw, page);
update_rw_regs(host, 1, true, raw_cw);
- config_nand_page_read(chip);
+ qcom_nandc_config_page_read(nandc);
data_size1 = mtd->writesize - host->cw_size * (ecc->steps - 1);
oob_size1 = host->bbm_size;
@@ -727,7 +727,7 @@ static int read_page_ecc(struct qcom_nand_host *host, u8 *data_buf,
u8 *data_buf_start = data_buf, *oob_buf_start = oob_buf;
int i, ret;
- config_nand_page_read(chip);
+ qcom_nandc_config_page_read(nandc);
/* queue cmd descs for each codeword */
for (i = 0; i < ecc->steps; i++) {
--
2.55.0
^ permalink raw reply [flat|nested] 16+ messages in thread* Re: [PATCH 2/8] mtd: rawnand: qcom: make config_nand_page_read() more generic
2026-09-24 20:04 ` [PATCH 2/8] mtd: rawnand: qcom: make config_nand_page_read() " Gabor Juhos
@ 2026-09-24 20:10 ` sashiko-bot
0 siblings, 0 replies; 16+ messages in thread
From: sashiko-bot @ 2026-09-24 20:10 UTC (permalink / raw)
To: Richard Weinberger, Miquel Raynal, Gabor Juhos,
Manivannan Sadhasivam, Vignesh Raghavendra
Cc: linux-mtd, linux-kernel, Md Sadre Alam, linux-arm-msm
Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:
- [Medium] mtd: code and commit message mismatch in config_nand_page_read() changes
--
commit 83713aed92ebeefb24101c6bd3b2c47c7e4e9dfd
Author: Gabor Juhos <j4g8y7@gmail.com>
mtd: rawnand: qcom: make config_nand_page_read() more generic
This commit modifies config_nand_page_read() to take a controller pointer
directly instead of a nand_chip pointer. It updates the callers accordingly
and renames the function to prepare for future reuse.
> In order to make the function more generic, change the declaration
> to get a 'qcom_nandc_controller' pointer directly, and update the
> callers accordingly. While at it, also change the function name to
> use a 'qpic_nandc' prefix.
[Severity: Medium]
Does the commit message accurately reflect the changes made in the patch?
The commit message mentions changing the parameter to a 'qcom_nandc_controller'
pointer and using a 'qpic_nandc' prefix for the function name. However, the
code uses a 'struct qcom_nand_controller *' pointer and names the function
qcom_nandc_config_page_read():
> diff --git a/drivers/mtd/nand/raw/qcom_nandc.c b/drivers/mtd/nand/raw/qcom_nandc.c
> index 12bfb14cd9a37..c65a8416c3f5d 100644
> --- a/drivers/mtd/nand/raw/qcom_nandc.c
> +++ b/drivers/mtd/nand/raw/qcom_nandc.c
[ ... ]
> @@ -305,10 +305,8 @@ static void update_rw_regs(struct qcom_nand_host *host, int num_cw, bool read, i
> * Helper to prepare DMA descriptors for configuring registers
> * before reading a NAND page.
> */
> -static void config_nand_page_read(struct nand_chip *chip)
> +static void qcom_nandc_config_page_read(struct qcom_nand_controller *nandc)
> {
--
Sashiko AI review · https://sashiko.dev/#/patchset/20260924-qcom_nandc-share-more-code-v1-0-f3012199b161@gmail.com?part=2
^ permalink raw reply [flat|nested] 16+ messages in thread
* [PATCH 3/8] mtd: rawnand: qcom: make config_nand_page_write() more generic
2026-09-24 20:04 [PATCH 0/8] mtd: rawnand: qcom: share more common code Gabor Juhos
2026-09-24 20:04 ` [PATCH 1/8] mtd: rawnand: qcom: make check_flash_errors() more generic Gabor Juhos
2026-09-24 20:04 ` [PATCH 2/8] mtd: rawnand: qcom: make config_nand_page_read() " Gabor Juhos
@ 2026-09-24 20:04 ` Gabor Juhos
2026-09-24 20:09 ` sashiko-bot
2026-09-24 20:04 ` [PATCH 4/8] mtd: rawnand: qcom: make config_nand_cw_write() " Gabor Juhos
` (4 subsequent siblings)
7 siblings, 1 reply; 16+ messages in thread
From: Gabor Juhos @ 2026-09-24 20:04 UTC (permalink / raw)
To: Manivannan Sadhasivam, Miquel Raynal, Richard Weinberger,
Vignesh Raghavendra
Cc: Md Sadre Alam, linux-mtd, linux-arm-msm, linux-kernel, Gabor Juhos
The function gets a 'nand_chip' pointer as a parameter but it is
only used to extract a pointer to the nand controller's private
structure from that.
In order to make the function more generic, change the declaration
to get a 'qcom_nandc_controller' pointer directly, and update the
callers accordingly. While at it, also change the function name to
use a 'qpic_nandc' prefix.
No functional changes intended. This is in preparation of moving
the function into the 'qpic_common' code to allow reusing it from
the 'spi-qpic-snand' driver.
Signed-off-by: Gabor Juhos <j4g8y7@gmail.com>
---
drivers/mtd/nand/raw/qcom_nandc.c | 12 +++++-------
1 file changed, 5 insertions(+), 7 deletions(-)
diff --git a/drivers/mtd/nand/raw/qcom_nandc.c b/drivers/mtd/nand/raw/qcom_nandc.c
index c65a8416c3f5..1f3c00823309 100644
--- a/drivers/mtd/nand/raw/qcom_nandc.c
+++ b/drivers/mtd/nand/raw/qcom_nandc.c
@@ -365,10 +365,8 @@ config_nand_single_cw_page_read(struct nand_chip *chip,
* Helper to prepare DMA descriptors used to configure registers needed for
* before writing a NAND page.
*/
-static void config_nand_page_write(struct nand_chip *chip)
+static void qcom_nandc_config_page_write(struct qcom_nand_controller *nandc)
{
- struct qcom_nand_controller *nandc = get_qcom_nand_controller(chip);
-
qcom_write_reg_dma(nandc, &nandc->regs->addr0, NAND_ADDR0, 2, 0);
qcom_write_reg_dma(nandc, &nandc->regs->cfg0, NAND_DEV0_CFG0, 3, 0);
if (!nandc->props->qpic_version2)
@@ -989,7 +987,7 @@ static int qcom_nandc_write_page(struct nand_chip *chip, const u8 *buf,
host->use_ecc = true;
update_rw_regs(host, ecc->steps, false, 0);
- config_nand_page_write(chip);
+ qcom_nandc_config_page_write(nandc);
for (i = 0; i < ecc->steps; i++) {
int data_size, oob_size;
@@ -1059,7 +1057,7 @@ static int qcom_nandc_write_page_raw(struct nand_chip *chip,
host->use_ecc = false;
update_rw_regs(host, ecc->steps, false, 0);
- config_nand_page_write(chip);
+ qcom_nandc_config_page_write(nandc);
for (i = 0; i < ecc->steps; i++) {
int data_size1, data_size2, oob_size1, oob_size2;
@@ -1143,7 +1141,7 @@ static int qcom_nandc_write_oob(struct nand_chip *chip, int page)
set_address(host, host->cw_size * (ecc->steps - 1), page);
update_rw_regs(host, 1, false, 0);
- config_nand_page_write(chip);
+ qcom_nandc_config_page_write(nandc);
qcom_write_data_dma(nandc, FLASH_BUF_ACC,
nandc->data_buffer, data_size + oob_size, 0);
config_nand_cw_write(chip);
@@ -1219,7 +1217,7 @@ static int qcom_nandc_block_markbad(struct nand_chip *chip, loff_t ofs)
set_address(host, host->cw_size * (ecc->steps - 1), page);
update_rw_regs(host, 1, false, ecc->steps - 1);
- config_nand_page_write(chip);
+ qcom_nandc_config_page_write(nandc);
qcom_write_data_dma(nandc, FLASH_BUF_ACC,
nandc->data_buffer, host->cw_size, 0);
config_nand_cw_write(chip);
--
2.55.0
^ permalink raw reply [flat|nested] 16+ messages in thread* Re: [PATCH 3/8] mtd: rawnand: qcom: make config_nand_page_write() more generic
2026-09-24 20:04 ` [PATCH 3/8] mtd: rawnand: qcom: make config_nand_page_write() " Gabor Juhos
@ 2026-09-24 20:09 ` sashiko-bot
0 siblings, 0 replies; 16+ messages in thread
From: sashiko-bot @ 2026-09-24 20:09 UTC (permalink / raw)
To: Richard Weinberger, Gabor Juhos, Manivannan Sadhasivam,
Vignesh Raghavendra, Miquel Raynal
Cc: linux-mtd, linux-arm-msm, linux-kernel, Md Sadre Alam
Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:
- [Medium] mtd: commit message claims qpic_nandc prefix but applies qcom_nandc
--
commit 2cd47b90aa23e587aa720b2d04c9ca024d8178d5
Author: Gabor Juhos <j4g8y7@gmail.com>
mtd: rawnand: qcom: make config_nand_page_write() more generic
This commit updates config_nand_page_write() to take a pointer to the
qcom_nand_controller directly instead of extracting it from nand_chip.
It also renames the function to prepare for future code reuse.
> In order to make the function more generic, change the declaration
> to get a 'qcom_nandc_controller' pointer directly, and update the
> callers accordingly. While at it, also change the function name to
> use a 'qpic_nandc' prefix.
[Severity: Medium]
This isn't a bug introduced by this patch, but there is a discrepancy between
the commit message and the actual code changes. The commit message states the
function is being renamed to use a 'qpic_nandc' prefix, but as seen below, it
is actually renamed to qcom_nandc_config_page_write() using a 'qcom_nandc'
prefix.
Could the commit message be updated to match the code, or should the code be
updated to use the intended prefix?
> diff --git a/drivers/mtd/nand/raw/qcom_nandc.c b/drivers/mtd/nand/raw/qcom_nandc.c
> index c65a8416c3f5d..1f3c00823309f 100644
> --- a/drivers/mtd/nand/raw/qcom_nandc.c
> +++ b/drivers/mtd/nand/raw/qcom_nandc.c
> @@ -365,10 +365,8 @@ config_nand_single_cw_page_read(struct nand_chip *chip,
> * Helper to prepare DMA descriptors used to configure registers needed for
> * before writing a NAND page.
> */
> -static void config_nand_page_write(struct nand_chip *chip)
> +static void qcom_nandc_config_page_write(struct qcom_nand_controller *nandc)
> {
--
Sashiko AI review · https://sashiko.dev/#/patchset/20260924-qcom_nandc-share-more-code-v1-0-f3012199b161@gmail.com?part=3
^ permalink raw reply [flat|nested] 16+ messages in thread
* [PATCH 4/8] mtd: rawnand: qcom: make config_nand_cw_write() more generic
2026-09-24 20:04 [PATCH 0/8] mtd: rawnand: qcom: share more common code Gabor Juhos
` (2 preceding siblings ...)
2026-09-24 20:04 ` [PATCH 3/8] mtd: rawnand: qcom: make config_nand_page_write() " Gabor Juhos
@ 2026-09-24 20:04 ` Gabor Juhos
2026-09-24 20:09 ` sashiko-bot
2026-09-24 20:04 ` [PATCH 5/8] mtd: rawnand: qcom: make nandc_set_read_loc_first() " Gabor Juhos
` (3 subsequent siblings)
7 siblings, 1 reply; 16+ messages in thread
From: Gabor Juhos @ 2026-09-24 20:04 UTC (permalink / raw)
To: Manivannan Sadhasivam, Miquel Raynal, Richard Weinberger,
Vignesh Raghavendra
Cc: Md Sadre Alam, linux-mtd, linux-arm-msm, linux-kernel, Gabor Juhos
The function gets a 'nand_chip' pointer as a parameter but it is
only used to extract a pointer to the nand controller's private
structure from that.
In order to make the function more generic, change the declaration
to get a 'qcom_nandc_controller' pointer directly, and update the
callers accordingly. While at it, also change the function name to
use a 'qpic_nandc' prefix.
No functional changes intended. This is in preparation of moving
the function into the 'qpic_common' code to allow reusing it from
the 'spi-qpic-snand' driver.
Signed-off-by: Gabor Juhos <j4g8y7@gmail.com>
---
drivers/mtd/nand/raw/qcom_nandc.c | 12 +++++-------
1 file changed, 5 insertions(+), 7 deletions(-)
diff --git a/drivers/mtd/nand/raw/qcom_nandc.c b/drivers/mtd/nand/raw/qcom_nandc.c
index 1f3c00823309..99fbf5458083 100644
--- a/drivers/mtd/nand/raw/qcom_nandc.c
+++ b/drivers/mtd/nand/raw/qcom_nandc.c
@@ -378,10 +378,8 @@ static void qcom_nandc_config_page_write(struct qcom_nand_controller *nandc)
* Helper to prepare DMA descriptors for configuring registers
* before writing each codeword in NAND page.
*/
-static void config_nand_cw_write(struct nand_chip *chip)
+static void qcom_nandc_config_cw_write(struct qcom_nand_controller *nandc)
{
- struct qcom_nand_controller *nandc = get_qcom_nand_controller(chip);
-
qcom_write_reg_dma(nandc, &nandc->regs->cmd, NAND_FLASH_CMD, 1, NAND_BAM_NEXT_SGL);
qcom_write_reg_dma(nandc, &nandc->regs->exec, NAND_EXEC_CMD, 1, NAND_BAM_NEXT_SGL);
@@ -1018,7 +1016,7 @@ static int qcom_nandc_write_page(struct nand_chip *chip, const u8 *buf,
oob_buf, oob_size, 0);
}
- config_nand_cw_write(chip);
+ qcom_nandc_config_cw_write(nandc);
data_buf += data_size;
oob_buf += oob_size;
@@ -1094,7 +1092,7 @@ static int qcom_nandc_write_page_raw(struct nand_chip *chip,
qcom_write_data_dma(nandc, reg_off, oob_buf, oob_size2, 0);
oob_buf += oob_size2;
- config_nand_cw_write(chip);
+ qcom_nandc_config_cw_write(nandc);
}
ret = qcom_submit_descs(nandc);
@@ -1144,7 +1142,7 @@ static int qcom_nandc_write_oob(struct nand_chip *chip, int page)
qcom_nandc_config_page_write(nandc);
qcom_write_data_dma(nandc, FLASH_BUF_ACC,
nandc->data_buffer, data_size + oob_size, 0);
- config_nand_cw_write(chip);
+ qcom_nandc_config_cw_write(nandc);
ret = qcom_submit_descs(nandc);
if (ret) {
@@ -1220,7 +1218,7 @@ static int qcom_nandc_block_markbad(struct nand_chip *chip, loff_t ofs)
qcom_nandc_config_page_write(nandc);
qcom_write_data_dma(nandc, FLASH_BUF_ACC,
nandc->data_buffer, host->cw_size, 0);
- config_nand_cw_write(chip);
+ qcom_nandc_config_cw_write(nandc);
ret = qcom_submit_descs(nandc);
if (ret) {
--
2.55.0
^ permalink raw reply [flat|nested] 16+ messages in thread* Re: [PATCH 4/8] mtd: rawnand: qcom: make config_nand_cw_write() more generic
2026-09-24 20:04 ` [PATCH 4/8] mtd: rawnand: qcom: make config_nand_cw_write() " Gabor Juhos
@ 2026-09-24 20:09 ` sashiko-bot
0 siblings, 0 replies; 16+ messages in thread
From: sashiko-bot @ 2026-09-24 20:09 UTC (permalink / raw)
To: Manivannan Sadhasivam, Richard Weinberger, Gabor Juhos,
Vignesh Raghavendra, Miquel Raynal
Cc: linux-arm-msm, linux-kernel, Md Sadre Alam, linux-mtd
Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:
- [Medium] mtd: code and commit message mismatch for config_nand_cw_write prefix
--
commit 0e6310636afbfd85ec148281a9348c826d2b016a
Author: Gabor Juhos <j4g8y7@gmail.com>
mtd: rawnand: qcom: make config_nand_cw_write() more generic
This commit changes the declaration of config_nand_cw_write() to receive
a qcom_nand_controller pointer directly instead of a nand_chip pointer,
and renames the function.
> In order to make the function more generic, change the declaration
> to get a 'qcom_nandc_controller' pointer directly, and update the
> callers accordingly. While at it, also change the function name to
> use a 'qpic_nandc' prefix.
>
> No functional changes intended. This is in preparation of moving
> the function into the 'qpic_common' code to allow reusing it from
> the 'spi-qpic-snand' driver.
> diff --git a/drivers/mtd/nand/raw/qcom_nandc.c b/drivers/mtd/nand/raw/qcom_nandc.c
> index 1f3c00823309f..99fbf54580836 100644
> --- a/drivers/mtd/nand/raw/qcom_nandc.c
> +++ b/drivers/mtd/nand/raw/qcom_nandc.c
[ ... ]
> @@ -378,10 +378,8 @@ static void qcom_nandc_config_page_write(struct qcom_nand_controller *nandc)
> * Helper to prepare DMA descriptors for configuring registers
> * before writing each codeword in NAND page.
> */
> -static void config_nand_cw_write(struct nand_chip *chip)
> +static void qcom_nandc_config_cw_write(struct qcom_nand_controller *nandc)
[Severity: Medium]
The commit message states the function is being renamed to use a
'qpic_nandc' prefix, but here it is renamed to use a 'qcom_nandc_'
prefix instead.
Could the commit message be updated to match the actual code change, or
should the code be using the qpic prefix since the preparation is for
moving it into qpic_common?
--
Sashiko AI review · https://sashiko.dev/#/patchset/20260924-qcom_nandc-share-more-code-v1-0-f3012199b161@gmail.com?part=4
^ permalink raw reply [flat|nested] 16+ messages in thread
* [PATCH 5/8] mtd: rawnand: qcom: make nandc_set_read_loc_first() more generic
2026-09-24 20:04 [PATCH 0/8] mtd: rawnand: qcom: share more common code Gabor Juhos
` (3 preceding siblings ...)
2026-09-24 20:04 ` [PATCH 4/8] mtd: rawnand: qcom: make config_nand_cw_write() " Gabor Juhos
@ 2026-09-24 20:04 ` Gabor Juhos
2026-09-24 20:10 ` sashiko-bot
2026-09-24 20:04 ` [PATCH 6/8] mtd: rawnand: qcom: make nandc_set_read_loc_last() " Gabor Juhos
` (2 subsequent siblings)
7 siblings, 1 reply; 16+ messages in thread
From: Gabor Juhos @ 2026-09-24 20:04 UTC (permalink / raw)
To: Manivannan Sadhasivam, Miquel Raynal, Richard Weinberger,
Vignesh Raghavendra
Cc: Md Sadre Alam, linux-mtd, linux-arm-msm, linux-kernel, Gabor Juhos
The function gets a 'nand_chip' pointer as a parameter but it is
only used to extract a pointer to the nand controller's private
structure from that.
In order to make the function more generic, change the declaration
to get a 'qcom_nandc_controller' pointer directly, and update the
callers accordingly. While at it, also change the function name to
use a 'qpic_nandc' prefix.
No functional changes intended. This is in preparation of moving
the function into the 'qpic_common' code to allow reusing it from
the 'spi-qpic-snand' driver.
Signed-off-by: Gabor Juhos <j4g8y7@gmail.com>
---
drivers/mtd/nand/raw/qcom_nandc.c | 18 +++++++++---------
1 file changed, 9 insertions(+), 9 deletions(-)
diff --git a/drivers/mtd/nand/raw/qcom_nandc.c b/drivers/mtd/nand/raw/qcom_nandc.c
index 99fbf5458083..96a1a5a03de8 100644
--- a/drivers/mtd/nand/raw/qcom_nandc.c
+++ b/drivers/mtd/nand/raw/qcom_nandc.c
@@ -150,8 +150,8 @@ static bool qcom_nandc_is_last_cw(struct nand_ecc_ctrl *ecc, int cw)
}
/**
- * nandc_set_read_loc_first() - to set read location first register
- * @chip: NAND Private Flash Chip Data
+ * qcom_nandc_set_read_loc_first() - to set read location first register
+ * @nandc: NAND controller's private data
* @reg_base: location register base
* @cw_offset: code word offset
* @read_size: code word read length
@@ -159,11 +159,10 @@ static bool qcom_nandc_is_last_cw(struct nand_ecc_ctrl *ecc, int cw)
*
* This function will set location register value
*/
-static void nandc_set_read_loc_first(struct nand_chip *chip,
- int reg_base, u32 cw_offset,
- u32 read_size, u32 is_last_read_loc)
+static void qcom_nandc_set_read_loc_first(struct qcom_nand_controller *nandc,
+ int reg_base, u32 cw_offset,
+ u32 read_size, u32 is_last_read_loc)
{
- struct qcom_nand_controller *nandc = get_qcom_nand_controller(chip);
__le32 locreg_val;
u32 val = FIELD_PREP(READ_LOCATION_OFFSET_MASK, cw_offset) |
FIELD_PREP(READ_LOCATION_SIZE_MASK, read_size) |
@@ -230,8 +229,9 @@ static void nandc_set_read_loc(struct nand_chip *chip, int cw, int reg,
return nandc_set_read_loc_last(chip, reg_base, cw_offset,
read_size, is_last_read_loc);
else
- return nandc_set_read_loc_first(chip, reg_base, cw_offset,
- read_size, is_last_read_loc);
+ return qcom_nandc_set_read_loc_first(nandc, reg_base, cw_offset,
+ read_size,
+ is_last_read_loc);
}
/* helper to configure address register values */
@@ -1918,7 +1918,7 @@ static int qcom_param_page_type_exec(struct nand_chip *chip, const struct nand_
if (nandc->props->qpic_version2)
nandc_set_read_loc_last(chip, reg_base, 0, len, 1);
else
- nandc_set_read_loc_first(chip, reg_base, 0, len, 1);
+ qcom_nandc_set_read_loc_first(nandc, reg_base, 0, len, 1);
if (!nandc->props->has_onfi_read_op) {
qcom_write_reg_dma(nandc, &nandc->regs->vld, NAND_DEV_CMD_VLD, 1, 0);
--
2.55.0
^ permalink raw reply [flat|nested] 16+ messages in thread* Re: [PATCH 5/8] mtd: rawnand: qcom: make nandc_set_read_loc_first() more generic
2026-09-24 20:04 ` [PATCH 5/8] mtd: rawnand: qcom: make nandc_set_read_loc_first() " Gabor Juhos
@ 2026-09-24 20:10 ` sashiko-bot
0 siblings, 0 replies; 16+ messages in thread
From: sashiko-bot @ 2026-09-24 20:10 UTC (permalink / raw)
To: Manivannan Sadhasivam, Gabor Juhos, Vignesh Raghavendra,
Miquel Raynal, Richard Weinberger
Cc: Md Sadre Alam, linux-mtd, linux-arm-msm, linux-kernel
Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:
- [Medium] mtd: rawnand: commit message and code mismatch on function prefix
--
commit 443343cbb11c6cfd82ac881ace012fb8d533a7a8
Author: Gabor Juhos <j4g8y7@gmail.com>
mtd: rawnand: qcom: make nandc_set_read_loc_first() more generic
This commit modifies nandc_set_read_loc_first() to take a controller
pointer rather than a chip pointer to make it more generic. It also
intends to rename the function with a new prefix.
> In order to make the function more generic, change the declaration
> to get a 'qcom_nandc_controller' pointer directly, and update the
> callers accordingly. While at it, also change the function name to
> use a 'qpic_nandc' prefix.
> diff --git a/drivers/mtd/nand/raw/qcom_nandc.c b/drivers/mtd/nand/raw/qcom_nandc.c
> index 99fbf54580836..96a1a5a03de87 100644
> --- a/drivers/mtd/nand/raw/qcom_nandc.c
> +++ b/drivers/mtd/nand/raw/qcom_nandc.c
> @@ -150,8 +150,8 @@ static bool qcom_nandc_is_last_cw(struct nand_ecc_ctrl *ecc, int cw)
> }
>
> /**
> - * nandc_set_read_loc_first() - to set read location first register
> - * @chip: NAND Private Flash Chip Data
> + * qcom_nandc_set_read_loc_first() - to set read location first register
> + * @nandc: NAND controller's private data
> * @reg_base: location register base
> * @cw_offset: code word offset
> * @read_size: code word read length
> @@ -159,11 +159,10 @@ static bool qcom_nandc_is_last_cw(struct nand_ecc_ctrl *ecc, int cw)
> *
> * This function will set location register value
> */
> -static void nandc_set_read_loc_first(struct nand_chip *chip,
> - int reg_base, u32 cw_offset,
> - u32 read_size, u32 is_last_read_loc)
> +static void qcom_nandc_set_read_loc_first(struct qcom_nand_controller *nandc,
> + int reg_base, u32 cw_offset,
> + u32 read_size, u32 is_last_read_loc)
[Severity: Medium]
Does this implementation match the intended function name prefix? The commit
message mentions using a 'qpic_nandc' prefix, but it is defined here as
qcom_nandc_set_read_loc_first.
--
Sashiko AI review · https://sashiko.dev/#/patchset/20260924-qcom_nandc-share-more-code-v1-0-f3012199b161@gmail.com?part=5
^ permalink raw reply [flat|nested] 16+ messages in thread
* [PATCH 6/8] mtd: rawnand: qcom: make nandc_set_read_loc_last() more generic
2026-09-24 20:04 [PATCH 0/8] mtd: rawnand: qcom: share more common code Gabor Juhos
` (4 preceding siblings ...)
2026-09-24 20:04 ` [PATCH 5/8] mtd: rawnand: qcom: make nandc_set_read_loc_first() " Gabor Juhos
@ 2026-09-24 20:04 ` Gabor Juhos
2026-09-24 20:09 ` sashiko-bot
2026-09-24 20:04 ` [PATCH 7/8] mtd: rawnand: qcom: rename 'nand_stats' structure Gabor Juhos
2026-09-24 20:04 ` [PATCH 8/8] mtd: rawnand: qcom: move common code to the 'qpic_common' module Gabor Juhos
7 siblings, 1 reply; 16+ messages in thread
From: Gabor Juhos @ 2026-09-24 20:04 UTC (permalink / raw)
To: Manivannan Sadhasivam, Miquel Raynal, Richard Weinberger,
Vignesh Raghavendra
Cc: Md Sadre Alam, linux-mtd, linux-arm-msm, linux-kernel, Gabor Juhos
The function gets a 'nand_chip' pointer as a parameter but it is
only used to extract a pointer to the nand controller's private
structure from that.
In order to make the function more generic, change the declaration
to get a 'qcom_nandc_controller' pointer directly, and update the
callers accordingly. While at it, also change the function name to
use a 'qpic_nandc' prefix.
No functional changes intended. This is in preparation of moving
the function into the 'qpic_common' code to allow reusing it from
the 'spi-qpic-snand' driver.
Signed-off-by: Gabor Juhos <j4g8y7@gmail.com>
---
drivers/mtd/nand/raw/qcom_nandc.c | 18 +++++++++---------
1 file changed, 9 insertions(+), 9 deletions(-)
diff --git a/drivers/mtd/nand/raw/qcom_nandc.c b/drivers/mtd/nand/raw/qcom_nandc.c
index 96a1a5a03de8..cc1e64ac4245 100644
--- a/drivers/mtd/nand/raw/qcom_nandc.c
+++ b/drivers/mtd/nand/raw/qcom_nandc.c
@@ -181,8 +181,8 @@ static void qcom_nandc_set_read_loc_first(struct qcom_nand_controller *nandc,
}
/**
- * nandc_set_read_loc_last - to set read location last register
- * @chip: NAND Private Flash Chip Data
+ * qcom_nandc_set_read_loc_last - to set read location last register
+ * @nandc: NAND controller's private data
* @reg_base: location register base
* @cw_offset: code word offset
* @read_size: code word read length
@@ -190,11 +190,10 @@ static void qcom_nandc_set_read_loc_first(struct qcom_nand_controller *nandc,
*
* This function will set location last register value
*/
-static void nandc_set_read_loc_last(struct nand_chip *chip,
- int reg_base, u32 cw_offset,
- u32 read_size, u32 is_last_read_loc)
+static void qcom_nandc_set_read_loc_last(struct qcom_nand_controller *nandc,
+ int reg_base, u32 cw_offset,
+ u32 read_size, u32 is_last_read_loc)
{
- struct qcom_nand_controller *nandc = get_qcom_nand_controller(chip);
__le32 locreg_val;
u32 val = FIELD_PREP(READ_LOCATION_OFFSET_MASK, cw_offset) |
FIELD_PREP(READ_LOCATION_SIZE_MASK, read_size) |
@@ -226,8 +225,9 @@ static void nandc_set_read_loc(struct nand_chip *chip, int cw, int reg,
reg_base += reg * 4;
if (nandc->props->qpic_version2 && qcom_nandc_is_last_cw(ecc, cw))
- return nandc_set_read_loc_last(chip, reg_base, cw_offset,
- read_size, is_last_read_loc);
+ return qcom_nandc_set_read_loc_last(nandc, reg_base, cw_offset,
+ read_size,
+ is_last_read_loc);
else
return qcom_nandc_set_read_loc_first(nandc, reg_base, cw_offset,
read_size,
@@ -1916,7 +1916,7 @@ static int qcom_param_page_type_exec(struct nand_chip *chip, const struct nand_
len = nand_subop_get_data_len(subop, op_id);
if (nandc->props->qpic_version2)
- nandc_set_read_loc_last(chip, reg_base, 0, len, 1);
+ qcom_nandc_set_read_loc_last(nandc, reg_base, 0, len, 1);
else
qcom_nandc_set_read_loc_first(nandc, reg_base, 0, len, 1);
--
2.55.0
^ permalink raw reply [flat|nested] 16+ messages in thread* Re: [PATCH 6/8] mtd: rawnand: qcom: make nandc_set_read_loc_last() more generic
2026-09-24 20:04 ` [PATCH 6/8] mtd: rawnand: qcom: make nandc_set_read_loc_last() " Gabor Juhos
@ 2026-09-24 20:09 ` sashiko-bot
0 siblings, 0 replies; 16+ messages in thread
From: sashiko-bot @ 2026-09-24 20:09 UTC (permalink / raw)
To: Manivannan Sadhasivam, Gabor Juhos, Miquel Raynal,
Richard Weinberger, Vignesh Raghavendra
Cc: linux-arm-msm, linux-kernel, Md Sadre Alam, linux-mtd
Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:
- [Medium] mtd: commit message incorrectly claims 'qpic_nandc' prefix is used
--
commit 640e8b0121507d995cca38494c17f8a44fcdb750
Author: Gabor Juhos <j4g8y7@gmail.com>
mtd: rawnand: qcom: make nandc_set_read_loc_last() more generic
This commit modifies nandc_set_read_loc_last() to take a qcom_nand_controller
pointer directly instead of a nand_chip pointer, aiming to make it more
generic. It also renames the function as part of a preparation to move it
into common code.
> In order to make the function more generic, change the declaration
> to get a 'qcom_nandc_controller' pointer directly, and update the
> callers accordingly. While at it, also change the function name to
> use a 'qpic_nandc' prefix.
[Severity: Medium]
Does the commit message accurately reflect the new function name? The message
states the function is renamed using a 'qpic_nandc' prefix, but looking at
the changes to drivers/mtd/nand/raw/qcom_nandc.c, the function is actually
renamed to use a 'qcom_nandc' prefix:
> --- a/drivers/mtd/nand/raw/qcom_nandc.c
> +++ b/drivers/mtd/nand/raw/qcom_nandc.c
[ ... ]
> -static void nandc_set_read_loc_last(struct nand_chip *chip,
> - int reg_base, u32 cw_offset,
> - u32 read_size, u32 is_last_read_loc)
> +static void qcom_nandc_set_read_loc_last(struct qcom_nand_controller *nandc,
> + int reg_base, u32 cw_offset,
> + u32 read_size, u32 is_last_read_loc)
Should the commit message be updated to mention 'qcom_nandc' instead, or was
the function intended to be named qpic_nandc_set_read_loc_last()?
--
Sashiko AI review · https://sashiko.dev/#/patchset/20260924-qcom_nandc-share-more-code-v1-0-f3012199b161@gmail.com?part=6
^ permalink raw reply [flat|nested] 16+ messages in thread
* [PATCH 7/8] mtd: rawnand: qcom: rename 'nand_stats' structure
2026-09-24 20:04 [PATCH 0/8] mtd: rawnand: qcom: share more common code Gabor Juhos
` (5 preceding siblings ...)
2026-09-24 20:04 ` [PATCH 6/8] mtd: rawnand: qcom: make nandc_set_read_loc_last() " Gabor Juhos
@ 2026-09-24 20:04 ` Gabor Juhos
2026-09-24 20:04 ` [PATCH 8/8] mtd: rawnand: qcom: move common code to the 'qpic_common' module Gabor Juhos
7 siblings, 0 replies; 16+ messages in thread
From: Gabor Juhos @ 2026-09-24 20:04 UTC (permalink / raw)
To: Manivannan Sadhasivam, Miquel Raynal, Richard Weinberger,
Vignesh Raghavendra
Cc: Md Sadre Alam, linux-mtd, linux-arm-msm, linux-kernel, Gabor Juhos
Give 'read_stats' structure a 'qcom_nandc' prefix to indicate that
it corresponds to the Qualcomm NAND driver. The definition is going
to be moved into a common header this helps to avoid global namespace
pollution/collision.
No functional changes. This is in preparation of moving the declaration
into the 'nand-qpic-common.h' header to allow reusing it from the
'spi-qpic-snand' driver.
Signed-off-by: Gabor Juhos <j4g8y7@gmail.com>
---
drivers/mtd/nand/raw/qcom_nandc.c | 6 +++---
1 file changed, 3 insertions(+), 3 deletions(-)
diff --git a/drivers/mtd/nand/raw/qcom_nandc.c b/drivers/mtd/nand/raw/qcom_nandc.c
index cc1e64ac4245..99fe2c434ce7 100644
--- a/drivers/mtd/nand/raw/qcom_nandc.c
+++ b/drivers/mtd/nand/raw/qcom_nandc.c
@@ -438,7 +438,7 @@ static bool erased_chunk_check_and_fixup(u8 *data_buf, int data_len)
return true;
}
-struct read_stats {
+struct qcom_nandc_read_stats {
__le32 flash;
__le32 buffer;
__le32 erased_cw;
@@ -619,12 +619,12 @@ static int parse_read_errors(struct qcom_nand_host *host, u8 *data_buf,
struct mtd_info *mtd = nand_to_mtd(chip);
struct nand_ecc_ctrl *ecc = &chip->ecc;
unsigned int max_bitflips = 0, uncorrectable_cws = 0;
- struct read_stats *buf;
+ struct qcom_nandc_read_stats *buf;
bool flash_op_err = false, erased;
int i;
u8 *data_buf_start = data_buf, *oob_buf_start = oob_buf;
- buf = (struct read_stats *)nandc->reg_read_buf;
+ buf = (struct qcom_nandc_read_stats *)nandc->reg_read_buf;
qcom_nandc_dev_to_mem(nandc, true);
for (i = 0; i < ecc->steps; i++, buf++) {
--
2.55.0
^ permalink raw reply [flat|nested] 16+ messages in thread* [PATCH 8/8] mtd: rawnand: qcom: move common code to the 'qpic_common' module
2026-09-24 20:04 [PATCH 0/8] mtd: rawnand: qcom: share more common code Gabor Juhos
` (6 preceding siblings ...)
2026-09-24 20:04 ` [PATCH 7/8] mtd: rawnand: qcom: rename 'nand_stats' structure Gabor Juhos
@ 2026-09-24 20:04 ` Gabor Juhos
7 siblings, 0 replies; 16+ messages in thread
From: Gabor Juhos @ 2026-09-24 20:04 UTC (permalink / raw)
To: Manivannan Sadhasivam, Miquel Raynal, Richard Weinberger,
Vignesh Raghavendra
Cc: Md Sadre Alam, linux-mtd, linux-arm-msm, linux-kernel, Gabor Juhos
The 'qpic_common' module provides some generic functions which are
usable by both the 'qcom_nandc' and by the 'spi-qpic-snand' driver.
Move more code from the 'qcom_nandc' driver to there in order to
allow using those also from the 'spi-qpic-snand' driver.
No functional changes.
Signed-off-by: Gabor Juhos <j4g8y7@gmail.com>
---
drivers/mtd/nand/qpic_common.c | 131 +++++++++++++++++++++++++++++++++++
drivers/mtd/nand/raw/qcom_nandc.c | 131 -----------------------------------
include/linux/mtd/nand-qpic-common.h | 17 +++++
3 files changed, 148 insertions(+), 131 deletions(-)
diff --git a/drivers/mtd/nand/qpic_common.c b/drivers/mtd/nand/qpic_common.c
index 4f3e4dd766da..91ae970734f8 100644
--- a/drivers/mtd/nand/qpic_common.c
+++ b/drivers/mtd/nand/qpic_common.c
@@ -775,5 +775,136 @@ int qcom_nandc_alloc(struct qcom_nand_controller *nandc)
}
EXPORT_SYMBOL(qcom_nandc_alloc);
+/* reads back FLASH_STATUS register set by the controller */
+int qcom_nandc_check_flash_errors(struct qcom_nand_controller *nandc,
+ int cw_cnt)
+{
+ int i;
+
+ qcom_nandc_dev_to_mem(nandc, true);
+
+ for (i = 0; i < cw_cnt; i++) {
+ u32 flash = le32_to_cpu(nandc->reg_read_buf[i]);
+
+ if (flash & (FS_OP_ERR | FS_MPU_ERR))
+ return -EIO;
+ }
+
+ return 0;
+}
+EXPORT_SYMBOL(qcom_nandc_check_flash_errors);
+
+/*
+ * Helper to prepare DMA descriptors for configuring registers
+ * before reading a NAND page.
+ */
+void qcom_nandc_config_page_read(struct qcom_nand_controller *nandc)
+{
+ qcom_write_reg_dma(nandc, &nandc->regs->addr0, NAND_ADDR0, 2, 0);
+ qcom_write_reg_dma(nandc, &nandc->regs->cfg0, NAND_DEV0_CFG0, 3, 0);
+ if (!nandc->props->qpic_version2)
+ qcom_write_reg_dma(nandc, &nandc->regs->ecc_buf_cfg, NAND_EBI2_ECC_BUF_CFG, 1, 0);
+ qcom_write_reg_dma(nandc, &nandc->regs->erased_cw_detect_cfg_clr,
+ NAND_ERASED_CW_DETECT_CFG, 1, 0);
+ qcom_write_reg_dma(nandc, &nandc->regs->erased_cw_detect_cfg_set,
+ NAND_ERASED_CW_DETECT_CFG, 1, NAND_ERASED_CW_SET | NAND_BAM_NEXT_SGL);
+}
+EXPORT_SYMBOL(qcom_nandc_config_page_read);
+
+/*
+ * Helper to prepare DMA descriptors used to configure registers needed for
+ * before writing a NAND page.
+ */
+void qcom_nandc_config_page_write(struct qcom_nand_controller *nandc)
+{
+ qcom_write_reg_dma(nandc, &nandc->regs->addr0, NAND_ADDR0, 2, 0);
+ qcom_write_reg_dma(nandc, &nandc->regs->cfg0, NAND_DEV0_CFG0, 3, 0);
+ if (!nandc->props->qpic_version2)
+ qcom_write_reg_dma(nandc, &nandc->regs->ecc_buf_cfg, NAND_EBI2_ECC_BUF_CFG, 1,
+ NAND_BAM_NEXT_SGL);
+}
+EXPORT_SYMBOL(qcom_nandc_config_page_write);
+
+/*
+ * Helper to prepare DMA descriptors for configuring registers
+ * before writing each codeword in NAND page.
+ */
+void qcom_nandc_config_cw_write(struct qcom_nand_controller *nandc)
+{
+ qcom_write_reg_dma(nandc, &nandc->regs->cmd, NAND_FLASH_CMD, 1, NAND_BAM_NEXT_SGL);
+ qcom_write_reg_dma(nandc, &nandc->regs->exec, NAND_EXEC_CMD, 1, NAND_BAM_NEXT_SGL);
+
+ qcom_read_reg_dma(nandc, NAND_FLASH_STATUS, 1, NAND_BAM_NEXT_SGL);
+
+ qcom_write_reg_dma(nandc, &nandc->regs->clrflashstatus, NAND_FLASH_STATUS, 1, 0);
+ qcom_write_reg_dma(nandc, &nandc->regs->clrreadstatus, NAND_READ_STATUS, 1,
+ NAND_BAM_NEXT_SGL);
+}
+EXPORT_SYMBOL(qcom_nandc_config_cw_write);
+
+/**
+ * qcom_nandc_set_read_loc_first() - to set read location first register
+ * @nandc: NAND controller's private data
+ * @reg_base: location register base
+ * @cw_offset: code word offset
+ * @read_size: code word read length
+ * @is_last_read_loc: is this the last read location
+ *
+ * This function will set location register value
+ */
+void qcom_nandc_set_read_loc_first(struct qcom_nand_controller *nandc,
+ int reg_base, u32 cw_offset,
+ u32 read_size, u32 is_last_read_loc)
+{
+ __le32 locreg_val;
+ u32 val = FIELD_PREP(READ_LOCATION_OFFSET_MASK, cw_offset) |
+ FIELD_PREP(READ_LOCATION_SIZE_MASK, read_size) |
+ FIELD_PREP(READ_LOCATION_LAST_MASK, is_last_read_loc);
+
+ locreg_val = cpu_to_le32(val);
+
+ if (reg_base == NAND_READ_LOCATION_0)
+ nandc->regs->read_location0 = locreg_val;
+ else if (reg_base == NAND_READ_LOCATION_1)
+ nandc->regs->read_location1 = locreg_val;
+ else if (reg_base == NAND_READ_LOCATION_2)
+ nandc->regs->read_location2 = locreg_val;
+ else if (reg_base == NAND_READ_LOCATION_3)
+ nandc->regs->read_location3 = locreg_val;
+}
+EXPORT_SYMBOL(qcom_nandc_set_read_loc_first);
+
+/**
+ * qcom_nandc_set_read_loc_last - to set read location last register
+ * @nandc: NAND controller's private data
+ * @reg_base: location register base
+ * @cw_offset: code word offset
+ * @read_size: code word read length
+ * @is_last_read_loc: is this the last read location
+ *
+ * This function will set location last register value
+ */
+void qcom_nandc_set_read_loc_last(struct qcom_nand_controller *nandc,
+ int reg_base, u32 cw_offset,
+ u32 read_size, u32 is_last_read_loc)
+{
+ __le32 locreg_val;
+ u32 val = FIELD_PREP(READ_LOCATION_OFFSET_MASK, cw_offset) |
+ FIELD_PREP(READ_LOCATION_SIZE_MASK, read_size) |
+ FIELD_PREP(READ_LOCATION_LAST_MASK, is_last_read_loc);
+
+ locreg_val = cpu_to_le32(val);
+
+ if (reg_base == NAND_READ_LOCATION_LAST_CW_0)
+ nandc->regs->read_location_last0 = locreg_val;
+ else if (reg_base == NAND_READ_LOCATION_LAST_CW_1)
+ nandc->regs->read_location_last1 = locreg_val;
+ else if (reg_base == NAND_READ_LOCATION_LAST_CW_2)
+ nandc->regs->read_location_last2 = locreg_val;
+ else if (reg_base == NAND_READ_LOCATION_LAST_CW_3)
+ nandc->regs->read_location_last3 = locreg_val;
+}
+EXPORT_SYMBOL(qcom_nandc_set_read_loc_last);
+
MODULE_DESCRIPTION("QPIC controller common api");
MODULE_LICENSE("GPL");
diff --git a/drivers/mtd/nand/raw/qcom_nandc.c b/drivers/mtd/nand/raw/qcom_nandc.c
index 99fe2c434ce7..d65c0101f471 100644
--- a/drivers/mtd/nand/raw/qcom_nandc.c
+++ b/drivers/mtd/nand/raw/qcom_nandc.c
@@ -149,68 +149,6 @@ static bool qcom_nandc_is_last_cw(struct nand_ecc_ctrl *ecc, int cw)
return cw == (ecc->steps - 1);
}
-/**
- * qcom_nandc_set_read_loc_first() - to set read location first register
- * @nandc: NAND controller's private data
- * @reg_base: location register base
- * @cw_offset: code word offset
- * @read_size: code word read length
- * @is_last_read_loc: is this the last read location
- *
- * This function will set location register value
- */
-static void qcom_nandc_set_read_loc_first(struct qcom_nand_controller *nandc,
- int reg_base, u32 cw_offset,
- u32 read_size, u32 is_last_read_loc)
-{
- __le32 locreg_val;
- u32 val = FIELD_PREP(READ_LOCATION_OFFSET_MASK, cw_offset) |
- FIELD_PREP(READ_LOCATION_SIZE_MASK, read_size) |
- FIELD_PREP(READ_LOCATION_LAST_MASK, is_last_read_loc);
-
- locreg_val = cpu_to_le32(val);
-
- if (reg_base == NAND_READ_LOCATION_0)
- nandc->regs->read_location0 = locreg_val;
- else if (reg_base == NAND_READ_LOCATION_1)
- nandc->regs->read_location1 = locreg_val;
- else if (reg_base == NAND_READ_LOCATION_2)
- nandc->regs->read_location2 = locreg_val;
- else if (reg_base == NAND_READ_LOCATION_3)
- nandc->regs->read_location3 = locreg_val;
-}
-
-/**
- * qcom_nandc_set_read_loc_last - to set read location last register
- * @nandc: NAND controller's private data
- * @reg_base: location register base
- * @cw_offset: code word offset
- * @read_size: code word read length
- * @is_last_read_loc: is this the last read location
- *
- * This function will set location last register value
- */
-static void qcom_nandc_set_read_loc_last(struct qcom_nand_controller *nandc,
- int reg_base, u32 cw_offset,
- u32 read_size, u32 is_last_read_loc)
-{
- __le32 locreg_val;
- u32 val = FIELD_PREP(READ_LOCATION_OFFSET_MASK, cw_offset) |
- FIELD_PREP(READ_LOCATION_SIZE_MASK, read_size) |
- FIELD_PREP(READ_LOCATION_LAST_MASK, is_last_read_loc);
-
- locreg_val = cpu_to_le32(val);
-
- if (reg_base == NAND_READ_LOCATION_LAST_CW_0)
- nandc->regs->read_location_last0 = locreg_val;
- else if (reg_base == NAND_READ_LOCATION_LAST_CW_1)
- nandc->regs->read_location_last1 = locreg_val;
- else if (reg_base == NAND_READ_LOCATION_LAST_CW_2)
- nandc->regs->read_location_last2 = locreg_val;
- else if (reg_base == NAND_READ_LOCATION_LAST_CW_3)
- nandc->regs->read_location_last3 = locreg_val;
-}
-
/* helper to configure location register values */
static void nandc_set_read_loc(struct nand_chip *chip, int cw, int reg,
u32 cw_offset, u32 read_size, u32 is_last_read_loc)
@@ -301,22 +239,6 @@ static void update_rw_regs(struct qcom_nand_host *host, int num_cw, bool read, i
host->cw_data : host->cw_size, 1);
}
-/*
- * Helper to prepare DMA descriptors for configuring registers
- * before reading a NAND page.
- */
-static void qcom_nandc_config_page_read(struct qcom_nand_controller *nandc)
-{
- qcom_write_reg_dma(nandc, &nandc->regs->addr0, NAND_ADDR0, 2, 0);
- qcom_write_reg_dma(nandc, &nandc->regs->cfg0, NAND_DEV0_CFG0, 3, 0);
- if (!nandc->props->qpic_version2)
- qcom_write_reg_dma(nandc, &nandc->regs->ecc_buf_cfg, NAND_EBI2_ECC_BUF_CFG, 1, 0);
- qcom_write_reg_dma(nandc, &nandc->regs->erased_cw_detect_cfg_clr,
- NAND_ERASED_CW_DETECT_CFG, 1, 0);
- qcom_write_reg_dma(nandc, &nandc->regs->erased_cw_detect_cfg_set,
- NAND_ERASED_CW_DETECT_CFG, 1, NAND_ERASED_CW_SET | NAND_BAM_NEXT_SGL);
-}
-
/*
* Helper to prepare DMA descriptors for configuring registers
* before reading each codeword in NAND page.
@@ -361,35 +283,6 @@ config_nand_single_cw_page_read(struct nand_chip *chip,
config_nand_cw_read(chip, use_ecc, cw);
}
-/*
- * Helper to prepare DMA descriptors used to configure registers needed for
- * before writing a NAND page.
- */
-static void qcom_nandc_config_page_write(struct qcom_nand_controller *nandc)
-{
- qcom_write_reg_dma(nandc, &nandc->regs->addr0, NAND_ADDR0, 2, 0);
- qcom_write_reg_dma(nandc, &nandc->regs->cfg0, NAND_DEV0_CFG0, 3, 0);
- if (!nandc->props->qpic_version2)
- qcom_write_reg_dma(nandc, &nandc->regs->ecc_buf_cfg, NAND_EBI2_ECC_BUF_CFG, 1,
- NAND_BAM_NEXT_SGL);
-}
-
-/*
- * Helper to prepare DMA descriptors for configuring registers
- * before writing each codeword in NAND page.
- */
-static void qcom_nandc_config_cw_write(struct qcom_nand_controller *nandc)
-{
- qcom_write_reg_dma(nandc, &nandc->regs->cmd, NAND_FLASH_CMD, 1, NAND_BAM_NEXT_SGL);
- qcom_write_reg_dma(nandc, &nandc->regs->exec, NAND_EXEC_CMD, 1, NAND_BAM_NEXT_SGL);
-
- qcom_read_reg_dma(nandc, NAND_FLASH_STATUS, 1, NAND_BAM_NEXT_SGL);
-
- qcom_write_reg_dma(nandc, &nandc->regs->clrflashstatus, NAND_FLASH_STATUS, 1, 0);
- qcom_write_reg_dma(nandc, &nandc->regs->clrreadstatus, NAND_READ_STATUS, 1,
- NAND_BAM_NEXT_SGL);
-}
-
/*
* when using BCH ECC, the HW flags an error in NAND_FLASH_STATUS if it read
* an erased CW, and reports an erased CW in NAND_ERASED_CW_DETECT_STATUS.
@@ -438,30 +331,6 @@ static bool erased_chunk_check_and_fixup(u8 *data_buf, int data_len)
return true;
}
-struct qcom_nandc_read_stats {
- __le32 flash;
- __le32 buffer;
- __le32 erased_cw;
-};
-
-/* reads back FLASH_STATUS register set by the controller */
-static int qcom_nandc_check_flash_errors(struct qcom_nand_controller *nandc,
- int cw_cnt)
-{
- int i;
-
- qcom_nandc_dev_to_mem(nandc, true);
-
- for (i = 0; i < cw_cnt; i++) {
- u32 flash = le32_to_cpu(nandc->reg_read_buf[i]);
-
- if (flash & (FS_OP_ERR | FS_MPU_ERR))
- return -EIO;
- }
-
- return 0;
-}
-
/* performs raw read for one codeword */
static int
qcom_nandc_read_cw_raw(struct mtd_info *mtd, struct nand_chip *chip,
diff --git a/include/linux/mtd/nand-qpic-common.h b/include/linux/mtd/nand-qpic-common.h
index 437448995187..87bf9f67b267 100644
--- a/include/linux/mtd/nand-qpic-common.h
+++ b/include/linux/mtd/nand-qpic-common.h
@@ -458,6 +458,12 @@ struct qcom_nandc_props {
bool use_codeword_fixup;
};
+struct qcom_nandc_read_stats {
+ __le32 flash;
+ __le32 buffer;
+ __le32 erased_cw;
+};
+
void qcom_free_bam_transaction(struct qcom_nand_controller *nandc);
struct bam_transaction *qcom_alloc_bam_transaction(struct qcom_nand_controller *nandc);
void qcom_clear_bam_transaction(struct qcom_nand_controller *nandc);
@@ -483,5 +489,16 @@ int qcom_submit_descs(struct qcom_nand_controller *nandc);
void qcom_clear_read_regs(struct qcom_nand_controller *nandc);
void qcom_nandc_unalloc(struct qcom_nand_controller *nandc);
int qcom_nandc_alloc(struct qcom_nand_controller *nandc);
+int qcom_nandc_check_flash_errors(struct qcom_nand_controller *nandc,
+ int cw_cnt);
+void qcom_nandc_config_page_read(struct qcom_nand_controller *nandc);
+void qcom_nandc_config_page_write(struct qcom_nand_controller *nandc);
+void qcom_nandc_config_cw_write(struct qcom_nand_controller *nandc);
+void qcom_nandc_set_read_loc_first(struct qcom_nand_controller *nandc,
+ int reg_base, u32 cw_offset,
+ u32 read_size, u32 is_last_read_loc);
+void qcom_nandc_set_read_loc_last(struct qcom_nand_controller *nandc,
+ int reg_base, u32 cw_offset,
+ u32 read_size, u32 is_last_read_loc);
#endif
--
2.55.0
^ permalink raw reply [flat|nested] 16+ messages in thread