lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-Id: <1450741676-5865-30-git-send-email-viro@ZenIV.linux.org.uk>
Date:	Mon, 21 Dec 2015 23:47:03 +0000
From:	Al Viro <viro@...IV.linux.org.uk>
To:	linux-kernel@...r.kernel.org
Cc:	Linus Torvalds <torvalds@...ux-foundation.org>
Subject: [POC][PATCH 30/83] sparc: get rid of pointless casts

From: Al Viro <viro@...iv.linux.org.uk>

Signed-off-by: Al Viro <viro@...iv.linux.org.uk>
---
 arch/sparc/include/asm/dma.h      |  2 +-
 arch/sparc/include/asm/iommu_64.h |  2 +-
 arch/sparc/kernel/iommu.c         |  8 ++++----
 arch/sparc/kernel/ioport.c        |  8 ++++----
 arch/sparc/kernel/irq_64.c        |  4 ++--
 arch/sparc/kernel/pci_fire.c      | 18 ++++++++----------
 arch/sparc/kernel/pci_sun4v.c     | 24 +++++++++++++-----------
 arch/sparc/mm/io-unit.c           |  9 ++++-----
 arch/sparc/mm/iommu.c             | 10 +++++-----
 9 files changed, 42 insertions(+), 43 deletions(-)

diff --git a/arch/sparc/include/asm/dma.h b/arch/sparc/include/asm/dma.h
index 3d434ef..9bf9f53 100644
--- a/arch/sparc/include/asm/dma.h
+++ b/arch/sparc/include/asm/dma.h
@@ -101,7 +101,7 @@ struct sparc32_dma_ops {
 	void (*release_scsi_one)(struct device *, __u32, unsigned long);
 	void (*release_scsi_sgl)(struct device *, struct scatterlist *,int);
 #ifdef CONFIG_SBUS
-	int (*map_dma_area)(struct device *, dma_addr_t *, unsigned long, unsigned long, int);
+	int (*map_dma_area)(struct device *, dma_addr_t *, void *, unsigned long, int);
 	void (*unmap_dma_area)(struct device *, unsigned long, int);
 #endif
 };
diff --git a/arch/sparc/include/asm/iommu_64.h b/arch/sparc/include/asm/iommu_64.h
index cd0d69f..e781f29 100644
--- a/arch/sparc/include/asm/iommu_64.h
+++ b/arch/sparc/include/asm/iommu_64.h
@@ -36,7 +36,7 @@ struct iommu {
 	unsigned long		iommu_tags;
 	unsigned long		iommu_ctxflush;
 	unsigned long		write_complete_reg;
-	unsigned long		dummy_page;
+	void			*dummy_page;
 	unsigned long		dummy_page_pa;
 	unsigned long		ctx_lowest_free;
 	DECLARE_BITMAP(ctx_bitmap, IOMMU_NUM_CTXS);
diff --git a/arch/sparc/kernel/iommu.c b/arch/sparc/kernel/iommu.c
index 18a40c6..47c2822 100644
--- a/arch/sparc/kernel/iommu.c
+++ b/arch/sparc/kernel/iommu.c
@@ -124,8 +124,8 @@ int iommu_table_init(struct iommu *iommu, int tsbsize,
 		printk(KERN_ERR "IOMMU: Error, gfp(dummy_page) failed.\n");
 		goto out_free_map;
 	}
-	iommu->dummy_page = (unsigned long) page_address(page);
-	memset((void *)iommu->dummy_page, 0, PAGE_SIZE);
+	iommu->dummy_page = page_address(page);
+	memset(iommu->dummy_page, 0, PAGE_SIZE);
 	iommu->dummy_page_pa = (unsigned long) __pa(iommu->dummy_page);
 
 	/* Now allocate and setup the IOMMU page table itself.  */
@@ -143,8 +143,8 @@ int iommu_table_init(struct iommu *iommu, int tsbsize,
 	return 0;
 
 out_free_dummy_page:
-	free_page((void *)iommu->dummy_page);
-	iommu->dummy_page = 0UL;
+	free_page(iommu->dummy_page);
+	iommu->dummy_page = NULL;
 
 out_free_map:
 	kfree(iommu->tbl.map);
diff --git a/arch/sparc/kernel/ioport.c b/arch/sparc/kernel/ioport.c
index 39b406a..3bd3481 100644
--- a/arch/sparc/kernel/ioport.c
+++ b/arch/sparc/kernel/ioport.c
@@ -264,7 +264,7 @@ static void *sbus_alloc_coherent(struct device *dev, size_t len,
 {
 	struct platform_device *op = to_platform_device(dev);
 	unsigned long len_total = PAGE_ALIGN(len);
-	unsigned long va;
+	void *va;
 	struct resource *res;
 	int order;
 
@@ -278,8 +278,8 @@ static void *sbus_alloc_coherent(struct device *dev, size_t len,
 	}
 
 	order = get_order(len_total);
-	va = __get_free_pages(gfp, order);
-	if (va == 0)
+	va = (void *)__get_free_pages(gfp, order);
+	if (!va)
 		goto err_nopages;
 
 	if ((res = kzalloc(sizeof(struct resource), GFP_KERNEL)) == NULL)
@@ -309,7 +309,7 @@ err_noiommu:
 err_nova:
 	kfree(res);
 err_nomem:
-	free_pages((void *)va, order);
+	free_pages(va, order);
 err_nopages:
 	return NULL;
 }
diff --git a/arch/sparc/kernel/irq_64.c b/arch/sparc/kernel/irq_64.c
index 24847b2..e2d198d 100644
--- a/arch/sparc/kernel/irq_64.c
+++ b/arch/sparc/kernel/irq_64.c
@@ -1033,11 +1033,11 @@ static void __init alloc_one_queue(unsigned long *pa_ptr, unsigned long qmask)
 static void __init init_cpu_send_mondo_info(struct trap_per_cpu *tb)
 {
 #ifdef CONFIG_SMP
-	unsigned long page;
+	void *page;
 
 	BUILD_BUG_ON((NR_CPUS * sizeof(u16)) > (PAGE_SIZE - 64));
 
-	page = (unsigned long)get_zeroed_page(GFP_KERNEL);
+	page = get_zeroed_page(GFP_KERNEL);
 	if (!page) {
 		prom_printf("SUN4V: Error, cannot allocate cpu mondo page.\n");
 		prom_halt();
diff --git a/arch/sparc/kernel/pci_fire.c b/arch/sparc/kernel/pci_fire.c
index b8ac1bb..ff44386 100644
--- a/arch/sparc/kernel/pci_fire.c
+++ b/arch/sparc/kernel/pci_fire.c
@@ -228,17 +228,18 @@ static int pci_fire_msi_teardown(struct pci_pbm_info *pbm, unsigned long msi)
 
 static int pci_fire_msiq_alloc(struct pci_pbm_info *pbm)
 {
-	unsigned long pages, order, i;
+	unsigned long order, i;
+	void *pages;
 
 	order = get_order(512 * 1024);
-	pages = __get_free_pages(GFP_KERNEL | __GFP_COMP, order);
-	if (pages == 0UL) {
+	pages = (void *)__get_free_pages(GFP_KERNEL | __GFP_COMP, order);
+	if (!pages) {
 		printk(KERN_ERR "MSI: Cannot allocate MSI queues (o=%lu).\n",
 		       order);
 		return -ENOMEM;
 	}
-	memset((char *)pages, 0, PAGE_SIZE << order);
-	pbm->msi_queues = (void *) pages;
+	memset(pages, 0, PAGE_SIZE << order);
+	pbm->msi_queues = pages;
 
 	upa_writeq((EVENT_QUEUE_BASE_ADDR_ALL_ONES |
 		    __pa(pbm->msi_queues)),
@@ -260,12 +261,9 @@ static int pci_fire_msiq_alloc(struct pci_pbm_info *pbm)
 
 static void pci_fire_msiq_free(struct pci_pbm_info *pbm)
 {
-	unsigned long pages, order;
+	void *pages = pbm->msi_queues;
 
-	order = get_order(512 * 1024);
-	pages = (unsigned long) pbm->msi_queues;
-
-	free_pages((void *)pages, order);
+	free_pages(pages, get_order(512 * 1024));
 
 	pbm->msi_queues = NULL;
 }
diff --git a/arch/sparc/kernel/pci_sun4v.c b/arch/sparc/kernel/pci_sun4v.c
index 3ea1937..9d84e4e 100644
--- a/arch/sparc/kernel/pci_sun4v.c
+++ b/arch/sparc/kernel/pci_sun4v.c
@@ -746,20 +746,21 @@ static int pci_sun4v_msi_teardown(struct pci_pbm_info *pbm, unsigned long msi)
 
 static int pci_sun4v_msiq_alloc(struct pci_pbm_info *pbm)
 {
-	unsigned long q_size, alloc_size, pages, order;
+	unsigned long q_size, alloc_size, order;
+	void *pages;
 	int i;
 
 	q_size = pbm->msiq_ent_count * sizeof(struct pci_sun4v_msiq_entry);
 	alloc_size = (pbm->msiq_num * q_size);
 	order = get_order(alloc_size);
-	pages = __get_free_pages(GFP_KERNEL | __GFP_COMP, order);
-	if (pages == 0UL) {
+	pages = (void *)__get_free_pages(GFP_KERNEL | __GFP_COMP, order);
+	if (!pages) {
 		printk(KERN_ERR "MSI: Cannot allocate MSI queues (o=%lu).\n",
 		       order);
 		return -ENOMEM;
 	}
-	memset((char *)pages, 0, PAGE_SIZE << order);
-	pbm->msi_queues = (void *) pages;
+	memset(pages, 0, PAGE_SIZE << order);
+	pbm->msi_queues = pages;
 
 	for (i = 0; i < pbm->msiq_num; i++) {
 		unsigned long err, base = __pa(pages + (i * q_size));
@@ -794,13 +795,14 @@ static int pci_sun4v_msiq_alloc(struct pci_pbm_info *pbm)
 	return 0;
 
 h_error:
-	free_pages((void *)pages, order);
+	free_pages(pages, order);
 	return -EINVAL;
 }
 
 static void pci_sun4v_msiq_free(struct pci_pbm_info *pbm)
 {
-	unsigned long q_size, alloc_size, pages, order;
+	unsigned long q_size, alloc_size, order;
+	void *pages;
 	int i;
 
 	for (i = 0; i < pbm->msiq_num; i++) {
@@ -813,9 +815,9 @@ static void pci_sun4v_msiq_free(struct pci_pbm_info *pbm)
 	alloc_size = (pbm->msiq_num * q_size);
 	order = get_order(alloc_size);
 
-	pages = (unsigned long) pbm->msi_queues;
+	pages = pbm->msi_queues;
 
-	free_pages((void *)pages, order);
+	free_pages(pages, order);
 
 	pbm->msi_queues = NULL;
 }
@@ -937,12 +939,12 @@ static int pci_sun4v_probe(struct platform_device *op)
 	err = -ENOMEM;
 	if (!iommu_batch_initialized) {
 		for_each_possible_cpu(i) {
-			unsigned long page = (unsigned long)get_zeroed_page(GFP_KERNEL);
+			u64 *page = get_zeroed_page(GFP_KERNEL);
 
 			if (!page)
 				goto out_err;
 
-			per_cpu(iommu_batch, i).pglist = (u64 *) page;
+			per_cpu(iommu_batch, i).pglist = page;
 		}
 		iommu_batch_initialized = 1;
 	}
diff --git a/arch/sparc/mm/io-unit.c b/arch/sparc/mm/io-unit.c
index f311bf2..707d5a0 100644
--- a/arch/sparc/mm/io-unit.c
+++ b/arch/sparc/mm/io-unit.c
@@ -200,10 +200,10 @@ static void iounit_release_scsi_sgl(struct device *dev, struct scatterlist *sg,
 }
 
 #ifdef CONFIG_SBUS
-static int iounit_map_dma_area(struct device *dev, dma_addr_t *pba, unsigned long va, unsigned long addr, int len)
+static int iounit_map_dma_area(struct device *dev, dma_addr_t *pba, void *va, unsigned long addr, int len)
 {
 	struct iounit_struct *iounit = dev->archdata.iommu;
-	unsigned long page, end;
+	unsigned long end;
 	pgprot_t dvma_prot;
 	iopte_t __iomem *iopte;
 
@@ -212,7 +212,6 @@ static int iounit_map_dma_area(struct device *dev, dma_addr_t *pba, unsigned lon
 	dvma_prot = __pgprot(SRMMU_CACHE | SRMMU_ET_PTE | SRMMU_PRIV);
 	end = PAGE_ALIGN((addr + len));
 	while(addr < end) {
-		page = va;
 		{
 			pgd_t *pgdp;
 			pmd_t *pmdp;
@@ -223,12 +222,12 @@ static int iounit_map_dma_area(struct device *dev, dma_addr_t *pba, unsigned lon
 			pmdp = pmd_offset(pgdp, addr);
 			ptep = pte_offset_map(pmdp, addr);
 
-			set_pte(ptep, mk_pte(virt_to_page(page), dvma_prot));
+			set_pte(ptep, mk_pte(virt_to_page(va), dvma_prot));
 			
 			i = ((addr - IOUNIT_DMA_BASE) >> PAGE_SHIFT);
 
 			iopte = iounit->page_table + i;
-			sbus_writel(MKIOPTE(__pa(page)), iopte);
+			sbus_writel(MKIOPTE(__pa(va)), iopte);
 		}
 		addr += PAGE_SIZE;
 		va += PAGE_SIZE;
diff --git a/arch/sparc/mm/iommu.c b/arch/sparc/mm/iommu.c
index 491511d..f9d30bd 100644
--- a/arch/sparc/mm/iommu.c
+++ b/arch/sparc/mm/iommu.c
@@ -321,7 +321,7 @@ static void iommu_release_scsi_sgl(struct device *dev, struct scatterlist *sg, i
 }
 
 #ifdef CONFIG_SBUS
-static int iommu_map_dma_area(struct device *dev, dma_addr_t *pba, unsigned long va,
+static int iommu_map_dma_area(struct device *dev, dma_addr_t *pba, void *va,
 			      unsigned long addr, int len)
 {
 	struct iommu_struct *iommu = dev->archdata.iommu;
@@ -330,7 +330,7 @@ static int iommu_map_dma_area(struct device *dev, dma_addr_t *pba, unsigned long
 	iopte_t *first;
 	int ioptex;
 
-	BUG_ON((va & ~PAGE_MASK) != 0);
+	BUG_ON(((unsigned long)va & ~PAGE_MASK) != 0);
 	BUG_ON((addr & ~PAGE_MASK) != 0);
 	BUG_ON((len & ~PAGE_MASK) != 0);
 
@@ -344,7 +344,7 @@ static int iommu_map_dma_area(struct device *dev, dma_addr_t *pba, unsigned long
 	first = iopte;
 	end = addr + len;
 	while(addr < end) {
-		page = va;
+		page = (unsigned long)va;
 		{
 			pgd_t *pgdp;
 			pmd_t *pmdp;
@@ -361,10 +361,10 @@ static int iommu_map_dma_area(struct device *dev, dma_addr_t *pba, unsigned long
 			pmdp = pmd_offset(pgdp, addr);
 			ptep = pte_offset_map(pmdp, addr);
 
-			set_pte(ptep, mk_pte(virt_to_page(page), dvma_prot));
+			set_pte(ptep, mk_pte(virt_to_page(va), dvma_prot));
 		}
 		iopte_val(*iopte++) =
-		    MKIOPTE(page_to_pfn(virt_to_page(page)), ioperm_noc);
+		    MKIOPTE(page_to_pfn(virt_to_page(va)), ioperm_noc);
 		addr += PAGE_SIZE;
 		va += PAGE_SIZE;
 	}
-- 
2.1.4

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ