* [PATCH][2.4.28-pre3] USB drivers gcc-3.4 fixes
@ 2004-09-12 11:29 Mikael Pettersson
2004-09-13 0:30 ` Pete Zaitcev
2004-09-13 3:49 ` Pete Zaitcev
0 siblings, 2 replies; 5+ messages in thread
From: Mikael Pettersson @ 2004-09-12 11:29 UTC (permalink / raw)
To: alan, drivers, marcelo.tosatti, sailer, zaitcev; +Cc: linux-kernel
This patch fixes gcc-3.4 cast-as-lvalue warnings in the 2.4.28-pre3
kernel's USB drivers. The audio.c and uss720.c changes are backports
from the 2.6 kernel. The hpusbscsi.c and microtek.c changes are new,
since the 2.6 code is different.
/Mikael
--- linux-2.4.28-pre3/drivers/usb/audio.c.~1~ 2004-08-08 10:56:31.000000000 +0200
+++ linux-2.4.28-pre3/drivers/usb/audio.c 2004-09-12 01:56:20.000000000 +0200
@@ -609,7 +609,7 @@
pgrem = rem;
memcpy((db->sgbuf[db->wrptr >> PAGE_SHIFT]) + (db->wrptr & (PAGE_SIZE-1)), buffer, pgrem);
size -= pgrem;
- (char *)buffer += pgrem;
+ buffer += pgrem;
db->wrptr += pgrem;
if (db->wrptr >= db->dmasize)
db->wrptr = 0;
@@ -632,7 +632,7 @@
pgrem = rem;
memcpy(buffer, (db->sgbuf[db->rdptr >> PAGE_SHIFT]) + (db->rdptr & (PAGE_SIZE-1)), pgrem);
size -= pgrem;
- (char *)buffer += pgrem;
+ buffer += pgrem;
db->rdptr += pgrem;
if (db->rdptr >= db->dmasize)
db->rdptr = 0;
@@ -657,7 +657,7 @@
if (copy_from_user((db->sgbuf[ptr >> PAGE_SHIFT]) + (ptr & (PAGE_SIZE-1)), buffer, pgrem))
return -EFAULT;
size -= pgrem;
- (char *)buffer += pgrem;
+ buffer += pgrem;
ptr += pgrem;
if (ptr >= db->dmasize)
ptr = 0;
@@ -682,7 +682,7 @@
if (copy_to_user(buffer, (db->sgbuf[ptr >> PAGE_SHIFT]) + (ptr & (PAGE_SIZE-1)), pgrem))
return -EFAULT;
size -= pgrem;
- (char *)buffer += pgrem;
+ buffer += pgrem;
ptr += pgrem;
if (ptr >= db->dmasize)
ptr = 0;
--- linux-2.4.28-pre3/drivers/usb/hpusbscsi.c.~1~ 2003-06-14 13:30:26.000000000 +0200
+++ linux-2.4.28-pre3/drivers/usb/hpusbscsi.c 2004-09-12 01:56:20.000000000 +0200
@@ -182,7 +182,7 @@
memcpy (&(new->ctempl), &hpusbscsi_scsi_host_template,
sizeof (hpusbscsi_scsi_host_template));
- (struct hpusbscsi *) new->ctempl.proc_dir = new;
+ new->ctempl.proc_dir = (void *) new;
new->ctempl.module = THIS_MODULE;
if (scsi_register_module (MODULE_SCSI_HA, &(new->ctempl)))
--- linux-2.4.28-pre3/drivers/usb/microtek.c.~1~ 2002-11-30 17:12:27.000000000 +0100
+++ linux-2.4.28-pre3/drivers/usb/microtek.c 2004-09-12 01:56:20.000000000 +0200
@@ -987,7 +987,7 @@
/* Initialize the host template based on the default one */
memcpy(&(new_desc->ctempl), &mts_scsi_host_template, sizeof(mts_scsi_host_template));
/* HACK from usb-storage - this is needed for scsi detection */
- (struct mts_desc *)new_desc->ctempl.proc_dir = new_desc; /* FIXME */
+ new_desc->ctempl.proc_dir = (void *)new_desc; /* FIXME */
MTS_DEBUG("registering SCSI module\n");
--- linux-2.4.28-pre3/drivers/usb/uss720.c.~1~ 2001-10-24 11:59:14.000000000 +0200
+++ linux-2.4.28-pre3/drivers/usb/uss720.c 2004-09-12 01:56:20.000000000 +0200
@@ -333,7 +333,7 @@
for (; got < length; got++) {
if (get_1284_register(pp, 4, (char *)buf))
break;
- ((char*)buf)++;
+ buf++;
if (priv->reg[0] & 0x01) {
clear_epp_timeout(pp);
break;
@@ -392,7 +392,7 @@
for (; got < length; got++) {
if (get_1284_register(pp, 3, (char *)buf))
break;
- ((char*)buf)++;
+ buf++;
if (priv->reg[0] & 0x01) {
clear_epp_timeout(pp);
break;
@@ -412,7 +412,7 @@
for (; written < length; written++) {
if (set_1284_register(pp, 3, *(char *)buf))
break;
- ((char*)buf)++;
+ buf++;
if (get_1284_register(pp, 1, NULL))
break;
if (priv->reg[0] & 0x01) {
@@ -469,7 +469,7 @@
for (; written < len; written++) {
if (set_1284_register(pp, 5, *(char *)buffer))
break;
- ((char*)buffer)++;
+ buffer++;
}
change_mode(pp, ECR_PS2);
return written;
^ permalink raw reply [flat|nested] 5+ messages in thread* Re: [PATCH][2.4.28-pre3] USB drivers gcc-3.4 fixes 2004-09-12 11:29 [PATCH][2.4.28-pre3] USB drivers gcc-3.4 fixes Mikael Pettersson @ 2004-09-13 0:30 ` Pete Zaitcev 2004-09-13 10:54 ` Alan Cox 2004-09-13 3:49 ` Pete Zaitcev 1 sibling, 1 reply; 5+ messages in thread From: Pete Zaitcev @ 2004-09-13 0:30 UTC (permalink / raw) To: Mikael Pettersson Cc: alan, drivers, marcelo.tosatti, sailer, linux-kernel, zaitcev On Sun, 12 Sep 2004 13:29:05 +0200 (MEST) Mikael Pettersson <mikpe@csd.uu.se> wrote: > This patch fixes gcc-3.4 cast-as-lvalue warnings in the 2.4.28-pre3 > kernel's USB drivers. The audio.c and uss720.c changes are backports > from the 2.6 kernel. The hpusbscsi.c and microtek.c changes are new, > since the 2.6 code is different. > +++ linux-2.4.28-pre3/drivers/usb/audio.c 2004-09-12 01:56:20.000000000 +0200 > @@ -609,7 +609,7 @@ > size -= pgrem; > - (char *)buffer += pgrem; > + buffer += pgrem; I'm pretty sure it's done that way on purpose. There were compilers which did not allow any arithmetics on void*, and it had to be cast to char*. So perhaps it's correct for 2.6, which requires gcc 3 anyway, but I have my doubts about applicability of this to 2.4. -- Pete ^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH][2.4.28-pre3] USB drivers gcc-3.4 fixes 2004-09-13 0:30 ` Pete Zaitcev @ 2004-09-13 10:54 ` Alan Cox 0 siblings, 0 replies; 5+ messages in thread From: Alan Cox @ 2004-09-13 10:54 UTC (permalink / raw) To: Pete Zaitcev Cc: Mikael Pettersson, drivers, marcelo.tosatti, sailer, Linux Kernel Mailing List On Llu, 2004-09-13 at 01:30, Pete Zaitcev wrote: > > size -= pgrem; > > - (char *)buffer += pgrem; > > + buffer += pgrem; > > I'm pretty sure it's done that way on purpose. There were compilers which > did not allow any arithmetics on void*, and it had to be cast to char*. > So perhaps it's correct for 2.6, which requires gcc 3 anyway, but I have > my doubts about applicability of this to 2.4. Should be ok for the 2.* gcc we support. (BTW is anyone using anything less than 2.95 nowdays because we've still got 2.7.* workarounds in asm-i386/semaphore.h !) Otherwise in "valid" C it's buffer = ((char *)buffer) + pgrem; ^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH][2.4.28-pre3] USB drivers gcc-3.4 fixes 2004-09-12 11:29 [PATCH][2.4.28-pre3] USB drivers gcc-3.4 fixes Mikael Pettersson 2004-09-13 0:30 ` Pete Zaitcev @ 2004-09-13 3:49 ` Pete Zaitcev 2004-09-13 13:48 ` Mikael Pettersson 1 sibling, 1 reply; 5+ messages in thread From: Pete Zaitcev @ 2004-09-13 3:49 UTC (permalink / raw) To: Mikael Pettersson Cc: alan, drivers, marcelo.tosatti, sailer, linux-kernel, zaitcev How about this now? -- Pete diff -urp -X dontdiff linux-2.4.28-pre3/drivers/usb/audio.c linux-2.4.28-pre3-usb/drivers/usb/audio.c --- linux-2.4.28-pre3/drivers/usb/audio.c 2004-08-24 12:38:50.000000000 -0700 +++ linux-2.4.28-pre3-usb/drivers/usb/audio.c 2004-09-12 17:49:35.000000000 -0700 @@ -593,9 +593,10 @@ static int dmabuf_mmap(struct dmabuf *db return 0; } -static void dmabuf_copyin(struct dmabuf *db, const void *buffer, unsigned int size) +static void dmabuf_copyin(struct dmabuf *db, const void *_buffer, unsigned int size) { unsigned int pgrem, rem; + const char *buffer = _buffer; db->total_bytes += size; for (;;) { @@ -609,16 +610,17 @@ static void dmabuf_copyin(struct dmabuf pgrem = rem; memcpy((db->sgbuf[db->wrptr >> PAGE_SHIFT]) + (db->wrptr & (PAGE_SIZE-1)), buffer, pgrem); size -= pgrem; - (char *)buffer += pgrem; + buffer += pgrem; db->wrptr += pgrem; if (db->wrptr >= db->dmasize) db->wrptr = 0; } } -static void dmabuf_copyout(struct dmabuf *db, void *buffer, unsigned int size) +static void dmabuf_copyout(struct dmabuf *db, void *_buffer, unsigned int size) { unsigned int pgrem, rem; + char *buffer = _buffer; db->total_bytes += size; for (;;) { @@ -632,16 +634,17 @@ static void dmabuf_copyout(struct dmabuf pgrem = rem; memcpy(buffer, (db->sgbuf[db->rdptr >> PAGE_SHIFT]) + (db->rdptr & (PAGE_SIZE-1)), pgrem); size -= pgrem; - (char *)buffer += pgrem; + buffer += pgrem; db->rdptr += pgrem; if (db->rdptr >= db->dmasize) db->rdptr = 0; } } -static int dmabuf_copyin_user(struct dmabuf *db, unsigned int ptr, const void *buffer, unsigned int size) +static int dmabuf_copyin_user(struct dmabuf *db, unsigned int ptr, const void *_buffer, unsigned int size) { unsigned int pgrem, rem; + const char *buffer = _buffer; if (!db->ready || db->mapped) return -EINVAL; @@ -657,16 +660,17 @@ static int dmabuf_copyin_user(struct dma if (copy_from_user((db->sgbuf[ptr >> PAGE_SHIFT]) + (ptr & (PAGE_SIZE-1)), buffer, pgrem)) return -EFAULT; size -= pgrem; - (char *)buffer += pgrem; + buffer += pgrem; ptr += pgrem; if (ptr >= db->dmasize) ptr = 0; } } -static int dmabuf_copyout_user(struct dmabuf *db, unsigned int ptr, void *buffer, unsigned int size) +static int dmabuf_copyout_user(struct dmabuf *db, unsigned int ptr, void *_buffer, unsigned int size) { unsigned int pgrem, rem; + char *buffer = _buffer; if (!db->ready || db->mapped) return -EINVAL; @@ -682,7 +686,7 @@ static int dmabuf_copyout_user(struct dm if (copy_to_user(buffer, (db->sgbuf[ptr >> PAGE_SHIFT]) + (ptr & (PAGE_SIZE-1)), pgrem)) return -EFAULT; size -= pgrem; - (char *)buffer += pgrem; + buffer += pgrem; ptr += pgrem; if (ptr >= db->dmasize) ptr = 0; diff -urp -X dontdiff linux-2.4.28-pre3/drivers/usb/hpusbscsi.c linux-2.4.28-pre3-usb/drivers/usb/hpusbscsi.c --- linux-2.4.28-pre3/drivers/usb/hpusbscsi.c 2003-06-13 07:51:36.000000000 -0700 +++ linux-2.4.28-pre3-usb/drivers/usb/hpusbscsi.c 2004-09-12 17:23:57.000000000 -0700 @@ -182,7 +182,7 @@ hpusbscsi_usb_probe (struct usb_device * memcpy (&(new->ctempl), &hpusbscsi_scsi_host_template, sizeof (hpusbscsi_scsi_host_template)); - (struct hpusbscsi *) new->ctempl.proc_dir = new; + new->ctempl.proc_dir = (void *) new; new->ctempl.module = THIS_MODULE; if (scsi_register_module (MODULE_SCSI_HA, &(new->ctempl))) diff -urp -X dontdiff linux-2.4.28-pre3/drivers/usb/microtek.c linux-2.4.28-pre3-usb/drivers/usb/microtek.c --- linux-2.4.28-pre3/drivers/usb/microtek.c 2002-11-28 15:53:14.000000000 -0800 +++ linux-2.4.28-pre3-usb/drivers/usb/microtek.c 2004-09-12 17:23:58.000000000 -0700 @@ -987,7 +987,7 @@ static void * mts_usb_probe (struct usb_ /* Initialize the host template based on the default one */ memcpy(&(new_desc->ctempl), &mts_scsi_host_template, sizeof(mts_scsi_host_template)); /* HACK from usb-storage - this is needed for scsi detection */ - (struct mts_desc *)new_desc->ctempl.proc_dir = new_desc; /* FIXME */ + new_desc->ctempl.proc_dir = (void *)new_desc; /* FIXME */ MTS_DEBUG("registering SCSI module\n"); diff -urp -X dontdiff linux-2.4.28-pre3/drivers/usb/uss720.c linux-2.4.28-pre3-usb/drivers/usb/uss720.c --- linux-2.4.28-pre3/drivers/usb/uss720.c 2001-10-20 19:13:11.000000000 -0700 +++ linux-2.4.28-pre3-usb/drivers/usb/uss720.c 2004-09-12 20:48:13.000000000 -0700 @@ -327,13 +327,14 @@ static size_t parport_uss720_epp_read_da { struct parport_uss720_private *priv = pp->private_data; size_t got = 0; + char *buff = buf; if (change_mode(pp, ECR_EPP)) return 0; for (; got < length; got++) { - if (get_1284_register(pp, 4, (char *)buf)) + if (get_1284_register(pp, 4, buff)) break; - ((char*)buf)++; + buff++; if (priv->reg[0] & 0x01) { clear_epp_timeout(pp); break; @@ -348,13 +349,14 @@ static size_t parport_uss720_epp_write_d #if 0 struct parport_uss720_private *priv = pp->private_data; size_t written = 0; + const char *buff = buf; if (change_mode(pp, ECR_EPP)) return 0; for (; written < length; written++) { - if (set_1284_register(pp, 4, (char *)buf)) + if (set_1284_register(pp, 4, *buff)) break; - ((char*)buf)++; + buff++; if (get_1284_register(pp, 1, NULL)) break; if (priv->reg[0] & 0x01) { @@ -386,13 +388,14 @@ static size_t parport_uss720_epp_read_ad { struct parport_uss720_private *priv = pp->private_data; size_t got = 0; + char *buff = buf; if (change_mode(pp, ECR_EPP)) return 0; for (; got < length; got++) { - if (get_1284_register(pp, 3, (char *)buf)) + if (get_1284_register(pp, 3, buff)) break; - ((char*)buf)++; + buff++; if (priv->reg[0] & 0x01) { clear_epp_timeout(pp); break; @@ -406,13 +409,14 @@ static size_t parport_uss720_epp_write_a { struct parport_uss720_private *priv = pp->private_data; size_t written = 0; + const char *buff = buf; if (change_mode(pp, ECR_EPP)) return 0; for (; written < length; written++) { - if (set_1284_register(pp, 3, *(char *)buf)) + if (set_1284_register(pp, 3, *buff)) break; - ((char*)buf)++; + buff++; if (get_1284_register(pp, 1, NULL)) break; if (priv->reg[0] & 0x01) { @@ -463,13 +467,14 @@ static size_t parport_uss720_ecp_read_da static size_t parport_uss720_ecp_write_addr(struct parport *pp, const void *buffer, size_t len, int flags) { size_t written = 0; + const char *buff = buffer; if (change_mode(pp, ECR_ECP)) return 0; for (; written < len; written++) { - if (set_1284_register(pp, 5, *(char *)buffer)) + if (set_1284_register(pp, 5, *buff)) break; - ((char*)buffer)++; + buff++; } change_mode(pp, ECR_PS2); return written; ^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH][2.4.28-pre3] USB drivers gcc-3.4 fixes 2004-09-13 3:49 ` Pete Zaitcev @ 2004-09-13 13:48 ` Mikael Pettersson 0 siblings, 0 replies; 5+ messages in thread From: Mikael Pettersson @ 2004-09-13 13:48 UTC (permalink / raw) To: Pete Zaitcev; +Cc: alan, drivers, marcelo.tosatti, sailer, linux-kernel Pete Zaitcev writes: > How about this now? > > -- Pete > > diff -urp -X dontdiff linux-2.4.28-pre3/drivers/usb/audio.c linux-2.4.28-pre3-usb/drivers/usb/audio.c > --- linux-2.4.28-pre3/drivers/usb/audio.c 2004-08-24 12:38:50.000000000 -0700 > +++ linux-2.4.28-pre3-usb/drivers/usb/audio.c 2004-09-12 17:49:35.000000000 -0700 > @@ -593,9 +593,10 @@ static int dmabuf_mmap(struct dmabuf *db > return 0; > } > > -static void dmabuf_copyin(struct dmabuf *db, const void *buffer, unsigned int size) > +static void dmabuf_copyin(struct dmabuf *db, const void *_buffer, unsigned int size) > { > unsigned int pgrem, rem; > + const char *buffer = _buffer; and more on the same theme. Yeah, that's much nicer. Thanks. Marcelo, please consider this patch instead of the one I sent. /Mikael ^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2004-09-13 13:48 UTC | newest] Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed) -- links below jump to the message on this page -- 2004-09-12 11:29 [PATCH][2.4.28-pre3] USB drivers gcc-3.4 fixes Mikael Pettersson 2004-09-13 0:30 ` Pete Zaitcev 2004-09-13 10:54 ` Alan Cox 2004-09-13 3:49 ` Pete Zaitcev 2004-09-13 13:48 ` Mikael Pettersson
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®