From: Geert Uytterhoeven <geert@linux-m68k.org>
To: Tejun Heo <tj@kernel.org>,
Bartlomiej Zolnierkiewicz <b.zolnierkie@samsung.com>
Cc: linux-ide@vger.kernel.org, linux-m68k@vger.kernel.org,
linux-kernel@vger.kernel.org,
Geert Uytterhoeven <geert@linux-m68k.org>
Subject: [PATCH 6/6] libata: Protect DMA core code by #ifdef CONFIG_HAS_DMA
Date: Tue, 3 Jan 2017 19:09:49 +0100 [thread overview]
Message-ID: <1483466989-9091-7-git-send-email-geert@linux-m68k.org> (raw)
In-Reply-To: <1483466989-9091-1-git-send-email-geert@linux-m68k.org>
If NO_DMA=y:
ERROR: "bad_dma_ops" [drivers/ata/libata.ko] undefined!
To fix this, protect the DMA code by #ifdef CONFIG_HAS_DMA, and provide
dummies of ata_sg_clean() and ata_sg_setup() for the !CONFIG_HAS_DMA
case.
Signed-off-by: Geert Uytterhoeven <geert@linux-m68k.org>
---
drivers/ata/libata-core.c | 61 +++++++++++++++++++++++++++--------------------
1 file changed, 35 insertions(+), 26 deletions(-)
diff --git a/drivers/ata/libata-core.c b/drivers/ata/libata-core.c
index a7e3df5abaa3124f..dc70b5f997f1f13e 100644
--- a/drivers/ata/libata-core.c
+++ b/drivers/ata/libata-core.c
@@ -4814,32 +4814,6 @@ static unsigned int ata_dev_init_params(struct ata_device *dev,
}
/**
- * ata_sg_clean - Unmap DMA memory associated with command
- * @qc: Command containing DMA memory to be released
- *
- * Unmap all mapped DMA memory associated with this command.
- *
- * LOCKING:
- * spin_lock_irqsave(host lock)
- */
-static void ata_sg_clean(struct ata_queued_cmd *qc)
-{
- struct ata_port *ap = qc->ap;
- struct scatterlist *sg = qc->sg;
- int dir = qc->dma_dir;
-
- WARN_ON_ONCE(sg == NULL);
-
- VPRINTK("unmapping %u sg elements\n", qc->n_elem);
-
- if (qc->n_elem)
- dma_unmap_sg(ap->dev, sg, qc->orig_n_elem, dir);
-
- qc->flags &= ~ATA_QCFLAG_DMAMAP;
- qc->sg = NULL;
-}
-
-/**
* atapi_check_dma - Check whether ATAPI DMA can be supported
* @qc: Metadata associated with taskfile to check
*
@@ -4923,6 +4897,34 @@ void ata_sg_init(struct ata_queued_cmd *qc, struct scatterlist *sg,
qc->cursg = qc->sg;
}
+#ifdef CONFIG_HAS_DMA
+
+/**
+ * ata_sg_clean - Unmap DMA memory associated with command
+ * @qc: Command containing DMA memory to be released
+ *
+ * Unmap all mapped DMA memory associated with this command.
+ *
+ * LOCKING:
+ * spin_lock_irqsave(host lock)
+ */
+void ata_sg_clean(struct ata_queued_cmd *qc)
+{
+ struct ata_port *ap = qc->ap;
+ struct scatterlist *sg = qc->sg;
+ int dir = qc->dma_dir;
+
+ WARN_ON_ONCE(sg == NULL);
+
+ VPRINTK("unmapping %u sg elements\n", qc->n_elem);
+
+ if (qc->n_elem)
+ dma_unmap_sg(ap->dev, sg, qc->orig_n_elem, dir);
+
+ qc->flags &= ~ATA_QCFLAG_DMAMAP;
+ qc->sg = NULL;
+}
+
/**
* ata_sg_setup - DMA-map the scatter-gather table associated with a command.
* @qc: Command with scatter-gather table to be mapped.
@@ -4955,6 +4957,13 @@ static int ata_sg_setup(struct ata_queued_cmd *qc)
return 0;
}
+#else /* !CONFIG_HAS_DMA */
+
+static inline void ata_sg_clean(struct ata_queued_cmd *qc) {}
+static inline int ata_sg_setup(struct ata_queued_cmd *qc) { return -1; }
+
+#endif /* !CONFIG_HAS_DMA */
+
/**
* swap_buf_le16 - swap halves of 16-bit words in place
* @buf: Buffer to swap
--
1.9.1
next prev parent reply other threads:[~2017-01-03 18:14 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-01-03 18:09 [PATCH 0/6] ata: Missing HAS_DMA dependencies Geert Uytterhoeven
2017-01-03 18:09 ` [PATCH 1/6] ata: SATA_MV should depend on HAS_DMA Geert Uytterhoeven
2017-01-03 18:09 ` [PATCH 2/6] ata: SATA_HIGHBANK " Geert Uytterhoeven
2017-01-03 18:09 ` [PATCH 3/6] ata: ATA_BMDMA " Geert Uytterhoeven
2017-01-03 18:09 ` [PATCH 4/6] ata: AHCI and other non-SFF native drivers " Geert Uytterhoeven
2017-01-03 18:09 ` [PATCH 5/6] libata: Make ata_sg_clean() static again Geert Uytterhoeven
2017-01-03 18:09 ` Geert Uytterhoeven [this message]
2017-01-06 16:37 ` [PATCH 0/6] ata: Missing HAS_DMA dependencies Tejun Heo
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1483466989-9091-7-git-send-email-geert@linux-m68k.org \
--to=geert@linux-m68k.org \
--cc=b.zolnierkie@samsung.com \
--cc=linux-ide@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-m68k@vger.kernel.org \
--cc=tj@kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).