usb-misc: sisusbvga: cleanup and bug fix
Subsystems (2)
v2 cover usb-misc: sisusbvga: cleanup and bug fix
The file drivers/usb/misc/sisusbvga/sisusb.c had many (192) coding style issues reported by checkpatch. This file also had a problematic error path in the probe function that could result in dereferencing a null pointer.
This patch series fix coding style issues and a problematic error path which could result in a null pointer dereference.
Patch 1 and 2 change whitespace only, patch 3 to 6 fix various coding style issues, and patch 7 fix a null pointer dereference bug.
Joe Perches suggested me to include objtdiff output for patches that are not supposed to make semantic changes, but it is not working well for me with gcc (GCC) 5.3.1 20151207 (Red Hat 5.3.1-2). Even compiling the same source code produces different output from objdump. The objdump command I'm using is from ./scripts/objdiff. See an example:
# A patch that should not make any semantic change
$ cat /tmp/patch
diff --git a/drivers/usb/misc/sisusbvga/sisusb.c b/drivers/usb/misc/sisusbvga/sisusb.c
index 8efbaba..a48b086d 100644
--- a/drivers/usb/misc/sisusbvga/sisusb.c
+++ b/drivers/usb/misc/sisusbvga/sisusb.c
@@ -1353,7 +1353,7 @@ sisusb_testreadwrite(struct sisusb_usb_data *sisusb)
static char srcbuffer[] = { 0x11, 0x22, 0x33, 0x44, 0x55, 0x66, 0x77 };
char destbuffer[10];
size_t dummy;
- int i,j;
+ int i, j;sisusb_copy_memory(sisusb, srcbuffer, sisusb->vrambase, 7, &dummy);
# Lets compile and collect a dump based on linux-next/master
$ git checkout linux-next/master $ md5sum drivers/usb/misc/sisusbvga/sisusb.c d6ffbd44f3f1cf81fd55ce84441ab889 drivers/usb/misc/sisusbvga/sisusb.c
$ make -j4 drivers/usb/misc/sisusbvga/sisusb.o $ objdump -D drivers/usb/misc/sisusbvga/sisusb.o| \ sed "s/^[[:space:]]\+[0-9a-f]\+//" > /tmp/base_dump
# Now let's apply the patch and collect other dump
$ git apply /tmp/patch $ md5sum drivers/usb/misc/sisusbvga/sisusb.c 0b7d579c8ae2159f677c6a5c6efc4956 drivers/usb/misc/sisusbvga/sisusb.c
$ make -j4 drivers/usb/misc/sisusbvga/sisusb.o $ objdump -D drivers/usb/misc/sisusbvga/sisusb.o| \ sed "s/^[[:space:]]\+[0-9a-f]\+//" > /tmp/dump
# I was expecting the diff to be empty
$ diff /tmp/base_dump /tmp/dump 9135,9136c9135 < : 8e 4d 31 mov 0x31(%rbp),%cs < : 46 00 00 rex.RX add %r8b,(%rax) ---
Quoted 1 line
: 25 c4 31 46 00 and $0x4631c4,%eax
9139c9138
< : 4b 00 00 rex.WXB add %al,(%r8)
---
Quoted 1 line
: 00 4b 00 add %cl,0x0(%rbx)
# But here is the interesting part. Even compiling the exact same source code
# produces different results $ git checkout -- . $ md5sum drivers/usb/misc/sisusbvga/sisusb.c d6ffbd44f3f1cf81fd55ce84441ab889 drivers/usb/misc/sisusbvga/sisusb.c
$ make -j4 drivers/usb/misc/sisusbvga/sisusb.o $ objdump -D drivers/usb/misc/sisusbvga/sisusb.o| \ sed "s/^[[:space:]]\+[0-9a-f]\+//" > /tmp/base_dump_again
$ diff /tmp/base_dump /tmp/base_dump_again 9135,9136c9135,9136 < : 8e 4d 31 mov 0x31(%rbp),%cs < : 46 00 00 rex.RX add %r8b,(%rax) ---
Quoted 2 lines
: de 10 ficom (%rax) : 33 46 00 xor 0x0(%rsi),%eax
9139c9139
< : 4b 00 00 rex.WXB add %al,(%r8)
---
Quoted 1 line
: 00 4b 00 add %cl,0x0(%rbx)
Peter Senna Tschudin (7):
usb-misc: sisusbvga: Fix coding style: horizontal whitespace changes
usb-misc: sisusbvga: Fix coding style: vertical whitespace changes
usb-misc: sisusbvga: Fix coding style: braces, parenthesis, comment
usb-misc: sisusbvga: Fix coding style: remove assignment from if tests
usb-misc: sisusbvga: Remove null test before calls to kfree()
usb-misc: sisusbvga: Remove memory allocation logs
usb-misc: sisusbvga: fix error path
drivers/usb/misc/sisusbvga/sisusb.c | 1543 +++++++++++++++++------------------ 1 file changed, 752 insertions(+), 791 deletions(-)
Signature · 1 line
2.5.0
PATCH v2 7/7 usb-misc: sisusbvga: fix error path
Remove a call to dev_err() that was reporting an unsuccesful call to kmalloc(), as reporting memory allocation failures is redundant. Instead of logging the error, clean up previously allocated resources and abort the probe with -ENOMEM. Before this change sisusb->SiS_Pr could be dereferenced even if null after failure of memory allocation.
---
Changes from V1:
- This patch fixes the bug and does cleanup only on the error path that was causing the bug.
Tested by compilation only.
drivers/usb/misc/sisusbvga/sisusb.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
drivers/usb/misc/sisusbvga/sisusb.c +2 -1
@@ -3112,7 +3112,8 @@ static int sisusb_probe(struct usb_interface *intf,/* Allocate our SiS_Pr */ sisusb->SiS_Pr =kmalloc (sizeof (struct SiS_Private ),GFP_KERNEL );if (!sisusb->SiS_Pr) { -dev_err (&sisusb->sisusb_dev->dev,"Failed to allocate SiS_Pr\n" ); + retval = -ENOMEM ; + goto error_4; }#endif
Signature · 1 line
2.5.0
PATCH v2 5/7 usb-misc: sisusbvga: Remove null test before calls to kfree()
In reply to Peter Senna TschudinFrom: Peter Senna Tschudin <[email protected]>
This patch removes null test before calls to kfree() as kfree() can handle null pointers safely.
---
No changes from V1.
Tested by compilation only.
drivers/usb/misc/sisusbvga/sisusb.c | 12 ++++-------- 1 file changed, 4 insertions(+), 8 deletions(-)
drivers/usb/misc/sisusbvga/sisusb.c +4 -8
@@ -76,15 +76,11 @@ static void sisusb_free_buffers(struct sisusb_usb_data *sisusb)int i;for (i =0 ; i <NUMOBUFS ; i++) { -if (sisusb->obuf[i]) { -kfree (sisusb->obuf[i]); - sisusb->obuf[i] =NULL ; - } - } -if (sisusb->ibuf) { -kfree (sisusb->ibuf); - sisusb->ibuf =NULL ; +kfree (sisusb->obuf[i]); + sisusb->obuf[i] =NULL ; } +kfree (sisusb->ibuf); + sisusb->ibuf =NULL ; }static void sisusb_free_urbs (struct sisusb_usb_data *sisusb)
Signature · 1 line
2.5.0
PATCH v2 6/7 usb-misc: sisusbvga: Remove memory allocation logs
In reply to Peter Senna TschudinThis patch remove three calls to dev_err() from sisusb_probe() as reporting memory allocation failures is redundant:
- Remove a call to dev_err() that was reporting unsuccesful call to kzalloc().
- Remove two calls to dev_err() that were reporting unsuccesful calls to kmalloc().
One call to dev_err() reporting memory allocation is left unchanged as the last patch of the series removes it.
---
Changes from V1:
- This patch contains only cleanups.
- The bug fix was moved to another patch.
Tested by compilation only.
drivers/usb/misc/sisusbvga/sisusb.c | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-)
drivers/usb/misc/sisusbvga/sisusb.c +2 -5
@@ -3036,10 +3036,9 @@ static int sisusb_probe(struct usb_interface *intf,/* Allocate memory for our private */ sisusb =kzalloc (sizeof (*sisusb),GFP_KERNEL ); -if (!sisusb) { -dev_err (&dev->dev,"Failed to allocate memory for private data\n" ); +if (!sisusb)return -ENOMEM ; - } +kref_init (&sisusb->kref);mutex_init (&(sisusb->lock));
@@ -3066,7 +3065,6 @@ static int sisusb_probe(struct usb_interface *intf, sisusb->ibufsize =SISUSB_IBUF_SIZE ; sisusb->ibuf =kmalloc (SISUSB_IBUF_SIZE ,GFP_KERNEL );if (!sisusb->ibuf) { -dev_err (&sisusb->sisusb_dev->dev,"Failed to allocate memory for input buffer" ); retval = -ENOMEM ; goto error_2; }
@@ -3077,7 +3075,6 @@ static int sisusb_probe(struct usb_interface *intf, sisusb->obuf[i] =kmalloc (SISUSB_OBUF_SIZE ,GFP_KERNEL );if (!sisusb->obuf[i]) {if (i ==0 ) { -dev_err (&sisusb->sisusb_dev->dev,"Failed to allocate memory for output buffer\n" ); retval = -ENOMEM ; goto error_3; }
Signature · 1 line
2.5.0
PATCH v2 3/7 usb-misc: sisusbvga: Fix coding style: braces, parenthesis, comment
In reply to Peter Senna TschudinFrom: Peter Senna Tschudin <[email protected]>
The file drivers/usb/misc/sisusbvga/sisusb.c contained coding style issues reported by checkpatch. This patch fixes the following errors:
- 12 WARNING: braces {} are not necessary for single statement blocks
- 04 ERROR: return is not a function, parentheses are not required
- 03 ERROR: do not initialise statics to 0
- 1 WARNING: else is not generally useful after a break or return
- 1 WARNING: braces {} are not necessary for any arm of this statement
- 1 WARNING: Block comments use * on subsequent lines
One case in which braces are not necessary is left unchanged as other patch of the series will fix it.
---
No changes from V1.
Tested by compilation only.
drivers/usb/misc/sisusbvga/sisusb.c | 88 +++++++++++++++++-------------------- 1 file changed, 41 insertions(+), 47 deletions(-)
drivers/usb/misc/sisusbvga/sisusb.c +41 -47
@@ -61,8 +61,8 @@/* Forward declarations / clean-up routines */ #ifdef INCL_SISUSB_CON -static int sisusb_first_vc =0 ; -static int sisusb_last_vc =0 ; +static int sisusb_first_vc; +static int sisusb_last_vc;module_param_named (first, sisusb_first_vc, int,0 );module_param_named (last, sisusb_last_vc, int,0 );MODULE_PARM_DESC (first,"Number of first console to take over (1 - MAX_NR_CONSOLES)" );
@@ -762,7 +762,7 @@ static int sisusb_write_mem_bulk(struct sisusb_usb_data *sisusb, u32 addr, {struct sisusb_packet packet;int ret =0 ; -static int msgcount =0 ; +static int msgcount;u8 swap8, fromkern = kernbuffer ?1 :0 ;u16 swap16;u32 swap32, flag = (length >>28 ) &1 ;
@@ -1129,12 +1129,10 @@ static int sisusb_read_mem_bulk(struct sisusb_usb_data *sisusb, u32 addr,if (!ret) { (*bytes_read)++;if (userbuffer) { -if (put_user (buf[0 ], (u8 __user *)userbuffer)) { +if (put_user (buf[0 ], (u8 __user *)userbuffer))return -EFAULT ; - } - }else { + }else kernbuffer[0 ] = buf[0 ]; - } }return ret;
@@ -1268,13 +1266,13 @@ static int sisusb_setidxregmask(struct sisusb_usb_data *sisusb,int sisusb_setidxregor (struct sisusb_usb_data *sisusb,int port,u8 index,u8 myor) { -return (sisusb_setidxregandor (sisusb, port, index,0xff , myor)); +return sisusb_setidxregandor (sisusb, port, index,0xff , myor); }int sisusb_setidxregand (struct sisusb_usb_data *sisusb,int port,u8 idx,u8 myand) { -return (sisusb_setidxregandor (sisusb, port, idx, myand,0x00 )); +return sisusb_setidxregandor (sisusb, port, idx, myand,0x00 ); }/* Write/read video ram */
@@ -1282,27 +1280,27 @@ int sisusb_setidxregand(struct sisusb_usb_data *sisusb, int port,#ifdef INCL_SISUSB_CON int sisusb_writeb (struct sisusb_usb_data *sisusb,u32 adr,u8 data) { -return (sisusb_write_memio_byte (sisusb,SISUSB_TYPE_MEM , adr, data)); +return sisusb_write_memio_byte (sisusb,SISUSB_TYPE_MEM , adr, data); }int sisusb_readb (struct sisusb_usb_data *sisusb,u32 adr,u8 *data) { -return (sisusb_read_memio_byte (sisusb,SISUSB_TYPE_MEM , adr, data)); +return sisusb_read_memio_byte (sisusb,SISUSB_TYPE_MEM , adr, data); }int sisusb_copy_memory (struct sisusb_usb_data *sisusb,char *src,u32 dest,int length,size_t *bytes_written) { -return (sisusb_write_mem_bulk (sisusb, dest, src, length, -NULL ,0 , bytes_written)); +return sisusb_write_mem_bulk (sisusb, dest, src, length, +NULL ,0 , bytes_written); }#ifdef SISUSBENDIANTEST int sisusb_read_memory (struct sisusb_usb_data *sisusb,char *dest,u32 src,int length,size_t *bytes_written) { -return (sisusb_read_mem_bulk (sisusb, src, dest, length, -NULL , bytes_written)); +return sisusb_read_mem_bulk (sisusb, src, dest, length, +NULL , bytes_written); }#endif #endif
@@ -1818,18 +1816,18 @@ static int sisusb_set_default_mode(struct sisusb_usb_data *sisusb,SETIREGAND (SISSR ,0x37 ,0xfe );SETREG (SISMISCW ,0xef );/* sync */ SETIREG (SISCR ,0x11 ,0x00 );/* crtc */ -for (j =0x00 , i =0 ; i <=7 ; i++, j++) { +for (j =0x00 , i =0 ; i <=7 ; i++, j++)SETIREG (SISCR , j, crtcdata[i]); - } -for (j =0x10 ; i <=10 ; i++, j++) { + +for (j =0x10 ; i <=10 ; i++, j++)SETIREG (SISCR , j, crtcdata[i]); - } -for (j =0x15 ; i <=12 ; i++, j++) { + +for (j =0x15 ; i <=12 ; i++, j++)SETIREG (SISCR , j, crtcdata[i]); - } -for (j =0x0A ; i <=15 ; i++, j++) { + +for (j =0x0A ; i <=15 ; i++, j++)SETIREG (SISSR , j, crtcdata[i]); - } +SETIREG (SISSR ,0x0E , (crtcdata[16 ] &0xE0 ));SETIREGANDOR (SISCR ,0x09 ,0x5f , ((crtcdata[16 ] &0x01 ) <<5 ));SETIREG (SISCR ,0x14 ,0x4f );
@@ -1943,21 +1941,20 @@ static int sisusb_init_gfxcore(struct sisusb_usb_data *sisusb) ret |=SETREG (SISMISCW ,0x67 ); -for (i =0x06 ; i <=0x1f ; i++) { +for (i =0x06 ; i <=0x1f ; i++) ret |=SETIREG (SISSR , i,0x00 ); - } -for (i =0x21 ; i <=0x27 ; i++) { + +for (i =0x21 ; i <=0x27 ; i++) ret |=SETIREG (SISSR , i,0x00 ); - } -for (i =0x31 ; i <=0x3d ; i++) { + +for (i =0x31 ; i <=0x3d ; i++) ret |=SETIREG (SISSR , i,0x00 ); - } -for (i =0x12 ; i <=0x1b ; i++) { + +for (i =0x12 ; i <=0x1b ; i++) ret |=SETIREG (SISSR , i,0x00 ); - } -for (i =0x79 ; i <=0x7c ; i++) { + +for (i =0x79 ; i <=0x7c ; i++) ret |=SETIREG (SISCR , i,0x00 ); - }if (ret)continue ;
@@ -2108,11 +2105,11 @@ static void sisusb_get_ramconfig(struct sisusb_usb_data *sisusb)switch ((tmp8 >>2 ) &0x03 ) {case 0 : ramtypetext1 ="1 ch/1 r" ; -if (tmp82 &0x10 ) { +if (tmp82 &0x10 ) bw =32 ; - }else { +else bw = busSDR[(tmp8 &0x03 )]; - } +break ;case 1 : ramtypetext1 ="1 ch/2 r" ;
@@ -2271,10 +2268,10 @@ static int sisusb_init_gfxdevice(struct sisusb_usb_data *sisusb, int initscreen)#ifdef INCL_SISUSB_CON /* Set up default text mode: -- Set text mode (0x03) -- Upload default font -- Upload user font (if available) -*/ +* - Set text mode (0x03) +* - Upload default font +* - Upload user font (if available) +*/ int sisusb_reset_text_mode (struct sisusb_usb_data *sisusb,int init) {
@@ -2405,14 +2402,12 @@ static int sisusb_open(struct inode *inode, struct file *file)int subminor =iminor (inode); interface =usb_find_interface (&sisusb_driver, subminor); -if (!interface) { +if (!interface)return -ENODEV ; - } sisusb =usb_get_intfdata (interface); -if (!sisusb) { +if (!sisusb)return -ENODEV ; - }mutex_lock (&sisusb->lock);
@@ -3088,9 +3083,8 @@ static int sisusb_probe(struct usb_interface *intf, goto error_3; }break ; - }else - sisusb->numobufs++; - + } + sisusb->numobufs++; }/* Allocate URBs */
Signature · 1 line
2.5.0
PATCH v2 4/7 usb-misc: sisusbvga: Fix coding style: remove assignment from if tests
In reply to Peter Senna TschudinFrom: Peter Senna Tschudin <[email protected]>
The file drivers/usb/misc/sisusbvga/sisusb.c had 6 assignments inside if tests. This patch move the assignment outside the test. The changes also fix the remaining 2 lines that were over 80 characters.
---
No changes from V1.
Tested by compilation only.
drivers/usb/misc/sisusbvga/sisusb.c | 18 ++++++++++++------ 1 file changed, 12 insertions(+), 6 deletions(-)
drivers/usb/misc/sisusbvga/sisusb.c +12 -6
@@ -1378,7 +1378,8 @@ static int sisusb_clear_vram(struct sisusb_usb_data *sisusb,return 0 ;/* allocate free buffer/urb and clear the buffer */ -if ((i =sisusb_alloc_outbuf (sisusb)) <0 ) + i =sisusb_alloc_outbuf (sisusb); +if (i <0 )return -EBUSY ;memset (sisusb->obuf[i],0 , sisusb->obufsize);
@@ -3067,7 +3068,8 @@ static int sisusb_probe(struct usb_interface *intf,/* Allocate buffers */ sisusb->ibufsize =SISUSB_IBUF_SIZE ; -if (!(sisusb->ibuf =kmalloc (SISUSB_IBUF_SIZE ,GFP_KERNEL ))) { + sisusb->ibuf =kmalloc (SISUSB_IBUF_SIZE ,GFP_KERNEL ); +if (!sisusb->ibuf) {dev_err (&sisusb->sisusb_dev->dev,"Failed to allocate memory for input buffer" ); retval = -ENOMEM ; goto error_2;
@@ -3076,7 +3078,8 @@ static int sisusb_probe(struct usb_interface *intf, sisusb->numobufs =0 ; sisusb->obufsize =SISUSB_OBUF_SIZE ;for (i =0 ; i <NUMOBUFS ; i++) { -if (!(sisusb->obuf[i] =kmalloc (SISUSB_OBUF_SIZE ,GFP_KERNEL ))) { + sisusb->obuf[i] =kmalloc (SISUSB_OBUF_SIZE ,GFP_KERNEL ); +if (!sisusb->obuf[i]) {if (i ==0 ) {dev_err (&sisusb->sisusb_dev->dev,"Failed to allocate memory for output buffer\n" ); retval = -ENOMEM ;
@@ -3088,7 +3091,8 @@ static int sisusb_probe(struct usb_interface *intf, }/* Allocate URBs */ -if (!(sisusb->sisurbin =usb_alloc_urb (0 ,GFP_KERNEL ))) { + sisusb->sisurbin =usb_alloc_urb (0 ,GFP_KERNEL ); +if (!sisusb->sisurbin) {dev_err (&sisusb->sisusb_dev->dev,"Failed to allocate URBs\n" ); retval = -ENOMEM ; goto error_3;
@@ -3096,7 +3100,8 @@ static int sisusb_probe(struct usb_interface *intf, sisusb->completein =1 ;for (i =0 ; i < sisusb->numobufs; i++) { -if (!(sisusb->sisurbout[i] =usb_alloc_urb (0 ,GFP_KERNEL ))) { + sisusb->sisurbout[i] =usb_alloc_urb (0 ,GFP_KERNEL ); +if (!sisusb->sisurbout[i]) {dev_err (&sisusb->sisusb_dev->dev,"Failed to allocate URBs\n" ); retval = -ENOMEM ;
@@ -3112,7 +3117,8 @@ static int sisusb_probe(struct usb_interface *intf,#ifdef INCL_SISUSB_CON /* Allocate our SiS_Pr */ -if (!(sisusb->SiS_Pr =kmalloc (sizeof (struct SiS_Private ),GFP_KERNEL ))) { + sisusb->SiS_Pr =kmalloc (sizeof (struct SiS_Private ),GFP_KERNEL ); +if (!sisusb->SiS_Pr) {dev_err (&sisusb->sisusb_dev->dev,"Failed to allocate SiS_Pr\n" ); }#endif
Signature · 1 line
2.5.0
PATCH v2 2/7 usb-misc: sisusbvga: Fix coding style: vertical whitespace changes
In reply to Peter Senna TschudinThis patch fixes whitespace coding style issues that can't be fixed without adding newlines. This patch fixes the following checkpatch warnings:
- 20 ERROR: trailing statements should be on next line
- 15 WARNING: line over 80 characters
- 03 WARNING: Missing a blank line after declarations
- 01 ERROR: space required after that ','
Five lines over 80 characters are left. The first three wont change as the fix would require split the cast and variable name in different lines which makes the code less readable. The last two will be fixed by other patch in the series.
---
Changes from V1:
- This patch contains vertical whitespace changes
- Horizontal whitespace changes are now in the previous patch
Tested by compilation only.
drivers/usb/misc/sisusbvga/sisusb.c | 494 +++++++++++++++++------------------- 1 file changed, 236 insertions(+), 258 deletions(-)
drivers/usb/misc/sisusbvga/sisusb.c +236 -258
@@ -71,8 +71,7 @@ MODULE_PARM_DESC(last, "Number of last console to take over (1 - MAX_NR_CONSOLESstatic struct usb_driver sisusb_driver; -static void -sisusb_free_buffers (struct sisusb_usb_data *sisusb) +static void sisusb_free_buffers (struct sisusb_usb_data *sisusb) {int i;
@@ -88,8 +87,7 @@ sisusb_free_buffers(struct sisusb_usb_data *sisusb) } } -static void -sisusb_free_urbs (struct sisusb_usb_data *sisusb) +static void sisusb_free_urbs (struct sisusb_usb_data *sisusb) {int i;
@@ -108,8 +106,7 @@ sisusb_free_urbs(struct sisusb_usb_data *sisusb)/* out-urb management */ /* Return 1 if all free, 0 otherwise */ -static int -sisusb_all_free (struct sisusb_usb_data *sisusb) +static int sisusb_all_free (struct sisusb_usb_data *sisusb) {int i;
@@ -124,8 +121,7 @@ sisusb_all_free(struct sisusb_usb_data *sisusb) }/* Kill all busy URBs */ -static void -sisusb_kill_all_busy (struct sisusb_usb_data *sisusb) +static void sisusb_kill_all_busy (struct sisusb_usb_data *sisusb) {int i;
@@ -141,20 +137,17 @@ sisusb_kill_all_busy(struct sisusb_usb_data *sisusb) }/* Return 1 if ok, 0 if error (not all complete within timeout) */ -static int -sisusb_wait_all_out_complete (struct sisusb_usb_data *sisusb) +static int sisusb_wait_all_out_complete (struct sisusb_usb_data *sisusb) {int timeout =5 *HZ , i =1 ; -wait_event_timeout (sisusb->wait_q, - (i =sisusb_all_free (sisusb)), - timeout); +wait_event_timeout (sisusb->wait_q, (i =sisusb_all_free (sisusb)), + timeout);return i; } -static int -sisusb_outurb_available (struct sisusb_usb_data *sisusb) +static int sisusb_outurb_available (struct sisusb_usb_data *sisusb) {int i;
@@ -168,20 +161,17 @@ sisusb_outurb_available(struct sisusb_usb_data *sisusb)return -1 ; } -static int -sisusb_get_free_outbuf (struct sisusb_usb_data *sisusb) +static int sisusb_get_free_outbuf (struct sisusb_usb_data *sisusb) {int i, timeout =5 *HZ ;wait_event_timeout (sisusb->wait_q, - ((i =sisusb_outurb_available (sisusb)) >=0 ), - timeout); + ((i =sisusb_outurb_available (sisusb)) >=0 ), timeout);return i; } -static int -sisusb_alloc_outbuf (struct sisusb_usb_data *sisusb) +static int sisusb_alloc_outbuf (struct sisusb_usb_data *sisusb) {int i;
@@ -193,8 +183,7 @@ sisusb_alloc_outbuf(struct sisusb_usb_data *sisusb)return i; } -static void -sisusb_free_outbuf (struct sisusb_usb_data *sisusb,int index) +static void sisusb_free_outbuf (struct sisusb_usb_data *sisusb,int index) {if ((index >=0 ) && (index < sisusb->numobufs)) sisusb->urbstatus[index] &= ~SU_URB_ALLOC ;
@@ -202,8 +191,7 @@ sisusb_free_outbuf(struct sisusb_usb_data *sisusb, int index)/* completion callback */ -static void -sisusb_bulk_completeout (struct urb *urb) +static void sisusb_bulk_completeout (struct urb *urb) {struct sisusb_urb_context *context = urb->context;struct sisusb_usb_data *sisusb;
@@ -225,9 +213,9 @@ sisusb_bulk_completeout(struct urb *urb)wake_up (&sisusb->wait_q); } -static int -sisusb_bulkout_msg (struct sisusb_usb_data *sisusb,int index,unsigned int pipe,void *data, -int len,int *actual_length,int timeout,unsigned int tflags) +static int sisusb_bulkout_msg (struct sisusb_usb_data *sisusb,int index, +unsigned int pipe,void *data,int len,int *actual_length, +int timeout,unsigned int tflags) {struct urb *urb = sisusb->sisurbout[index];int retval, byteswritten =0 ;
@@ -236,7 +224,8 @@ sisusb_bulkout_msg(struct sisusb_usb_data *sisusb, int index, unsigned int pipe, urb->transfer_flags =0 ;usb_fill_bulk_urb (urb, sisusb->sisusb_dev, pipe, data, len, - sisusb_bulk_completeout, &sisusb->urbout_context[index]); + sisusb_bulk_completeout, + &sisusb->urbout_context[index]); urb->transfer_flags |= tflags; urb->actual_length =0 ;
@@ -277,8 +266,7 @@ sisusb_bulkout_msg(struct sisusb_usb_data *sisusb, int index, unsigned int pipe,/* completion callback */ -static void -sisusb_bulk_completein (struct urb *urb) +static void sisusb_bulk_completein (struct urb *urb) {struct sisusb_usb_data *sisusb = urb->context;
@@ -289,9 +277,9 @@ sisusb_bulk_completein(struct urb *urb)wake_up (&sisusb->wait_q); } -static int -sisusb_bulkin_msg (struct sisusb_usb_data *sisusb,unsigned int pipe,void *data, -int len,int *actual_length,int timeout,unsigned int tflags) +static int sisusb_bulkin_msg (struct sisusb_usb_data *sisusb, +unsigned int pipe,void *data,int len, +int *actual_length,int timeout,unsigned int tflags) {struct urb *urb = sisusb->sisurbin;int retval, readbytes =0 ;
@@ -405,14 +393,9 @@ static int sisusb_send_bulk_msg(struct sisusb_usb_data *sisusb, int ep, int len,if (!sisusb->sisusb_dev)return -ENODEV ; - result =sisusb_bulkout_msg (sisusb, - index, - pipe, - buffer, - thispass, - &transferred_len, - async ?0 :5 *HZ , - tflags); + result =sisusb_bulkout_msg (sisusb, index, pipe, + buffer, thispass, &transferred_len, + async ?0 :5 *HZ , tflags);if (result == -ETIMEDOUT ) {
@@ -500,13 +483,8 @@ static int sisusb_recv_bulk_msg(struct sisusb_usb_data *sisusb, int ep, int len, thispass = (bufsize < count) ? bufsize : count; - result =sisusb_bulkin_msg (sisusb, - pipe, - buffer, - thispass, - &transferred_len, -5 *HZ , - tflags); + result =sisusb_bulkin_msg (sisusb, pipe, buffer, thispass, + &transferred_len,5 *HZ , tflags);if (transferred_len) thispass = transferred_len;
@@ -585,8 +563,7 @@ static int sisusb_send_packet(struct sisusb_usb_data *sisusb, int len, }static int sisusb_send_bridge_packet (struct sisusb_usb_data *sisusb,int len, -struct sisusb_packet *packet, -unsigned int tflags) +struct sisusb_packet *packet,unsigned int tflags) {int ret;ssize_t bytes_transferred =0 ;
@@ -780,9 +757,8 @@ static int sisusb_write_memio_long(struct sisusb_usb_data *sisusb, int type,*/ static int sisusb_write_mem_bulk (struct sisusb_usb_data *sisusb,u32 addr, -char *kernbuffer,int length, -const char __user *userbuffer,int index, -ssize_t *bytes_written) +char *kernbuffer,int length,const char __user *userbuffer, +int index,ssize_t *bytes_written) {struct sisusb_packet packet;int ret =0 ;
@@ -811,9 +787,8 @@ static int sisusb_write_mem_bulk(struct sisusb_usb_data *sisusb, u32 addr, }else swap8 = kernbuffer[0 ]; - ret =sisusb_write_memio_byte (sisusb, -SISUSB_TYPE_MEM , - addr, swap8); + ret =sisusb_write_memio_byte (sisusb,SISUSB_TYPE_MEM , + addr, swap8);if (!ret) (*bytes_written)++;
@@ -827,10 +802,8 @@ static int sisusb_write_mem_bulk(struct sisusb_usb_data *sisusb, u32 addr, }else swap16 = *((u16 *)kernbuffer); - ret =sisusb_write_memio_word (sisusb, -SISUSB_TYPE_MEM , - addr, - swap16); + ret =sisusb_write_memio_word (sisusb,SISUSB_TYPE_MEM , + addr, swap16);if (!ret) (*bytes_written) +=2 ;
@@ -861,10 +834,8 @@ static int sisusb_write_mem_bulk(struct sisusb_usb_data *sisusb, u32 addr, kernbuffer[0 ];#endif - ret =sisusb_write_memio_24bit (sisusb, -SISUSB_TYPE_MEM , - addr, - swap32); + ret =sisusb_write_memio_24bit (sisusb,SISUSB_TYPE_MEM , + addr, swap32);if (!ret) (*bytes_written) +=3 ;
@@ -878,10 +849,8 @@ static int sisusb_write_mem_bulk(struct sisusb_usb_data *sisusb, u32 addr, }else swap32 = *((u32 *)kernbuffer); - ret =sisusb_write_memio_long (sisusb, -SISUSB_TYPE_MEM , - addr, - swap32); + ret =sisusb_write_memio_long (sisusb,SISUSB_TYPE_MEM , + addr, swap32);if (!ret) (*bytes_written) +=4 ;
@@ -976,10 +945,13 @@ static int sisusb_write_mem_bulk(struct sisusb_usb_data *sisusb, u32 addr,if (ret) { msgcount++;if (msgcount <500 ) -dev_err (&sisusb->sisusb_dev->dev,"Wrote %zd of %d bytes, error %d\n" , - *bytes_written, length, ret); +dev_err (&sisusb->sisusb_dev->dev, +"Wrote %zd of %d bytes, error %d\n" , + *bytes_written, length, + ret);else if (msgcount ==500 ) -dev_err (&sisusb->sisusb_dev->dev,"Too many errors, logging stopped\n" ); +dev_err (&sisusb->sisusb_dev->dev, +"Too many errors, logging stopped\n" ); } addr += (*bytes_written); length -= (*bytes_written);
@@ -1137,8 +1109,8 @@ static int sisusb_read_memio_long(struct sisusb_usb_data *sisusb, int type, }static int sisusb_read_mem_bulk (struct sisusb_usb_data *sisusb,u32 addr, -char *kernbuffer,int length, -char __user *userbuffer,ssize_t *bytes_read) +char *kernbuffer,int length,char __user *userbuffer, +ssize_t *bytes_read) {int ret =0 ;char buf[4 ];
@@ -1157,8 +1129,7 @@ static int sisusb_read_mem_bulk(struct sisusb_usb_data *sisusb, u32 addr,if (!ret) { (*bytes_read)++;if (userbuffer) { -if (put_user (buf[0 ], - (u8 __user *)userbuffer)) { +if (put_user (buf[0 ], (u8 __user *)userbuffer)) {return -EFAULT ; } }else {
@@ -1173,8 +1144,7 @@ static int sisusb_read_mem_bulk(struct sisusb_usb_data *sisusb, u32 addr,if (!ret) { (*bytes_read) +=2 ;if (userbuffer) { -if (put_user (swap16, - (u16 __user *)userbuffer)) +if (put_user (swap16, (u16 __user *)userbuffer))return -EFAULT ; }else { *((u16 *)kernbuffer) = swap16;
@@ -1197,7 +1167,8 @@ static int sisusb_read_mem_bulk(struct sisusb_usb_data *sisusb, u32 addr, buf[0 ] = swap32 &0xff ;#endif if (userbuffer) { -if (copy_to_user (userbuffer, &buf[0 ],3 )) +if (copy_to_user (userbuffer, + &buf[0 ],3 ))return -EFAULT ; }else { kernbuffer[0 ] = buf[0 ];
@@ -1213,8 +1184,7 @@ static int sisusb_read_mem_bulk(struct sisusb_usb_data *sisusb, u32 addr,if (!ret) { (*bytes_read) +=4 ;if (userbuffer) { -if (put_user (swap32, - (u32 __user *)userbuffer)) +if (put_user (swap32, (u32 __user *)userbuffer))return -EFAULT ; userbuffer +=4 ;
@@ -1236,40 +1206,39 @@ static int sisusb_read_mem_bulk(struct sisusb_usb_data *sisusb, u32 addr,/* High level: Gfx (indexed) register access */ #ifdef INCL_SISUSB_CON -int -sisusb_setreg (struct sisusb_usb_data *sisusb,int port,u8 data) +int sisusb_setreg (struct sisusb_usb_data *sisusb,int port,u8 data) {return sisusb_write_memio_byte (sisusb,SISUSB_TYPE_IO , port, data); } -int -sisusb_getreg (struct sisusb_usb_data *sisusb,int port,u8 *data) +int sisusb_getreg (struct sisusb_usb_data *sisusb,int port,u8 *data) {return sisusb_read_memio_byte (sisusb,SISUSB_TYPE_IO , port, data); }#endif -int -sisusb_setidxreg (struct sisusb_usb_data *sisusb,int port,u8 index,u8 data) +int sisusb_setidxreg (struct sisusb_usb_data *sisusb,int port, +u8 index,u8 data) {int ret; + ret =sisusb_write_memio_byte (sisusb,SISUSB_TYPE_IO , port, index); ret |=sisusb_write_memio_byte (sisusb,SISUSB_TYPE_IO , port +1 , data);return ret; } -int -sisusb_getidxreg (struct sisusb_usb_data *sisusb,int port,u8 index,u8 *data) +int sisusb_getidxreg (struct sisusb_usb_data *sisusb,int port, +u8 index,u8 *data) {int ret; + ret =sisusb_write_memio_byte (sisusb,SISUSB_TYPE_IO , port, index); ret |=sisusb_read_memio_byte (sisusb,SISUSB_TYPE_IO , port +1 , data);return ret; } -int -sisusb_setidxregandor (struct sisusb_usb_data *sisusb,int port,u8 idx, -u8 myand,u8 myor) +int sisusb_setidxregandor (struct sisusb_usb_data *sisusb,int port,u8 idx, +u8 myand,u8 myor) {int ret;u8 tmp;
@@ -1282,12 +1251,12 @@ sisusb_setidxregandor(struct sisusb_usb_data *sisusb, int port, u8 idx,return ret; } -static int -sisusb_setidxregmask (struct sisusb_usb_data *sisusb,int port,u8 idx, -u8 data,u8 mask) +static int sisusb_setidxregmask (struct sisusb_usb_data *sisusb, +int port,u8 idx,u8 data,u8 mask) {int ret;u8 tmp; + ret =sisusb_write_memio_byte (sisusb,SISUSB_TYPE_IO , port, idx); ret |=sisusb_read_memio_byte (sisusb,SISUSB_TYPE_IO , port +1 , &tmp); tmp &= ~(mask);
@@ -1296,14 +1265,14 @@ sisusb_setidxregmask(struct sisusb_usb_data *sisusb, int port, u8 idx,return ret; } -int -sisusb_setidxregor (struct sisusb_usb_data *sisusb,int port,u8 index,u8 myor) +int sisusb_setidxregor (struct sisusb_usb_data *sisusb,int port, +u8 index,u8 myor) {return (sisusb_setidxregandor (sisusb, port, index,0xff , myor)); } -int -sisusb_setidxregand (struct sisusb_usb_data *sisusb,int port,u8 idx,u8 myand) +int sisusb_setidxregand (struct sisusb_usb_data *sisusb,int port, +u8 idx,u8 myand) {return (sisusb_setidxregandor (sisusb, port, idx, myand,0x00 )); }
@@ -1311,38 +1280,35 @@ sisusb_setidxregand(struct sisusb_usb_data *sisusb, int port, u8 idx, u8 myand)/* Write/read video ram */ #ifdef INCL_SISUSB_CON -int -sisusb_writeb (struct sisusb_usb_data *sisusb,u32 adr,u8 data) +int sisusb_writeb (struct sisusb_usb_data *sisusb,u32 adr,u8 data) {return (sisusb_write_memio_byte (sisusb,SISUSB_TYPE_MEM , adr, data)); } -int -sisusb_readb (struct sisusb_usb_data *sisusb,u32 adr,u8 *data) +int sisusb_readb (struct sisusb_usb_data *sisusb,u32 adr,u8 *data) {return (sisusb_read_memio_byte (sisusb,SISUSB_TYPE_MEM , adr, data)); } -int -sisusb_copy_memory (struct sisusb_usb_data *sisusb,char *src, -u32 dest,int length,size_t *bytes_written) +int sisusb_copy_memory (struct sisusb_usb_data *sisusb,char *src, +u32 dest,int length,size_t *bytes_written) { -return (sisusb_write_mem_bulk (sisusb, dest, src, length,NULL ,0 , bytes_written)); +return (sisusb_write_mem_bulk (sisusb, dest, src, length, +NULL ,0 , bytes_written)); }#ifdef SISUSBENDIANTEST -int -sisusb_read_memory (struct sisusb_usb_data *sisusb,char *dest, -u32 src,int length,size_t *bytes_written) +int sisusb_read_memory (struct sisusb_usb_data *sisusb,char *dest, +u32 src,int length,size_t *bytes_written) { -return (sisusb_read_mem_bulk (sisusb, src, dest, length,NULL , bytes_written)); +return (sisusb_read_mem_bulk (sisusb, src, dest, length, +NULL , bytes_written)); }#endif #endif #ifdef SISUSBENDIANTEST -static void -sisusb_testreadwrite (struct sisusb_usb_data *sisusb) +static void sisusb_testreadwrite (struct sisusb_usb_data *sisusb) {static char srcbuffer[] = {0x11 ,0x22 ,0x33 ,0x44 ,0x55 ,0x66 ,0x77 };char destbuffer[10 ];
@@ -1367,8 +1333,8 @@ sisusb_testreadwrite(struct sisusb_usb_data *sisusb)/* access pci config registers (reg numbers 0, 4, 8, etc) */ -static int -sisusb_write_pci_config (struct sisusb_usb_data *sisusb,int regnum,u32 data) +static int sisusb_write_pci_config (struct sisusb_usb_data *sisusb, +int regnum,u32 data) {struct sisusb_packet packet;int ret;
@@ -1380,8 +1346,8 @@ sisusb_write_pci_config(struct sisusb_usb_data *sisusb, int regnum, u32 data)return ret; } -static int -sisusb_read_pci_config (struct sisusb_usb_data *sisusb,int regnum,u32 *data) +static int sisusb_read_pci_config (struct sisusb_usb_data *sisusb, +int regnum,u32 *data) {struct sisusb_packet packet;int ret;
@@ -1395,8 +1361,8 @@ sisusb_read_pci_config(struct sisusb_usb_data *sisusb, int regnum, u32 *data)/* Clear video RAM */ -static int -sisusb_clear_vram (struct sisusb_usb_data *sisusb,u32 address,int length) +static int sisusb_clear_vram (struct sisusb_usb_data *sisusb, +u32 address,int length) {int ret, i;ssize_t j;
@@ -1447,8 +1413,7 @@ sisusb_clear_vram(struct sisusb_usb_data *sisusb, u32 address, int length)#define READB (a, d) sisusb_read_memio_byte(sisusb, SISUSB_TYPE_MEM, a, d)#define WRITEB (a, d) sisusb_write_memio_byte(sisusb, SISUSB_TYPE_MEM, a, d) -static int -sisusb_triggersr16 (struct sisusb_usb_data *sisusb,u8 ramtype) +static int sisusb_triggersr16 (struct sisusb_usb_data *sisusb,u8 ramtype) {int ret;u8 tmp8;
@@ -1478,8 +1443,8 @@ sisusb_triggersr16(struct sisusb_usb_data *sisusb, u8 ramtype)return ret; } -static int -sisusb_getbuswidth (struct sisusb_usb_data *sisusb,int *bw,int *chab) +static int sisusb_getbuswidth (struct sisusb_usb_data *sisusb, +int *bw,int *chab) {int ret;u8 ramtype, done =0 ;
@@ -1591,8 +1556,7 @@ sisusb_getbuswidth(struct sisusb_usb_data *sisusb, int *bw, int *chab)return ret; } -static int -sisusb_verify_mclk (struct sisusb_usb_data *sisusb) +static int sisusb_verify_mclk (struct sisusb_usb_data *sisusb) {int ret =0 ;u32 ramptr =SISUSB_PCI_MEMBASE ;
@@ -1620,10 +1584,8 @@ sisusb_verify_mclk(struct sisusb_usb_data *sisusb)return ret; } -static int -sisusb_set_rank (struct sisusb_usb_data *sisusb,int *iret,int index, -u8 rankno,u8 chab,const u8 dramtype[][5 ], -int bw) +static int sisusb_set_rank (struct sisusb_usb_data *sisusb,int *iret, +int index,u8 rankno,u8 chab,const u8 dramtype[][5 ],int bw) {int ret =0 , ranksize;u8 tmp;
@@ -1639,7 +1601,9 @@ sisusb_set_rank(struct sisusb_usb_data *sisusb, int *iret, int index,return ret; tmp =0 ; -while ((ranksize >>=1 ) >0 ) tmp +=0x10 ; +while ((ranksize >>=1 ) >0 ) + tmp +=0x10 ; + tmp |= ((rankno -1 ) <<2 ); tmp |= ((bw /64 ) &0x02 ); tmp |= (chab &0x01 );
@@ -1652,8 +1616,8 @@ sisusb_set_rank(struct sisusb_usb_data *sisusb, int *iret, int index,return ret; } -static int -sisusb_check_rbc (struct sisusb_usb_data *sisusb,int *iret,u32 inc,int testn) +static int sisusb_check_rbc (struct sisusb_usb_data *sisusb,int *iret, +u32 inc,int testn) {int ret =0 , i;u32 j, tmp;
@@ -1667,7 +1631,9 @@ sisusb_check_rbc(struct sisusb_usb_data *sisusb, int *iret, u32 inc, int testn)for (i =0 , j =0 ; i < testn; i++) { ret |=READL (sisusb->vrambase + j, &tmp); -if (tmp != j)return ret; +if (tmp != j) +return ret; + j += inc; }
@@ -1675,9 +1641,8 @@ sisusb_check_rbc(struct sisusb_usb_data *sisusb, int *iret, u32 inc, int testn)return ret; } -static int -sisusb_check_ranks (struct sisusb_usb_data *sisusb,int *iret,int rankno, -int idx,int bw,const u8 rtype[][5 ]) +static int sisusb_check_ranks (struct sisusb_usb_data *sisusb, +int *iret,int rankno,int idx,int bw,const u8 rtype[][5 ]) {int ret =0 , i, i2ret;u32 inc;
@@ -1685,10 +1650,8 @@ sisusb_check_ranks(struct sisusb_usb_data *sisusb, int *iret, int rankno, *iret =0 ;for (i = rankno; i >=1 ; i--) { - inc =1 << (rtype[idx][2 ] + - rtype[idx][1 ] + - rtype[idx][0 ] + - bw /64 + i); + inc =1 << (rtype[idx][2 ] + rtype[idx][1 ] + rtype[idx][0 ] + + bw /64 + i); ret |=sisusb_check_rbc (sisusb, &i2ret, inc,2 );if (!i2ret)return ret;
@@ -1708,9 +1671,8 @@ sisusb_check_ranks(struct sisusb_usb_data *sisusb, int *iret, int rankno,return ret; } -static int -sisusb_get_sdram_size (struct sisusb_usb_data *sisusb,int *iret,int bw, -int chab) +static int sisusb_get_sdram_size (struct sisusb_usb_data *sisusb,int *iret, +int bw,int chab) {int ret =0 , i2ret =0 , i, j;static const u8 sdramtype[13 ][5 ] = {
@@ -1734,13 +1696,13 @@ sisusb_get_sdram_size(struct sisusb_usb_data *sisusb, int *iret, int bw,for (i =0 ; i <13 ; i++) { ret |=SETIREGANDOR (SISSR ,0x13 ,0x80 , sdramtype[i][4 ]);for (j =2 ; j >0 ; j--) { - ret |=sisusb_set_rank (sisusb, &i2ret, i, j, - chab, sdramtype, bw); + ret |=sisusb_set_rank (sisusb, &i2ret, i, j, chab, + sdramtype, bw);if (!i2ret)continue ; - ret |=sisusb_check_ranks (sisusb, &i2ret, j, i, - bw, sdramtype); + ret |=sisusb_check_ranks (sisusb, &i2ret, j, i, bw, + sdramtype);if (i2ret) { *iret =0 ;/* ram size found */ return ret;
@@ -1751,8 +1713,8 @@ sisusb_get_sdram_size(struct sisusb_usb_data *sisusb, int *iret, int bw,return ret; } -static int -sisusb_setup_screen (struct sisusb_usb_data *sisusb,int clrall,int drwfr) +static int sisusb_setup_screen (struct sisusb_usb_data *sisusb, +int clrall,int drwfr) {int ret =0 ;u32 address;
@@ -1791,8 +1753,8 @@ sisusb_setup_screen(struct sisusb_usb_data *sisusb, int clrall, int drwfr)return ret; } -static int -sisusb_set_default_mode (struct sisusb_usb_data *sisusb,int touchengines) +static int sisusb_set_default_mode (struct sisusb_usb_data *sisusb, +int touchengines) {int ret =0 , i, j, modex, modey, bpp, du;u8 sr31, cr63, tmp8;
@@ -1872,12 +1834,16 @@ sisusb_set_default_mode(struct sisusb_usb_data *sisusb, int touchengines)SETIREGANDOR (SISCR ,0x09 ,0x5f , ((crtcdata[16 ] &0x01 ) <<5 ));SETIREG (SISCR ,0x14 ,0x4f ); du = (modex /16 ) * (bpp *2 );/* offset/pitch */ -if (modex %16 ) du += bpp; +if (modex %16 ) + du += bpp; +SETIREGANDOR (SISSR ,0x0e ,0xf0 , ((du >>8 ) &0x0f ));SETIREG (SISCR ,0x13 , (du &0xff )); du <<=5 ; tmp8 = du >>8 ; -if (du &0xff ) tmp8++; +if (du &0xff ) + tmp8++; +SETIREG (SISSR ,0x10 , tmp8);SETIREG (SISSR ,0x31 ,0x00 );/* VCLK */ SETIREG (SISSR ,0x2b ,0x1b );
@@ -1923,8 +1889,7 @@ sisusb_set_default_mode(struct sisusb_usb_data *sisusb, int touchengines)return ret; } -static int -sisusb_init_gfxcore (struct sisusb_usb_data *sisusb) +static int sisusb_init_gfxcore (struct sisusb_usb_data *sisusb) {int ret =0 , i, j, bw, chab, iret, retry =3 ;u8 tmp8, ramtype;
@@ -1968,7 +1933,8 @@ sisusb_init_gfxcore(struct sisusb_usb_data *sisusb) ret |=GETREG (SISMISCR , &tmp8); ret |=SETREG (SISMISCW , (tmp8 |0x01 )); -if (ret)continue ; +if (ret) +continue ;/* Reset registers */ ret |=SETIREGAND (SISCR ,0x5b ,0xdf );
@@ -1993,7 +1959,8 @@ sisusb_init_gfxcore(struct sisusb_usb_data *sisusb) ret |=SETIREG (SISCR , i,0x00 ); } -if (ret)continue ; +if (ret) +continue ; ret |=SETIREG (SISCR ,0x63 ,0x80 );
@@ -2011,13 +1978,16 @@ sisusb_init_gfxcore(struct sisusb_usb_data *sisusb) ret |=SETIREG (SISSR ,0x07 ,0x18 ); ret |=SETIREG (SISSR ,0x11 ,0x0f ); -if (ret)continue ; +if (ret) +continue ;for (i =0x15 , j =0 ; i <=0x1b ; i++, j++) { - ret |=SETIREG (SISSR , i, ramtypetable1[(j*4 ) + ramtype]); + ret |=SETIREG (SISSR , i, + ramtypetable1[(j*4 ) + ramtype]); }for (i =0x40 , j =0 ; i <=0x44 ; i++, j++) { - ret |=SETIREG (SISCR , i, ramtypetable2[(j*4 ) + ramtype]); + ret |=SETIREG (SISCR , i, + ramtypetable2[(j*4 ) + ramtype]); } ret |=SETIREG (SISCR ,0x49 ,0xaa );
@@ -2034,7 +2004,8 @@ sisusb_init_gfxcore(struct sisusb_usb_data *sisusb) ret |=SETIREGAND (SISCAP ,0x3f ,0xef ); -if (ret)continue ; +if (ret) +continue ; ret |=SETIREG (SISPART1 ,0x00 ,0x00 );
@@ -2056,7 +2027,8 @@ sisusb_init_gfxcore(struct sisusb_usb_data *sisusb) ret |=SETIREG (SISSR ,0x32 ,0x11 ); ret |=SETIREG (SISSR ,0x33 ,0x00 ); -if (ret)continue ; +if (ret) +continue ; ret |=SETIREG (SISCR ,0x83 ,0x00 );
@@ -2078,12 +2050,14 @@ sisusb_init_gfxcore(struct sisusb_usb_data *sisusb)if (ramtype <=1 ) { ret |=sisusb_get_sdram_size (sisusb, &iret, bw, chab);if (iret) { -dev_err (&sisusb->sisusb_dev->dev,"RAM size detection failed, assuming 8MB video RAM\n" ); +dev_err (&sisusb->sisusb_dev->dev, +"RAM size detection failed, assuming 8MB video RAM\n" ); ret |=SETIREG (SISSR ,0x14 ,0x31 );/* TODO */ } }else { -dev_err (&sisusb->sisusb_dev->dev,"DDR RAM device found, assuming 8MB video RAM\n" ); +dev_err (&sisusb->sisusb_dev->dev, +"DDR RAM device found, assuming 8MB video RAM\n" ); ret |=SETIREG (SISSR ,0x14 ,0x31 );/* *** TODO *** */ }
@@ -2115,8 +2089,7 @@ sisusb_init_gfxcore(struct sisusb_usb_data *sisusb)#undef READL#undef WRITEL -static void -sisusb_get_ramconfig (struct sisusb_usb_data *sisusb) +static void sisusb_get_ramconfig (struct sisusb_usb_data *sisusb) {u8 tmp8, tmp82, ramtype;int bw =0 ;
@@ -2133,35 +2106,38 @@ sisusb_get_ramconfig(struct sisusb_usb_data *sisusb) sisusb->vramsize = (1 << ((tmp8 &0xf0 ) >>4 )) *1024 *1024 ; ramtype &=0x03 ;switch ((tmp8 >>2 ) &0x03 ) { -case 0 : ramtypetext1 ="1 ch/1 r" ; +case 0 : + ramtypetext1 ="1 ch/1 r" ;if (tmp82 &0x10 ) { bw =32 ; }else { bw = busSDR[(tmp8 &0x03 )]; }break ; -case 1 : ramtypetext1 ="1 ch/2 r" ; +case 1 : + ramtypetext1 ="1 ch/2 r" ; sisusb->vramsize <<=1 ; bw = busSDR[(tmp8 &0x03 )];break ; -case 2 : ramtypetext1 ="asymmeric" ; +case 2 : + ramtypetext1 ="asymmeric" ; sisusb->vramsize += sisusb->vramsize/2 ; bw = busDDRA[(tmp8 &0x03 )];break ; -case 3 : ramtypetext1 ="2 channel" ; +case 3 : + ramtypetext1 ="2 channel" ; sisusb->vramsize <<=1 ; bw = busDDR[(tmp8 &0x03 )];break ; } - -dev_info (&sisusb->sisusb_dev->dev,"%dMB %s %cDR S%cRAM, bus width %d\n" , - sisusb->vramsize >>20 , ramtypetext1, - ram_datarate[ramtype], ram_dynamictype[ramtype], bw); +dev_info (&sisusb->sisusb_dev->dev, +"%dMB %s %cDR S%cRAM, bus width %d\n" , + sisusb->vramsize >>20 , ramtypetext1, + ram_datarate[ramtype], ram_dynamictype[ramtype], bw); } -static int -sisusb_do_init_gfxdevice (struct sisusb_usb_data *sisusb) +static int sisusb_do_init_gfxdevice (struct sisusb_usb_data *sisusb) {struct sisusb_packet packet;int ret;
@@ -2239,8 +2215,7 @@ sisusb_do_init_gfxdevice(struct sisusb_usb_data *sisusb)* of the graphics board. */ -static int -sisusb_init_gfxdevice (struct sisusb_usb_data *sisusb,int initscreen) +static int sisusb_init_gfxdevice (struct sisusb_usb_data *sisusb,int initscreen) {int ret =0 , test =0 ;u32 tmp32;
@@ -2248,16 +2223,25 @@ sisusb_init_gfxdevice(struct sisusb_usb_data *sisusb, int initscreen)if (sisusb->devinit ==1 ) {/* Read PCI BARs and see if they have been set up */ ret |=sisusb_read_pci_config (sisusb,0x10 , &tmp32); -if (ret)return ret; -if ((tmp32 &0xfffffff0 ) ==SISUSB_PCI_MEMBASE ) test++; +if (ret) +return ret; + +if ((tmp32 &0xfffffff0 ) ==SISUSB_PCI_MEMBASE ) + test++; ret |=sisusb_read_pci_config (sisusb,0x14 , &tmp32); -if (ret)return ret; -if ((tmp32 &0xfffffff0 ) ==SISUSB_PCI_MMIOBASE ) test++; +if (ret) +return ret; + +if ((tmp32 &0xfffffff0 ) ==SISUSB_PCI_MMIOBASE ) + test++; ret |=sisusb_read_pci_config (sisusb,0x18 , &tmp32); -if (ret)return ret; -if ((tmp32 &0xfffffff0 ) ==SISUSB_PCI_IOPORTBASE ) test++; +if (ret) +return ret; + +if ((tmp32 &0xfffffff0 ) ==SISUSB_PCI_IOPORTBASE ) + test++; }/* No? So reset the device */
@@ -2292,15 +2276,15 @@ sisusb_init_gfxdevice(struct sisusb_usb_data *sisusb, int initscreen)- Upload user font (if available) */ -int -sisusb_reset_text_mode (struct sisusb_usb_data *sisusb,int init) +int sisusb_reset_text_mode (struct sisusb_usb_data *sisusb,int init) {int ret =0 , slot = sisusb->font_slot, i;const struct font_desc *myfont;u8 *tempbuf;u16 *tempbufb;size_t written; -static const char bootstring[] ="SiSUSB VGA text console, (C) 2005 Thomas Winischhofer." ; +static const char bootstring[] = +"SiSUSB VGA text console, (C) 2005 Thomas Winischhofer." ;static const char bootlogo[] ="(o_ //\\ V_/_" ;/* sisusb->lock is down */
@@ -2326,7 +2310,8 @@ sisusb_reset_text_mode(struct sisusb_usb_data *sisusb, int init)memcpy (tempbuf + (i *32 ), myfont->data + (i *16 ),16 );/* Upload default font */ - ret =sisusbcon_do_font_op (sisusb,1 ,0 , tempbuf,8192 ,0 ,1 ,NULL ,16 ,0 ); + ret =sisusbcon_do_font_op (sisusb,1 ,0 , tempbuf,8192 , +0 ,1 ,NULL ,16 ,0 );vfree (tempbuf);
@@ -2373,7 +2358,8 @@ sisusb_reset_text_mode(struct sisusb_usb_data *sisusb, int init) }else if (sisusb->scrbuf) { ret |=sisusb_copy_memory (sisusb, (char *)sisusb->scrbuf, - sisusb->vrambase, sisusb->scrbuf_size, &written); + sisusb->vrambase, sisusb->scrbuf_size, + &written); }
@@ -2390,7 +2376,8 @@ sisusb_reset_text_mode(struct sisusb_usb_data *sisusb, int init) } slot = sisusb->sisusb_cursor_loc; -if (slot <0 ) slot =0 ; +if (slot <0 ) + slot =0 ; sisusb->sisusb_cursor_loc =-1 ; sisusb->bad_cursor_pos =1 ;
@@ -2411,8 +2398,7 @@ sisusb_reset_text_mode(struct sisusb_usb_data *sisusb, int init)/* fops */ -static int -sisusb_open (struct inode *inode,struct file *file) +static int sisusb_open (struct inode *inode,struct file *file) {struct sisusb_usb_data *sisusb;struct usb_interface *interface;
@@ -2445,12 +2431,14 @@ sisusb_open(struct inode *inode, struct file *file) sisusb->sisusb_dev->speed == USB_SPEED_SUPER) { if (sisusb_init_gfxdevice(sisusb, 0)) { mutex_unlock(&sisusb->lock); - dev_err(&sisusb->sisusb_dev->dev, "Failed to initialize device\n"); + dev_err(&sisusb->sisusb_dev->dev, + "Failed to initialize device\n"); return -EIO; } } else {mutex_unlock (&sisusb->lock); -dev_err (&sisusb->sisusb_dev->dev,"Device not attached to USB 2.0 hub\n" ); +dev_err (&sisusb->sisusb_dev->dev, +"Device not attached to USB 2.0 hub\n" );return -EIO ; } }
@@ -2467,8 +2455,7 @@ sisusb_open(struct inode *inode, struct file *file)return 0 ; } -void -sisusb_delete (struct kref *kref) +void sisusb_delete (struct kref *kref) {struct sisusb_usb_data *sisusb =to_sisusb_dev (kref);
@@ -2486,8 +2473,7 @@ sisusb_delete(struct kref *kref)kfree (sisusb); } -static int -sisusb_release (struct inode *inode,struct file *file) +static int sisusb_release (struct inode *inode,struct file *file) {struct sisusb_usb_data *sisusb;
@@ -2514,8 +2500,8 @@ sisusb_release(struct inode *inode, struct file *file)return 0 ; } -static ssize_t -sisusb_read (struct file *file,char __user *buffer,size_t count,loff_t *ppos) +static ssize_t sisusb_read (struct file *file,char __user *buffer, +size_t count,loff_t *ppos) {struct sisusb_usb_data *sisusb;ssize_t bytes_read =0 ;
@@ -2539,9 +2525,8 @@ sisusb_read(struct file *file, char __user *buffer, size_t count, loff_t *ppos)if ((*ppos) >=SISUSB_PCI_PSEUDO_IOPORTBASE && (*ppos) <SISUSB_PCI_PSEUDO_IOPORTBASE +128 ) { - address = (*ppos) - -SISUSB_PCI_PSEUDO_IOPORTBASE + -SISUSB_PCI_IOPORTBASE ; + address = (*ppos) -SISUSB_PCI_PSEUDO_IOPORTBASE + +SISUSB_PCI_IOPORTBASE ;/* Read i/o ports * Byte, word and long(32) can be read. As this
@@ -2550,8 +2535,7 @@ sisusb_read(struct file *file, char __user *buffer, size_t count, loff_t *ppos)*/ switch (count) {case 1 : -if (sisusb_read_memio_byte (sisusb, -SISUSB_TYPE_IO , +if (sisusb_read_memio_byte (sisusb,SISUSB_TYPE_IO , address, &buf8)) errno = -EIO ;else if (put_user (buf8, (u8 __user *)buffer))
@@ -2562,8 +2546,7 @@ sisusb_read(struct file *file, char __user *buffer, size_t count, loff_t *ppos)break ;case 2 : -if (sisusb_read_memio_word (sisusb, -SISUSB_TYPE_IO , +if (sisusb_read_memio_word (sisusb,SISUSB_TYPE_IO , address, &buf16)) errno = -EIO ;else if (put_user (buf16, (u16 __user *)buffer))
@@ -2574,8 +2557,7 @@ sisusb_read(struct file *file, char __user *buffer, size_t count, loff_t *ppos)break ;case 4 : -if (sisusb_read_memio_long (sisusb, -SISUSB_TYPE_IO , +if (sisusb_read_memio_long (sisusb,SISUSB_TYPE_IO , address, &buf32)) errno = -EIO ;else if (put_user (buf32, (u32 __user *)buffer))
@@ -2590,12 +2572,11 @@ sisusb_read(struct file *file, char __user *buffer, size_t count, loff_t *ppos) } - }else if ((*ppos) >=SISUSB_PCI_PSEUDO_MEMBASE && - (*ppos) <SISUSB_PCI_PSEUDO_MEMBASE + sisusb->vramsize) { + }else if ((*ppos) >=SISUSB_PCI_PSEUDO_MEMBASE && (*ppos) < +SISUSB_PCI_PSEUDO_MEMBASE + sisusb->vramsize) { - address = (*ppos) - -SISUSB_PCI_PSEUDO_MEMBASE + -SISUSB_PCI_MEMBASE ; + address = (*ppos) -SISUSB_PCI_PSEUDO_MEMBASE + +SISUSB_PCI_MEMBASE ;/* Read video ram * Remember: Data delivered is never endian-corrected
@@ -2607,11 +2588,11 @@ sisusb_read(struct file *file, char __user *buffer, size_t count, loff_t *ppos) errno = bytes_read; }else if ((*ppos) >=SISUSB_PCI_PSEUDO_MMIOBASE && - (*ppos) <SISUSB_PCI_PSEUDO_MMIOBASE +SISUSB_PCI_MMIOSIZE ) { + (*ppos) <SISUSB_PCI_PSEUDO_MMIOBASE + +SISUSB_PCI_MMIOSIZE ) { - address = (*ppos) - -SISUSB_PCI_PSEUDO_MMIOBASE + -SISUSB_PCI_MMIOBASE ; + address = (*ppos) -SISUSB_PCI_PSEUDO_MMIOBASE + +SISUSB_PCI_MMIOBASE ;/* Read MMIO * Remember: Data delivered is never endian-corrected
@@ -2655,9 +2636,8 @@ sisusb_read(struct file *file, char __user *buffer, size_t count, loff_t *ppos)return errno ? errno : bytes_read; } -static ssize_t -sisusb_write (struct file *file,const char __user *buffer,size_t count, -loff_t *ppos) +static ssize_t sisusb_write (struct file *file,const char __user *buffer, +size_t count,loff_t *ppos) {struct sisusb_usb_data *sisusb;int errno =0 ;
@@ -2681,9 +2661,8 @@ sisusb_write(struct file *file, const char __user *buffer, size_t count,if ((*ppos) >=SISUSB_PCI_PSEUDO_IOPORTBASE && (*ppos) <SISUSB_PCI_PSEUDO_IOPORTBASE +128 ) { - address = (*ppos) - -SISUSB_PCI_PSEUDO_IOPORTBASE + -SISUSB_PCI_IOPORTBASE ; + address = (*ppos) -SISUSB_PCI_PSEUDO_IOPORTBASE + +SISUSB_PCI_IOPORTBASE ;/* Write i/o ports * Byte, word and long(32) can be written. As this
@@ -2695,8 +2674,7 @@ sisusb_write(struct file *file, const char __user *buffer, size_t count,if (get_user (buf8, (u8 __user *)buffer)) errno = -EFAULT ;else if (sisusb_write_memio_byte (sisusb, -SISUSB_TYPE_IO , - address, buf8)) +SISUSB_TYPE_IO , address, buf8)) errno = -EIO ;else bytes_written =1 ;
@@ -2707,8 +2685,7 @@ sisusb_write(struct file *file, const char __user *buffer, size_t count,if (get_user (buf16, (u16 __user *)buffer)) errno = -EFAULT ;else if (sisusb_write_memio_word (sisusb, -SISUSB_TYPE_IO , - address, buf16)) +SISUSB_TYPE_IO , address, buf16)) errno = -EIO ;else bytes_written =2 ;
@@ -2719,8 +2696,7 @@ sisusb_write(struct file *file, const char __user *buffer, size_t count,if (get_user (buf32, (u32 __user *)buffer)) errno = -EFAULT ;else if (sisusb_write_memio_long (sisusb, -SISUSB_TYPE_IO , - address, buf32)) +SISUSB_TYPE_IO , address, buf32)) errno = -EIO ;else bytes_written =4 ;
@@ -2732,11 +2708,11 @@ sisusb_write(struct file *file, const char __user *buffer, size_t count, } }else if ((*ppos) >=SISUSB_PCI_PSEUDO_MEMBASE && - (*ppos) <SISUSB_PCI_PSEUDO_MEMBASE + sisusb->vramsize) { + (*ppos) <SISUSB_PCI_PSEUDO_MEMBASE + + sisusb->vramsize) { - address = (*ppos) - -SISUSB_PCI_PSEUDO_MEMBASE + -SISUSB_PCI_MEMBASE ; + address = (*ppos) -SISUSB_PCI_PSEUDO_MEMBASE + +SISUSB_PCI_MEMBASE ;/* Write video ram. * Buffer is copied 1:1, therefore, on big-endian
@@ -2751,11 +2727,11 @@ sisusb_write(struct file *file, const char __user *buffer, size_t count, errno = bytes_written; }else if ((*ppos) >=SISUSB_PCI_PSEUDO_MMIOBASE && - (*ppos) <SISUSB_PCI_PSEUDO_MMIOBASE +SISUSB_PCI_MMIOSIZE ) { + (*ppos) <SISUSB_PCI_PSEUDO_MMIOBASE + +SISUSB_PCI_MMIOSIZE ) { - address = (*ppos) - -SISUSB_PCI_PSEUDO_MMIOBASE + -SISUSB_PCI_MMIOBASE ; + address = (*ppos) -SISUSB_PCI_PSEUDO_MMIOBASE + +SISUSB_PCI_MMIOBASE ;/* Write MMIO. * Buffer is copied 1:1, therefore, on big-endian
@@ -2769,7 +2745,8 @@ sisusb_write(struct file *file, const char __user *buffer, size_t count, errno = bytes_written; }else if ((*ppos) >=SISUSB_PCI_PSEUDO_PCIBASE && - (*ppos) <=SISUSB_PCI_PSEUDO_PCIBASE +SISUSB_PCI_PCONFSIZE ) { + (*ppos) <=SISUSB_PCI_PSEUDO_PCIBASE + +SISUSB_PCI_PCONFSIZE ) {if (count !=4 ) {mutex_unlock (&sisusb->lock);
@@ -2803,8 +2780,7 @@ sisusb_write(struct file *file, const char __user *buffer, size_t count,return errno ? errno : bytes_written; } -static loff_t -sisusb_lseek (struct file *file,loff_t offset,int orig) +static loff_t sisusb_lseek (struct file *file,loff_t offset,int orig) {struct sisusb_usb_data *sisusb;loff_t ret;
@@ -2827,9 +2803,8 @@ sisusb_lseek(struct file *file, loff_t offset, int orig)return ret; } -static int -sisusb_handle_command (struct sisusb_usb_data *sisusb,struct sisusb_command *y, -unsigned long arg) +static int sisusb_handle_command (struct sisusb_usb_data *sisusb, +struct sisusb_command *y,unsigned long arg) {int retval, port, length;u32 address;
@@ -2946,8 +2921,7 @@ sisusb_handle_command(struct sisusb_usb_data *sisusb, struct sisusb_command *y,return retval; } -static long -sisusb_ioctl (struct file *file,unsigned int cmd,unsigned long arg) +static long sisusb_ioctl (struct file *file,unsigned int cmd,unsigned long arg) {struct sisusb_usb_data *sisusb;struct sisusb_info x;
@@ -3021,8 +2995,8 @@ err_out: }#ifdef SISUSB_NEW_CONFIG_COMPAT -static long -sisusb_compat_ioctl (struct file *f,unsigned int cmd,unsigned long arg) +static long sisusb_compat_ioctl (struct file *f,unsigned int cmd, +unsigned long arg) {long retval;
@@ -3081,8 +3055,9 @@ static int sisusb_probe(struct usb_interface *intf,/* Register device */ retval =usb_register_dev (intf, &usb_sisusb_class);if (retval) { -dev_err (&sisusb->sisusb_dev->dev,"Failed to get a minor for device %d\n" , - dev->devnum); +dev_err (&sisusb->sisusb_dev->dev, +"Failed to get a minor for device %d\n" , + dev->devnum); retval = -ENODEV ; goto error_1; }
@@ -3128,7 +3103,8 @@ static int sisusb_probe(struct usb_interface *intf,for (i =0 ; i < sisusb->numobufs; i++) {if (!(sisusb->sisurbout[i] =usb_alloc_urb (0 ,GFP_KERNEL ))) { -dev_err (&sisusb->sisusb_dev->dev,"Failed to allocate URBs\n" ); +dev_err (&sisusb->sisusb_dev->dev, +"Failed to allocate URBs\n" ); retval = -ENOMEM ; goto error_4; }
@@ -3137,7 +3113,8 @@ static int sisusb_probe(struct usb_interface *intf, sisusb->urbstatus[i] =0 ; } -dev_info (&sisusb->sisusb_dev->dev,"Allocated %d output buffers\n" , sisusb->numobufs); +dev_info (&sisusb->sisusb_dev->dev,"Allocated %d output buffers\n" , + sisusb->numobufs);#ifdef INCL_SISUSB_CON /* Allocate our SiS_Pr */
@@ -3159,17 +3136,18 @@ static int sisusb_probe(struct usb_interface *intf,if (dev->speed ==USB_SPEED_HIGH || dev->speed ==USB_SPEED_SUPER ) {int initscreen =1 ;#ifdef INCL_SISUSB_CON -if (sisusb_first_vc >0 && - sisusb_last_vc >0 && - sisusb_first_vc <= sisusb_last_vc && - sisusb_last_vc <=MAX_NR_CONSOLES ) +if (sisusb_first_vc >0 && sisusb_last_vc >0 && + sisusb_first_vc <= sisusb_last_vc && + sisusb_last_vc <=MAX_NR_CONSOLES ) initscreen =0 ;#endif if (sisusb_init_gfxdevice (sisusb, initscreen)) -dev_err (&sisusb->sisusb_dev->dev,"Failed to early initialize device\n" ); +dev_err (&sisusb->sisusb_dev->dev, +"Failed to early initialize device\n" ); }else -dev_info (&sisusb->sisusb_dev->dev,"Not attached to USB 2.0 hub, deferring init\n" ); +dev_info (&sisusb->sisusb_dev->dev, +"Not attached to USB 2.0 hub, deferring init\n" ); sisusb->ready =1 ;
Signature · 1 line
2.5.0
PATCH v2 1/7 usb-misc: sisusbvga: Fix coding style: horizontal whitespace changes
In reply to Peter Senna TschudinThis patch fixes whitespace coding style issues that can be fixed within a single line. This patch fixes the following checkpatch warnings:
- 83 ERROR: space required after that ','
- 13 ERROR: switch and case should be at the same indent
- 08 WARNING: please, no spaces at the start of a line
- 03 ERROR: space required before the open parenthesis '('
- 04 WARNING: suspect code indent for conditional statements
- 01 WARNING: space prohibited between function name and open parenthesis
- 01 ERROR: spaces required around that '='
- 01 ERROR: code indent should use tabs where possible
---
Changes from V1:
- This patch contain mostly horizontal changes, with a few exceptions to minimize the number of unfixed coding style issues.
- Vertical whitespace changes are now in other patch.
Tested by compilation only.
drivers/usb/misc/sisusbvga/sisusb.c | 953 ++++++++++++++++++------------------ 1 file changed, 471 insertions(+), 482 deletions(-)
drivers/usb/misc/sisusbvga/sisusb.c +471 -482
@@ -243,7 +243,7 @@ sisusb_bulkout_msg(struct sisusb_usb_data *sisusb, int index, unsigned int pipe,/* Set up context */ sisusb->urbout_context[index].actual_length = (timeout) ? -NULL : actual_length; +NULL : actual_length;/* Declare this urb/buffer in use */ sisusb->urbstatus[index] |=SU_URB_BUSY ;
@@ -254,8 +254,8 @@ sisusb_bulkout_msg(struct sisusb_usb_data *sisusb, int index, unsigned int pipe,/* If OK, and if timeout > 0, wait for completion */ if ((retval ==0 ) && timeout) {wait_event_timeout (sisusb->wait_q, - (!(sisusb->urbstatus[index] &SU_URB_BUSY )), - timeout); + (!(sisusb->urbstatus[index] &SU_URB_BUSY )), + timeout);if (sisusb->urbstatus[index] &SU_URB_BUSY ) {/* URB timed out... kill it and report error */ usb_kill_urb (urb);
@@ -375,7 +375,7 @@ static int sisusb_send_bulk_msg(struct sisusb_usb_data *sisusb, int ep, int len, do { passsize = thispass = (sisusb->obufsize < count) ? - sisusb->obufsize : count; + sisusb->obufsize : count; if (index < 0) index = sisusb_get_free_outbuf(sisusb);
@@ -549,7 +549,7 @@ static int sisusb_recv_bulk_msg(struct sisusb_usb_data *sisusb, int ep, int len, }static int sisusb_send_packet (struct sisusb_usb_data *sisusb,int len, -struct sisusb_packet *packet) +struct sisusb_packet *packet) {int ret;ssize_t bytes_transferred =0 ;
@@ -634,7 +634,7 @@ static int sisusb_send_bridge_packet(struct sisusb_usb_data *sisusb, int len,*/ static int sisusb_write_memio_byte (struct sisusb_usb_data *sisusb,int type, -u32 addr,u8 data) +u32 addr,u8 data) {struct sisusb_packet packet;int ret;
@@ -647,7 +647,7 @@ static int sisusb_write_memio_byte(struct sisusb_usb_data *sisusb, int type, }static int sisusb_write_memio_word (struct sisusb_usb_data *sisusb,int type, -u32 addr,u16 data) +u32 addr,u16 data) {struct sisusb_packet packet;int ret =0 ;
@@ -655,36 +655,36 @@ static int sisusb_write_memio_word(struct sisusb_usb_data *sisusb, int type, packet.address = addr & ~3 ;switch (addr &3 ) { -case 0 : - packet.header = (type <<6 ) |0x0003 ; - packet.data = (u32 )data; - ret =sisusb_send_packet (sisusb,10 , &packet); -break ; -case 1 : - packet.header = (type <<6 ) |0x0006 ; - packet.data = (u32 )data <<8 ; - ret =sisusb_send_packet (sisusb,10 , &packet); -break ; -case 2 : - packet.header = (type <<6 ) |0x000c ; - packet.data = (u32 )data <<16 ; - ret =sisusb_send_packet (sisusb,10 , &packet); -break ; -case 3 : - packet.header = (type <<6 ) |0x0008 ; - packet.data = (u32 )data <<24 ; - ret =sisusb_send_packet (sisusb,10 , &packet); - packet.header = (type <<6 ) |0x0001 ; - packet.address = (addr & ~3 ) +4 ; - packet.data = (u32 )data >>8 ; - ret |=sisusb_send_packet (sisusb,10 , &packet); +case 0 : + packet.header = (type <<6 ) |0x0003 ; + packet.data = (u32 )data; + ret =sisusb_send_packet (sisusb,10 , &packet); +break ; +case 1 : + packet.header = (type <<6 ) |0x0006 ; + packet.data = (u32 )data <<8 ; + ret =sisusb_send_packet (sisusb,10 , &packet); +break ; +case 2 : + packet.header = (type <<6 ) |0x000c ; + packet.data = (u32 )data <<16 ; + ret =sisusb_send_packet (sisusb,10 , &packet); +break ; +case 3 : + packet.header = (type <<6 ) |0x0008 ; + packet.data = (u32 )data <<24 ; + ret =sisusb_send_packet (sisusb,10 , &packet); + packet.header = (type <<6 ) |0x0001 ; + packet.address = (addr & ~3 ) +4 ; + packet.data = (u32 )data >>8 ; + ret |=sisusb_send_packet (sisusb,10 , &packet); }return ret; }static int sisusb_write_memio_24bit (struct sisusb_usb_data *sisusb,int type, -u32 addr,u32 data) +u32 addr,u32 data) {struct sisusb_packet packet;int ret =0 ;
@@ -692,40 +692,40 @@ static int sisusb_write_memio_24bit(struct sisusb_usb_data *sisusb, int type, packet.address = addr & ~3 ;switch (addr &3 ) { -case 0 : - packet.header = (type <<6 ) |0x0007 ; - packet.data = data &0x00ffffff ; - ret =sisusb_send_packet (sisusb,10 , &packet); -break ; -case 1 : - packet.header = (type <<6 ) |0x000e ; - packet.data = data <<8 ; - ret =sisusb_send_packet (sisusb,10 , &packet); -break ; -case 2 : - packet.header = (type <<6 ) |0x000c ; - packet.data = data <<16 ; - ret =sisusb_send_packet (sisusb,10 , &packet); - packet.header = (type <<6 ) |0x0001 ; - packet.address = (addr & ~3 ) +4 ; - packet.data = (data >>16 ) &0x00ff ; - ret |=sisusb_send_packet (sisusb,10 , &packet); -break ; -case 3 : - packet.header = (type <<6 ) |0x0008 ; - packet.data = data <<24 ; - ret =sisusb_send_packet (sisusb,10 , &packet); - packet.header = (type <<6 ) |0x0003 ; - packet.address = (addr & ~3 ) +4 ; - packet.data = (data >>8 ) &0xffff ; - ret |=sisusb_send_packet (sisusb,10 , &packet); +case 0 : + packet.header = (type <<6 ) |0x0007 ; + packet.data = data &0x00ffffff ; + ret =sisusb_send_packet (sisusb,10 , &packet); +break ; +case 1 : + packet.header = (type <<6 ) |0x000e ; + packet.data = data <<8 ; + ret =sisusb_send_packet (sisusb,10 , &packet); +break ; +case 2 : + packet.header = (type <<6 ) |0x000c ; + packet.data = data <<16 ; + ret =sisusb_send_packet (sisusb,10 , &packet); + packet.header = (type <<6 ) |0x0001 ; + packet.address = (addr & ~3 ) +4 ; + packet.data = (data >>16 ) &0x00ff ; + ret |=sisusb_send_packet (sisusb,10 , &packet); +break ; +case 3 : + packet.header = (type <<6 ) |0x0008 ; + packet.data = data <<24 ; + ret =sisusb_send_packet (sisusb,10 , &packet); + packet.header = (type <<6 ) |0x0003 ; + packet.address = (addr & ~3 ) +4 ; + packet.data = (data >>8 ) &0xffff ; + ret |=sisusb_send_packet (sisusb,10 , &packet); }return ret; }static int sisusb_write_memio_long (struct sisusb_usb_data *sisusb,int type, -u32 addr,u32 data) +u32 addr,u32 data) {struct sisusb_packet packet;int ret =0 ;
@@ -733,37 +733,37 @@ static int sisusb_write_memio_long(struct sisusb_usb_data *sisusb, int type, packet.address = addr & ~3 ;switch (addr &3 ) { -case 0 : - packet.header = (type <<6 ) |0x000f ; - packet.data = data; - ret =sisusb_send_packet (sisusb,10 , &packet); -break ; -case 1 : - packet.header = (type <<6 ) |0x000e ; - packet.data = data <<8 ; - ret =sisusb_send_packet (sisusb,10 , &packet); - packet.header = (type <<6 ) |0x0001 ; - packet.address = (addr & ~3 ) +4 ; - packet.data = data >>24 ; - ret |=sisusb_send_packet (sisusb,10 , &packet); -break ; -case 2 : - packet.header = (type <<6 ) |0x000c ; - packet.data = data <<16 ; - ret =sisusb_send_packet (sisusb,10 , &packet); - packet.header = (type <<6 ) |0x0003 ; - packet.address = (addr & ~3 ) +4 ; - packet.data = data >>16 ; - ret |=sisusb_send_packet (sisusb,10 , &packet); -break ; -case 3 : - packet.header = (type <<6 ) |0x0008 ; - packet.data = data <<24 ; - ret =sisusb_send_packet (sisusb,10 , &packet); - packet.header = (type <<6 ) |0x0007 ; - packet.address = (addr & ~3 ) +4 ; - packet.data = data >>8 ; - ret |=sisusb_send_packet (sisusb,10 , &packet); +case 0 : + packet.header = (type <<6 ) |0x000f ; + packet.data = data; + ret =sisusb_send_packet (sisusb,10 , &packet); +break ; +case 1 : + packet.header = (type <<6 ) |0x000e ; + packet.data = data <<8 ; + ret =sisusb_send_packet (sisusb,10 , &packet); + packet.header = (type <<6 ) |0x0001 ; + packet.address = (addr & ~3 ) +4 ; + packet.data = data >>24 ; + ret |=sisusb_send_packet (sisusb,10 , &packet); +break ; +case 2 : + packet.header = (type <<6 ) |0x000c ; + packet.data = data <<16 ; + ret =sisusb_send_packet (sisusb,10 , &packet); + packet.header = (type <<6 ) |0x0003 ; + packet.address = (addr & ~3 ) +4 ; + packet.data = data >>16 ; + ret |=sisusb_send_packet (sisusb,10 , &packet); +break ; +case 3 : + packet.header = (type <<6 ) |0x0008 ; + packet.data = data <<24 ; + ret =sisusb_send_packet (sisusb,10 , &packet); + packet.header = (type <<6 ) |0x0007 ; + packet.address = (addr & ~3 ) +4 ; + packet.data = data >>8 ; + ret |=sisusb_send_packet (sisusb,10 , &packet); }return ret;
@@ -803,9 +803,7 @@ static int sisusb_write_mem_bulk(struct sisusb_usb_data *sisusb, u32 addr, length &=0x00ffffff ;while (length) { - -switch (length) { - +switch (length) {case 1 :if (userbuffer) {if (get_user (swap8, (u8 __user *)userbuffer))
@@ -892,88 +890,88 @@ static int sisusb_write_mem_bulk(struct sisusb_usb_data *sisusb, u32 addr,default :if ((length & ~3 ) >0x10000 ) { - packet.header =0x001f ; - packet.address =0x000001d4 ; - packet.data = addr; - ret =sisusb_send_bridge_packet (sisusb,10 , - &packet,0 ); - packet.header =0x001f ; - packet.address =0x000001d0 ; - packet.data = (length & ~3 ); - ret |=sisusb_send_bridge_packet (sisusb,10 , - &packet,0 ); - packet.header =0x001f ; - packet.address =0x000001c0 ; - packet.data = flag |0x16 ; - ret |=sisusb_send_bridge_packet (sisusb,10 , - &packet,0 ); -if (userbuffer) { - ret |=sisusb_send_bulk_msg (sisusb, + packet.header =0x001f ; + packet.address =0x000001d4 ; + packet.data = addr; + ret =sisusb_send_bridge_packet (sisusb,10 , + &packet,0 ); + packet.header =0x001f ; + packet.address =0x000001d0 ; + packet.data = (length & ~3 ); + ret |=sisusb_send_bridge_packet (sisusb,10 , + &packet,0 ); + packet.header =0x001f ; + packet.address =0x000001c0 ; + packet.data = flag |0x16 ; + ret |=sisusb_send_bridge_packet (sisusb,10 , + &packet,0 ); +if (userbuffer) { + ret |=sisusb_send_bulk_msg (sisusb,SISUSB_EP_GFX_LBULK_OUT , (length & ~3 ),NULL , userbuffer,0 , bytes_written,0 ,1 ); - userbuffer += (*bytes_written); - }else if (fromkern) { - ret |=sisusb_send_bulk_msg (sisusb, + userbuffer += (*bytes_written); + }else if (fromkern) { + ret |=sisusb_send_bulk_msg (sisusb,SISUSB_EP_GFX_LBULK_OUT , (length & ~3 ), kernbuffer,NULL ,0 , bytes_written,0 ,1 ); - kernbuffer += (*bytes_written); - }else { - ret |=sisusb_send_bulk_msg (sisusb, + kernbuffer += (*bytes_written); + }else { + ret |=sisusb_send_bulk_msg (sisusb,SISUSB_EP_GFX_LBULK_OUT , (length & ~3 ),NULL ,NULL , index, bytes_written,0 ,1 ); - kernbuffer += ((*bytes_written) & - (sisusb->obufsize-1 )); - } + kernbuffer += ((*bytes_written) & + (sisusb->obufsize-1 )); + } }else { - packet.header =0x001f ; - packet.address =0x00000194 ; - packet.data = addr; - ret =sisusb_send_bridge_packet (sisusb,10 , - &packet,0 ); - packet.header =0x001f ; - packet.address =0x00000190 ; - packet.data = (length & ~3 ); - ret |=sisusb_send_bridge_packet (sisusb,10 , - &packet,0 ); -if (sisusb->flagb0 !=0x16 ) { packet.header =0x001f ; - packet.address =0x00000180 ; - packet.data = flag |0x16 ; + packet.address =0x00000194 ; + packet.data = addr; + ret =sisusb_send_bridge_packet (sisusb,10 , + &packet,0 ); + packet.header =0x001f ; + packet.address =0x00000190 ; + packet.data = (length & ~3 ); ret |=sisusb_send_bridge_packet (sisusb,10 , - &packet,0 ); - sisusb->flagb0 =0x16 ; - } -if (userbuffer) { - ret |=sisusb_send_bulk_msg (sisusb, + &packet,0 ); +if (sisusb->flagb0 !=0x16 ) { + packet.header =0x001f ; + packet.address =0x00000180 ; + packet.data = flag |0x16 ; + ret |=sisusb_send_bridge_packet (sisusb, +10 , &packet,0 ); + sisusb->flagb0 =0x16 ; + } +if (userbuffer) { + ret |=sisusb_send_bulk_msg (sisusb,SISUSB_EP_GFX_BULK_OUT , (length & ~3 ),NULL , userbuffer,0 , bytes_written,0 ,1 ); - userbuffer += (*bytes_written); - }else if (fromkern) { - ret |=sisusb_send_bulk_msg (sisusb, + userbuffer += (*bytes_written); + }else if (fromkern) { + ret |=sisusb_send_bulk_msg (sisusb,SISUSB_EP_GFX_BULK_OUT , (length & ~3 ), kernbuffer,NULL ,0 , bytes_written,0 ,1 ); - kernbuffer += (*bytes_written); - }else { - ret |=sisusb_send_bulk_msg (sisusb, + kernbuffer += (*bytes_written); + }else { + ret |=sisusb_send_bulk_msg (sisusb,SISUSB_EP_GFX_BULK_OUT , (length & ~3 ),NULL ,NULL , index, bytes_written,0 ,1 ); - kernbuffer += ((*bytes_written) & - (sisusb->obufsize-1 )); - } + kernbuffer += ((*bytes_written) & + (sisusb->obufsize-1 )); + } }if (ret) { msgcount++;
@@ -985,10 +983,10 @@ static int sisusb_write_mem_bulk(struct sisusb_usb_data *sisusb, u32 addr, } addr += (*bytes_written); length -= (*bytes_written); - } + } -if (ret) -break ; +if (ret) +break ; }
@@ -1000,7 +998,7 @@ static int sisusb_write_mem_bulk(struct sisusb_usb_data *sisusb, u32 addr,*/ static int sisusb_read_memio_byte (struct sisusb_usb_data *sisusb,int type, -u32 addr,u8 *data) +u32 addr,u8 *data) {struct sisusb_packet packet;int ret;
@@ -1014,7 +1012,7 @@ static int sisusb_read_memio_byte(struct sisusb_usb_data *sisusb, int type, }static int sisusb_read_memio_word (struct sisusb_usb_data *sisusb,int type, -u32 addr,u16 *data) +u32 addr,u16 *data) {struct sisusb_packet packet;int ret =0 ;
@@ -1024,36 +1022,36 @@ static int sisusb_read_memio_word(struct sisusb_usb_data *sisusb, int type, packet.address = addr & ~3 ;switch (addr &3 ) { -case 0 : - packet.header = (type <<6 ) |0x0003 ; - ret =sisusb_send_packet (sisusb,6 , &packet); - *data = (u16)(packet.data); -break ; -case 1 : - packet.header = (type <<6 ) |0x0006 ; - ret =sisusb_send_packet (sisusb,6 , &packet); - *data = (u16)(packet.data >>8 ); -break ; -case 2 : - packet.header = (type <<6 ) |0x000c ; - ret =sisusb_send_packet (sisusb,6 , &packet); - *data = (u16)(packet.data >>16 ); -break ; -case 3 : - packet.header = (type <<6 ) |0x0008 ; - ret =sisusb_send_packet (sisusb,6 , &packet); - *data = (u16)(packet.data >>24 ); - packet.header = (type <<6 ) |0x0001 ; - packet.address = (addr & ~3 ) +4 ; - ret |=sisusb_send_packet (sisusb,6 , &packet); - *data |= (u16)(packet.data <<8 ); +case 0 : + packet.header = (type <<6 ) |0x0003 ; + ret =sisusb_send_packet (sisusb,6 , &packet); + *data = (u16)(packet.data); +break ; +case 1 : + packet.header = (type <<6 ) |0x0006 ; + ret =sisusb_send_packet (sisusb,6 , &packet); + *data = (u16)(packet.data >>8 ); +break ; +case 2 : + packet.header = (type <<6 ) |0x000c ; + ret =sisusb_send_packet (sisusb,6 , &packet); + *data = (u16)(packet.data >>16 ); +break ; +case 3 : + packet.header = (type <<6 ) |0x0008 ; + ret =sisusb_send_packet (sisusb,6 , &packet); + *data = (u16)(packet.data >>24 ); + packet.header = (type <<6 ) |0x0001 ; + packet.address = (addr & ~3 ) +4 ; + ret |=sisusb_send_packet (sisusb,6 , &packet); + *data |= (u16)(packet.data <<8 ); }return ret; }static int sisusb_read_memio_24bit (struct sisusb_usb_data *sisusb,int type, -u32 addr,u32 *data) +u32 addr,u32 *data) {struct sisusb_packet packet;int ret =0 ;
@@ -1061,40 +1059,40 @@ static int sisusb_read_memio_24bit(struct sisusb_usb_data *sisusb, int type, packet.address = addr & ~3 ;switch (addr &3 ) { -case 0 : - packet.header = (type <<6 ) |0x0007 ; - ret =sisusb_send_packet (sisusb,6 , &packet); - *data = packet.data &0x00ffffff ; -break ; -case 1 : - packet.header = (type <<6 ) |0x000e ; - ret =sisusb_send_packet (sisusb,6 , &packet); - *data = packet.data >>8 ; -break ; -case 2 : - packet.header = (type <<6 ) |0x000c ; - ret =sisusb_send_packet (sisusb,6 , &packet); - *data = packet.data >>16 ; - packet.header = (type <<6 ) |0x0001 ; - packet.address = (addr & ~3 ) +4 ; - ret |=sisusb_send_packet (sisusb,6 , &packet); - *data |= ((packet.data &0xff ) <<16 ); -break ; -case 3 : - packet.header = (type <<6 ) |0x0008 ; - ret =sisusb_send_packet (sisusb,6 , &packet); - *data = packet.data >>24 ; - packet.header = (type <<6 ) |0x0003 ; - packet.address = (addr & ~3 ) +4 ; - ret |=sisusb_send_packet (sisusb,6 , &packet); - *data |= ((packet.data &0xffff ) <<8 ); +case 0 : + packet.header = (type <<6 ) |0x0007 ; + ret =sisusb_send_packet (sisusb,6 , &packet); + *data = packet.data &0x00ffffff ; +break ; +case 1 : + packet.header = (type <<6 ) |0x000e ; + ret =sisusb_send_packet (sisusb,6 , &packet); + *data = packet.data >>8 ; +break ; +case 2 : + packet.header = (type <<6 ) |0x000c ; + ret =sisusb_send_packet (sisusb,6 , &packet); + *data = packet.data >>16 ; + packet.header = (type <<6 ) |0x0001 ; + packet.address = (addr & ~3 ) +4 ; + ret |=sisusb_send_packet (sisusb,6 , &packet); + *data |= ((packet.data &0xff ) <<16 ); +break ; +case 3 : + packet.header = (type <<6 ) |0x0008 ; + ret =sisusb_send_packet (sisusb,6 , &packet); + *data = packet.data >>24 ; + packet.header = (type <<6 ) |0x0003 ; + packet.address = (addr & ~3 ) +4 ; + ret |=sisusb_send_packet (sisusb,6 , &packet); + *data |= ((packet.data &0xffff ) <<8 ); }return ret; }static int sisusb_read_memio_long (struct sisusb_usb_data *sisusb,int type, -u32 addr,u32 *data) +u32 addr,u32 *data) {struct sisusb_packet packet;int ret =0 ;
@@ -1102,37 +1100,37 @@ static int sisusb_read_memio_long(struct sisusb_usb_data *sisusb, int type, packet.address = addr & ~3 ;switch (addr &3 ) { -case 0 : - packet.header = (type <<6 ) |0x000f ; - ret =sisusb_send_packet (sisusb,6 , &packet); - *data = packet.data; -break ; -case 1 : - packet.header = (type <<6 ) |0x000e ; - ret =sisusb_send_packet (sisusb,6 , &packet); - *data = packet.data >>8 ; - packet.header = (type <<6 ) |0x0001 ; - packet.address = (addr & ~3 ) +4 ; - ret |=sisusb_send_packet (sisusb,6 , &packet); - *data |= (packet.data <<24 ); -break ; -case 2 : - packet.header = (type <<6 ) |0x000c ; - ret =sisusb_send_packet (sisusb,6 , &packet); - *data = packet.data >>16 ; - packet.header = (type <<6 ) |0x0003 ; - packet.address = (addr & ~3 ) +4 ; - ret |=sisusb_send_packet (sisusb,6 , &packet); - *data |= (packet.data <<16 ); -break ; -case 3 : - packet.header = (type <<6 ) |0x0008 ; - ret =sisusb_send_packet (sisusb,6 , &packet); - *data = packet.data >>24 ; - packet.header = (type <<6 ) |0x0007 ; - packet.address = (addr & ~3 ) +4 ; - ret |=sisusb_send_packet (sisusb,6 , &packet); - *data |= (packet.data <<8 ); +case 0 : + packet.header = (type <<6 ) |0x000f ; + ret =sisusb_send_packet (sisusb,6 , &packet); + *data = packet.data; +break ; +case 1 : + packet.header = (type <<6 ) |0x000e ; + ret =sisusb_send_packet (sisusb,6 , &packet); + *data = packet.data >>8 ; + packet.header = (type <<6 ) |0x0001 ; + packet.address = (addr & ~3 ) +4 ; + ret |=sisusb_send_packet (sisusb,6 , &packet); + *data |= (packet.data <<24 ); +break ; +case 2 : + packet.header = (type <<6 ) |0x000c ; + ret =sisusb_send_packet (sisusb,6 , &packet); + *data = packet.data >>16 ; + packet.header = (type <<6 ) |0x0003 ; + packet.address = (addr & ~3 ) +4 ; + ret |=sisusb_send_packet (sisusb,6 , &packet); + *data |= (packet.data <<16 ); +break ; +case 3 : + packet.header = (type <<6 ) |0x0008 ; + ret =sisusb_send_packet (sisusb,6 , &packet); + *data = packet.data >>24 ; + packet.header = (type <<6 ) |0x0007 ; + packet.address = (addr & ~3 ) +4 ; + ret |=sisusb_send_packet (sisusb,6 , &packet); + *data |= (packet.data <<8 ); }return ret;
@@ -1152,13 +1150,10 @@ static int sisusb_read_mem_bulk(struct sisusb_usb_data *sisusb, u32 addr, length &=0x00ffffff ;while (length) { - -switch (length) { - +switch (length) {case 1 : - ret |=sisusb_read_memio_byte (sisusb,SISUSB_TYPE_MEM , - addr, &buf[0 ]); + addr, &buf[0 ]);if (!ret) { (*bytes_read)++;if (userbuffer) {
@@ -1174,7 +1169,7 @@ static int sisusb_read_mem_bulk(struct sisusb_usb_data *sisusb, u32 addr,case 2 : ret |=sisusb_read_memio_word (sisusb,SISUSB_TYPE_MEM , - addr, &swap16); + addr, &swap16);if (!ret) { (*bytes_read) +=2 ;if (userbuffer) {
@@ -1189,7 +1184,7 @@ static int sisusb_read_mem_bulk(struct sisusb_usb_data *sisusb, u32 addr,case 3 : ret |=sisusb_read_memio_24bit (sisusb,SISUSB_TYPE_MEM , - addr, &swap32); + addr, &swap32);if (!ret) { (*bytes_read) +=3 ;#ifdef __BIG_ENDIAN
@@ -1214,7 +1209,7 @@ static int sisusb_read_mem_bulk(struct sisusb_usb_data *sisusb, u32 addr,default : ret |=sisusb_read_memio_long (sisusb,SISUSB_TYPE_MEM , - addr, &swap32); + addr, &swap32);if (!ret) { (*bytes_read) +=4 ;if (userbuffer) {
@@ -1230,10 +1225,9 @@ static int sisusb_read_mem_bulk(struct sisusb_usb_data *sisusb, u32 addr, addr +=4 ; length -=4 ; } - } - -if (ret) -break ; + } +if (ret) +break ; }return ret;
@@ -1350,20 +1344,24 @@ sisusb_read_memory(struct sisusb_usb_data *sisusb, char *dest,static void sisusb_testreadwrite (struct sisusb_usb_data *sisusb) { -static char srcbuffer[] = {0x11 ,0x22 ,0x33 ,0x44 ,0x55 ,0x66 ,0x77 }; -char destbuffer[10 ]; -size_t dummy; -int i,j; - -sisusb_copy_memory (sisusb, srcbuffer, sisusb->vrambase,7 , &dummy); - -for (i =1 ; i <=7 ; i++) { -dev_dbg (&sisusb->sisusb_dev->dev,"sisusb: rwtest %d bytes\n" , i); -sisusb_read_memory (sisusb, destbuffer, sisusb->vrambase, i, &dummy); -for (j =0 ; j < i; j++) { -dev_dbg (&sisusb->sisusb_dev->dev,"rwtest read[%d] = %x\n" , j, destbuffer[j]); +static char srcbuffer[] = {0x11 ,0x22 ,0x33 ,0x44 ,0x55 ,0x66 ,0x77 }; +char destbuffer[10 ]; +size_t dummy; +int i, j; + +sisusb_copy_memory (sisusb, srcbuffer, sisusb->vrambase,7 , &dummy); + +for (i =1 ; i <=7 ; i++) { +dev_dbg (&sisusb->sisusb_dev->dev, +"sisusb: rwtest %d bytes\n" , i); +sisusb_read_memory (sisusb, destbuffer, sisusb->vrambase, + i, &dummy); +for (j =0 ; j < i; j++) { +dev_dbg (&sisusb->sisusb_dev->dev, +"rwtest read[%d] = %x\n" , + j, destbuffer[j]); + } } - } }#endif
@@ -1437,17 +1435,17 @@ sisusb_clear_vram(struct sisusb_usb_data *sisusb, u32 address, int length)* a defined mode (640x480@60Hz) */ -#define GETREG (r,d) sisusb_read_memio_byte(sisusb, SISUSB_TYPE_IO, r, d) -#define SETREG (r,d) sisusb_write_memio_byte(sisusb, SISUSB_TYPE_IO, r, d) -#define SETIREG (r,i,d) sisusb_setidxreg(sisusb, r, i, d) -#define GETIREG (r,i,d) sisusb_getidxreg(sisusb, r, i, d) -#define SETIREGOR (r,i,o) sisusb_setidxregor(sisusb, r, i, o) -#define SETIREGAND (r,i,a) sisusb_setidxregand(sisusb, r, i, a) -#define SETIREGANDOR (r,i,a,o) sisusb_setidxregandor(sisusb, r, i, a, o) -#define READL (a,d) sisusb_read_memio_long(sisusb, SISUSB_TYPE_MEM, a, d) -#define WRITEL (a,d) sisusb_write_memio_long(sisusb, SISUSB_TYPE_MEM, a, d) -#define READB (a,d) sisusb_read_memio_byte(sisusb, SISUSB_TYPE_MEM, a, d) -#define WRITEB (a,d) sisusb_write_memio_byte(sisusb, SISUSB_TYPE_MEM, a, d) +#define GETREG (r, d) sisusb_read_memio_byte(sisusb, SISUSB_TYPE_IO, r, d) +#define SETREG (r, d) sisusb_write_memio_byte(sisusb, SISUSB_TYPE_IO, r, d) +#define SETIREG (r, i, d) sisusb_setidxreg(sisusb, r, i, d) +#define GETIREG (r, i, d) sisusb_getidxreg(sisusb, r, i, d) +#define SETIREGOR (r, i, o) sisusb_setidxregor(sisusb, r, i, o) +#define SETIREGAND (r, i, a) sisusb_setidxregand(sisusb, r, i, a) +#define SETIREGANDOR (r, i, a, o) sisusb_setidxregandor(sisusb, r, i, a, o) +#define READL (a, d) sisusb_read_memio_long(sisusb, SISUSB_TYPE_MEM, a, d) +#define WRITEL (a, d) sisusb_write_memio_long(sisusb, SISUSB_TYPE_MEM, a, d) +#define READB (a, d) sisusb_read_memio_byte(sisusb, SISUSB_TYPE_MEM, a, d) +#define WRITEB (a, d) sisusb_write_memio_byte(sisusb, SISUSB_TYPE_MEM, a, d)static int sisusb_triggersr16 (struct sisusb_usb_data *sisusb,u8 ramtype)
@@ -1526,7 +1524,7 @@ sisusb_getbuswidth(struct sisusb_usb_data *sisusb, int *bw, int *chab) }if ((t1 !=0x456789ab ) || (t0 !=0x01234567 )) { *chab =1 ; *bw =64 ; - ret |=SETIREGANDOR (SISSR ,0x14 ,0xfc ,0x01 ); + ret |=SETIREGANDOR (SISSR ,0x14 ,0xfc ,0x01 ); ret |=sisusb_triggersr16 (sisusb, ramtype); ret |=WRITEL (ramptr +0 ,0x89abcdef );
@@ -1775,18 +1773,18 @@ sisusb_setup_screen(struct sisusb_usb_data *sisusb, int clrall, int drwfr)for (i =0 ; i < modex; i++) { address = sisusb->vrambase + (i * bpp); ret |=sisusb_write_memio_word (sisusb,SISUSB_TYPE_MEM , - address,0xf100 ); + address,0xf100 ); address += (modex * (modey-1 ) * bpp); ret |=sisusb_write_memio_word (sisusb,SISUSB_TYPE_MEM , - address,0xf100 ); + address,0xf100 ); }for (i =0 ; i < modey; i++) { address = sisusb->vrambase + ((i * modex) * bpp); ret |=sisusb_write_memio_word (sisusb,SISUSB_TYPE_MEM , - address,0xf100 ); + address,0xf100 ); address += ((modex -1 ) * bpp); ret |=sisusb_write_memio_word (sisusb,SISUSB_TYPE_MEM , - address,0xf100 ); + address,0xf100 ); } }
@@ -1799,23 +1797,23 @@ sisusb_set_default_mode(struct sisusb_usb_data *sisusb, int touchengines)int ret =0 , i, j, modex, modey, bpp, du;u8 sr31, cr63, tmp8;static const char attrdata[] = { -0x00 ,0x01 ,0x02 ,0x03 ,0x04 ,0x05 ,0x06 ,0x07 , -0x08 ,0x09 ,0x0a ,0x0b ,0x0c ,0x0d ,0x0e ,0x0f , -0x01 ,0x00 ,0x00 ,0x00 +0x00 ,0x01 ,0x02 ,0x03 ,0x04 ,0x05 ,0x06 ,0x07 , +0x08 ,0x09 ,0x0a ,0x0b ,0x0c ,0x0d ,0x0e ,0x0f , +0x01 ,0x00 ,0x00 ,0x00 };static const char crtcrdata[] = { -0x5f ,0x4f ,0x50 ,0x82 ,0x54 ,0x80 ,0x0b ,0x3e , -0x00 ,0x40 ,0x00 ,0x00 ,0x00 ,0x00 ,0x00 ,0x00 , -0xea ,0x8c ,0xdf ,0x28 ,0x40 ,0xe7 ,0x04 ,0xa3 , +0x5f ,0x4f ,0x50 ,0x82 ,0x54 ,0x80 ,0x0b ,0x3e , +0x00 ,0x40 ,0x00 ,0x00 ,0x00 ,0x00 ,0x00 ,0x00 , +0xea ,0x8c ,0xdf ,0x28 ,0x40 ,0xe7 ,0x04 ,0xa3 ,0xff };static const char grcdata[] = { -0x00 ,0x00 ,0x00 ,0x00 ,0x00 ,0x40 ,0x05 ,0x0f , +0x00 ,0x00 ,0x00 ,0x00 ,0x00 ,0x40 ,0x05 ,0x0f ,0xff };static const char crtcdata[] = { -0x5f ,0x4f ,0x4f ,0x83 ,0x55 ,0x81 ,0x0b ,0x3e , -0xe9 ,0x8b ,0xdf ,0xe8 ,0x0c ,0x00 ,0x00 ,0x05 , +0x5f ,0x4f ,0x4f ,0x83 ,0x55 ,0x81 ,0x0b ,0x3e , +0xe9 ,0x8b ,0xdf ,0xe8 ,0x0c ,0x00 ,0x00 ,0x05 ,0x00 };
@@ -2081,12 +2079,12 @@ sisusb_init_gfxcore(struct sisusb_usb_data *sisusb) ret |=sisusb_get_sdram_size (sisusb, &iret, bw, chab);if (iret) {dev_err (&sisusb->sisusb_dev->dev,"RAM size detection failed, assuming 8MB video RAM\n" ); - ret |=SETIREG (SISSR ,0x14 ,0x31 ); + ret |=SETIREG (SISSR ,0x14 ,0x31 );/* TODO */ } }else {dev_err (&sisusb->sisusb_dev->dev,"DDR RAM device found, assuming 8MB video RAM\n" ); - ret |=SETIREG (SISSR ,0x14 ,0x31 ); + ret |=SETIREG (SISSR ,0x14 ,0x31 );/* *** TODO *** */ }
@@ -2127,7 +2125,7 @@ sisusb_get_ramconfig(struct sisusb_usb_data *sisusb)static const char ram_dynamictype[4 ] = {'D' ,'G' ,'D' ,'G' };static const int busSDR[4 ] = {64 ,64 ,128 ,128 };static const int busDDR[4 ] = {32 ,32 ,64 ,64 }; -static const int busDDRA[4 ] = {64 +32 ,64 +32 , (64 +32 )*2 , (64 +32 )*2 }; +static const int busDDRA[4 ] = {64 +32 ,64 +32 , (64 +32 )*2 , (64 +32 )*2 };sisusb_getidxreg (sisusb,SISSR ,0x14 , &tmp8);sisusb_getidxreg (sisusb,SISSR ,0x15 , &tmp82);
@@ -2366,7 +2364,7 @@ sisusb_reset_text_mode(struct sisusb_usb_data *sisusb, int init) *(tempbufb++) =0x0700 | bootstring[i++]; ret |=sisusb_copy_memory (sisusb, tempbuf, - sisusb->vrambase,8192 , &written); + sisusb->vrambase,8192 , &written);vfree (tempbuf);
@@ -2380,7 +2378,7 @@ sisusb_reset_text_mode(struct sisusb_usb_data *sisusb, int init) }if (sisusb->sisusb_cursor_size_from >=0 && - sisusb->sisusb_cursor_size_to >=0 ) { + sisusb->sisusb_cursor_size_to >=0 ) {sisusb_setidxreg (sisusb,SISCR ,0x0a , sisusb->sisusb_cursor_size_from); sisusb_setidxregandor(sisusb, SISCR, 0x0b, 0xe0,
@@ -2392,7 +2390,7 @@ sisusb_reset_text_mode(struct sisusb_usb_data *sisusb, int init) } slot = sisusb->sisusb_cursor_loc; -if (slot <0 ) slot =0 ; +if (slot <0 ) slot =0 ; sisusb->sisusb_cursor_loc =-1 ; sisusb->bad_cursor_pos =1 ;
@@ -2444,7 +2442,7 @@ sisusb_open(struct inode *inode, struct file *file)if (!sisusb->devinit) {if (sisusb->sisusb_dev->speed ==USB_SPEED_HIGH || - sisusb->sisusb_dev->speed ==USB_SPEED_SUPER ) { + sisusb->sisusb_dev->speed ==USB_SPEED_SUPER ) {if (sisusb_init_gfxdevice (sisusb,0 )) {mutex_unlock (&sisusb->lock);dev_err (&sisusb->sisusb_dev->dev,"Failed to initialize device\n" );
@@ -2539,7 +2537,7 @@ sisusb_read(struct file *file, char __user *buffer, size_t count, loff_t *ppos) }if ((*ppos) >=SISUSB_PCI_PSEUDO_IOPORTBASE && - (*ppos) <SISUSB_PCI_PSEUDO_IOPORTBASE +128 ) { + (*ppos) <SISUSB_PCI_PSEUDO_IOPORTBASE +128 ) { address = (*ppos) - SISUSB_PCI_PSEUDO_IOPORTBASE +
@@ -2551,45 +2549,44 @@ sisusb_read(struct file *file, char __user *buffer, size_t count, loff_t *ppos)* in machine-endianness. */ switch (count) { +case 1 : +if (sisusb_read_memio_byte (sisusb, +SISUSB_TYPE_IO , + address, &buf8)) + errno = -EIO ; +else if (put_user (buf8, (u8 __user *)buffer)) + errno = -EFAULT ; +else + bytes_read =1 ; -case 1 : -if (sisusb_read_memio_byte (sisusb, -SISUSB_TYPE_IO , - address, &buf8)) - errno = -EIO ; -else if (put_user (buf8, (u8 __user *)buffer)) - errno = -EFAULT ; -else - bytes_read =1 ; - -break ; +break ; -case 2 : -if (sisusb_read_memio_word (sisusb, -SISUSB_TYPE_IO , - address, &buf16)) - errno = -EIO ; -else if (put_user (buf16, (u16 __user *)buffer)) - errno = -EFAULT ; -else - bytes_read =2 ; +case 2 : +if (sisusb_read_memio_word (sisusb, +SISUSB_TYPE_IO , + address, &buf16)) + errno = -EIO ; +else if (put_user (buf16, (u16 __user *)buffer)) + errno = -EFAULT ; +else + bytes_read =2 ; -break ; +break ; -case 4 : -if (sisusb_read_memio_long (sisusb, -SISUSB_TYPE_IO , - address, &buf32)) - errno = -EIO ; -else if (put_user (buf32, (u32 __user *)buffer)) - errno = -EFAULT ; -else - bytes_read =4 ; +case 4 : +if (sisusb_read_memio_long (sisusb, +SISUSB_TYPE_IO , + address, &buf32)) + errno = -EIO ; +else if (put_user (buf32, (u32 __user *)buffer)) + errno = -EFAULT ; +else + bytes_read =4 ; -break ; +break ; -default : - errno = -EIO ; +default : + errno = -EIO ; }
@@ -2604,7 +2601,7 @@ sisusb_read(struct file *file, char __user *buffer, size_t count, loff_t *ppos)* Remember: Data delivered is never endian-corrected */ errno =sisusb_read_mem_bulk (sisusb, address, -NULL , count, buffer, &bytes_read); +NULL , count, buffer, &bytes_read);if (bytes_read) errno = bytes_read;
@@ -2620,13 +2617,13 @@ sisusb_read(struct file *file, char __user *buffer, size_t count, loff_t *ppos)* Remember: Data delivered is never endian-corrected */ errno =sisusb_read_mem_bulk (sisusb, address, -NULL , count, buffer, &bytes_read); +NULL , count, buffer, &bytes_read);if (bytes_read) errno = bytes_read; }else if ((*ppos) >=SISUSB_PCI_PSEUDO_PCIBASE && - (*ppos) <=SISUSB_PCI_PSEUDO_PCIBASE +0x5c ) { + (*ppos) <=SISUSB_PCI_PSEUDO_PCIBASE +0x5c ) {if (count !=4 ) {mutex_unlock (&sisusb->lock);
@@ -2682,7 +2679,7 @@ sisusb_write(struct file *file, const char __user *buffer, size_t count, }if ((*ppos) >=SISUSB_PCI_PSEUDO_IOPORTBASE && - (*ppos) <SISUSB_PCI_PSEUDO_IOPORTBASE +128 ) { + (*ppos) <SISUSB_PCI_PSEUDO_IOPORTBASE +128 ) { address = (*ppos) - SISUSB_PCI_PSEUDO_IOPORTBASE +
@@ -2694,45 +2691,44 @@ sisusb_write(struct file *file, const char __user *buffer, size_t count,* in machine-endianness. */ switch (count) { +case 1 : +if (get_user (buf8, (u8 __user *)buffer)) + errno = -EFAULT ; +else if (sisusb_write_memio_byte (sisusb, +SISUSB_TYPE_IO , + address, buf8)) + errno = -EIO ; +else + bytes_written =1 ; -case 1 : -if (get_user (buf8, (u8 __user *)buffer)) - errno = -EFAULT ; -else if (sisusb_write_memio_byte (sisusb, -SISUSB_TYPE_IO , - address, buf8)) - errno = -EIO ; -else - bytes_written =1 ; - -break ; +break ; -case 2 : -if (get_user (buf16, (u16 __user *)buffer)) - errno = -EFAULT ; -else if (sisusb_write_memio_word (sisusb, -SISUSB_TYPE_IO , - address, buf16)) - errno = -EIO ; -else - bytes_written =2 ; +case 2 : +if (get_user (buf16, (u16 __user *)buffer)) + errno = -EFAULT ; +else if (sisusb_write_memio_word (sisusb, +SISUSB_TYPE_IO , + address, buf16)) + errno = -EIO ; +else + bytes_written =2 ; -break ; +break ; -case 4 : -if (get_user (buf32, (u32 __user *)buffer)) - errno = -EFAULT ; -else if (sisusb_write_memio_long (sisusb, -SISUSB_TYPE_IO , - address, buf32)) - errno = -EIO ; -else - bytes_written =4 ; +case 4 : +if (get_user (buf32, (u32 __user *)buffer)) + errno = -EFAULT ; +else if (sisusb_write_memio_long (sisusb, +SISUSB_TYPE_IO , + address, buf32)) + errno = -EIO ; +else + bytes_written =4 ; -break ; +break ; -default : - errno = -EIO ; +default : + errno = -EIO ; } } else if ((*ppos) >= SISUSB_PCI_PSEUDO_MEMBASE &&
@@ -2749,7 +2745,7 @@ sisusb_write(struct file *file, const char __user *buffer, size_t count,* mode or if YUV data is being transferred). */ errno =sisusb_write_mem_bulk (sisusb, address,NULL , - count, buffer,0 , &bytes_written); + count, buffer,0 , &bytes_written);if (bytes_written) errno = bytes_written;
@@ -2767,7 +2763,7 @@ sisusb_write(struct file *file, const char __user *buffer, size_t count,* in advance. */ errno =sisusb_write_mem_bulk (sisusb, address,NULL , - count, buffer,0 , &bytes_written); + count, buffer,0 , &bytes_written);if (bytes_written) errno = bytes_written;
@@ -2849,105 +2845,99 @@ sisusb_handle_command(struct sisusb_usb_data *sisusb, struct sisusb_command *y,SISUSB_PCI_IOPORTBASE ;switch (y->operation) { -case SUCMD_GET : - retval =sisusb_getidxreg (sisusb, port, - y->data0, &y->data1); -if (!retval) { -if (copy_to_user ((void __user *)arg, y, -sizeof (*y))) - retval = -EFAULT ; - } -break ; +case SUCMD_GET : + retval =sisusb_getidxreg (sisusb, port, y->data0, &y->data1); +if (!retval) { +if (copy_to_user ((void __user *)arg, y,sizeof (*y))) + retval = -EFAULT ; + } +break ; -case SUCMD_SET : - retval =sisusb_setidxreg (sisusb, port, - y->data0, y->data1); -break ; +case SUCMD_SET : + retval =sisusb_setidxreg (sisusb, port, y->data0, y->data1); +break ; -case SUCMD_SETOR : - retval =sisusb_setidxregor (sisusb, port, - y->data0, y->data1); -break ; +case SUCMD_SETOR : + retval =sisusb_setidxregor (sisusb, port, y->data0, y->data1); +break ; -case SUCMD_SETAND : - retval =sisusb_setidxregand (sisusb, port, - y->data0, y->data1); -break ; +case SUCMD_SETAND : + retval =sisusb_setidxregand (sisusb, port, y->data0, y->data1); +break ; -case SUCMD_SETANDOR : - retval =sisusb_setidxregandor (sisusb, port, - y->data0, y->data1, y->data2); -break ; +case SUCMD_SETANDOR : + retval =sisusb_setidxregandor (sisusb, port, y->data0, + y->data1, y->data2); +break ; -case SUCMD_SETMASK : - retval =sisusb_setidxregmask (sisusb, port, - y->data0, y->data1, y->data2); -break ; +case SUCMD_SETMASK : + retval =sisusb_setidxregmask (sisusb, port, y->data0, + y->data1, y->data2); +break ; -case SUCMD_CLRSCR : -/* Gfx core must be initialized */ -if (!sisusb->gfxinit) -return -ENODEV ; +case SUCMD_CLRSCR : +/* Gfx core must be initialized */ +if (!sisusb->gfxinit) +return -ENODEV ; - length = (y->data0 <<16 ) | (y->data1 <<8 ) | y->data2; - address = y->data3 - -SISUSB_PCI_PSEUDO_MEMBASE + + length = (y->data0 <<16 ) | (y->data1 <<8 ) | y->data2; + address = y->data3 -SISUSB_PCI_PSEUDO_MEMBASE +SISUSB_PCI_MEMBASE ; - retval =sisusb_clear_vram (sisusb, address, length); -break ; + retval =sisusb_clear_vram (sisusb, address, length); +break ; -case SUCMD_HANDLETEXTMODE : - retval =0 ; +case SUCMD_HANDLETEXTMODE : + retval =0 ;#ifdef INCL_SISUSB_CON -/* Gfx core must be initialized, SiS_Pr must exist */ -if (!sisusb->gfxinit || !sisusb->SiS_Pr) -return -ENODEV ; +/* Gfx core must be initialized, SiS_Pr must exist */ +if (!sisusb->gfxinit || !sisusb->SiS_Pr) +return -ENODEV ; -switch (y->data0) { -case 0 : - retval =sisusb_reset_text_mode (sisusb,0 ); -break ; -case 1 : - sisusb->textmodedestroyed =1 ; -break ; - } -#endif +switch (y->data0) { +case 0 : + retval =sisusb_reset_text_mode (sisusb,0 ); +break ; +case 1 : + sisusb->textmodedestroyed =1 ;break ; + } +#endif +break ;#ifdef INCL_SISUSB_CON -case SUCMD_SETMODE : -/* Gfx core must be initialized, SiS_Pr must exist */ -if (!sisusb->gfxinit || !sisusb->SiS_Pr) -return -ENODEV ; +case SUCMD_SETMODE : +/* Gfx core must be initialized, SiS_Pr must exist */ +if (!sisusb->gfxinit || !sisusb->SiS_Pr) +return -ENODEV ; - retval =0 ; + retval =0 ; - sisusb->SiS_Pr->IOAddress =SISUSB_PCI_IOPORTBASE +0x30 ; - sisusb->SiS_Pr->sisusb = (void *)sisusb; + sisusb->SiS_Pr->IOAddress =SISUSB_PCI_IOPORTBASE +0x30 ; + sisusb->SiS_Pr->sisusb = (void *)sisusb; -if (SiSUSBSetMode (sisusb->SiS_Pr, y->data3)) - retval = -EINVAL ; +if (SiSUSBSetMode (sisusb->SiS_Pr, y->data3)) + retval = -EINVAL ; -break ; +break ; -case SUCMD_SETVESAMODE : -/* Gfx core must be initialized, SiS_Pr must exist */ -if (!sisusb->gfxinit || !sisusb->SiS_Pr) -return -ENODEV ; +case SUCMD_SETVESAMODE : +/* Gfx core must be initialized, SiS_Pr must exist */ +if (!sisusb->gfxinit || !sisusb->SiS_Pr) +return -ENODEV ; - retval =0 ; + retval =0 ; - sisusb->SiS_Pr->IOAddress =SISUSB_PCI_IOPORTBASE +0x30 ; - sisusb->SiS_Pr->sisusb = (void *)sisusb; + sisusb->SiS_Pr->IOAddress =SISUSB_PCI_IOPORTBASE +0x30 ; + sisusb->SiS_Pr->sisusb = (void *)sisusb; -if (SiSUSBSetVESAMode (sisusb->SiS_Pr, y->data3)) - retval = -EINVAL ; +if (SiSUSBSetVESAMode (sisusb->SiS_Pr, y->data3)) + retval = -EINVAL ; -break ; +break ;#endif -default : - retval = -EINVAL ; +default : + retval = -EINVAL ; }if (retval >0 )
@@ -2978,52 +2968,51 @@ sisusb_ioctl(struct file *file, unsigned int cmd, unsigned long arg) }switch (cmd) { +case SISUSB_GET_CONFIG_SIZE : -case SISUSB_GET_CONFIG_SIZE : +if (put_user (sizeof (x), argp)) + retval = -EFAULT ; -if (put_user (sizeof (x), argp)) - retval = -EFAULT ; - -break ; +break ; -case SISUSB_GET_CONFIG : - - x.sisusb_id =SISUSB_ID ; - x.sisusb_version =SISUSB_VERSION ; - x.sisusb_revision =SISUSB_REVISION ; - x.sisusb_patchlevel =SISUSB_PATCHLEVEL ; - x.sisusb_gfxinit = sisusb->gfxinit; - x.sisusb_vrambase =SISUSB_PCI_PSEUDO_MEMBASE ; - x.sisusb_mmiobase =SISUSB_PCI_PSEUDO_MMIOBASE ; - x.sisusb_iobase =SISUSB_PCI_PSEUDO_IOPORTBASE ; - x.sisusb_pcibase =SISUSB_PCI_PSEUDO_PCIBASE ; - x.sisusb_vramsize = sisusb->vramsize; - x.sisusb_minor = sisusb->minor; - x.sisusb_fbdevactive=0 ; +case SISUSB_GET_CONFIG : + + x.sisusb_id =SISUSB_ID ; + x.sisusb_version =SISUSB_VERSION ; + x.sisusb_revision =SISUSB_REVISION ; + x.sisusb_patchlevel =SISUSB_PATCHLEVEL ; + x.sisusb_gfxinit = sisusb->gfxinit; + x.sisusb_vrambase =SISUSB_PCI_PSEUDO_MEMBASE ; + x.sisusb_mmiobase =SISUSB_PCI_PSEUDO_MMIOBASE ; + x.sisusb_iobase =SISUSB_PCI_PSEUDO_IOPORTBASE ; + x.sisusb_pcibase =SISUSB_PCI_PSEUDO_PCIBASE ; + x.sisusb_vramsize = sisusb->vramsize; + x.sisusb_minor = sisusb->minor; + x.sisusb_fbdevactive =0 ;#ifdef INCL_SISUSB_CON - x.sisusb_conactive = sisusb->haveconsole ?1 :0 ; + x.sisusb_conactive = sisusb->haveconsole ?1 :0 ;#else - x.sisusb_conactive =0 ; + x.sisusb_conactive =0 ;#endif -memset (x.sisusb_reserved,0 ,sizeof (x.sisusb_reserved)); +memset (x.sisusb_reserved,0 ,sizeof (x.sisusb_reserved)); -if (copy_to_user ((void __user *)arg, &x,sizeof (x))) - retval = -EFAULT ; +if (copy_to_user ((void __user *)arg, &x,sizeof (x))) + retval = -EFAULT ; -break ; +break ; -case SISUSB_COMMAND : +case SISUSB_COMMAND : -if (copy_from_user (&y, (void __user *)arg,sizeof (y))) - retval = -EFAULT ; -else - retval =sisusb_handle_command (sisusb, &y, arg); +if (copy_from_user (&y, (void __user *)arg,sizeof (y))) + retval = -EFAULT ; +else + retval =sisusb_handle_command (sisusb, &y, arg); -break ; +break ; -default : - retval = -ENOTTY ; -break ; +default : + retval = -ENOTTY ; +break ; } err_out:
@@ -3038,14 +3027,14 @@ sisusb_compat_ioctl(struct file *f, unsigned int cmd, unsigned long arg)long retval;switch (cmd) { -case SISUSB_GET_CONFIG_SIZE : -case SISUSB_GET_CONFIG : -case SISUSB_COMMAND : - retval =sisusb_ioctl (f, cmd, arg); -return retval; +case SISUSB_GET_CONFIG_SIZE : +case SISUSB_GET_CONFIG : +case SISUSB_COMMAND : + retval =sisusb_ioctl (f, cmd, arg); +return retval; -default : -return -ENOIOCTLCMD ; +default : +return -ENOIOCTLCMD ; } }#endif
@@ -3070,14 +3059,14 @@ static struct usb_class_driver usb_sisusb_class = { };static int sisusb_probe (struct usb_interface *intf, -const struct usb_device_id *id) +const struct usb_device_id *id) {struct usb_device *dev =interface_to_usbdev (intf);struct sisusb_usb_data *sisusb;int retval =0 , i;dev_info (&dev->dev,"USB2VGA dongle found at address %d\n" , - dev->devnum); + dev->devnum);/* Allocate memory for our private */ sisusb =kzalloc (sizeof (*sisusb),GFP_KERNEL );
@@ -3254,7 +3243,7 @@ static const struct usb_device_id sisusb_table[] = { { } }; -MODULE_DEVICE_TABLE (usb, sisusb_table); +MODULE_DEVICE_TABLE (usb, sisusb_table);static struct usb_driver sisusb_driver = { .name ="sisusb" ,
Signature · 1 line
2.5.0
(cc'ing Masahiro Yamada and Jason Cooper for objdiff)
Quoted 7 lines · Peter Senna Tschudin
The file
drivers/usb/misc/sisusbvga/sisusb.chad many (192) coding style issues reported by checkpatch. This file also had a problematic error path in the probe function that could result in dereferencing a null pointer.This patch series fix coding style issues and a problematic error path which could result in a null pointer dereference.
Quoted 8 lines
Patch 1 and 2 change whitespace only, patch 3 to 6 fix various coding style issues, and patch 7 fix a null pointer dereference bug.
Joe Perches suggested me to include objtdiff output for patches that are not supposed to make semantic changes, but it is not working well for me with gcc (GCC) 5.3.1 20151207 (Red Hat 5.3.1-2). Even compiling the same source code produces different output from objdump. The objdump command I'm using is from
./scripts/objdiff. See an example:
It seems gcc 5.3 isn't producing consistent output for whitespace changes.
As far as I know, gcc has never made guarantees about object output for the same input content.
Quoted 79 lines
# A patch that should not make any semantic change
$ cat /tmp/patch diff --git a/drivers/usb/misc/sisusbvga/sisusb.c b/drivers/usb/misc/sisusbvga/sisusb.c index 8efbaba..a48b086d 100644 --- a/drivers/usb/misc/sisusbvga/sisusb.c +++ b/drivers/usb/misc/sisusbvga/sisusb.c @@ -1353,7 +1353,7 @@ sisusb_testreadwrite(struct sisusb_usb_data *sisusb) static char srcbuffer[] = { 0x11, 0x22, 0x33, 0x44, 0x55, 0x66, 0x77 }; char destbuffer[10]; size_t dummy; - int i,j; + int i, j; sisusb_copy_memory(sisusb, srcbuffer, sisusb->vrambase, 7, &dummy);# Lets compile and collect a dump based on linux-next/master
$ git checkout linux-next/master $ md5sum drivers/usb/misc/sisusbvga/sisusb.c d6ffbd44f3f1cf81fd55ce84441ab889 drivers/usb/misc/sisusbvga/sisusb.c$ make -j4 drivers/usb/misc/sisusbvga/sisusb.o $ objdump -D drivers/usb/misc/sisusbvga/sisusb.o| \ sed "s/^[[:space:]]\+[0-9a-f]\+//" > /tmp/base_dump# Now let's apply the patch and collect other dump
$ git apply /tmp/patch $ md5sum drivers/usb/misc/sisusbvga/sisusb.c 0b7d579c8ae2159f677c6a5c6efc4956 drivers/usb/misc/sisusbvga/sisusb.c$ make -j4 drivers/usb/misc/sisusbvga/sisusb.o $ objdump -D drivers/usb/misc/sisusbvga/sisusb.o| \ sed "s/^[[:space:]]\+[0-9a-f]\+//" > /tmp/dump# I was expecting the diff to be empty
$ diff /tmp/base_dump /tmp/dump 9135,9136c9135 < : 8e 4d 31 mov 0x31(%rbp),%cs < : 46 00 00 rex.RX add %r8b,(%rax) --- > : 25 c4 31 46 00 and $0x4631c4,%eax 9139c9138 < : 4b 00 00 rex.WXB add %al,(%r8) --- > : 00 4b 00 add %cl,0x0(%rbx)# But here is the interesting part. Even compiling the exact same source code
# produces different results $ git checkout -- . $ md5sum drivers/usb/misc/sisusbvga/sisusb.c d6ffbd44f3f1cf81fd55ce84441ab889 drivers/usb/misc/sisusbvga/sisusb.c$ make -j4 drivers/usb/misc/sisusbvga/sisusb.o $ objdump -D drivers/usb/misc/sisusbvga/sisusb.o| \ sed "s/^[[:space:]]\+[0-9a-f]\+//" > /tmp/base_dump_again$ diff /tmp/base_dump /tmp/base_dump_again 9135,9136c9135,9136 < : 8e 4d 31 mov 0x31(%rbp),%cs < : 46 00 00 rex.RX add %r8b,(%rax) --- > : de 10 ficom (%rax) > : 33 46 00 xor 0x0(%rsi),%eax 9139c9139 < : 4b 00 00 rex.WXB add %al,(%r8) --- > : 00 4b 00 add %cl,0x0(%rbx)Peter Senna Tschudin (7):
usb-misc: sisusbvga: Fix coding style: horizontal whitespace changes
usb-misc: sisusbvga: Fix coding style: vertical whitespace changes
usb-misc: sisusbvga: Fix coding style: braces, parenthesis, comment
usb-misc: sisusbvga: Fix coding style: remove assignment from if tests
usb-misc: sisusbvga: Remove null test before calls tokfree()
usb-misc: sisusbvga: Remove memory allocation logs
usb-misc: sisusbvga: fix error pathdrivers/usb/misc/sisusbvga/sisusb.c | 1543 +++++++++++++++++------------------
1 file changed, 752 insertions(+), 791 deletions(-)
Re: [PATCH V2 1/7] usb-misc: sisusbvga: Fix coding style: horizontal whitespace changes
In reply to Peter Senna TschudinQuoted 2 lines · Peter Senna Tschudin
This patch fixes whitespace coding style issues that can be fixed within a single line.
trivia:
drivers/usb/misc/sisusbvga/sisusb.c
Quoted 1 line
drivers/usb/misc/sisusbvga/sisusb.c +0
-0
[]
drivers/usb/misc/sisusbvga/sisusb.c static int sisusb_recv_bulk_msg(struct sisusb_usb_data *sisusb, int ep, int len, · line 552
Quoted 6 lines
drivers/usb/misc/sisusbvga/sisusb.c +0
-0@@ -549,7 +549,7 @@ static int sisusb_recv_bulk_msg(struct sisusb_usb_data *sisusb, int ep, int len, }
static int sisusb_send_packet(structsisusb_usb_data*sisusb, int len,drivers/usb/misc/sisusbvga/sisusb.c +1
-1- struct sisusb_packet *packet) + struct sisusb_packet *packet)
I think all of these should use indentation alignment to open parenthesis.
Hey Joe, Peter,
Quoted 3 lines · Joe Perches
(cc'ing Masahiro Yamada and Jason Cooper for objdiff)
On Fri, 2016-01-15 at 18:41 +0100, Peter Senna Tschudin wrote:
...
Quoted 2 lines
As far as I know, gcc has never made guarantees about object output for the same input content.
True, we may want to reach out to the folks doing reproducible builds. They may have seen/diagnosed/fixed this already.
Quoted 10 lines
Quoted 10 lines
# But here is the interesting part. Even compiling the exact same source code
# produces different results $ git checkout -- . $ md5sum drivers/usb/misc/sisusbvga/sisusb.c d6ffbd44f3f1cf81fd55ce84441ab889 drivers/usb/misc/sisusbvga/sisusb.c$ make -j4 drivers/usb/misc/sisusbvga/sisusb.o $ objdump -D drivers/usb/misc/sisusbvga/sisusb.o| \ sed "s/^[[:space:]]\+[0-9a-f]\+//" > /tmp/base_dump_again
Quoted 11 lines
Quoted 11 lines
$ diff /tmp/base_dump /tmp/base_dump_again 9135,9136c9135,9136 < : 8e 4d 31 mov 0x31(%rbp),%cs < : 46 00 00 rex.RX add %r8b,(%rax) --- > : de 10 ficom (%rax) > : 33 46 00 xor 0x0(%rsi),%eax 9139c9139 < : 4b 00 00 rex.WXB add %al,(%r8) --- > : 00 4b 00 add %cl,0x0(%rbx)
Well, this clearly shows that the whitespace change is a red herring. I'm just guessing here, but could you try with -j1 to see if you can still reproduce this inconsistency?
Cleaning the tree between builds may also narrow down the suspects.
thx,
Jason.
Re: [PATCH V2 1/7] usb-misc: sisusbvga: Fix coding style: horizontal whitespace changes
In reply to Joe PerchesQuoted 8 lines · Joe Perches
Quoted 2 lines · Peter Senna Tschudin
This patch fixes whitespace coding style issues that can be fixed within a single line.
trivia:
drivers/usb/misc/sisusbvga/sisusb.c
Quoted 1 line
drivers/usb/misc/sisusbvga/sisusb.c +0
-0[]
Quoted 9 lines
drivers/usb/misc/sisusbvga/sisusb.c static int sisusb_recv_bulk_msg(struct sisusb_usb_data *sisusb, int ep, int len, · line 552
Quoted 6 lines
drivers/usb/misc/sisusbvga/sisusb.c +0
-0@@ -549,7 +549,7 @@ static int sisusb_recv_bulk_msg(struct sisusb_usb_data *sisusb, int ep, int len, }
static int sisusb_send_packet(structsisusb_usb_data*sisusb, int len,drivers/usb/misc/sisusbvga/sisusb.c +1
-1- struct sisusb_packet *packet) + struct sisusb_packet *packet)I think all of these should use indentation alignment to open parenthesis.
That was my original idea too, but I have the impression things are different for usb, at least for usb-host. Alan, can you comment on this continuation line style issue here?
Re: Re: [PATCH V2 1/7] usb-misc: sisusbvga: Fix coding style: horizontal whitespace changes
Quoted 21 lines · Peter Senna
CC Alan Stern <[email protected]>Quoted 8 lines · Joe Perches
Quoted 2 lines · Peter Senna Tschudin
This patch fixes whitespace coding style issues that can be fixed within a single line.
trivia:
drivers/usb/misc/sisusbvga/sisusb.c
Quoted 1 line
drivers/usb/misc/sisusbvga/sisusb.c +0
-0[]
Quoted 9 lines
drivers/usb/misc/sisusbvga/sisusb.c static int sisusb_recv_bulk_msg(struct sisusb_usb_data *sisusb, int ep, int len, · line 552
Quoted 6 lines
drivers/usb/misc/sisusbvga/sisusb.c +0
-0@@ -549,7 +549,7 @@ static int sisusb_recv_bulk_msg(struct sisusb_usb_data *sisusb, int ep, int len, }
static int sisusb_send_packet(structsisusb_usb_data*sisusb, int len,drivers/usb/misc/sisusbvga/sisusb.c +1
-1- struct sisusb_packet *packet) + struct sisusb_packet *packet)I think all of these should use indentation alignment to open parenthesis.
Quoted 1 line
That was my original idea too, but I have the impression things are different for usb, at least for usb-host. Alan, can you comment on this continuation line style issue here?
Different files use different alignment for continuation lines. I use the style I like (two extra tabs) for the code I write, but other people make different choices. Unless I happen to be the maintainer or an active contributor for the source file in question, my preferences don't matter much.
Alan Stern