Skip to content

Commit d7e02a9

Browse files
author
Christoph Hellwig
committed
dma-mapping: remove leftover NULL device support
Most dma_map_ops implementations already had some issues with a NULL device, or did simply crash if one was fed to them. Now that we have cleaned up all the obvious offenders we can stop to pretend we support this mode. Signed-off-by: Christoph Hellwig <hch@lst.de>
1 parent 5ab6a91 commit d7e02a9

3 files changed

Lines changed: 10 additions & 11 deletions

File tree

‎Documentation/DMA-API-HOWTO.txt‎

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -365,13 +365,12 @@ __get_free_pages() (but takes size instead of a page order). If your
365365
driver needs regions sized smaller than a page, you may prefer using
366366
the dma_pool interface, described below.
367367

368-
The consistent DMA mapping interfaces, for non-NULL dev, will by
369-
default return a DMA address which is 32-bit addressable. Even if the
370-
device indicates (via DMA mask) that it may address the upper 32-bits,
371-
consistent allocation will only return > 32-bit addresses for DMA if
372-
the consistent DMA mask has been explicitly changed via
373-
dma_set_coherent_mask(). This is true of the dma_pool interface as
374-
well.
368+
The consistent DMA mapping interfaces, will by default return a DMA address
369+
which is 32-bit addressable. Even if the device indicates (via the DMA mask)
370+
that it may address the upper 32-bits, consistent allocation will only
371+
return > 32-bit addresses for DMA if the consistent DMA mask has been
372+
explicitly changed via dma_set_coherent_mask(). This is true of the
373+
dma_pool interface as well.
375374

376375
dma_alloc_coherent() returns two values: the virtual address which you
377376
can use to access it from the CPU and dma_handle which you pass to the

‎include/linux/dma-mapping.h‎

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -267,9 +267,9 @@ size_t dma_direct_max_mapping_size(struct device *dev);
267267

268268
static inline const struct dma_map_ops *get_dma_ops(struct device *dev)
269269
{
270-
if (dev && dev->dma_ops)
270+
if (dev->dma_ops)
271271
return dev->dma_ops;
272-
return get_arch_dma_ops(dev ? dev->bus : NULL);
272+
return get_arch_dma_ops(dev->bus);
273273
}
274274

275275
static inline void set_dma_ops(struct device *dev,
@@ -650,7 +650,7 @@ static inline void dma_free_coherent(struct device *dev, size_t size,
650650

651651
static inline u64 dma_get_mask(struct device *dev)
652652
{
653-
if (dev && dev->dma_mask && *dev->dma_mask)
653+
if (dev->dma_mask && *dev->dma_mask)
654654
return *dev->dma_mask;
655655
return DMA_BIT_MASK(32);
656656
}

‎kernel/dma/direct.c‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -311,7 +311,7 @@ static inline bool dma_direct_possible(struct device *dev, dma_addr_t dma_addr,
311311
size_t size)
312312
{
313313
return swiotlb_force != SWIOTLB_FORCE &&
314-
(!dev || dma_capable(dev, dma_addr, size));
314+
dma_capable(dev, dma_addr, size);
315315
}
316316

317317
dma_addr_t dma_direct_map_page(struct device *dev, struct page *page,

0 commit comments

Comments
 (0)