Commit faee6c35 authored by Boris BREZILLON's avatar Boris BREZILLON Committed by Brian Norris

mtd: nand: nuc900: create and use mtd_to_nuc900()

Create and use mtd_to_nuc900() instead of direct container_of() calls.
Signed-off-by: default avatarBoris Brezillon <boris.brezillon@free-electrons.com>
Signed-off-by: default avatarBrian Norris <computersforpeace@gmail.com>
parent 277af429
...@@ -62,6 +62,11 @@ struct nuc900_nand { ...@@ -62,6 +62,11 @@ struct nuc900_nand {
spinlock_t lock; spinlock_t lock;
}; };
static inline struct nuc900_nand *mtd_to_nuc900(struct mtd_info *mtd)
{
return container_of(mtd, struct nuc900_nand, mtd);
}
static const struct mtd_partition partitions[] = { static const struct mtd_partition partitions[] = {
{ {
.name = "NAND FS 0", .name = "NAND FS 0",
...@@ -78,9 +83,7 @@ static const struct mtd_partition partitions[] = { ...@@ -78,9 +83,7 @@ static const struct mtd_partition partitions[] = {
static unsigned char nuc900_nand_read_byte(struct mtd_info *mtd) static unsigned char nuc900_nand_read_byte(struct mtd_info *mtd)
{ {
unsigned char ret; unsigned char ret;
struct nuc900_nand *nand; struct nuc900_nand *nand = mtd_to_nuc900(mtd);
nand = container_of(mtd, struct nuc900_nand, mtd);
ret = (unsigned char)read_data_reg(nand); ret = (unsigned char)read_data_reg(nand);
...@@ -91,9 +94,7 @@ static void nuc900_nand_read_buf(struct mtd_info *mtd, ...@@ -91,9 +94,7 @@ static void nuc900_nand_read_buf(struct mtd_info *mtd,
unsigned char *buf, int len) unsigned char *buf, int len)
{ {
int i; int i;
struct nuc900_nand *nand; struct nuc900_nand *nand = mtd_to_nuc900(mtd);
nand = container_of(mtd, struct nuc900_nand, mtd);
for (i = 0; i < len; i++) for (i = 0; i < len; i++)
buf[i] = (unsigned char)read_data_reg(nand); buf[i] = (unsigned char)read_data_reg(nand);
...@@ -103,9 +104,7 @@ static void nuc900_nand_write_buf(struct mtd_info *mtd, ...@@ -103,9 +104,7 @@ static void nuc900_nand_write_buf(struct mtd_info *mtd,
const unsigned char *buf, int len) const unsigned char *buf, int len)
{ {
int i; int i;
struct nuc900_nand *nand; struct nuc900_nand *nand = mtd_to_nuc900(mtd);
nand = container_of(mtd, struct nuc900_nand, mtd);
for (i = 0; i < len; i++) for (i = 0; i < len; i++)
write_data_reg(nand, buf[i]); write_data_reg(nand, buf[i]);
...@@ -124,11 +123,9 @@ static int nuc900_check_rb(struct nuc900_nand *nand) ...@@ -124,11 +123,9 @@ static int nuc900_check_rb(struct nuc900_nand *nand)
static int nuc900_nand_devready(struct mtd_info *mtd) static int nuc900_nand_devready(struct mtd_info *mtd)
{ {
struct nuc900_nand *nand; struct nuc900_nand *nand = mtd_to_nuc900(mtd);
int ready; int ready;
nand = container_of(mtd, struct nuc900_nand, mtd);
ready = (nuc900_check_rb(nand)) ? 1 : 0; ready = (nuc900_check_rb(nand)) ? 1 : 0;
return ready; return ready;
} }
...@@ -137,9 +134,7 @@ static void nuc900_nand_command_lp(struct mtd_info *mtd, unsigned int command, ...@@ -137,9 +134,7 @@ static void nuc900_nand_command_lp(struct mtd_info *mtd, unsigned int command,
int column, int page_addr) int column, int page_addr)
{ {
register struct nand_chip *chip = mtd_to_nand(mtd); register struct nand_chip *chip = mtd_to_nand(mtd);
struct nuc900_nand *nand; struct nuc900_nand *nand = mtd_to_nuc900(mtd);
nand = container_of(mtd, struct nuc900_nand, mtd);
if (command == NAND_CMD_READOOB) { if (command == NAND_CMD_READOOB) {
column += mtd->writesize; column += mtd->writesize;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment