From: Manuel Dipolt <mdipolt@robart.cc>
To: miquel raynal <miquel.raynal@bootlin.com>
Cc: Roland Ruckerbauer <rruckerbauer@robart.cc>,
linux-mtd <linux-mtd@lists.infradead.org>,
maxime <maxime@cerno.tech>, bbrezillon <bbrezillon@kernel.org>
Subject: Re: [PATCH v2] mtd: sunxi-nand: add dma support for allwinner h3 - corrected obvious style issues
Date: Mon, 5 Oct 2020 16:56:51 +0200 (CEST) [thread overview]
Message-ID: <1455289470.532044.1601909811425.JavaMail.zimbra@robart.cc> (raw)
In-Reply-To: <20201005143423.5a9dd1ee@xps13>
hi Miquèl,
sorry for the style issues, patched now
yours,
Manuel
Signed-off-by: Manuel Dipolt <manuel.dipolt@robart.cc>
---
drivers/mtd/nand/raw/sunxi_nand.c | 73 ++++++++++++++++---------------
1 file changed, 37 insertions(+), 36 deletions(-)
diff --git a/drivers/mtd/nand/raw/sunxi_nand.c b/drivers/mtd/nand/raw/sunxi_nand.c
index 33f910599275..28dc5ed36290 100644
--- a/drivers/mtd/nand/raw/sunxi_nand.c
+++ b/drivers/mtd/nand/raw/sunxi_nand.c
@@ -61,7 +61,7 @@
#define NFC_RESET BIT(1)
#define NFC_BUS_WIDTH_MSK BIT(2)
#define NFC_BUS_WIDTH_8 (0 << 2)
-#define NFC_BUS_WIDTH_16 (1 << 2)
+#define NFC_BUS_WIDTH_16 BIT(2)
#define NFC_RB_SEL_MSK BIT(3)
#define NFC_RB_SEL(x) ((x) << 3)
#define NFC_CE_SEL_MSK GENMASK(26, 24)
@@ -119,7 +119,7 @@
#define NFC_SEND_CMD4 BIT(29)
#define NFC_CMD_TYPE_MSK GENMASK(31, 30)
#define NFC_NORMAL_OP (0 << 30)
-#define NFC_ECC_OP (1 << 30)
+#define NFC_ECC_OP BIT(30)
#define NFC_PAGE_OP (2U << 30)
/* define bit use in NFC_RCMD_SET */
@@ -266,11 +266,11 @@ static irqreturn_t sunxi_nfc_interrupt(int irq, void *dev_id)
if (!(ien & st))
return IRQ_NONE;
- if ((ien & st) == NFC_CMD_INT_ENABLE)
+ if ((ien & st) == NFC_CMD_INT_ENABLE)
complete(&nfc->complete);
if ((ien & st) == NFC_DMA_INT_ENABLE)
- complete(&nfc->complete);
+ complete(&nfc->complete);
writel(st & NFC_INT_MASK, nfc->regs + NFC_REG_ST);
writel(~st & ien & NFC_INT_MASK, nfc->regs + NFC_REG_INT);
@@ -295,7 +295,7 @@ static int sunxi_nfc_wait_events(struct sunxi_nfc *nfc, u32 events,
writel(events, nfc->regs + NFC_REG_INT);
ret = wait_for_completion_timeout(&nfc->complete,
- msecs_to_jiffies(timeout_ms));
+ msecs_to_jiffies(timeout_ms));
if (!ret)
ret = -ETIMEDOUT;
else
@@ -662,7 +662,7 @@ static void sunxi_nfc_randomize_bbm(struct nand_chip *nand, int page, u8 *bbm)
}
static void sunxi_nfc_randomizer_write_buf(struct nand_chip *nand,
- const uint8_t *buf, int len,
+ const u8 *buf, int len,
bool ecc, int page)
{
sunxi_nfc_randomizer_config(nand, page, ecc);
@@ -920,22 +920,23 @@ static int sunxi_nfc_hw_ecc_read_chunks_dma(struct nand_chip *nand, uint8_t *buf
u32 status;
int chunksize;
__u32 mem_addr;
-
+
ret = sunxi_nfc_wait_cmd_fifo_empty(nfc);
if (ret)
return ret;
if (nfc->caps->dma_mode == 1) {
ret = sunxi_nfc_dma_op_prepare(nfc, buf, ecc->size, nchunks,
- DMA_FROM_DEVICE, &sg);
+ DMA_FROM_DEVICE, &sg);
if (ret)
return ret;
} else {
- chunksize = ecc->size;
- mem_addr = (__u32)dma_map_single(nfc->dev, (void *)buf, nchunks * chunksize, DMA_DEV_TO_MEM);
- if (dma_mapping_error(nfc->dev, mem_addr)) {
+ chunksize = ecc->size;
+ mem_addr = (__u32)dma_map_single(nfc->dev, (void *)buf, nchunks * chunksize,
+ DMA_DEV_TO_MEM);
+
+ if (dma_mapping_error(nfc->dev, mem_addr))
dev_err(nfc->dev, "DMA mapping error\n");
- }
writel(readl(nfc->regs + NFC_REG_CTL) | NFC_RAM_METHOD, nfc->regs + NFC_REG_CTL);
writel(nchunks, nfc->regs + NFC_REG_SECTOR_NUM);
@@ -955,7 +956,7 @@ static int sunxi_nfc_hw_ecc_read_chunks_dma(struct nand_chip *nand, uint8_t *buf
dma_async_issue_pending(nfc->dmac);
writel(NFC_PAGE_OP | NFC_DATA_SWAP_METHOD | NFC_DATA_TRANS,
- nfc->regs + NFC_REG_CMD);
+ nfc->regs + NFC_REG_CMD);
ret = sunxi_nfc_wait_events(nfc, NFC_CMD_INT_FLAG, false, 0);
@@ -963,7 +964,7 @@ static int sunxi_nfc_hw_ecc_read_chunks_dma(struct nand_chip *nand, uint8_t *buf
dmaengine_terminate_all(nfc->dmac);
} else {
writel(NFC_PAGE_OP | NFC_DATA_SWAP_METHOD | NFC_DATA_TRANS,
- nfc->regs + NFC_REG_CMD);
+ nfc->regs + NFC_REG_CMD);
ret = sunxi_nfc_wait_events(nfc, NFC_DMA_INT_FLAG, false, 0);
}
@@ -1163,7 +1164,7 @@ static int sunxi_nfc_hw_ecc_read_page_dma(struct nand_chip *nand, u8 *buf,
int oob_required, int page)
{
int ret;
-
+
sunxi_nfc_select_chip(nand, nand->cur_cs);
nand_read_page_op(nand, page, 0, NULL, 0);
@@ -1234,7 +1235,7 @@ static int sunxi_nfc_hw_ecc_read_subpage_dma(struct nand_chip *nand,
}
static int sunxi_nfc_hw_ecc_write_page(struct nand_chip *nand,
- const uint8_t *buf, int oob_required,
+ const u8 *buf, int oob_required,
int page)
{
struct mtd_info *mtd = nand_to_mtd(nand);
@@ -1313,7 +1314,7 @@ static int sunxi_nfc_hw_ecc_write_page_dma(struct nand_chip *nand,
struct scatterlist sg;
int ret, i, nchunks, chunksize;
__u32 mem_addr;
-
+
sunxi_nfc_select_chip(nand, nand->cur_cs);
ret = sunxi_nfc_wait_cmd_fifo_empty(nfc);
@@ -1322,15 +1323,16 @@ static int sunxi_nfc_hw_ecc_write_page_dma(struct nand_chip *nand,
if (nfc->caps->dma_mode == 1) {
ret = sunxi_nfc_dma_op_prepare(nfc, buf, ecc->size, ecc->steps,
- DMA_TO_DEVICE, &sg);
+ DMA_TO_DEVICE, &sg);
if (ret)
goto pio_fallback;
} else {
chunksize = ecc->size;
nchunks = ecc->steps;
mem_addr = (__u32)dma_map_single(nfc->dev, (void *)buf, nchunks * chunksize, DMA_MEM_TO_DEV);
- if (dma_mapping_error(nfc->dev, mem_addr)) {
- dev_err(nfc->dev, "DMA mapping error\n");
+ if (dma_mapping_error(nfc->dev, mem_addr)) {
+ dev_err(nfc->dev, "DMA mapping error, fallback to pio...\n");
+ goto pio_fallback;
}
writel(readl(nfc->regs + NFC_REG_CTL) | NFC_RAM_METHOD, nfc->regs + NFC_REG_CTL);
@@ -1339,7 +1341,7 @@ static int sunxi_nfc_hw_ecc_write_page_dma(struct nand_chip *nand,
writel(mem_addr, nfc->regs + NFC_REG_MDMA_ADDR);
writel(chunksize, nfc->regs + NFC_REG_CNT);
}
-
+
for (i = 0; i < ecc->steps; i++) {
const u8 *oob = nand->oob_poi + (i * (ecc->bytes + 4));
@@ -1423,7 +1425,7 @@ static const s32 tWB_lut[] = {6, 12, 16, 20};
static const s32 tRHW_lut[] = {4, 8, 12, 20};
static int _sunxi_nand_lookup_timing(const s32 *lut, int lut_size, u32 duration,
- u32 clk_period)
+ u32 clk_period)
{
u32 clk_cycles = DIV_ROUND_UP(duration, clk_period);
int i;
@@ -2013,10 +2015,8 @@ static int sunxi_nand_chip_init(struct device *dev, struct sunxi_nfc *nfc,
sunxi_nand = devm_kzalloc(dev, struct_size(sunxi_nand, sels, nsels),
GFP_KERNEL);
- if (!sunxi_nand) {
- dev_err(dev, "could not allocate chip\n");
+ if (!sunxi_nand)
return -ENOMEM;
- }
sunxi_nand->nsels = nsels;
@@ -2196,9 +2196,10 @@ static int sunxi_nfc_probe(struct platform_device *pdev)
if (ret)
goto out_ahb_reset_reassert;
- if(nfc->caps->dma_mode == 0) {
- writel(readl(nfc->regs + NFC_REG_CTL) & ~NFC_DMA_TYPE_NORMAL, nfc->regs + NFC_REG_CTL);
- nfc->dmac = NULL;
+ if (nfc->caps->dma_mode == 0) {
+ writel(readl(nfc->regs + NFC_REG_CTL) & ~NFC_DMA_TYPE_NORMAL,
+ nfc->regs + NFC_REG_CTL);
+ nfc->dmac = NULL;
} else {
nfc->dmac = dma_request_chan(dev, "rxtx");
if (IS_ERR(nfc->dmac)) {
@@ -2225,14 +2226,14 @@ static int sunxi_nfc_probe(struct platform_device *pdev)
NFC_DMA_TYPE_NORMAL, nfc->regs + NFC_REG_CTL);
}
}
-
- platform_set_drvdata(pdev, nfc);
-
- ret = sunxi_nand_chips_init(dev, nfc);
- if (ret) {
- dev_err(dev, "failed to init nand chips\n");
- goto out_release_dmac;
- }
+
+ platform_set_drvdata(pdev, nfc);
+
+ ret = sunxi_nand_chips_init(dev, nfc);
+ if (ret) {
+ dev_err(dev, "failed to init nand chips\n");
+ goto out_release_dmac;
+ }
return 0;
--
2.20.1
______________________________________________________
Linux MTD discussion mailing list
http://lists.infradead.org/mailman/listinfo/linux-mtd/
next prev parent reply other threads:[~2020-10-05 14:58 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-10-05 12:20 [PATCH -next] mtd: sunxi-nand: add dma support for allwinner h3 Manuel Dipolt
2020-10-05 12:34 ` Miquel Raynal
2020-10-05 14:56 ` Manuel Dipolt [this message]
2020-10-05 13:09 ` Boris Brezillon
2020-10-06 17:20 ` [PATCH v3] mtd: sunxi-nand: add dma support for allwinner h3 - review changes Manuel Dipolt
2020-10-07 13:02 ` Boris Brezillon
2020-10-07 14:21 ` Manuel Dipolt
2020-10-08 14:31 ` Fwd: " Manuel Dipolt
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1455289470.532044.1601909811425.JavaMail.zimbra@robart.cc \
--to=mdipolt@robart.cc \
--cc=bbrezillon@kernel.org \
--cc=linux-mtd@lists.infradead.org \
--cc=maxime@cerno.tech \
--cc=miquel.raynal@bootlin.com \
--cc=rruckerbauer@robart.cc \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.