Skip to content

Commit

Permalink
mtd: rawnand: Pass a nand_chip object to chip->dev_ready()
Browse files Browse the repository at this point in the history
Let's make the raw NAND API consistent by patching all helpers and
hooks to take a nand_chip object instead of an mtd_info one or
remove the mtd_info object when both are passed.

Let's tackle the chip->dev_ready() hook.

Signed-off-by: Boris Brezillon <boris.brezillon@bootlin.com>
Signed-off-by: Miquel Raynal <miquel.raynal@bootlin.com>
  • Loading branch information
Boris Brezillon authored and Miquel Raynal committed Oct 3, 2018
1 parent 0f808c1 commit 50a487e
Show file tree
Hide file tree
Showing 37 changed files with 68 additions and 88 deletions.
2 changes: 1 addition & 1 deletion drivers/mtd/nand/raw/ams-delta.c
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,7 @@ static void ams_delta_hwcontrol(struct nand_chip *this, int cmd,
ams_delta_write_byte(this, cmd);
}

static int ams_delta_nand_ready(struct mtd_info *mtd)
static int ams_delta_nand_ready(struct nand_chip *this)
{
return gpio_get_value(AMS_DELTA_GPIO_PIN_NAND_RB);
}
Expand Down
6 changes: 2 additions & 4 deletions drivers/mtd/nand/raw/atmel/nand-controller.c
Original file line number Diff line number Diff line change
Expand Up @@ -475,9 +475,8 @@ static void atmel_nand_write_buf(struct nand_chip *chip, const u8 *buf, int len)
iowrite8_rep(nand->activecs->io.virt, buf, len);
}

static int atmel_nand_dev_ready(struct mtd_info *mtd)
static int atmel_nand_dev_ready(struct nand_chip *chip)
{
struct nand_chip *chip = mtd_to_nand(mtd);
struct atmel_nand *nand = to_atmel_nand(chip);

return gpiod_get_value(nand->activecs->rb.gpio);
Expand All @@ -499,9 +498,8 @@ static void atmel_nand_select_chip(struct nand_chip *chip, int cs)
chip->dev_ready = atmel_nand_dev_ready;
}

static int atmel_hsmc_nand_dev_ready(struct mtd_info *mtd)
static int atmel_hsmc_nand_dev_ready(struct nand_chip *chip)
{
struct nand_chip *chip = mtd_to_nand(mtd);
struct atmel_nand *nand = to_atmel_nand(chip);
struct atmel_hsmc_nand_controller *nc;
u32 status;
Expand Down
6 changes: 3 additions & 3 deletions drivers/mtd/nand/raw/au1550nd.c
Original file line number Diff line number Diff line change
Expand Up @@ -213,7 +213,7 @@ static void au1550_hwcontrol(struct mtd_info *mtd, int cmd)
wmb(); /* Drain the writebuffer */
}

int au1550_device_ready(struct mtd_info *mtd)
int au1550_device_ready(struct nand_chip *this)
{
return (alchemy_rdsmem(AU1000_MEM_STSTAT) & 0x1) ? 1 : 0;
}
Expand Down Expand Up @@ -341,7 +341,7 @@ static void au1550_command(struct mtd_info *mtd, unsigned command, int column, i
/* Apply a short delay always to ensure that we do wait tWB. */
ndelay(100);
/* Wait for a chip to become ready... */
for (i = this->chip_delay; !this->dev_ready(mtd) && i > 0; --i)
for (i = this->chip_delay; !this->dev_ready(this) && i > 0; --i)
udelay(1);

/* Release -CE and re-enable interrupts. */
Expand All @@ -352,7 +352,7 @@ static void au1550_command(struct mtd_info *mtd, unsigned command, int column, i
/* Apply this short delay always to ensure that we do wait tWB. */
ndelay(100);

while(!this->dev_ready(mtd));
while(!this->dev_ready(this));
}

static int find_nand_cs(unsigned long nand_base)
Expand Down
3 changes: 1 addition & 2 deletions drivers/mtd/nand/raw/bcm47xxnflash/ops_bcm4706.c
Original file line number Diff line number Diff line change
Expand Up @@ -196,9 +196,8 @@ static void bcm47xxnflash_ops_bcm4706_select_chip(struct nand_chip *chip,
return;
}

static int bcm47xxnflash_ops_bcm4706_dev_ready(struct mtd_info *mtd)
static int bcm47xxnflash_ops_bcm4706_dev_ready(struct nand_chip *nand_chip)
{
struct nand_chip *nand_chip = mtd_to_nand(mtd);
struct bcm47xxnflash *b47n = nand_get_controller_data(nand_chip);

return !!(bcma_cc_read32(b47n->cc, BCMA_CC_NFLASH_CTL) & NCTL_READY);
Expand Down
3 changes: 1 addition & 2 deletions drivers/mtd/nand/raw/cafe_nand.c
Original file line number Diff line number Diff line change
Expand Up @@ -100,9 +100,8 @@ static const char *part_probes[] = { "cmdlinepart", "RedBoot", NULL };
#define cafe_readl(cafe, addr) readl((cafe)->mmio + CAFE_##addr)
#define cafe_writel(cafe, datum, addr) writel(datum, (cafe)->mmio + CAFE_##addr)

static int cafe_device_ready(struct mtd_info *mtd)
static int cafe_device_ready(struct nand_chip *chip)
{
struct nand_chip *chip = mtd_to_nand(mtd);
struct cafe_priv *cafe = nand_get_controller_data(chip);
int result = !!(cafe_readl(cafe, NAND_STATUS) & 0x40000000);
uint32_t irqs = cafe_readl(cafe, NAND_IRQ);
Expand Down
2 changes: 1 addition & 1 deletion drivers/mtd/nand/raw/cmx270_nand.c
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,7 @@ static void cmx270_hwcontrol(struct nand_chip *this, int dat,
/*
* read device ready pin
*/
static int cmx270_device_ready(struct mtd_info *mtd)
static int cmx270_device_ready(struct nand_chip *this)
{
dsb();

Expand Down
3 changes: 1 addition & 2 deletions drivers/mtd/nand/raw/cs553x_nand.c
Original file line number Diff line number Diff line change
Expand Up @@ -141,9 +141,8 @@ static void cs553x_hwcontrol(struct nand_chip *this, int cmd,
cs553x_write_byte(this, cmd);
}

static int cs553x_device_ready(struct mtd_info *mtd)
static int cs553x_device_ready(struct nand_chip *this)
{
struct nand_chip *this = mtd_to_nand(mtd);
void __iomem *mmio_base = this->IO_ADDR_R;
unsigned char foo = readb(mmio_base + MM_NAND_STS);

Expand Down
4 changes: 2 additions & 2 deletions drivers/mtd/nand/raw/davinci_nand.c
Original file line number Diff line number Diff line change
Expand Up @@ -460,9 +460,9 @@ static void nand_davinci_write_buf(struct nand_chip *chip, const uint8_t *buf,
* Check hardware register for wait status. Returns 1 if device is ready,
* 0 if it is still busy.
*/
static int nand_davinci_dev_ready(struct mtd_info *mtd)
static int nand_davinci_dev_ready(struct nand_chip *chip)
{
struct davinci_nand_info *info = to_davinci_nand(mtd);
struct davinci_nand_info *info = to_davinci_nand(nand_to_mtd(chip));

return davinci_nand_readl(info, NANDFSR_OFFSET) & BIT(0);
}
Expand Down
4 changes: 2 additions & 2 deletions drivers/mtd/nand/raw/denali.c
Original file line number Diff line number Diff line change
Expand Up @@ -296,9 +296,9 @@ static void denali_cmd_ctrl(struct nand_chip *chip, int dat, unsigned int ctrl)
denali->host_write(denali, DENALI_BANK(denali) | type, dat);
}

static int denali_dev_ready(struct mtd_info *mtd)
static int denali_dev_ready(struct nand_chip *chip)
{
struct denali_nand_info *denali = mtd_to_denali(mtd);
struct denali_nand_info *denali = mtd_to_denali(nand_to_mtd(chip));

return !!(denali_check_irq(denali) & INTR__INT_ACT);
}
Expand Down
5 changes: 2 additions & 3 deletions drivers/mtd/nand/raw/diskonchip.c
Original file line number Diff line number Diff line change
Expand Up @@ -739,12 +739,11 @@ static void doc2001plus_command(struct mtd_info *mtd, unsigned command, int colu
* any case on any machine. */
ndelay(100);
/* wait until command is processed */
while (!this->dev_ready(mtd)) ;
while (!this->dev_ready(this)) ;
}

static int doc200x_dev_ready(struct mtd_info *mtd)
static int doc200x_dev_ready(struct nand_chip *this)
{
struct nand_chip *this = mtd_to_nand(mtd);
struct doc_priv *doc = nand_get_controller_data(this);
void __iomem *docptr = doc->virtadr;

Expand Down
6 changes: 3 additions & 3 deletions drivers/mtd/nand/raw/fsl_upm.c
Original file line number Diff line number Diff line change
Expand Up @@ -52,9 +52,9 @@ static inline struct fsl_upm_nand *to_fsl_upm_nand(struct mtd_info *mtdinfo)
chip);
}

static int fun_chip_ready(struct mtd_info *mtd)
static int fun_chip_ready(struct nand_chip *chip)
{
struct fsl_upm_nand *fun = to_fsl_upm_nand(mtd);
struct fsl_upm_nand *fun = to_fsl_upm_nand(nand_to_mtd(chip));

if (gpio_get_value(fun->rnb_gpio[fun->mchip_number]))
return 1;
Expand All @@ -69,7 +69,7 @@ static void fun_wait_rnb(struct fsl_upm_nand *fun)
struct mtd_info *mtd = nand_to_mtd(&fun->chip);
int cnt = 1000000;

while (--cnt && !fun_chip_ready(mtd))
while (--cnt && !fun_chip_ready(&fun->chip))
cpu_relax();
if (!cnt)
dev_err(fun->dev, "tired waiting for RNB\n");
Expand Down
4 changes: 2 additions & 2 deletions drivers/mtd/nand/raw/gpio.c
Original file line number Diff line number Diff line change
Expand Up @@ -94,9 +94,9 @@ static void gpio_nand_cmd_ctrl(struct nand_chip *chip, int cmd,
gpio_nand_dosync(gpiomtd);
}

static int gpio_nand_devready(struct mtd_info *mtd)
static int gpio_nand_devready(struct nand_chip *chip)
{
struct gpiomtd *gpiomtd = gpio_nand_getpriv(mtd);
struct gpiomtd *gpiomtd = gpio_nand_getpriv(nand_to_mtd(chip));

return gpiod_get_value(gpiomtd->rdy);
}
Expand Down
3 changes: 1 addition & 2 deletions drivers/mtd/nand/raw/gpmi-nand/gpmi-nand.c
Original file line number Diff line number Diff line change
Expand Up @@ -816,9 +816,8 @@ static void gpmi_cmd_ctrl(struct nand_chip *chip, int data, unsigned int ctrl)
this->command_length = 0;
}

static int gpmi_dev_ready(struct mtd_info *mtd)
static int gpmi_dev_ready(struct nand_chip *chip)
{
struct nand_chip *chip = mtd_to_nand(mtd);
struct gpmi_nand_data *this = nand_get_controller_data(chip);

return gpmi_is_ready(this, this->current_chip);
Expand Down
4 changes: 2 additions & 2 deletions drivers/mtd/nand/raw/jz4740_nand.c
Original file line number Diff line number Diff line change
Expand Up @@ -127,9 +127,9 @@ static void jz_nand_cmd_ctrl(struct nand_chip *chip, int dat,
writeb(dat, chip->IO_ADDR_W);
}

static int jz_nand_dev_ready(struct mtd_info *mtd)
static int jz_nand_dev_ready(struct nand_chip *chip)
{
struct jz_nand *nand = mtd_to_jz_nand(mtd);
struct jz_nand *nand = mtd_to_jz_nand(nand_to_mtd(chip));
return gpiod_get_value_cansleep(nand->busy_gpio);
}

Expand Down
4 changes: 2 additions & 2 deletions drivers/mtd/nand/raw/jz4780_nand.c
Original file line number Diff line number Diff line change
Expand Up @@ -109,9 +109,9 @@ static void jz4780_nand_cmd_ctrl(struct nand_chip *chip, int cmd,
writeb(cmd, cs->base + OFFSET_CMD);
}

static int jz4780_nand_dev_ready(struct mtd_info *mtd)
static int jz4780_nand_dev_ready(struct nand_chip *chip)
{
struct jz4780_nand_chip *nand = to_jz4780_nand_chip(mtd);
struct jz4780_nand_chip *nand = to_jz4780_nand_chip(nand_to_mtd(chip));

return !gpiod_get_value_cansleep(nand->busy_gpio);
}
Expand Down
3 changes: 1 addition & 2 deletions drivers/mtd/nand/raw/lpc32xx_mlc.c
Original file line number Diff line number Diff line change
Expand Up @@ -302,9 +302,8 @@ static void lpc32xx_nand_cmd_ctrl(struct nand_chip *nand_chip, int cmd,
/*
* Read Device Ready (NAND device _and_ controller ready)
*/
static int lpc32xx_nand_device_ready(struct mtd_info *mtd)
static int lpc32xx_nand_device_ready(struct nand_chip *nand_chip)
{
struct nand_chip *nand_chip = mtd_to_nand(mtd);
struct lpc32xx_nand_host *host = nand_get_controller_data(nand_chip);

if ((readb(MLC_ISR(host->io_base)) &
Expand Down
3 changes: 1 addition & 2 deletions drivers/mtd/nand/raw/lpc32xx_slc.c
Original file line number Diff line number Diff line change
Expand Up @@ -303,9 +303,8 @@ static void lpc32xx_nand_cmd_ctrl(struct nand_chip *chip, int cmd,
/*
* Read the Device Ready pin
*/
static int lpc32xx_nand_device_ready(struct mtd_info *mtd)
static int lpc32xx_nand_device_ready(struct nand_chip *chip)
{
struct nand_chip *chip = mtd_to_nand(mtd);
struct lpc32xx_nand_host *host = nand_get_controller_data(chip);
int rdy = 0;

Expand Down
2 changes: 1 addition & 1 deletion drivers/mtd/nand/raw/mpc5121_nfc.c
Original file line number Diff line number Diff line change
Expand Up @@ -320,7 +320,7 @@ static void ads5121_select_chip(struct nand_chip *nand, int chip)
}

/* Read NAND Ready/Busy signal */
static int mpc5121_nfc_dev_ready(struct mtd_info *mtd)
static int mpc5121_nfc_dev_ready(struct nand_chip *nand)
{
/*
* NFC handles ready/busy signal internally. Therefore, this function
Expand Down
4 changes: 2 additions & 2 deletions drivers/mtd/nand/raw/mtk_nand.c
Original file line number Diff line number Diff line change
Expand Up @@ -402,9 +402,9 @@ static void mtk_nfc_select_chip(struct nand_chip *nand, int chip)
nfi_writel(nfc, mtk_nand->sels[chip], NFI_CSEL);
}

static int mtk_nfc_dev_ready(struct mtd_info *mtd)
static int mtk_nfc_dev_ready(struct nand_chip *nand)
{
struct mtk_nfc *nfc = nand_get_controller_data(mtd_to_nand(mtd));
struct mtk_nfc *nfc = nand_get_controller_data(nand);

if (nfi_readl(nfc, NFI_STA) & STA_BUSY)
return 0;
Expand Down
2 changes: 1 addition & 1 deletion drivers/mtd/nand/raw/mxc_nand.c
Original file line number Diff line number Diff line change
Expand Up @@ -701,7 +701,7 @@ static void mxc_nand_enable_hwecc_v3(struct nand_chip *chip, bool enable)
}

/* This functions is used by upper layer to checks if device is ready */
static int mxc_nand_dev_ready(struct mtd_info *mtd)
static int mxc_nand_dev_ready(struct nand_chip *chip)
{
/*
* NFC handles R/B internally. Therefore, this function
Expand Down
10 changes: 5 additions & 5 deletions drivers/mtd/nand/raw/nand_base.c
Original file line number Diff line number Diff line change
Expand Up @@ -603,7 +603,7 @@ static void panic_nand_wait_ready(struct mtd_info *mtd, unsigned long timeo)

/* Wait for the device to get ready */
for (i = 0; i < timeo; i++) {
if (chip->dev_ready(mtd))
if (chip->dev_ready(chip))
break;
touch_softlockup_watchdog();
mdelay(1);
Expand All @@ -627,12 +627,12 @@ void nand_wait_ready(struct nand_chip *chip)
/* Wait until command is processed or timeout occurs */
timeo = jiffies + msecs_to_jiffies(timeo);
do {
if (chip->dev_ready(mtd))
if (chip->dev_ready(chip))
return;
cond_resched();
} while (time_before(jiffies, timeo));

if (!chip->dev_ready(mtd))
if (!chip->dev_ready(chip))
pr_warn_ratelimited("timeout while waiting for chip to become ready\n");
}
EXPORT_SYMBOL_GPL(nand_wait_ready);
Expand Down Expand Up @@ -1068,7 +1068,7 @@ static void panic_nand_wait(struct mtd_info *mtd, struct nand_chip *chip,
int i;
for (i = 0; i < timeo; i++) {
if (chip->dev_ready) {
if (chip->dev_ready(mtd))
if (chip->dev_ready(chip))
break;
} else {
int ret;
Expand Down Expand Up @@ -1116,7 +1116,7 @@ static int nand_wait(struct mtd_info *mtd, struct nand_chip *chip)
timeo = jiffies + msecs_to_jiffies(timeo);
do {
if (chip->dev_ready) {
if (chip->dev_ready(mtd))
if (chip->dev_ready(chip))
break;
} else {
ret = nand_read_data_op(chip, &status,
Expand Down
2 changes: 1 addition & 1 deletion drivers/mtd/nand/raw/nandsim.c
Original file line number Diff line number Diff line change
Expand Up @@ -2099,7 +2099,7 @@ static void ns_hwcontrol(struct nand_chip *chip, int cmd, unsigned int bitmask)
ns_nand_write_byte(chip, cmd);
}

static int ns_device_ready(struct mtd_info *mtd)
static int ns_device_ready(struct nand_chip *chip)
{
NS_DBG("device_ready\n");
return 1;
Expand Down
3 changes: 1 addition & 2 deletions drivers/mtd/nand/raw/ndfc.c
Original file line number Diff line number Diff line change
Expand Up @@ -71,9 +71,8 @@ static void ndfc_hwcontrol(struct nand_chip *chip, int cmd, unsigned int ctrl)
writel(cmd & 0xFF, ndfc->ndfcbase + NDFC_ALE);
}

static int ndfc_ready(struct mtd_info *mtd)
static int ndfc_ready(struct nand_chip *chip)
{
struct nand_chip *chip = mtd_to_nand(mtd);
struct ndfc_controller *ndfc = nand_get_controller_data(chip);

return in_be32(ndfc->ndfcbase + NDFC_STAT) & NDFC_STAT_IS_READY;
Expand Down
6 changes: 3 additions & 3 deletions drivers/mtd/nand/raw/nuc900_nand.c
Original file line number Diff line number Diff line change
Expand Up @@ -120,9 +120,9 @@ static int nuc900_check_rb(struct nuc900_nand *nand)
return val;
}

static int nuc900_nand_devready(struct mtd_info *mtd)
static int nuc900_nand_devready(struct nand_chip *chip)
{
struct nuc900_nand *nand = mtd_to_nuc900(mtd);
struct nuc900_nand *nand = mtd_to_nuc900(nand_to_mtd(chip));
int ready;

ready = (nuc900_check_rb(nand)) ? 1 : 0;
Expand Down Expand Up @@ -205,7 +205,7 @@ static void nuc900_nand_command_lp(struct mtd_info *mtd, unsigned int command,
* any case on any machine. */
ndelay(100);

while (!chip->dev_ready(mtd))
while (!chip->dev_ready(chip))
;
}

Expand Down
4 changes: 2 additions & 2 deletions drivers/mtd/nand/raw/omap2.c
Original file line number Diff line number Diff line change
Expand Up @@ -1021,9 +1021,9 @@ static int omap_wait(struct mtd_info *mtd, struct nand_chip *chip)
*
* Returns true if ready and false if busy.
*/
static int omap_dev_ready(struct mtd_info *mtd)
static int omap_dev_ready(struct nand_chip *chip)
{
struct omap_nand_info *info = mtd_to_omap(mtd);
struct omap_nand_info *info = mtd_to_omap(nand_to_mtd(chip));

return gpiod_get_value(info->ready_gpiod);
}
Expand Down
2 changes: 1 addition & 1 deletion drivers/mtd/nand/raw/pasemi_nand.c
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ static void pasemi_hwcontrol(struct nand_chip *chip, int cmd,
inl(lpcctl);
}

int pasemi_device_ready(struct mtd_info *mtd)
int pasemi_device_ready(struct nand_chip *chip)
{
return !!(inl(lpcctl) & LBICTRL_LPCCTL_NR);
}
Expand Down
12 changes: 1 addition & 11 deletions drivers/mtd/nand/raw/plat_nand.c
Original file line number Diff line number Diff line change
Expand Up @@ -23,13 +23,6 @@ struct plat_nand_data {
void __iomem *io_base;
};

static int plat_nand_dev_ready(struct mtd_info *mtd)
{
struct platform_nand_data *pdata = dev_get_platdata(mtd->dev.parent);

return pdata->ctrl.dev_ready(mtd_to_nand(mtd));
}

/*
* Probe for the NAND device.
*/
Expand Down Expand Up @@ -70,10 +63,7 @@ static int plat_nand_probe(struct platform_device *pdev)
data->chip.IO_ADDR_R = data->io_base;
data->chip.IO_ADDR_W = data->io_base;
data->chip.cmd_ctrl = pdata->ctrl.cmd_ctrl;

if (pdata->ctrl.dev_ready)
data->chip.dev_ready = plat_nand_dev_ready;

data->chip.dev_ready = pdata->ctrl.dev_ready;
data->chip.select_chip = pdata->ctrl.select_chip;
data->chip.write_buf = pdata->ctrl.write_buf;
data->chip.read_buf = pdata->ctrl.read_buf;
Expand Down
Loading

0 comments on commit 50a487e

Please sign in to comment.