From 58a88273b8a8cb0722de9f3a767b987a6f2692f2 Mon Sep 17 00:00:00 2001 From: Andrew Morton Date: Thu, 5 Feb 2004 16:51:55 -0800 Subject: [PATCH] [PATCH] meye: Fix dma_addr_t usage From: Stelian Pop This driver had an array which contained both dma_addr_t's and kernel virtual addresses. Split those up, thus tidying things and avoiding a printk warning. --- drivers/media/video/Kconfig | 2 +- drivers/media/video/meye.c | 38 ++++++++++++++++++++++++------------- drivers/media/video/meye.h | 3 ++- 3 files changed, 28 insertions(+), 15 deletions(-) diff --git a/drivers/media/video/Kconfig b/drivers/media/video/Kconfig index 013bdf8935093..40efcf8e2e279 100644 --- a/drivers/media/video/Kconfig +++ b/drivers/media/video/Kconfig @@ -205,7 +205,7 @@ config VIDEO_ZR36120 config VIDEO_MEYE tristate "Sony Vaio Picturebook Motion Eye Video For Linux (EXPERIMENTAL)" - depends on VIDEO_DEV && SONYPI + depends on VIDEO_DEV && SONYPI && !HIGHMEM64G ---help--- This is the video4linux driver for the Motion Eye camera found in the Vaio Picturebook laptops. Please read the material in diff --git a/drivers/media/video/meye.c b/drivers/media/video/meye.c index a8f623903b46e..53d5722ac2a89 100644 --- a/drivers/media/video/meye.c +++ b/drivers/media/video/meye.c @@ -160,23 +160,29 @@ static void rvfree(void * mem, unsigned long size) { } } -/* return a page table pointing to N pages of locked memory */ +/* return a page table pointing to N pages of locked memory + * + * NOTE: The meye device expects dma_addr_t size to be 32 bits + * (the toc must be exactly 1024 entries each of them being 4 bytes + * in size, the whole result being 4096 bytes). We're using here + * dma_addr_t for corectness but the compilation of this driver is + * disabled for HIGHMEM64G=y, where sizeof(dma_addr_t) != 4 */ static int ptable_alloc(void) { - u32 *pt; + dma_addr_t *pt; int i; memset(meye.mchip_ptable, 0, sizeof(meye.mchip_ptable)); - meye.mchip_ptable[MCHIP_NB_PAGES] = dma_alloc_coherent(&meye.mchip_dev->dev, - PAGE_SIZE, - &meye.mchip_dmahandle, - GFP_KERNEL); - if (!meye.mchip_ptable[MCHIP_NB_PAGES]) { + meye.mchip_ptable_toc = dma_alloc_coherent(&meye.mchip_dev->dev, + PAGE_SIZE, + &meye.mchip_dmahandle, + GFP_KERNEL); + if (!meye.mchip_ptable_toc) { meye.mchip_dmahandle = 0; return -1; } - pt = (u32 *)meye.mchip_ptable[MCHIP_NB_PAGES]; + pt = meye.mchip_ptable_toc; for (i = 0; i < MCHIP_NB_PAGES; i++) { meye.mchip_ptable[i] = dma_alloc_coherent(&meye.mchip_dev->dev, PAGE_SIZE, @@ -184,13 +190,18 @@ static int ptable_alloc(void) { GFP_KERNEL); if (!meye.mchip_ptable[i]) { int j; - pt = (u32 *)meye.mchip_ptable[MCHIP_NB_PAGES]; + pt = meye.mchip_ptable_toc; for (j = 0; j < i; ++j) { dma_free_coherent(&meye.mchip_dev->dev, PAGE_SIZE, meye.mchip_ptable[j], *pt); pt++; } + dma_free_coherent(&meye.mchip_dev->dev, + PAGE_SIZE, + meye.mchip_ptable_toc, + meye.mchip_dmahandle); + meye.mchip_ptable_toc = 0; meye.mchip_dmahandle = 0; return -1; } @@ -200,10 +211,10 @@ static int ptable_alloc(void) { } static void ptable_free(void) { - u32 *pt; + dma_addr_t *pt; int i; - pt = (u32 *)meye.mchip_ptable[MCHIP_NB_PAGES]; + pt = meye.mchip_ptable_toc; for (i = 0; i < MCHIP_NB_PAGES; i++) { if (meye.mchip_ptable[i]) dma_free_coherent(&meye.mchip_dev->dev, @@ -212,13 +223,14 @@ static void ptable_free(void) { pt++; } - if (meye.mchip_ptable[MCHIP_NB_PAGES]) + if (meye.mchip_ptable_toc) dma_free_coherent(&meye.mchip_dev->dev, PAGE_SIZE, - meye.mchip_ptable[MCHIP_NB_PAGES], + meye.mchip_ptable_toc, meye.mchip_dmahandle); memset(meye.mchip_ptable, 0, sizeof(meye.mchip_ptable)); + meye.mchip_ptable_toc = 0; meye.mchip_dmahandle = 0; } diff --git a/drivers/media/video/meye.h b/drivers/media/video/meye.h index 5e1f6589bc54f..9ac39190882f6 100644 --- a/drivers/media/video/meye.h +++ b/drivers/media/video/meye.h @@ -298,7 +298,8 @@ struct meye { u8 mchip_fnum; /* current mchip frame number */ unsigned char *mchip_mmregs; /* mchip: memory mapped registers */ - u8 *mchip_ptable[MCHIP_NB_PAGES+1];/* mchip: ptable + ptable toc */ + u8 *mchip_ptable[MCHIP_NB_PAGES];/* mchip: ptable */ + dma_addr_t *mchip_ptable_toc; /* mchip: ptable toc */ dma_addr_t mchip_dmahandle; /* mchip: dma handle to ptable toc */ unsigned char *grab_fbuffer; /* capture framebuffer */ -- 2.53.0