aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/scsi
diff options
context:
space:
mode:
authorTejun Heo <htejun@gmail.com>2006-02-11 05:11:13 -0500
committerJeff Garzik <jgarzik@pobox.com>2006-02-11 17:51:57 -0500
commita46314744d8fadb91451bf2e5d2fd949c4a752d8 (patch)
tree46757778593f4d24d4b69a5cefd522d22d60abcf /drivers/scsi
parent4bd00f6a201897af4cd50250a761e6bc4b2221ec (diff)
[PATCH] libata: convert assert(X)'s in libata core layer to WARN_ON(!X)'s
In an effort to kill libata-specific assert() and use generic WARN_ON(), this patch converts all assert(X)'s in libata core layer to WARN_ON(!X)'s. Most conversions are straight-forward logical negation exception for the followings. * In libata-core.c:ata_fill_sg(), assert(qc->n_elem > 0) is converted to WARN_ON(qc->n_elem == 0) because qc->n_elem is unsigned and unsigned <= 0 is weird. * In libata-scsi.c:ata_gen_ata_desc/fixed_sense(), assert(NULL != qc->ap->ops->tf_read) is converted to WARN_ON(qc->ap->ops->tf_read == NULL), as there are no other users of 'constant cond var' style in libata. Signed-off-by: Tejun Heo <htejun@gmail.com> Signed-off-by: Jeff Garzik <jgarzik@pobox.com>
Diffstat (limited to 'drivers/scsi')
-rw-r--r--drivers/scsi/libata-core.c46
-rw-r--r--drivers/scsi/libata-scsi.c14
2 files changed, 30 insertions, 30 deletions
diff --git a/drivers/scsi/libata-core.c b/drivers/scsi/libata-core.c
index fffbaa9dae76..cef85e515c4c 100644
--- a/drivers/scsi/libata-core.c
+++ b/drivers/scsi/libata-core.c
@@ -904,8 +904,8 @@ static void ata_dev_identify(struct ata_port *ap, unsigned int device)
904 904
905 DPRINTK("ENTER, host %u, dev %u\n", ap->id, device); 905 DPRINTK("ENTER, host %u, dev %u\n", ap->id, device);
906 906
907 assert (dev->class == ATA_DEV_ATA || dev->class == ATA_DEV_ATAPI || 907 WARN_ON(dev->class != ATA_DEV_ATA && dev->class != ATA_DEV_ATAPI &&
908 dev->class == ATA_DEV_NONE); 908 dev->class != ATA_DEV_NONE);
909 909
910 ata_dev_select(ap, device, 1, 1); /* select device 0/1 */ 910 ata_dev_select(ap, device, 1, 1); /* select device 0/1 */
911 911
@@ -2301,7 +2301,7 @@ static unsigned int ata_get_mode_mask(const struct ata_port *ap, int shift)
2301 master = &ap->device[0]; 2301 master = &ap->device[0];
2302 slave = &ap->device[1]; 2302 slave = &ap->device[1];
2303 2303
2304 assert (ata_dev_present(master) || ata_dev_present(slave)); 2304 WARN_ON(!ata_dev_present(master) && !ata_dev_present(slave));
2305 2305
2306 if (shift == ATA_SHIFT_UDMA) { 2306 if (shift == ATA_SHIFT_UDMA) {
2307 mask = ap->udma_mask; 2307 mask = ap->udma_mask;
@@ -2547,11 +2547,11 @@ static void ata_sg_clean(struct ata_queued_cmd *qc)
2547 int dir = qc->dma_dir; 2547 int dir = qc->dma_dir;
2548 void *pad_buf = NULL; 2548 void *pad_buf = NULL;
2549 2549
2550 assert(qc->flags & ATA_QCFLAG_DMAMAP); 2550 WARN_ON(!(qc->flags & ATA_QCFLAG_DMAMAP));
2551 assert(sg != NULL); 2551 WARN_ON(sg == NULL);
2552 2552
2553 if (qc->flags & ATA_QCFLAG_SINGLE) 2553 if (qc->flags & ATA_QCFLAG_SINGLE)
2554 assert(qc->n_elem == 1); 2554 WARN_ON(qc->n_elem != 1);
2555 2555
2556 VPRINTK("unmapping %u sg elements\n", qc->n_elem); 2556 VPRINTK("unmapping %u sg elements\n", qc->n_elem);
2557 2557
@@ -2606,8 +2606,8 @@ static void ata_fill_sg(struct ata_queued_cmd *qc)
2606 struct scatterlist *sg; 2606 struct scatterlist *sg;
2607 unsigned int idx; 2607 unsigned int idx;
2608 2608
2609 assert(qc->__sg != NULL); 2609 WARN_ON(qc->__sg == NULL);
2610 assert(qc->n_elem > 0); 2610 WARN_ON(qc->n_elem == 0);
2611 2611
2612 idx = 0; 2612 idx = 0;
2613 ata_for_each_sg(sg, qc) { 2613 ata_for_each_sg(sg, qc) {
@@ -2759,7 +2759,7 @@ static int ata_sg_setup_one(struct ata_queued_cmd *qc)
2759 void *pad_buf = ap->pad + (qc->tag * ATA_DMA_PAD_SZ); 2759 void *pad_buf = ap->pad + (qc->tag * ATA_DMA_PAD_SZ);
2760 struct scatterlist *psg = &qc->pad_sgent; 2760 struct scatterlist *psg = &qc->pad_sgent;
2761 2761
2762 assert(qc->dev->class == ATA_DEV_ATAPI); 2762 WARN_ON(qc->dev->class != ATA_DEV_ATAPI);
2763 2763
2764 memset(pad_buf, 0, ATA_DMA_PAD_SZ); 2764 memset(pad_buf, 0, ATA_DMA_PAD_SZ);
2765 2765
@@ -2821,7 +2821,7 @@ static int ata_sg_setup(struct ata_queued_cmd *qc)
2821 int n_elem, pre_n_elem, dir, trim_sg = 0; 2821 int n_elem, pre_n_elem, dir, trim_sg = 0;
2822 2822
2823 VPRINTK("ENTER, ata%u\n", ap->id); 2823 VPRINTK("ENTER, ata%u\n", ap->id);
2824 assert(qc->flags & ATA_QCFLAG_SG); 2824 WARN_ON(!(qc->flags & ATA_QCFLAG_SG));
2825 2825
2826 /* we must lengthen transfers to end on a 32-bit boundary */ 2826 /* we must lengthen transfers to end on a 32-bit boundary */
2827 qc->pad_len = lsg->length & 3; 2827 qc->pad_len = lsg->length & 3;
@@ -2830,7 +2830,7 @@ static int ata_sg_setup(struct ata_queued_cmd *qc)
2830 struct scatterlist *psg = &qc->pad_sgent; 2830 struct scatterlist *psg = &qc->pad_sgent;
2831 unsigned int offset; 2831 unsigned int offset;
2832 2832
2833 assert(qc->dev->class == ATA_DEV_ATAPI); 2833 WARN_ON(qc->dev->class != ATA_DEV_ATAPI);
2834 2834
2835 memset(pad_buf, 0, ATA_DMA_PAD_SZ); 2835 memset(pad_buf, 0, ATA_DMA_PAD_SZ);
2836 2836
@@ -2924,7 +2924,7 @@ static unsigned long ata_pio_poll(struct ata_port *ap)
2924 unsigned int reg_state = HSM_ST_UNKNOWN; 2924 unsigned int reg_state = HSM_ST_UNKNOWN;
2925 2925
2926 qc = ata_qc_from_tag(ap, ap->active_tag); 2926 qc = ata_qc_from_tag(ap, ap->active_tag);
2927 assert(qc != NULL); 2927 WARN_ON(qc == NULL);
2928 2928
2929 switch (ap->hsm_task_state) { 2929 switch (ap->hsm_task_state) {
2930 case HSM_ST: 2930 case HSM_ST:
@@ -2992,7 +2992,7 @@ static int ata_pio_complete (struct ata_port *ap)
2992 } 2992 }
2993 2993
2994 qc = ata_qc_from_tag(ap, ap->active_tag); 2994 qc = ata_qc_from_tag(ap, ap->active_tag);
2995 assert(qc != NULL); 2995 WARN_ON(qc == NULL);
2996 2996
2997 drv_stat = ata_wait_idle(ap); 2997 drv_stat = ata_wait_idle(ap);
2998 if (!ata_ok(drv_stat)) { 2998 if (!ata_ok(drv_stat)) {
@@ -3003,7 +3003,7 @@ static int ata_pio_complete (struct ata_port *ap)
3003 3003
3004 ap->hsm_task_state = HSM_ST_IDLE; 3004 ap->hsm_task_state = HSM_ST_IDLE;
3005 3005
3006 assert(qc->err_mask == 0); 3006 WARN_ON(qc->err_mask);
3007 ata_poll_qc_complete(qc); 3007 ata_poll_qc_complete(qc);
3008 3008
3009 /* another command may start at this point */ 3009 /* another command may start at this point */
@@ -3360,7 +3360,7 @@ static void ata_pio_block(struct ata_port *ap)
3360 } 3360 }
3361 3361
3362 qc = ata_qc_from_tag(ap, ap->active_tag); 3362 qc = ata_qc_from_tag(ap, ap->active_tag);
3363 assert(qc != NULL); 3363 WARN_ON(qc == NULL);
3364 3364
3365 /* check error */ 3365 /* check error */
3366 if (status & (ATA_ERR | ATA_DF)) { 3366 if (status & (ATA_ERR | ATA_DF)) {
@@ -3397,12 +3397,12 @@ static void ata_pio_error(struct ata_port *ap)
3397 printk(KERN_WARNING "ata%u: PIO error\n", ap->id); 3397 printk(KERN_WARNING "ata%u: PIO error\n", ap->id);
3398 3398
3399 qc = ata_qc_from_tag(ap, ap->active_tag); 3399 qc = ata_qc_from_tag(ap, ap->active_tag);
3400 assert(qc != NULL); 3400 WARN_ON(qc == NULL);
3401 3401
3402 /* make sure qc->err_mask is available to 3402 /* make sure qc->err_mask is available to
3403 * know what's wrong and recover 3403 * know what's wrong and recover
3404 */ 3404 */
3405 assert(qc->err_mask); 3405 WARN_ON(qc->err_mask == 0);
3406 3406
3407 ap->hsm_task_state = HSM_ST_IDLE; 3407 ap->hsm_task_state = HSM_ST_IDLE;
3408 3408
@@ -3609,7 +3609,7 @@ void ata_qc_free(struct ata_queued_cmd *qc)
3609 struct ata_port *ap = qc->ap; 3609 struct ata_port *ap = qc->ap;
3610 unsigned int tag; 3610 unsigned int tag;
3611 3611
3612 assert(qc != NULL); /* ata_qc_from_tag _might_ return NULL */ 3612 WARN_ON(qc == NULL); /* ata_qc_from_tag _might_ return NULL */
3613 3613
3614 qc->flags = 0; 3614 qc->flags = 0;
3615 tag = qc->tag; 3615 tag = qc->tag;
@@ -3623,8 +3623,8 @@ void ata_qc_free(struct ata_queued_cmd *qc)
3623 3623
3624void __ata_qc_complete(struct ata_queued_cmd *qc) 3624void __ata_qc_complete(struct ata_queued_cmd *qc)
3625{ 3625{
3626 assert(qc != NULL); /* ata_qc_from_tag _might_ return NULL */ 3626 WARN_ON(qc == NULL); /* ata_qc_from_tag _might_ return NULL */
3627 assert(qc->flags & ATA_QCFLAG_ACTIVE); 3627 WARN_ON(!(qc->flags & ATA_QCFLAG_ACTIVE));
3628 3628
3629 if (likely(qc->flags & ATA_QCFLAG_DMAMAP)) 3629 if (likely(qc->flags & ATA_QCFLAG_DMAMAP))
3630 ata_sg_clean(qc); 3630 ata_sg_clean(qc);
@@ -4155,8 +4155,8 @@ static void atapi_packet_task(void *_data)
4155 u8 status; 4155 u8 status;
4156 4156
4157 qc = ata_qc_from_tag(ap, ap->active_tag); 4157 qc = ata_qc_from_tag(ap, ap->active_tag);
4158 assert(qc != NULL); 4158 WARN_ON(qc == NULL);
4159 assert(qc->flags & ATA_QCFLAG_ACTIVE); 4159 WARN_ON(!(qc->flags & ATA_QCFLAG_ACTIVE));
4160 4160
4161 /* sleep-wait for BSY to clear */ 4161 /* sleep-wait for BSY to clear */
4162 DPRINTK("busy wait\n"); 4162 DPRINTK("busy wait\n");
@@ -4174,7 +4174,7 @@ static void atapi_packet_task(void *_data)
4174 4174
4175 /* send SCSI cdb */ 4175 /* send SCSI cdb */
4176 DPRINTK("send cdb\n"); 4176 DPRINTK("send cdb\n");
4177 assert(ap->cdb_len >= 12); 4177 WARN_ON(ap->cdb_len < 12);
4178 4178
4179 if (qc->tf.protocol == ATA_PROT_ATAPI_DMA || 4179 if (qc->tf.protocol == ATA_PROT_ATAPI_DMA ||
4180 qc->tf.protocol == ATA_PROT_ATAPI_NODATA) { 4180 qc->tf.protocol == ATA_PROT_ATAPI_NODATA) {
diff --git a/drivers/scsi/libata-scsi.c b/drivers/scsi/libata-scsi.c
index 9d67c6768335..26f07a2617f9 100644
--- a/drivers/scsi/libata-scsi.c
+++ b/drivers/scsi/libata-scsi.c
@@ -553,7 +553,7 @@ void ata_gen_ata_desc_sense(struct ata_queued_cmd *qc)
553 /* 553 /*
554 * Read the controller registers. 554 * Read the controller registers.
555 */ 555 */
556 assert(NULL != qc->ap->ops->tf_read); 556 WARN_ON(qc->ap->ops->tf_read == NULL);
557 qc->ap->ops->tf_read(qc->ap, tf); 557 qc->ap->ops->tf_read(qc->ap, tf);
558 558
559 /* 559 /*
@@ -628,7 +628,7 @@ void ata_gen_fixed_sense(struct ata_queued_cmd *qc)
628 /* 628 /*
629 * Read the controller registers. 629 * Read the controller registers.
630 */ 630 */
631 assert(NULL != qc->ap->ops->tf_read); 631 WARN_ON(qc->ap->ops->tf_read == NULL);
632 qc->ap->ops->tf_read(qc->ap, tf); 632 qc->ap->ops->tf_read(qc->ap, tf);
633 633
634 /* 634 /*
@@ -746,7 +746,7 @@ enum scsi_eh_timer_return ata_scsi_timed_out(struct scsi_cmnd *cmd)
746 spin_lock_irqsave(&ap->host_set->lock, flags); 746 spin_lock_irqsave(&ap->host_set->lock, flags);
747 qc = ata_qc_from_tag(ap, ap->active_tag); 747 qc = ata_qc_from_tag(ap, ap->active_tag);
748 if (qc) { 748 if (qc) {
749 assert(qc->scsicmd == cmd); 749 WARN_ON(qc->scsicmd != cmd);
750 qc->flags |= ATA_QCFLAG_EH_SCHEDULED; 750 qc->flags |= ATA_QCFLAG_EH_SCHEDULED;
751 qc->err_mask |= AC_ERR_TIMEOUT; 751 qc->err_mask |= AC_ERR_TIMEOUT;
752 ret = EH_NOT_HANDLED; 752 ret = EH_NOT_HANDLED;
@@ -780,14 +780,14 @@ int ata_scsi_error(struct Scsi_Host *host)
780 ap = (struct ata_port *) &host->hostdata[0]; 780 ap = (struct ata_port *) &host->hostdata[0];
781 781
782 spin_lock_irqsave(&ap->host_set->lock, flags); 782 spin_lock_irqsave(&ap->host_set->lock, flags);
783 assert(!(ap->flags & ATA_FLAG_IN_EH)); 783 WARN_ON(ap->flags & ATA_FLAG_IN_EH);
784 ap->flags |= ATA_FLAG_IN_EH; 784 ap->flags |= ATA_FLAG_IN_EH;
785 assert(ata_qc_from_tag(ap, ap->active_tag) != NULL); 785 WARN_ON(ata_qc_from_tag(ap, ap->active_tag) == NULL);
786 spin_unlock_irqrestore(&ap->host_set->lock, flags); 786 spin_unlock_irqrestore(&ap->host_set->lock, flags);
787 787
788 ap->ops->eng_timeout(ap); 788 ap->ops->eng_timeout(ap);
789 789
790 assert(host->host_failed == 0 && list_empty(&host->eh_cmd_q)); 790 WARN_ON(host->host_failed || !list_empty(&host->eh_cmd_q));
791 791
792 scsi_eh_flush_done_q(&ap->eh_done_q); 792 scsi_eh_flush_done_q(&ap->eh_done_q);
793 793
@@ -813,7 +813,7 @@ static void __ata_eh_qc_complete(struct ata_queued_cmd *qc)
813 spin_lock_irqsave(&ap->host_set->lock, flags); 813 spin_lock_irqsave(&ap->host_set->lock, flags);
814 qc->scsidone = ata_eh_scsidone; 814 qc->scsidone = ata_eh_scsidone;
815 __ata_qc_complete(qc); 815 __ata_qc_complete(qc);
816 assert(!ata_tag_valid(qc->tag)); 816 WARN_ON(ata_tag_valid(qc->tag));
817 spin_unlock_irqrestore(&ap->host_set->lock, flags); 817 spin_unlock_irqrestore(&ap->host_set->lock, flags);
818 818
819 scsi_eh_finish_cmd(scmd, &ap->eh_done_q); 819 scsi_eh_finish_cmd(scmd, &ap->eh_done_q);