public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Stelian Pop <stelian@popies.net>
To: "Randy.Dunlap" <rddunlap@osdl.org>
Cc: akpm@osdl.org, linux-kernel@vger.kernel.org,
	Linus Torvalds <torvalds@osdl.org>
Subject: Re: [PATCH] meye: correct printk of dma_addr_t
Date: Thu, 5 Feb 2004 14:37:26 +0100	[thread overview]
Message-ID: <20040205133726.GF13492@deep-space-9.dsnet> (raw)
In-Reply-To: <20040204080515.63eb4b96.rddunlap@osdl.org>

On Wed, Feb 04, 2004 at 08:05:15AM -0800, Randy.Dunlap wrote:

> | Which one do you prefer ?
> 
> 
> Well, both.  :)
> 
> The toc of dma_addr_t's should be in its own array/structure.
> 
> Adding some comments or help text about the highmem limitation
> would also be good.

I had a feeling you would say that :)

Here it is. It compiles and works just fine, please apply.

Stelian.

===== drivers/media/video/meye.h 1.11 vs edited =====
--- 1.11/drivers/media/video/meye.h	Fri Oct 24 23:14:38 2003
+++ edited/drivers/media/video/meye.h	Thu Feb  5 11:43:55 2004
@@ -298,7 +298,8 @@
 	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 */
===== drivers/media/video/meye.c 1.19 vs edited =====
--- 1.19/drivers/media/video/meye.c	Wed Aug 27 13:24:51 2003
+++ edited/drivers/media/video/meye.c	Thu Feb  5 10:46:29 2004
@@ -160,23 +160,29 @@
 	}
 }
 
-/* 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 @@
 							  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 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 @@
 		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;
 }
 
===== drivers/media/video/Kconfig 1.17 vs edited =====
--- 1.17/drivers/media/video/Kconfig	Tue Jan 20 00:20:19 2004
+++ edited/drivers/media/video/Kconfig	Thu Feb  5 11:12:49 2004
@@ -205,7 +205,7 @@
 
 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

-- 
Stelian Pop <stelian@popies.net>

      reply	other threads:[~2004-02-05 13:37 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2004-02-03 23:36 [PATCH] meye: correct printk of dma_addr_t Randy.Dunlap
2004-02-03 23:57 ` Andrew Morton
2004-02-04  0:28   ` Randy.Dunlap
2004-02-04  8:44     ` Stelian Pop
2004-02-04 16:05       ` Randy.Dunlap
2004-02-05 13:37         ` Stelian Pop [this message]

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=20040205133726.GF13492@deep-space-9.dsnet \
    --to=stelian@popies.net \
    --cc=akpm@osdl.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=rddunlap@osdl.org \
    --cc=torvalds@osdl.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