Re: Linux-2.1.62..

Robert Bihlmeyer (robbe@orcus.priv.at)
04 Nov 1997 11:24:41 +0059


Hi,

>>>>> On Mon, 3 Nov 1997 16:42:07 -0800 (PST)
>>>>> Linus Torvalds <torvalds@transmeta.com> said:

Linus> But what I _would_ like to see is patches in my mailbox that
Linus> have been tested - I follow the kernel mailing lists very
Linus> spottily, so sending the patches to the mailing list does not
Linus> mean they reach me. I still encourage people to do that
Linus> (that's what the mailing list is there for), but please
Linus> consider that a "testing phase", to then later send the
Linus> patches to me personally..

The problem with trivial patches is, that most people seem to regard
it as logical that the patch is working ("well, I would have done it
this way, so it surely is correct") and don't report this fact. So one
can't be quite sure that a simple modification is well-tested.

If I post a trivial patch for testing and get no complains for a week,
should I consider it correct?

As examples I include a patch to make nvram work with the new vfs
read/write interface. The second patch does the same for the
sound-driver. Both are courtesy of Janos Farkas.

Robbe

### 1. nvram fix

diff -urpN linux-2.1.60-ORIG/drivers/char/nvram.c linux/drivers/char/nvram.c
--- linux-2.1.60-ORIG/drivers/char/nvram.c Sat Sep 13 20:07:27 1997
+++ linux/drivers/char/nvram.c Sun Oct 26 17:38:37 1997
@@ -227,11 +227,11 @@ static long long nvram_llseek(struct fil
return( (offset >= 0) ? (file->f_pos = offset) : -EINVAL );
}

-static long nvram_read( struct inode * inode, struct file * file,
- char * buf, unsigned long count )
+static ssize_t nvram_read( struct file * file,
+ char * buf, size_t count, loff_t *ppos )
{
unsigned long flags;
- unsigned i = file->f_pos;
+ unsigned i = *ppos;
char *tmp = buf;

save_flags(flags);
@@ -244,17 +244,16 @@ static long nvram_read( struct inode * i

for( ; count-- > 0 && i < NVRAM_BYTES; ++i, ++tmp )
put_user( nvram_read_int(i), tmp );
- file->f_pos = i;
+ *ppos = i;

restore_flags(flags);
return( tmp - buf );
}

-static long nvram_write( struct inode * inode, struct file * file,
- const char * buf, unsigned long count )
+static ssize_t nvram_write( struct file * file, const char * buf, size_t count, loff_t *ppos )
{
unsigned long flags;
- unsigned i = file->f_pos;
+ unsigned i = *ppos;
const char *tmp = buf;
char c;

@@ -271,7 +270,7 @@ static long nvram_write( struct inode *
nvram_write_int( c, i );
}
nvram_set_checksum_int();
- file->f_pos = i;
+ *ppos = i;

restore_flags(flags);
return( tmp - buf );

### 2. sound-driver fix

diff -urpN linux-2.1.60-ORIG/drivers/sound/dmasound.c linux/drivers/sound/dmasound.c
--- linux-2.1.60-ORIG/drivers/sound/dmasound.c Sat Oct 18 13:42:23 1997
+++ linux/drivers/sound/dmasound.c Sun Oct 26 17:41:31 1997
@@ -670,11 +670,9 @@ static long state_read(char *dest, unsig
static int sound_open(struct inode *inode, struct file *file);
static int sound_fsync(struct file *filp, struct dentry *dentry);
static void sound_release(struct inode *inode, struct file *file);
-static long long sound_lseek(struct file *file, long long offset, int orig);
-static long sound_read(struct inode *inode, struct file *file, char *buf,
- unsigned long count);
-static long sound_write(struct inode *inode, struct file *file,
- const char *buf, unsigned long count);
+static loff_t sound_lseek(struct file *file, loff_t offset, int orig);
+static ssize_t sound_read(struct file *file, char *buf, size_t count, loff_t *ppos);
+static ssize_t sound_write(struct file *file, const char *buf, size_t count, loff_t *ppos);
static inline int ioctl_return(int *addr, int value)
{
if (value < 0)
@@ -3115,16 +3113,18 @@ static void sound_release(struct inode *
}


-static long long sound_lseek(struct file *file, long long offset, int orig)
+static loff_t sound_lseek(struct file *file, loff_t offset, int orig)
{
return -ESPIPE;
}


-static long sound_read(struct inode *inode, struct file *file, char *buf,
- unsigned long count)
+static ssize_t sound_read(struct file *file, char *buf,size_t count, loff_t *ppos)
{
- int dev = MINOR(inode->i_rdev);
+ int dev = MINOR(file->f_dentry->d_inode->i_rdev);
+
+ if (ppos != &file->f_pos)
+ return -ESPIPE;

switch (dev & 0x0f) {
case SND_DEV_STATUS:
@@ -3139,10 +3139,12 @@ static long sound_read(struct inode *ino
}


-static long sound_write(struct inode *inode, struct file *file,
- const char *buf, unsigned long count)
+static ssize_t sound_write(struct file *file, const char *buf, size_t count, loff_t *ppos)
{
- int dev = MINOR(inode->i_rdev);
+ int dev = MINOR(file->f_dentry->d_inode->i_rdev);
+
+ if (ppos != &file->f_pos)
+ return -ESPIPE;

switch (dev & 0x0f) {
case SND_DEV_STATUS:
diff -urpN linux-2.1.60-ORIG/drivers/sound/soundcard.c linux/drivers/sound/soundcard.c
--- linux-2.1.60-ORIG/drivers/sound/soundcard.c Mon Sep 15 21:46:21 1997
+++ linux/drivers/sound/soundcard.c Sun Oct 26 17:45:29 1997
@@ -56,33 +56,37 @@ static char dma_alloc_map[8] =



-static long
-sound_read (struct inode *inode, struct file *file, char *buf, unsigned long count)
+static ssize_t sound_read (struct file *file, char *buf, size_t count, loff_t *ppos)
{
int dev;

- dev = MINOR (inode->i_rdev);
+ if (ppos != &file->f_pos)
+ return -ESPIPE;
+
+ dev = MINOR (file->f_dentry->d_inode->i_rdev);

files[dev].flags = file->f_flags;

return sound_read_sw (dev, &files[dev], buf, count);
}

-static long
-sound_write (struct inode *inode, struct file *file, const char *buf, unsigned long count)
+static ssize_t sound_write (struct file *file, const char *buf, size_t count, loff_t *ppos)
{
int dev;

- dev = MINOR (inode->i_rdev);
+ if (ppos != &file->f_pos)
+ return -ESPIPE;
+
+ dev = MINOR (file->f_dentry->d_inode->i_rdev);

files[dev].flags = file->f_flags;

return sound_write_sw (dev, &files[dev], buf, count);
}

-static long long sound_lseek (struct file *file, long long offset, int orig)
+static loff_t sound_lseek (struct file *file, loff_t offset, int orig)
{
- return -EPERM;
+ return -ESPIPE;
}

static int

-- 
Robert Bihlmeyer	reads: Deutsch, English, MIME, Latin-1, NO SPAM!
<robbe@orcus.priv.at>	<http://stud2.tuwien.ac.at/~e9426626/sig.html>