Skip to content

Commit 02f6286

Browse files
ndreyscomputersforpeace
authored andcommitted
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: [email protected] Cc: David Woodhouse <[email protected]> Cc: Brian Norris <[email protected]> Cc: Boris Brezillon <[email protected]> Cc: Marek Vasut <[email protected]> Cc: Richard Weinberger <[email protected]> Cc: Cyrille Pitchen <[email protected]> Cc: [email protected] Reviewed-by: Marek Vasut <[email protected]> Tested-by: Chris Healy <[email protected]> Signed-off-by: Andrey Smirnov <[email protected]> Signed-off-by: Brian Norris <[email protected]>
1 parent 41c9c66 commit 02f6286

File tree

1 file changed

+33
-41
lines changed

1 file changed

+33
-41
lines changed

drivers/mtd/devices/mtd_dataflash.c

Lines changed: 33 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -130,8 +130,7 @@ static int dataflash_waitready(struct spi_device *spi)
130130
for (;;) {
131131
status = dataflash_status(spi);
132132
if (status < 0) {
133-
pr_debug("%s: status %d?\n",
134-
dev_name(&spi->dev), status);
133+
dev_dbg(&spi->dev, "status %d?\n", status);
135134
status = 0;
136135
}
137136

@@ -157,9 +156,8 @@ static int dataflash_erase(struct mtd_info *mtd, struct erase_info *instr)
157156
u8 *command;
158157
u32 rem;
159158

160-
pr_debug("%s: erase addr=0x%llx len 0x%llx\n",
161-
dev_name(&spi->dev), (long long)instr->addr,
162-
(long long)instr->len);
159+
dev_dbg(&spi->dev, "erase addr=0x%llx len 0x%llx\n",
160+
(long long)instr->addr, (long long)instr->len);
163161

164162
div_u64_rem(instr->len, priv->page_size, &rem);
165163
if (rem)
@@ -192,7 +190,7 @@ static int dataflash_erase(struct mtd_info *mtd, struct erase_info *instr)
192190
command[2] = (u8)(pageaddr >> 8);
193191
command[3] = 0;
194192

195-
pr_debug("ERASE %s: (%x) %x %x %x [%i]\n",
193+
dev_dbg(&spi->dev, "ERASE %s: (%x) %x %x %x [%i]\n",
196194
do_block ? "block" : "page",
197195
command[0], command[1], command[2], command[3],
198196
pageaddr);
@@ -201,8 +199,8 @@ static int dataflash_erase(struct mtd_info *mtd, struct erase_info *instr)
201199
(void) dataflash_waitready(spi);
202200

203201
if (status < 0) {
204-
printk(KERN_ERR "%s: erase %x, err %d\n",
205-
dev_name(&spi->dev), pageaddr, status);
202+
dev_err(&spi->dev, "erase %x, err %d\n",
203+
pageaddr, status);
206204
/* REVISIT: can retry instr->retries times; or
207205
* giveup and instr->fail_addr = instr->addr;
208206
*/
@@ -243,16 +241,16 @@ static int dataflash_read(struct mtd_info *mtd, loff_t from, size_t len,
243241
u8 *command;
244242
int status;
245243

246-
pr_debug("%s: read 0x%x..0x%x\n", dev_name(&priv->spi->dev),
247-
(unsigned)from, (unsigned)(from + len));
244+
dev_dbg(&priv->spi->dev, "read 0x%x..0x%x\n",
245+
(unsigned int)from, (unsigned int)(from + len));
248246

249247
/* Calculate flash page/byte address */
250248
addr = (((unsigned)from / priv->page_size) << priv->page_offset)
251249
+ ((unsigned)from % priv->page_size);
252250

253251
command = priv->command;
254252

255-
pr_debug("READ: (%x) %x %x %x\n",
253+
dev_dbg(&priv->spi->dev, "READ: (%x) %x %x %x\n",
256254
command[0], command[1], command[2], command[3]);
257255

258256
spi_message_init(&msg);
@@ -284,8 +282,7 @@ static int dataflash_read(struct mtd_info *mtd, loff_t from, size_t len,
284282
*retlen = msg.actual_length - 8;
285283
status = 0;
286284
} else
287-
pr_debug("%s: read %x..%x --> %d\n",
288-
dev_name(&priv->spi->dev),
285+
dev_dbg(&priv->spi->dev, "read %x..%x --> %d\n",
289286
(unsigned)from, (unsigned)(from + len),
290287
status);
291288
return status;
@@ -311,8 +308,8 @@ static int dataflash_write(struct mtd_info *mtd, loff_t to, size_t len,
311308
int status = -EINVAL;
312309
u8 *command;
313310

314-
pr_debug("%s: write 0x%x..0x%x\n",
315-
dev_name(&spi->dev), (unsigned)to, (unsigned)(to + len));
311+
dev_dbg(&spi->dev, "write 0x%x..0x%x\n",
312+
(unsigned int)to, (unsigned int)(to + len));
316313

317314
spi_message_init(&msg);
318315

@@ -329,7 +326,7 @@ static int dataflash_write(struct mtd_info *mtd, loff_t to, size_t len,
329326

330327
mutex_lock(&priv->lock);
331328
while (remaining > 0) {
332-
pr_debug("write @ %i:%i len=%i\n",
329+
dev_dbg(&spi->dev, "write @ %i:%i len=%i\n",
333330
pageaddr, offset, writelen);
334331

335332
/* REVISIT:
@@ -357,13 +354,13 @@ static int dataflash_write(struct mtd_info *mtd, loff_t to, size_t len,
357354
command[2] = (addr & 0x0000FF00) >> 8;
358355
command[3] = 0;
359356

360-
pr_debug("TRANSFER: (%x) %x %x %x\n",
357+
dev_dbg(&spi->dev, "TRANSFER: (%x) %x %x %x\n",
361358
command[0], command[1], command[2], command[3]);
362359

363360
status = spi_sync(spi, &msg);
364361
if (status < 0)
365-
pr_debug("%s: xfer %u -> %d\n",
366-
dev_name(&spi->dev), addr, status);
362+
dev_dbg(&spi->dev, "xfer %u -> %d\n",
363+
addr, status);
367364

368365
(void) dataflash_waitready(priv->spi);
369366
}
@@ -375,7 +372,7 @@ static int dataflash_write(struct mtd_info *mtd, loff_t to, size_t len,
375372
command[2] = (addr & 0x0000FF00) >> 8;
376373
command[3] = (addr & 0x000000FF);
377374

378-
pr_debug("PROGRAM: (%x) %x %x %x\n",
375+
dev_dbg(&spi->dev, "PROGRAM: (%x) %x %x %x\n",
379376
command[0], command[1], command[2], command[3]);
380377

381378
x[1].tx_buf = writebuf;
@@ -384,8 +381,8 @@ static int dataflash_write(struct mtd_info *mtd, loff_t to, size_t len,
384381
status = spi_sync(spi, &msg);
385382
spi_transfer_del(x + 1);
386383
if (status < 0)
387-
pr_debug("%s: pgm %u/%u -> %d\n",
388-
dev_name(&spi->dev), addr, writelen, status);
384+
dev_dbg(&spi->dev, "pgm %u/%u -> %d\n",
385+
addr, writelen, status);
389386

390387
(void) dataflash_waitready(priv->spi);
391388

@@ -399,20 +396,20 @@ static int dataflash_write(struct mtd_info *mtd, loff_t to, size_t len,
399396
command[2] = (addr & 0x0000FF00) >> 8;
400397
command[3] = 0;
401398

402-
pr_debug("COMPARE: (%x) %x %x %x\n",
399+
dev_dbg(&spi->dev, "COMPARE: (%x) %x %x %x\n",
403400
command[0], command[1], command[2], command[3]);
404401

405402
status = spi_sync(spi, &msg);
406403
if (status < 0)
407-
pr_debug("%s: compare %u -> %d\n",
408-
dev_name(&spi->dev), addr, status);
404+
dev_dbg(&spi->dev, "compare %u -> %d\n",
405+
addr, status);
409406

410407
status = dataflash_waitready(priv->spi);
411408

412409
/* Check result of the compare operation */
413410
if (status & (1 << 6)) {
414-
printk(KERN_ERR "%s: compare page %u, err %d\n",
415-
dev_name(&spi->dev), pageaddr, status);
411+
dev_err(&spi->dev, "compare page %u, err %d\n",
412+
pageaddr, status);
416413
remaining = 0;
417414
status = -EIO;
418415
break;
@@ -757,8 +754,7 @@ static struct flash_info *jedec_probe(struct spi_device *spi)
757754
*/
758755
ret = spi_write_then_read(spi, &code, 1, id, 3);
759756
if (ret < 0) {
760-
pr_debug("%s: error %d reading JEDEC ID\n",
761-
dev_name(&spi->dev), ret);
757+
dev_dbg(&spi->dev, "error %d reading JEDEC ID\n", ret);
762758
return ERR_PTR(ret);
763759
}
764760

@@ -775,16 +771,14 @@ static struct flash_info *jedec_probe(struct spi_device *spi)
775771
i < ARRAY_SIZE(dataflash_data);
776772
i++, info++) {
777773
if (info->jedec_id == jedec) {
778-
pr_debug("%s: OTP, sector protect%s\n",
779-
dev_name(&spi->dev),
780-
(info->flags & SUP_POW2PS)
781-
? ", binary pagesize" : ""
782-
);
774+
dev_dbg(&spi->dev, "OTP, sector protect%s\n",
775+
(info->flags & SUP_POW2PS) ?
776+
", binary pagesize" : "");
783777
if (info->flags & SUP_POW2PS) {
784778
status = dataflash_status(spi);
785779
if (status < 0) {
786-
pr_debug("%s: status error %d\n",
787-
dev_name(&spi->dev), status);
780+
dev_dbg(&spi->dev, "status error %d\n",
781+
status);
788782
return ERR_PTR(status);
789783
}
790784
if (status & 0x1) {
@@ -848,8 +842,7 @@ static int dataflash_probe(struct spi_device *spi)
848842
*/
849843
status = dataflash_status(spi);
850844
if (status <= 0 || status == 0xff) {
851-
pr_debug("%s: status error %d\n",
852-
dev_name(&spi->dev), status);
845+
dev_dbg(&spi->dev, "status error %d\n", status);
853846
if (status == 0 || status == 0xff)
854847
status = -ENODEV;
855848
return status;
@@ -890,8 +883,7 @@ static int dataflash_probe(struct spi_device *spi)
890883
}
891884

892885
if (status < 0)
893-
pr_debug("%s: add_dataflash --> %d\n", dev_name(&spi->dev),
894-
status);
886+
dev_dbg(&spi->dev, "add_dataflash --> %d\n", status);
895887

896888
return status;
897889
}
@@ -901,7 +893,7 @@ static int dataflash_remove(struct spi_device *spi)
901893
struct dataflash *flash = spi_get_drvdata(spi);
902894
int status;
903895

904-
pr_debug("%s: remove\n", dev_name(&spi->dev));
896+
dev_dbg(&spi->dev, "remove\n");
905897

906898
status = mtd_device_unregister(&flash->mtd);
907899
if (status == 0)

0 commit comments

Comments
 (0)