mtd: dataflash: Replace pr_debug, printk with dev_* functions

Lion's share of calls to pr_debug in this driver follow the pattern of
pr_debug("%s <message>", dev_name(<dev>), <arguments>), which should
be semantically identical to dev_dbg(<dev>, "<message>", <arguments>),
so replace such occurencies to simplify the code.

Convert the small minority of pr_debug that do not follow pattern from
above to use dev_dbg as well, for the sake of consistency.

Convert similar patter of printk(KERN_ERR, "%s: ...", dev_name(...),
...) to use dev_err instead.

No functional change intended.

Cc: cphealy@gmail.com
Cc: David Woodhouse <dwmw2@infradead.org>
Cc: Brian Norris <computersforpeace@gmail.com>
Cc: Boris Brezillon <boris.brezillon@free-electrons.com>
Cc: Marek Vasut <marek.vasut@gmail.com>
Cc: Richard Weinberger <richard@nod.at>
Cc: Cyrille Pitchen <cyrille.pitchen@atmel.com>
Cc: linux-kernel@vger.kernel.org
Reviewed-by: Marek Vasut <marek.vasut@gmail.com>
Tested-by: Chris Healy <cphealy@gmail.com>
Signed-off-by: Andrey Smirnov <andrew.smirnov@gmail.com>
Signed-off-by: Brian Norris <computersforpeace@gmail.com>
This commit is contained in:
Andrey Smirnov 2017-04-21 09:30:23 -07:00 committed by Brian Norris
parent 41c9c6621a
commit 02f62864f6
1 changed files with 33 additions and 41 deletions

View File

@ -130,8 +130,7 @@ static int dataflash_waitready(struct spi_device *spi)
for (;;) { for (;;) {
status = dataflash_status(spi); status = dataflash_status(spi);
if (status < 0) { if (status < 0) {
pr_debug("%s: status %d?\n", dev_dbg(&spi->dev, "status %d?\n", status);
dev_name(&spi->dev), status);
status = 0; status = 0;
} }
@ -157,9 +156,8 @@ static int dataflash_erase(struct mtd_info *mtd, struct erase_info *instr)
u8 *command; u8 *command;
u32 rem; u32 rem;
pr_debug("%s: erase addr=0x%llx len 0x%llx\n", dev_dbg(&spi->dev, "erase addr=0x%llx len 0x%llx\n",
dev_name(&spi->dev), (long long)instr->addr, (long long)instr->addr, (long long)instr->len);
(long long)instr->len);
div_u64_rem(instr->len, priv->page_size, &rem); div_u64_rem(instr->len, priv->page_size, &rem);
if (rem) if (rem)
@ -192,7 +190,7 @@ static int dataflash_erase(struct mtd_info *mtd, struct erase_info *instr)
command[2] = (u8)(pageaddr >> 8); command[2] = (u8)(pageaddr >> 8);
command[3] = 0; command[3] = 0;
pr_debug("ERASE %s: (%x) %x %x %x [%i]\n", dev_dbg(&spi->dev, "ERASE %s: (%x) %x %x %x [%i]\n",
do_block ? "block" : "page", do_block ? "block" : "page",
command[0], command[1], command[2], command[3], command[0], command[1], command[2], command[3],
pageaddr); pageaddr);
@ -201,8 +199,8 @@ static int dataflash_erase(struct mtd_info *mtd, struct erase_info *instr)
(void) dataflash_waitready(spi); (void) dataflash_waitready(spi);
if (status < 0) { if (status < 0) {
printk(KERN_ERR "%s: erase %x, err %d\n", dev_err(&spi->dev, "erase %x, err %d\n",
dev_name(&spi->dev), pageaddr, status); pageaddr, status);
/* REVISIT: can retry instr->retries times; or /* REVISIT: can retry instr->retries times; or
* giveup and instr->fail_addr = instr->addr; * giveup and instr->fail_addr = instr->addr;
*/ */
@ -243,8 +241,8 @@ static int dataflash_read(struct mtd_info *mtd, loff_t from, size_t len,
u8 *command; u8 *command;
int status; int status;
pr_debug("%s: read 0x%x..0x%x\n", dev_name(&priv->spi->dev), dev_dbg(&priv->spi->dev, "read 0x%x..0x%x\n",
(unsigned)from, (unsigned)(from + len)); (unsigned int)from, (unsigned int)(from + len));
/* Calculate flash page/byte address */ /* Calculate flash page/byte address */
addr = (((unsigned)from / priv->page_size) << priv->page_offset) addr = (((unsigned)from / priv->page_size) << priv->page_offset)
@ -252,7 +250,7 @@ static int dataflash_read(struct mtd_info *mtd, loff_t from, size_t len,
command = priv->command; command = priv->command;
pr_debug("READ: (%x) %x %x %x\n", dev_dbg(&priv->spi->dev, "READ: (%x) %x %x %x\n",
command[0], command[1], command[2], command[3]); command[0], command[1], command[2], command[3]);
spi_message_init(&msg); spi_message_init(&msg);
@ -284,8 +282,7 @@ static int dataflash_read(struct mtd_info *mtd, loff_t from, size_t len,
*retlen = msg.actual_length - 8; *retlen = msg.actual_length - 8;
status = 0; status = 0;
} else } else
pr_debug("%s: read %x..%x --> %d\n", dev_dbg(&priv->spi->dev, "read %x..%x --> %d\n",
dev_name(&priv->spi->dev),
(unsigned)from, (unsigned)(from + len), (unsigned)from, (unsigned)(from + len),
status); status);
return status; return status;
@ -311,8 +308,8 @@ static int dataflash_write(struct mtd_info *mtd, loff_t to, size_t len,
int status = -EINVAL; int status = -EINVAL;
u8 *command; u8 *command;
pr_debug("%s: write 0x%x..0x%x\n", dev_dbg(&spi->dev, "write 0x%x..0x%x\n",
dev_name(&spi->dev), (unsigned)to, (unsigned)(to + len)); (unsigned int)to, (unsigned int)(to + len));
spi_message_init(&msg); spi_message_init(&msg);
@ -329,7 +326,7 @@ static int dataflash_write(struct mtd_info *mtd, loff_t to, size_t len,
mutex_lock(&priv->lock); mutex_lock(&priv->lock);
while (remaining > 0) { while (remaining > 0) {
pr_debug("write @ %i:%i len=%i\n", dev_dbg(&spi->dev, "write @ %i:%i len=%i\n",
pageaddr, offset, writelen); pageaddr, offset, writelen);
/* REVISIT: /* REVISIT:
@ -357,13 +354,13 @@ static int dataflash_write(struct mtd_info *mtd, loff_t to, size_t len,
command[2] = (addr & 0x0000FF00) >> 8; command[2] = (addr & 0x0000FF00) >> 8;
command[3] = 0; command[3] = 0;
pr_debug("TRANSFER: (%x) %x %x %x\n", dev_dbg(&spi->dev, "TRANSFER: (%x) %x %x %x\n",
command[0], command[1], command[2], command[3]); command[0], command[1], command[2], command[3]);
status = spi_sync(spi, &msg); status = spi_sync(spi, &msg);
if (status < 0) if (status < 0)
pr_debug("%s: xfer %u -> %d\n", dev_dbg(&spi->dev, "xfer %u -> %d\n",
dev_name(&spi->dev), addr, status); addr, status);
(void) dataflash_waitready(priv->spi); (void) dataflash_waitready(priv->spi);
} }
@ -375,7 +372,7 @@ static int dataflash_write(struct mtd_info *mtd, loff_t to, size_t len,
command[2] = (addr & 0x0000FF00) >> 8; command[2] = (addr & 0x0000FF00) >> 8;
command[3] = (addr & 0x000000FF); command[3] = (addr & 0x000000FF);
pr_debug("PROGRAM: (%x) %x %x %x\n", dev_dbg(&spi->dev, "PROGRAM: (%x) %x %x %x\n",
command[0], command[1], command[2], command[3]); command[0], command[1], command[2], command[3]);
x[1].tx_buf = writebuf; x[1].tx_buf = writebuf;
@ -384,8 +381,8 @@ static int dataflash_write(struct mtd_info *mtd, loff_t to, size_t len,
status = spi_sync(spi, &msg); status = spi_sync(spi, &msg);
spi_transfer_del(x + 1); spi_transfer_del(x + 1);
if (status < 0) if (status < 0)
pr_debug("%s: pgm %u/%u -> %d\n", dev_dbg(&spi->dev, "pgm %u/%u -> %d\n",
dev_name(&spi->dev), addr, writelen, status); addr, writelen, status);
(void) dataflash_waitready(priv->spi); (void) dataflash_waitready(priv->spi);
@ -399,20 +396,20 @@ static int dataflash_write(struct mtd_info *mtd, loff_t to, size_t len,
command[2] = (addr & 0x0000FF00) >> 8; command[2] = (addr & 0x0000FF00) >> 8;
command[3] = 0; command[3] = 0;
pr_debug("COMPARE: (%x) %x %x %x\n", dev_dbg(&spi->dev, "COMPARE: (%x) %x %x %x\n",
command[0], command[1], command[2], command[3]); command[0], command[1], command[2], command[3]);
status = spi_sync(spi, &msg); status = spi_sync(spi, &msg);
if (status < 0) if (status < 0)
pr_debug("%s: compare %u -> %d\n", dev_dbg(&spi->dev, "compare %u -> %d\n",
dev_name(&spi->dev), addr, status); addr, status);
status = dataflash_waitready(priv->spi); status = dataflash_waitready(priv->spi);
/* Check result of the compare operation */ /* Check result of the compare operation */
if (status & (1 << 6)) { if (status & (1 << 6)) {
printk(KERN_ERR "%s: compare page %u, err %d\n", dev_err(&spi->dev, "compare page %u, err %d\n",
dev_name(&spi->dev), pageaddr, status); pageaddr, status);
remaining = 0; remaining = 0;
status = -EIO; status = -EIO;
break; break;
@ -757,8 +754,7 @@ static struct flash_info *jedec_probe(struct spi_device *spi)
*/ */
ret = spi_write_then_read(spi, &code, 1, id, 3); ret = spi_write_then_read(spi, &code, 1, id, 3);
if (ret < 0) { if (ret < 0) {
pr_debug("%s: error %d reading JEDEC ID\n", dev_dbg(&spi->dev, "error %d reading JEDEC ID\n", ret);
dev_name(&spi->dev), ret);
return ERR_PTR(ret); return ERR_PTR(ret);
} }
@ -775,16 +771,14 @@ static struct flash_info *jedec_probe(struct spi_device *spi)
i < ARRAY_SIZE(dataflash_data); i < ARRAY_SIZE(dataflash_data);
i++, info++) { i++, info++) {
if (info->jedec_id == jedec) { if (info->jedec_id == jedec) {
pr_debug("%s: OTP, sector protect%s\n", dev_dbg(&spi->dev, "OTP, sector protect%s\n",
dev_name(&spi->dev), (info->flags & SUP_POW2PS) ?
(info->flags & SUP_POW2PS) ", binary pagesize" : "");
? ", binary pagesize" : ""
);
if (info->flags & SUP_POW2PS) { if (info->flags & SUP_POW2PS) {
status = dataflash_status(spi); status = dataflash_status(spi);
if (status < 0) { if (status < 0) {
pr_debug("%s: status error %d\n", dev_dbg(&spi->dev, "status error %d\n",
dev_name(&spi->dev), status); status);
return ERR_PTR(status); return ERR_PTR(status);
} }
if (status & 0x1) { if (status & 0x1) {
@ -848,8 +842,7 @@ static int dataflash_probe(struct spi_device *spi)
*/ */
status = dataflash_status(spi); status = dataflash_status(spi);
if (status <= 0 || status == 0xff) { if (status <= 0 || status == 0xff) {
pr_debug("%s: status error %d\n", dev_dbg(&spi->dev, "status error %d\n", status);
dev_name(&spi->dev), status);
if (status == 0 || status == 0xff) if (status == 0 || status == 0xff)
status = -ENODEV; status = -ENODEV;
return status; return status;
@ -890,8 +883,7 @@ static int dataflash_probe(struct spi_device *spi)
} }
if (status < 0) if (status < 0)
pr_debug("%s: add_dataflash --> %d\n", dev_name(&spi->dev), dev_dbg(&spi->dev, "add_dataflash --> %d\n", status);
status);
return status; return status;
} }
@ -901,7 +893,7 @@ static int dataflash_remove(struct spi_device *spi)
struct dataflash *flash = spi_get_drvdata(spi); struct dataflash *flash = spi_get_drvdata(spi);
int status; int status;
pr_debug("%s: remove\n", dev_name(&spi->dev)); dev_dbg(&spi->dev, "remove\n");
status = mtd_device_unregister(&flash->mtd); status = mtd_device_unregister(&flash->mtd);
if (status == 0) if (status == 0)