Skip to content

Commit

Permalink
scsi: atp870u: Replace mdelay() with msleep()
Browse files Browse the repository at this point in the history
tscam(), atp870_init(), atp880_init() and atp885_init() are never
called in atomic context.
They call mdelay() to busily wait, which is not necessary.
mdelay() can be replaced with msleep().

This is found by a static analysis tool named DCNS written by myself.

Signed-off-by: Jia-Ju Bai <[email protected]>
Signed-off-by: Martin K. Petersen <[email protected]>
  • Loading branch information
XidianGeneral authored and martinkpetersen committed Jul 31, 2018
1 parent d6aec1c commit dcaa0c1
Showing 1 changed file with 8 additions and 8 deletions.
16 changes: 8 additions & 8 deletions drivers/scsi/atp870u.c
Original file line number Diff line number Diff line change
Expand Up @@ -1055,7 +1055,7 @@ static void tscam(struct Scsi_Host *host, bool wide_chip, u8 scam_on)
udelay(2); /* 2 deskew delay(45ns*2=90ns) */
val &= 0x007f; /* no bsy */
atp_writew_io(dev, 0, 0x1c, val);
mdelay(128);
msleep(128);
val &= 0x00fb; /* after 1ms no msg */
atp_writew_io(dev, 0, 0x1c, val);
while ((atp_readb_io(dev, 0, 0x1c) & 0x04) != 0)
Expand Down Expand Up @@ -1286,9 +1286,9 @@ static void atp870_init(struct Scsi_Host *shpnt)
k = (atp_readb_base(atpdev, 0x3a) & 0xf3) | 0x10;
atp_writeb_base(atpdev, 0x3a, k);
atp_writeb_base(atpdev, 0x3a, k & 0xdf);
mdelay(32);
msleep(32);
atp_writeb_base(atpdev, 0x3a, k);
mdelay(32);
msleep(32);
atp_set_host_id(atpdev, 0, host_id);

tscam(shpnt, wide_chip, scam_on);
Expand Down Expand Up @@ -1370,9 +1370,9 @@ static void atp880_init(struct Scsi_Host *shpnt)
k = atp_readb_base(atpdev, 0x38) & 0x80;
atp_writeb_base(atpdev, 0x38, k);
atp_writeb_base(atpdev, 0x3b, 0x20);
mdelay(32);
msleep(32);
atp_writeb_base(atpdev, 0x3b, 0);
mdelay(32);
msleep(32);
atp_readb_io(atpdev, 0, 0x1b);
atp_readb_io(atpdev, 0, 0x17);

Expand Down Expand Up @@ -1454,10 +1454,10 @@ static void atp885_init(struct Scsi_Host *shpnt)
atp_writeb_base(atpdev, 0x28, k);
atp_writeb_pci(atpdev, 0, 1, 0x80);
atp_writeb_pci(atpdev, 1, 1, 0x80);
mdelay(100);
msleep(100);
atp_writeb_pci(atpdev, 0, 1, 0);
atp_writeb_pci(atpdev, 1, 1, 0);
mdelay(1000);
msleep(1000);
atp_readb_io(atpdev, 0, 0x1b);
atp_readb_io(atpdev, 0, 0x17);
atp_readb_io(atpdev, 1, 0x1b);
Expand All @@ -1473,7 +1473,7 @@ static void atp885_init(struct Scsi_Host *shpnt)
k = (k & 0x07) | 0x40;
atp_set_host_id(atpdev, 1, k);

mdelay(600); /* this delay used to be called tscam_885() */
msleep(600); /* this delay used to be called tscam_885() */
dev_info(&pdev->dev, "Scanning Channel A SCSI Device ...\n");
atp_is(atpdev, 0, true, atp_readb_io(atpdev, 0, 0x1b) >> 7);
atp_writeb_io(atpdev, 0, 0x16, 0x80);
Expand Down

0 comments on commit dcaa0c1

Please sign in to comment.