dma-mapping: use unsigned long for dma_attrs
authorKrzysztof Kozlowski <k.kozlowski@samsung.com>
Wed, 3 Aug 2016 20:46:00 +0000 (13:46 -0700)
committerLinus Torvalds <torvalds@linux-foundation.org>
Thu, 4 Aug 2016 12:50:07 +0000 (08:50 -0400)
commit00085f1efa387a8ce100e3734920f7639c80caa3
tree41ff3d6e6884918b4fc4f1ae96a284098167c5b0
parent1605d2715ad2e67ddd0485a26e05ed670a4285ca
dma-mapping: use unsigned long for dma_attrs

The dma-mapping core and the implementations do not change the DMA
attributes passed by pointer.  Thus the pointer can point to const data.
However the attributes do not have to be a bitfield.  Instead unsigned
long will do fine:

1. This is just simpler.  Both in terms of reading the code and setting
   attributes.  Instead of initializing local attributes on the stack
   and passing pointer to it to dma_set_attr(), just set the bits.

2. It brings safeness and checking for const correctness because the
   attributes are passed by value.

Semantic patches for this change (at least most of them):

    virtual patch
    virtual context

    @r@
    identifier f, attrs;

    @@
    f(...,
    - struct dma_attrs *attrs
    + unsigned long attrs
    , ...)
    {
    ...
    }

    @@
    identifier r.f;
    @@
    f(...,
    - NULL
    + 0
     )

and

    // Options: --all-includes
    virtual patch
    virtual context

    @r@
    identifier f, attrs;
    type t;

    @@
    t f(..., struct dma_attrs *attrs);

    @@
    identifier r.f;
    @@
    f(...,
    - NULL
    + 0
     )

Link: http://lkml.kernel.org/r/1468399300-5399-2-git-send-email-k.kozlowski@samsung.com
Signed-off-by: Krzysztof Kozlowski <k.kozlowski@samsung.com>
Acked-by: Vineet Gupta <vgupta@synopsys.com>
Acked-by: Robin Murphy <robin.murphy@arm.com>
Acked-by: Hans-Christian Noren Egtvedt <egtvedt@samfundet.no>
Acked-by: Mark Salter <msalter@redhat.com> [c6x]
Acked-by: Jesper Nilsson <jesper.nilsson@axis.com> [cris]
Acked-by: Daniel Vetter <daniel.vetter@ffwll.ch> [drm]
Reviewed-by: Bart Van Assche <bart.vanassche@sandisk.com>
Acked-by: Joerg Roedel <jroedel@suse.de> [iommu]
Acked-by: Fabien Dessenne <fabien.dessenne@st.com> [bdisp]
Reviewed-by: Marek Szyprowski <m.szyprowski@samsung.com> [vb2-core]
Acked-by: David Vrabel <david.vrabel@citrix.com> [xen]
Acked-by: Konrad Rzeszutek Wilk <konrad.wilk@oracle.com> [xen swiotlb]
Acked-by: Joerg Roedel <jroedel@suse.de> [iommu]
Acked-by: Richard Kuo <rkuo@codeaurora.org> [hexagon]
Acked-by: Geert Uytterhoeven <geert@linux-m68k.org> [m68k]
Acked-by: Gerald Schaefer <gerald.schaefer@de.ibm.com> [s390]
Acked-by: Bjorn Andersson <bjorn.andersson@linaro.org>
Acked-by: Hans-Christian Noren Egtvedt <egtvedt@samfundet.no> [avr32]
Acked-by: Vineet Gupta <vgupta@synopsys.com> [arc]
Acked-by: Robin Murphy <robin.murphy@arm.com> [arm64 and dma-iommu]
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
111 files changed:
Documentation/DMA-API.txt
Documentation/DMA-attributes.txt
arch/alpha/include/asm/dma-mapping.h
arch/alpha/kernel/pci-noop.c
arch/alpha/kernel/pci_iommu.c
arch/arc/mm/dma.c
arch/arm/common/dmabounce.c
arch/arm/include/asm/dma-mapping.h
arch/arm/include/asm/xen/page-coherent.h
arch/arm/mm/dma-mapping.c
arch/arm/xen/mm.c
arch/arm64/mm/dma-mapping.c
arch/avr32/mm/dma-coherent.c
arch/blackfin/kernel/dma-mapping.c
arch/c6x/include/asm/dma-mapping.h
arch/c6x/kernel/dma.c
arch/c6x/mm/dma-coherent.c
arch/cris/arch-v32/drivers/pci/dma.c
arch/frv/mb93090-mb00/pci-dma-nommu.c
arch/frv/mb93090-mb00/pci-dma.c
arch/h8300/kernel/dma.c
arch/hexagon/include/asm/dma-mapping.h
arch/hexagon/kernel/dma.c
arch/ia64/hp/common/sba_iommu.c
arch/ia64/include/asm/machvec.h
arch/ia64/kernel/pci-swiotlb.c
arch/ia64/sn/pci/pci_dma.c
arch/m68k/kernel/dma.c
arch/metag/kernel/dma.c
arch/microblaze/include/asm/dma-mapping.h
arch/microblaze/kernel/dma.c
arch/mips/cavium-octeon/dma-octeon.c
arch/mips/loongson64/common/dma-swiotlb.c
arch/mips/mm/dma-default.c
arch/mips/netlogic/common/nlm-dma.c
arch/mn10300/mm/dma-alloc.c
arch/nios2/mm/dma-mapping.c
arch/openrisc/kernel/dma.c
arch/parisc/kernel/pci-dma.c
arch/powerpc/include/asm/dma-mapping.h
arch/powerpc/include/asm/iommu.h
arch/powerpc/kernel/dma-iommu.c
arch/powerpc/kernel/dma.c
arch/powerpc/kernel/ibmebus.c
arch/powerpc/kernel/iommu.c
arch/powerpc/kernel/vio.c
arch/powerpc/platforms/cell/iommu.c
arch/powerpc/platforms/pasemi/iommu.c
arch/powerpc/platforms/powernv/npu-dma.c
arch/powerpc/platforms/powernv/pci-ioda.c
arch/powerpc/platforms/powernv/pci.c
arch/powerpc/platforms/powernv/pci.h
arch/powerpc/platforms/ps3/system-bus.c
arch/powerpc/platforms/pseries/iommu.c
arch/powerpc/sysdev/dart_iommu.c
arch/s390/include/asm/dma-mapping.h
arch/s390/pci/pci_dma.c
arch/sh/include/asm/dma-mapping.h
arch/sh/kernel/dma-nommu.c
arch/sh/mm/consistent.c
arch/sparc/kernel/iommu.c
arch/sparc/kernel/ioport.c
arch/sparc/kernel/pci_sun4v.c
arch/tile/kernel/pci-dma.c
arch/unicore32/mm/dma-swiotlb.c
arch/x86/include/asm/dma-mapping.h
arch/x86/include/asm/swiotlb.h
arch/x86/include/asm/xen/page-coherent.h
arch/x86/kernel/amd_gart_64.c
arch/x86/kernel/pci-calgary_64.c
arch/x86/kernel/pci-dma.c
arch/x86/kernel/pci-nommu.c
arch/x86/kernel/pci-swiotlb.c
arch/x86/pci/sta2x11-fixup.c
arch/x86/pci/vmd.c
arch/xtensa/kernel/pci-dma.c
drivers/gpu/drm/exynos/exynos_drm_fbdev.c
drivers/gpu/drm/exynos/exynos_drm_g2d.c
drivers/gpu/drm/exynos/exynos_drm_gem.c
drivers/gpu/drm/exynos/exynos_drm_gem.h
drivers/gpu/drm/mediatek/mtk_drm_gem.c
drivers/gpu/drm/mediatek/mtk_drm_gem.h
drivers/gpu/drm/msm/msm_drv.c
drivers/gpu/drm/nouveau/nvkm/subdev/instmem/gk20a.c
drivers/gpu/drm/rockchip/rockchip_drm_gem.c
drivers/gpu/drm/rockchip/rockchip_drm_gem.h
drivers/infiniband/core/umem.c
drivers/iommu/amd_iommu.c
drivers/iommu/dma-iommu.c
drivers/iommu/intel-iommu.c
drivers/media/platform/sti/bdisp/bdisp-hw.c
drivers/media/v4l2-core/videobuf2-dma-contig.c
drivers/media/v4l2-core/videobuf2-dma-sg.c
drivers/media/v4l2-core/videobuf2-vmalloc.c
drivers/misc/mic/host/mic_boot.c
drivers/parisc/ccio-dma.c
drivers/parisc/sba_iommu.c
drivers/remoteproc/qcom_q6v5_pil.c
drivers/video/fbdev/omap2/omapfb/omapfb-main.c
drivers/video/fbdev/omap2/omapfb/omapfb.h
drivers/xen/swiotlb-xen.c
include/linux/dma-attrs.h [deleted file]
include/linux/dma-iommu.h
include/linux/dma-mapping.h
include/linux/swiotlb.h
include/media/videobuf2-core.h
include/media/videobuf2-dma-contig.h
include/rdma/ib_verbs.h
include/xen/swiotlb-xen.h
lib/dma-noop.c
lib/swiotlb.c