From c09d206be72ea3af42ec332264f965a45e12a6d3 Mon Sep 17 00:00:00 2001 From: Alexander Viro Date: Fri, 30 Jul 2004 08:47:29 -0700 Subject: [PATCH] [PATCH] sparse: ftape ftape got annotations and NULL noise removals. Propagated the dependency on alpha/i386/amd64 to Kconfig (it's already enforced by #error) Signed-off-by: Al Viro Signed-off-by: Linus Torvalds --- drivers/char/Kconfig | 2 +- drivers/char/ftape/compressor/lzrw3.c | 47 ++++++++----------- .../char/ftape/compressor/zftape-compress.c | 8 ++-- drivers/char/ftape/lowlevel/ftape-init.c | 2 +- drivers/char/ftape/lowlevel/ftape-proc.c | 2 +- drivers/char/ftape/zftape/zftape-ctl.c | 2 +- drivers/char/ftape/zftape/zftape-ctl.h | 2 +- drivers/char/ftape/zftape/zftape-init.c | 10 ++-- drivers/char/ftape/zftape/zftape-init.h | 4 +- drivers/char/ftape/zftape/zftape-read.c | 6 +-- drivers/char/ftape/zftape/zftape-read.h | 2 +- drivers/char/ftape/zftape/zftape-write.c | 6 +-- drivers/char/ftape/zftape/zftape-write.h | 2 +- include/linux/mtio.h | 2 +- 14 files changed, 45 insertions(+), 52 deletions(-) diff --git a/drivers/char/Kconfig b/drivers/char/Kconfig index 963986ae9aea1..60c50c2eb1af1 100644 --- a/drivers/char/Kconfig +++ b/drivers/char/Kconfig @@ -867,7 +867,7 @@ menu "Ftape, the floppy tape device driver" config FTAPE tristate "Ftape (QIC-80/Travan) support" - depends on BROKEN_ON_SMP + depends on BROKEN_ON_SMP && (ALPHA || X86) ---help--- If you have a tape drive that is connected to your floppy controller, say Y here. diff --git a/drivers/char/ftape/compressor/lzrw3.c b/drivers/char/ftape/compressor/lzrw3.c index a45cd2ba5af3d..a032a0ee2a99a 100644 --- a/drivers/char/ftape/compressor/lzrw3.c +++ b/drivers/char/ftape/compressor/lzrw3.c @@ -115,13 +115,14 @@ LOCAL void compress_decompress(UBYTE *,UBYTE *,LONG, UBYTE *, ULONG *); /* compress a block of memory, decompress a block of memory, or to identify */ /* itself. For more information, see the specification file "compress.h". */ -EXPORT void lzrw3_compress(action,wrk_mem,src_adr,src_len,dst_adr,p_dst_len) -UWORD action; /* Action to be performed. */ -UBYTE *wrk_mem; /* Address of working memory we can use. */ -UBYTE *src_adr; /* Address of input data. */ -LONG src_len; /* Length of input data. */ -UBYTE *dst_adr; /* Address to put output data. */ -void *p_dst_len; /* Address of longword for length of output data. */ +EXPORT void lzrw3_compress( + UWORD action, /* Action to be performed. */ + UBYTE *wrk_mem, /* Address of working memory we can use.*/ + UBYTE *src_adr, /* Address of input data. */ + LONG src_len, /* Length of input data. */ + UBYTE *dst_adr, /* Address to put output data. */ + void *p_dst_len /* Address of longword for length of output data.*/ +) { switch (action) { @@ -314,9 +315,7 @@ void *p_dst_len; /* Address of longword for length of output data. */ (((40543*(((*(PTR))<<8)^((*((PTR)+1))<<4)^(*((PTR)+2))))>>4) & 0xFFF) /******************************************************************************/ - -LOCAL void compress_compress - (p_wrk_mem,p_src_first,src_len,p_dst_first,p_dst_len) + /* Input : Hand over the required amount of working memory in p_wrk_mem. */ /* Input : Specify input block using p_src_first and src_len. */ /* Input : Point p_dst_first to the start of the output zone (OZ). */ @@ -326,11 +325,9 @@ LOCAL void compress_compress /* Output : Output block in Mem[p_dst_first..p_dst_first+*p_dst_len-1]. May */ /* Output : write in OZ=Mem[p_dst_first..p_dst_first+src_len+MAX_CMP_GROUP-1].*/ /* Output : Upon completion guaranteed *p_dst_len<=src_len+FLAG_BYTES. */ -UBYTE *p_wrk_mem; -UBYTE *p_src_first; -ULONG src_len; -UBYTE *p_dst_first; -LONG *p_dst_len; +LOCAL void compress_compress(UBYTE *p_wrk_mem, + UBYTE *p_src_first, ULONG src_len, + UBYTE *p_dst_first, LONG *p_dst_len) { /* p_src and p_dst step through the source and destination blocks. */ register UBYTE *p_src = p_src_first; @@ -366,8 +363,8 @@ LONG *p_dst_len; /* to the hash table entry corresponding to the second youngest literal. */ /* Note: p_h1=0=>p_h2=0 because zero values denote absence of a pending */ /* literal. The variables are initialized to zero meaning an empty "buffer". */ - UBYTE **p_h1=0; - UBYTE **p_h2=0; + UBYTE **p_h1=NULL; + UBYTE **p_h2=NULL; /* To start, we write the flag bytes. Being optimistic, we set the flag to */ /* FLAG_COMPRESS. The remaining flag bytes are zeroed so as to keep the */ @@ -488,9 +485,9 @@ LONG *p_dst_len; /* upon the arrival of extra context bytes. */ if (p_h1!=0) { - if (p_h2!=0) - {*p_h2=p_ziv-2; p_h2=0;} - *p_h1=p_ziv-1; p_h1=0; + if (p_h2) + {*p_h2=p_ziv-2; p_h2=NULL;} + *p_h1=p_ziv-1; p_h1=NULL; } /* In any case, we can update the hash table based on the current */ @@ -564,8 +561,6 @@ LONG *p_dst_len; /******************************************************************************/ -LOCAL void compress_decompress - (p_wrk_mem,p_src_first,src_len,p_dst_first,p_dst_len) /* Input : Hand over the required amount of working memory in p_wrk_mem. */ /* Input : Specify input block using p_src_first and src_len. */ /* Input : Point p_dst_first to the start of the output zone. */ @@ -576,11 +571,9 @@ LOCAL void compress_decompress /* Output : Length of output block written to *p_dst_len. */ /* Output : Output block in Mem[p_dst_first..p_dst_first+*p_dst_len-1]. */ /* Output : Writes only in Mem[p_dst_first..p_dst_first+*p_dst_len-1]. */ -UBYTE *p_wrk_mem; -UBYTE *p_src_first; -LONG src_len; -UBYTE *p_dst_first; -ULONG *p_dst_len; +LOCAL void compress_decompress( UBYTE *p_wrk_mem, + UBYTE *p_src_first, LONG src_len, + UBYTE *p_dst_first, ULONG *p_dst_len) { /* Byte pointers p_src and p_dst scan through the input and output blocks. */ register UBYTE *p_src = p_src_first+FLAG_BYTES; diff --git a/drivers/char/ftape/compressor/zftape-compress.c b/drivers/char/ftape/compressor/zftape-compress.c index 430aa0db6b3df..874627ab1e628 100644 --- a/drivers/char/ftape/compressor/zftape-compress.c +++ b/drivers/char/ftape/compressor/zftape-compress.c @@ -74,10 +74,10 @@ static unsigned int zftc_rd_compressed = 0; /* forward */ static int zftc_write(int *write_cnt, __u8 *dst_buf, const int seg_sz, - const __u8 *src_buf, const int req_len, + const __u8 __user *src_buf, const int req_len, const zft_position *pos, const zft_volinfo *volume); static int zftc_read(int *read_cnt, - __u8 *dst_buf, const int to_do, + __u8 __user *dst_buf, const int to_do, const __u8 *src_buf, const int seg_sz, const zft_position *pos, const zft_volinfo *volume); static int zftc_seek(unsigned int new_block_pos, @@ -539,7 +539,7 @@ static int start_new_cseg(cmpr_info *cluster, */ static int zftc_write(int *write_cnt, __u8 *dst_buf, const int seg_sz, - const __u8 *src_buf, const int req_len, + const __u8 __user *src_buf, const int req_len, const zft_position *pos, const zft_volinfo *volume) { int req_len_left = req_len; @@ -656,7 +656,7 @@ static int zftc_write(int *write_cnt, * be set to 0 */ static int zftc_read (int *read_cnt, - __u8 *dst_buf, const int to_do, + __u8 __user *dst_buf, const int to_do, const __u8 *src_buf, const int seg_sz, const zft_position *pos, const zft_volinfo *volume) { diff --git a/drivers/char/ftape/lowlevel/ftape-init.c b/drivers/char/ftape/lowlevel/ftape-init.c index 518e704281321..17a7f0e0c148c 100644 --- a/drivers/char/ftape/lowlevel/ftape-init.c +++ b/drivers/char/ftape/lowlevel/ftape-init.c @@ -90,7 +90,7 @@ KERN_INFO "Compiled for Linux version %s\n", UTS_RELEASE); TRACE(ft_t_info, "ftape_init @ 0x%p", ftape_init); /* Allocate the DMA buffers. They are deallocated at cleanup() time. */ -#if TESTING +#ifdef TESTING #ifdef MODULE while (ftape_set_nr_buffers(CONFIG_FT_NR_BUFFERS) < 0) { ftape_sleep(FT_SECOND/20); diff --git a/drivers/char/ftape/lowlevel/ftape-proc.c b/drivers/char/ftape/lowlevel/ftape-proc.c index 6b8844ff455c1..1e27c908eeee3 100644 --- a/drivers/char/ftape/lowlevel/ftape-proc.c +++ b/drivers/char/ftape/lowlevel/ftape-proc.c @@ -192,7 +192,7 @@ int ftape_read_proc(char *page, char **start, off_t off, ptr += get_history_info(ptr); len = strlen(page); - *start = 0; + *start = NULL; if (off+count >= len) { *eof = 1; } else { diff --git a/drivers/char/ftape/zftape/zftape-ctl.c b/drivers/char/ftape/zftape/zftape-ctl.c index 93010ccaa8526..6c7874e5c199e 100644 --- a/drivers/char/ftape/zftape/zftape-ctl.c +++ b/drivers/char/ftape/zftape/zftape-ctl.c @@ -1319,7 +1319,7 @@ ftmtcmd_error: /* IOCTL routine called by kernel-interface code */ -int _zft_ioctl(unsigned int command, void * arg) +int _zft_ioctl(unsigned int command, void __user * arg) { int result; union { struct mtop mtop; diff --git a/drivers/char/ftape/zftape/zftape-ctl.h b/drivers/char/ftape/zftape/zftape-ctl.h index 6c5a2532a3cc1..4141598919906 100644 --- a/drivers/char/ftape/zftape/zftape-ctl.h +++ b/drivers/char/ftape/zftape/zftape-ctl.h @@ -52,7 +52,7 @@ extern int zft_def_idle_state(void); */ extern int _zft_open(unsigned int dev_minor, unsigned int access_mode); extern int _zft_close(void); -extern int _zft_ioctl(unsigned int command, void *arg); +extern int _zft_ioctl(unsigned int command, void __user *arg); #endif diff --git a/drivers/char/ftape/zftape/zftape-init.c b/drivers/char/ftape/zftape/zftape-init.c index 1fc5feaf99226..95666a2ebe13e 100644 --- a/drivers/char/ftape/zftape/zftape-init.c +++ b/drivers/char/ftape/zftape/zftape-init.c @@ -88,9 +88,9 @@ static int zft_close(struct inode *ino, struct file *filep); static int zft_ioctl(struct inode *ino, struct file *filep, unsigned int command, unsigned long arg); static int zft_mmap(struct file *filep, struct vm_area_struct *vma); -static ssize_t zft_read (struct file *fp, char *buff, +static ssize_t zft_read (struct file *fp, char __user *buff, size_t req_len, loff_t *ppos); -static ssize_t zft_write(struct file *fp, const char *buff, +static ssize_t zft_write(struct file *fp, const char __user *buff, size_t req_len, loff_t *ppos); static struct file_operations zft_cdev = @@ -177,7 +177,7 @@ static int zft_ioctl(struct inode *ino, struct file *filep, old_sigmask = current->blocked; /* save mask */ sigfillset(¤t->blocked); /* This will work as long as sizeof(void *) == sizeof(long) */ - result = _zft_ioctl(command, (void *) arg); + result = _zft_ioctl(command, (void __user *) arg); current->blocked = old_sigmask; /* restore mask */ TRACE_EXIT result; } @@ -211,7 +211,7 @@ static int zft_mmap(struct file *filep, struct vm_area_struct *vma) /* Read from floppy tape device */ -static ssize_t zft_read(struct file *fp, char *buff, +static ssize_t zft_read(struct file *fp, char __user *buff, size_t req_len, loff_t *ppos) { int result = -EIO; @@ -234,7 +234,7 @@ static ssize_t zft_read(struct file *fp, char *buff, /* Write to tape device */ -static ssize_t zft_write(struct file *fp, const char *buff, +static ssize_t zft_write(struct file *fp, const char __user *buff, size_t req_len, loff_t *ppos) { int result = -EIO; diff --git a/drivers/char/ftape/zftape/zftape-init.h b/drivers/char/ftape/zftape/zftape-init.h index 5f9ce2eef1ff8..2145892b9eea7 100644 --- a/drivers/char/ftape/zftape/zftape-init.h +++ b/drivers/char/ftape/zftape/zftape-init.h @@ -52,10 +52,10 @@ extern const ftape_info *zft_status; /* needed for zftape-vtbl.h */ struct zft_cmpr_ops { int (*write)(int *write_cnt, __u8 *dst_buf, const int seg_sz, - const __u8 *src_buf, const int req_len, + const __u8 __user *src_buf, const int req_len, const zft_position *pos, const zft_volinfo *volume); int (*read)(int *read_cnt, - __u8 *dst_buf, const int req_len, + __u8 __user *dst_buf, const int req_len, const __u8 *src_buf, const int seg_sz, const zft_position *pos, const zft_volinfo *volume); int (*seek)(unsigned int new_block_pos, diff --git a/drivers/char/ftape/zftape/zftape-read.c b/drivers/char/ftape/zftape/zftape-read.c index 42de63254e535..214bf03dce687 100644 --- a/drivers/char/ftape/zftape/zftape-read.c +++ b/drivers/char/ftape/zftape/zftape-read.c @@ -154,7 +154,7 @@ int zft_fetch_segment_fraction(const unsigned int segment, void *buffer, * amount of data actually * copied to the user-buffer */ static int zft_simple_read (int *read_cnt, - __u8 *dst_buf, + __u8 __user *dst_buf, const int to_do, const __u8 *src_buf, const int seg_sz, @@ -252,7 +252,7 @@ static int check_read_access(int *req_len, * req_len: how much data should be read at most. * volume: contains information on current volume (blk_sz etc.) */ -static int empty_deblock_buf(__u8 *usr_buf, const int req_len, +static int empty_deblock_buf(__u8 __user *usr_buf, const int req_len, const __u8 *src_buf, const int seg_sz, zft_position *pos, const zft_volinfo *volume) @@ -293,7 +293,7 @@ static int empty_deblock_buf(__u8 *usr_buf, const int req_len, * use small block-sizes. The block-size may be 1kb (SECTOR_SIZE). In * this case a MTFSR 28 maybe still inside the same segment. */ -int _zft_read(char* buff, int req_len) +int _zft_read(char __user *buff, int req_len) { int req_clipped; int result = 0; diff --git a/drivers/char/ftape/zftape/zftape-read.h b/drivers/char/ftape/zftape/zftape-read.h index ad2e9dbc4f554..42941de0c23a9 100644 --- a/drivers/char/ftape/zftape/zftape-read.h +++ b/drivers/char/ftape/zftape/zftape-read.h @@ -48,6 +48,6 @@ extern int zft_fetch_segment_fraction(const unsigned int segment, 0, FT_SEGMENT_SIZE) /* hook for the VFS interface */ -extern int _zft_read(char* buff, int req_len); +extern int _zft_read(char __user *buff, int req_len); #endif /* _ZFTAPE_READ_H */ diff --git a/drivers/char/ftape/zftape/zftape-write.c b/drivers/char/ftape/zftape/zftape-write.c index 43129fdf0b0f0..94327b8c97b94 100644 --- a/drivers/char/ftape/zftape/zftape-write.c +++ b/drivers/char/ftape/zftape/zftape-write.c @@ -303,7 +303,7 @@ int zft_flush_buffers(void) */ static int zft_simple_write(int *cnt, __u8 *dst_buf, const int seg_sz, - const __u8 *src_buf, const int req_len, + const __u8 __user *src_buf, const int req_len, const zft_position *pos,const zft_volinfo *volume) { int space_left; @@ -379,7 +379,7 @@ static int check_write_access(int req_len, static int fill_deblock_buf(__u8 *dst_buf, const int seg_sz, zft_position *pos, const zft_volinfo *volume, - const char *usr_buf, const int req_len) + const char __user *usr_buf, const int req_len) { int cnt = 0; int result = 0; @@ -420,7 +420,7 @@ static int fill_deblock_buf(__u8 *dst_buf, const int seg_sz, /* called by the kernel-interface routine "zft_write()" */ -int _zft_write(const char* buff, int req_len) +int _zft_write(const char __user *buff, int req_len) { int result = 0; int written = 0; diff --git a/drivers/char/ftape/zftape/zftape-write.h b/drivers/char/ftape/zftape/zftape-write.h index 4a8d47687c3be..ea887015b493d 100644 --- a/drivers/char/ftape/zftape/zftape-write.h +++ b/drivers/char/ftape/zftape/zftape-write.h @@ -34,5 +34,5 @@ extern void zft_prevent_flush(void); /* hook for the VFS interface */ -extern int _zft_write(const char *buff, int req_len); +extern int _zft_write(const char __user *buff, int req_len); #endif /* _ZFTAPE_WRITE_H */ diff --git a/include/linux/mtio.h b/include/linux/mtio.h index 692088c6361d8..4f2daa83d3ad0 100644 --- a/include/linux/mtio.h +++ b/include/linux/mtio.h @@ -204,7 +204,7 @@ struct mtftseg unsigned mt_segno; /* the segment to read or write */ unsigned mt_mode; /* modes for read/write (sync/async etc.) */ int mt_result; /* result of r/w request, not of the ioctl */ - void *mt_data; /* User space buffer: must be 29kb */ + void __user *mt_data; /* User space buffer: must be 29kb */ }; /* get tape capacity (ftape/zftape) -- 2.53.0