* [PATCH] mtd: nand: tango: Use nand_to_mtd() instead of directly accessing chip->mtd
@ 2016-11-21 9:03 ` Boris Brezillon
0 siblings, 0 replies; 6+ messages in thread
From: Boris Brezillon @ 2016-11-21 9:03 UTC (permalink / raw)
To: Boris Brezillon, Richard Weinberger, linux-mtd, Marc Gonzalez
Cc: David Woodhouse, Brian Norris, Marek Vasut, Cyrille Pitchen,
linux-arm-kernel, linux-kernel
The nand_to_mtd() helper is here to hide internal mtd_info <-> nand_chip
association and ease future refactors.
Make use of this helper instead of directly accessing chip->mtd.
Signed-off-by: Boris Brezillon <boris.brezillon@free-electrons.com>
---
drivers/mtd/nand/tango_nand.c | 25 ++++++++++++++++---------
1 file changed, 16 insertions(+), 9 deletions(-)
diff --git a/drivers/mtd/nand/tango_nand.c b/drivers/mtd/nand/tango_nand.c
index 7ed35348993e..ec87516b87f5 100644
--- a/drivers/mtd/nand/tango_nand.c
+++ b/drivers/mtd/nand/tango_nand.c
@@ -171,6 +171,7 @@ static void tango_select_chip(struct mtd_info *mtd, int idx)
*/
static int check_erased_page(struct nand_chip *chip, u8 *buf)
{
+ struct mtd_info *mtd = nand_to_mtd(chip);
u8 *meta = chip->oob_poi + BBM_SIZE;
u8 *ecc = chip->oob_poi + BBM_SIZE + METADATA_SIZE;
const int ecc_size = chip->ecc.bytes;
@@ -183,7 +184,7 @@ static int check_erased_page(struct nand_chip *chip, u8 *buf)
meta, meta_len,
chip->ecc.strength);
if (res < 0)
- chip->mtd.ecc_stats.failed++;
+ mtd->ecc_stats.failed++;
bitflips = max(res, bitflips);
buf += pkt_size;
@@ -300,26 +301,30 @@ static int tango_write_page(struct mtd_info *mtd, struct nand_chip *chip,
static void aux_read(struct nand_chip *chip, u8 **buf, int len, int *pos)
{
+ struct mtd_info *mtd = nand_to_mtd(chip);
+
*pos += len;
if (!*buf) {
/* skip over "len" bytes */
- chip->cmdfunc(&chip->mtd, NAND_CMD_RNDOUT, *pos, -1);
+ chip->cmdfunc(mtd, NAND_CMD_RNDOUT, *pos, -1);
} else {
- tango_read_buf(&chip->mtd, *buf, len);
+ tango_read_buf(mtd, *buf, len);
*buf += len;
}
}
static void aux_write(struct nand_chip *chip, const u8 **buf, int len, int *pos)
{
+ struct mtd_info *mtd = nand_to_mtd(chip);
+
*pos += len;
if (!*buf) {
/* skip over "len" bytes */
- chip->cmdfunc(&chip->mtd, NAND_CMD_SEQIN, *pos, -1);
+ chip->cmdfunc(mtd, NAND_CMD_SEQIN, *pos, -1);
} else {
- tango_write_buf(&chip->mtd, *buf, len);
+ tango_write_buf(mtd, *buf, len);
*buf += len;
}
}
@@ -345,8 +350,9 @@ static void aux_write(struct nand_chip *chip, const u8 **buf, int len, int *pos)
*/
static void raw_read(struct nand_chip *chip, u8 *buf, u8 *oob)
{
+ struct mtd_info *mtd = nand_to_mtd(chip);
u8 *oob_orig = oob;
- const int page_size = chip->mtd.writesize;
+ const int page_size = mtd->writesize;
const int ecc_size = chip->ecc.bytes;
const int pkt_size = chip->ecc.size;
int pos = 0; /* position within physical page */
@@ -371,8 +377,9 @@ static void raw_read(struct nand_chip *chip, u8 *buf, u8 *oob)
static void raw_write(struct nand_chip *chip, const u8 *buf, const u8 *oob)
{
+ struct mtd_info *mtd = nand_to_mtd(chip);
const u8 *oob_orig = oob;
- const int page_size = chip->mtd.writesize;
+ const int page_size = mtd->writesize;
const int ecc_size = chip->ecc.bytes;
const int pkt_size = chip->ecc.size;
int pos = 0; /* position within physical page */
@@ -522,7 +529,7 @@ static int chip_init(struct device *dev, struct device_node *np)
chip = &tchip->nand_chip;
ecc = &chip->ecc;
- mtd = &chip->mtd;
+ mtd = nand_to_mtd(chip);
chip->read_byte = tango_read_byte;
chip->write_buf = tango_write_buf;
@@ -584,7 +591,7 @@ static int tango_nand_remove(struct platform_device *pdev)
for (cs = 0; cs < MAX_CS; ++cs) {
if (nfc->chips[cs])
- nand_release(&nfc->chips[cs]->nand_chip.mtd);
+ nand_release(nand_to_mtd(&nfc->chips[cs]->nand_chip));
}
return 0;
--
2.7.4
^ permalink raw reply related [flat|nested] 6+ messages in thread
* [PATCH] mtd: nand: tango: Use nand_to_mtd() instead of directly accessing chip->mtd
@ 2016-11-21 9:03 ` Boris Brezillon
0 siblings, 0 replies; 6+ messages in thread
From: Boris Brezillon @ 2016-11-21 9:03 UTC (permalink / raw)
To: linux-arm-kernel
The nand_to_mtd() helper is here to hide internal mtd_info <-> nand_chip
association and ease future refactors.
Make use of this helper instead of directly accessing chip->mtd.
Signed-off-by: Boris Brezillon <boris.brezillon@free-electrons.com>
---
drivers/mtd/nand/tango_nand.c | 25 ++++++++++++++++---------
1 file changed, 16 insertions(+), 9 deletions(-)
diff --git a/drivers/mtd/nand/tango_nand.c b/drivers/mtd/nand/tango_nand.c
index 7ed35348993e..ec87516b87f5 100644
--- a/drivers/mtd/nand/tango_nand.c
+++ b/drivers/mtd/nand/tango_nand.c
@@ -171,6 +171,7 @@ static void tango_select_chip(struct mtd_info *mtd, int idx)
*/
static int check_erased_page(struct nand_chip *chip, u8 *buf)
{
+ struct mtd_info *mtd = nand_to_mtd(chip);
u8 *meta = chip->oob_poi + BBM_SIZE;
u8 *ecc = chip->oob_poi + BBM_SIZE + METADATA_SIZE;
const int ecc_size = chip->ecc.bytes;
@@ -183,7 +184,7 @@ static int check_erased_page(struct nand_chip *chip, u8 *buf)
meta, meta_len,
chip->ecc.strength);
if (res < 0)
- chip->mtd.ecc_stats.failed++;
+ mtd->ecc_stats.failed++;
bitflips = max(res, bitflips);
buf += pkt_size;
@@ -300,26 +301,30 @@ static int tango_write_page(struct mtd_info *mtd, struct nand_chip *chip,
static void aux_read(struct nand_chip *chip, u8 **buf, int len, int *pos)
{
+ struct mtd_info *mtd = nand_to_mtd(chip);
+
*pos += len;
if (!*buf) {
/* skip over "len" bytes */
- chip->cmdfunc(&chip->mtd, NAND_CMD_RNDOUT, *pos, -1);
+ chip->cmdfunc(mtd, NAND_CMD_RNDOUT, *pos, -1);
} else {
- tango_read_buf(&chip->mtd, *buf, len);
+ tango_read_buf(mtd, *buf, len);
*buf += len;
}
}
static void aux_write(struct nand_chip *chip, const u8 **buf, int len, int *pos)
{
+ struct mtd_info *mtd = nand_to_mtd(chip);
+
*pos += len;
if (!*buf) {
/* skip over "len" bytes */
- chip->cmdfunc(&chip->mtd, NAND_CMD_SEQIN, *pos, -1);
+ chip->cmdfunc(mtd, NAND_CMD_SEQIN, *pos, -1);
} else {
- tango_write_buf(&chip->mtd, *buf, len);
+ tango_write_buf(mtd, *buf, len);
*buf += len;
}
}
@@ -345,8 +350,9 @@ static void aux_write(struct nand_chip *chip, const u8 **buf, int len, int *pos)
*/
static void raw_read(struct nand_chip *chip, u8 *buf, u8 *oob)
{
+ struct mtd_info *mtd = nand_to_mtd(chip);
u8 *oob_orig = oob;
- const int page_size = chip->mtd.writesize;
+ const int page_size = mtd->writesize;
const int ecc_size = chip->ecc.bytes;
const int pkt_size = chip->ecc.size;
int pos = 0; /* position within physical page */
@@ -371,8 +377,9 @@ static void raw_read(struct nand_chip *chip, u8 *buf, u8 *oob)
static void raw_write(struct nand_chip *chip, const u8 *buf, const u8 *oob)
{
+ struct mtd_info *mtd = nand_to_mtd(chip);
const u8 *oob_orig = oob;
- const int page_size = chip->mtd.writesize;
+ const int page_size = mtd->writesize;
const int ecc_size = chip->ecc.bytes;
const int pkt_size = chip->ecc.size;
int pos = 0; /* position within physical page */
@@ -522,7 +529,7 @@ static int chip_init(struct device *dev, struct device_node *np)
chip = &tchip->nand_chip;
ecc = &chip->ecc;
- mtd = &chip->mtd;
+ mtd = nand_to_mtd(chip);
chip->read_byte = tango_read_byte;
chip->write_buf = tango_write_buf;
@@ -584,7 +591,7 @@ static int tango_nand_remove(struct platform_device *pdev)
for (cs = 0; cs < MAX_CS; ++cs) {
if (nfc->chips[cs])
- nand_release(&nfc->chips[cs]->nand_chip.mtd);
+ nand_release(nand_to_mtd(&nfc->chips[cs]->nand_chip));
}
return 0;
--
2.7.4
^ permalink raw reply related [flat|nested] 6+ messages in thread
* Re: [PATCH] mtd: nand: tango: Use nand_to_mtd() instead of directly accessing chip->mtd
2016-11-21 9:03 ` Boris Brezillon
@ 2016-11-21 9:59 ` Marc Gonzalez
-1 siblings, 0 replies; 6+ messages in thread
From: Marc Gonzalez @ 2016-11-21 9:59 UTC (permalink / raw)
To: Boris Brezillon, Richard Weinberger, linux-mtd
Cc: David Woodhouse, Brian Norris, Marek Vasut, Cyrille Pitchen,
linux-arm-kernel, linux-kernel
On 21/11/2016 10:03, Boris Brezillon wrote:
> The nand_to_mtd() helper is here to hide internal mtd_info <-> nand_chip
> association and ease future refactors.
>
> Make use of this helper instead of directly accessing chip->mtd.
>
> Signed-off-by: Boris Brezillon <boris.brezillon@free-electrons.com>
> ---
> drivers/mtd/nand/tango_nand.c | 25 ++++++++++++++++---------
> 1 file changed, 16 insertions(+), 9 deletions(-)
Acked-by: Marc Gonzalez <marc_gonzalez@sigmadesigns.com>
Regards.
^ permalink raw reply [flat|nested] 6+ messages in thread
* [PATCH] mtd: nand: tango: Use nand_to_mtd() instead of directly accessing chip->mtd
@ 2016-11-21 9:59 ` Marc Gonzalez
0 siblings, 0 replies; 6+ messages in thread
From: Marc Gonzalez @ 2016-11-21 9:59 UTC (permalink / raw)
To: linux-arm-kernel
On 21/11/2016 10:03, Boris Brezillon wrote:
> The nand_to_mtd() helper is here to hide internal mtd_info <-> nand_chip
> association and ease future refactors.
>
> Make use of this helper instead of directly accessing chip->mtd.
>
> Signed-off-by: Boris Brezillon <boris.brezillon@free-electrons.com>
> ---
> drivers/mtd/nand/tango_nand.c | 25 ++++++++++++++++---------
> 1 file changed, 16 insertions(+), 9 deletions(-)
Acked-by: Marc Gonzalez <marc_gonzalez@sigmadesigns.com>
Regards.
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH] mtd: nand: tango: Use nand_to_mtd() instead of directly accessing chip->mtd
2016-11-21 9:59 ` Marc Gonzalez
@ 2016-11-21 11:01 ` Boris Brezillon
-1 siblings, 0 replies; 6+ messages in thread
From: Boris Brezillon @ 2016-11-21 11:01 UTC (permalink / raw)
To: Marc Gonzalez
Cc: Richard Weinberger, linux-mtd, David Woodhouse, Brian Norris,
Marek Vasut, Cyrille Pitchen, linux-arm-kernel, linux-kernel
On Mon, 21 Nov 2016 10:59:21 +0100
Marc Gonzalez <marc_gonzalez@sigmadesigns.com> wrote:
> On 21/11/2016 10:03, Boris Brezillon wrote:
>
> > The nand_to_mtd() helper is here to hide internal mtd_info <-> nand_chip
> > association and ease future refactors.
> >
> > Make use of this helper instead of directly accessing chip->mtd.
> >
> > Signed-off-by: Boris Brezillon <boris.brezillon@free-electrons.com>
> > ---
> > drivers/mtd/nand/tango_nand.c | 25 ++++++++++++++++---------
> > 1 file changed, 16 insertions(+), 9 deletions(-)
>
> Acked-by: Marc Gonzalez <marc_gonzalez@sigmadesigns.com>
Applied.
Thanks,
Boris
>
> Regards.
>
^ permalink raw reply [flat|nested] 6+ messages in thread
* [PATCH] mtd: nand: tango: Use nand_to_mtd() instead of directly accessing chip->mtd
@ 2016-11-21 11:01 ` Boris Brezillon
0 siblings, 0 replies; 6+ messages in thread
From: Boris Brezillon @ 2016-11-21 11:01 UTC (permalink / raw)
To: linux-arm-kernel
On Mon, 21 Nov 2016 10:59:21 +0100
Marc Gonzalez <marc_gonzalez@sigmadesigns.com> wrote:
> On 21/11/2016 10:03, Boris Brezillon wrote:
>
> > The nand_to_mtd() helper is here to hide internal mtd_info <-> nand_chip
> > association and ease future refactors.
> >
> > Make use of this helper instead of directly accessing chip->mtd.
> >
> > Signed-off-by: Boris Brezillon <boris.brezillon@free-electrons.com>
> > ---
> > drivers/mtd/nand/tango_nand.c | 25 ++++++++++++++++---------
> > 1 file changed, 16 insertions(+), 9 deletions(-)
>
> Acked-by: Marc Gonzalez <marc_gonzalez@sigmadesigns.com>
Applied.
Thanks,
Boris
>
> Regards.
>
^ permalink raw reply [flat|nested] 6+ messages in thread
end of thread, other threads:[~2016-11-21 11:02 UTC | newest]
Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2016-11-21 9:03 [PATCH] mtd: nand: tango: Use nand_to_mtd() instead of directly accessing chip->mtd Boris Brezillon
2016-11-21 9:03 ` Boris Brezillon
2016-11-21 9:59 ` Marc Gonzalez
2016-11-21 9:59 ` Marc Gonzalez
2016-11-21 11:01 ` Boris Brezillon
2016-11-21 11:01 ` Boris Brezillon
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.