From: Jan Blunck <jblunck@suse.de>
To: linux-fsdevel@vger.kernel.org,
Christoph Hellwig <hch@infradead.org>,
Alan Cox <alan@lxorguk.ukuu.org.uk>
Cc: "Linux-Kernel Mailinglist" <linux-kernel@vger.kernel.org>,
"Andrew Morton" <akpm@linux-foundation.org>,
"Thomas Gleixner" <tglx@linutronix.de>,
jkacur@redhat.com, "Arnd Bergmann" <arnd@arndb.de>,
"Frédéric Weisbecker" <fweisbec@gmail.com>,
"Jamie Lokier" <jamie@shareable.org>,
"Jan Blunck" <jblunck@suse.de>,
"Mikael Starvik" <starvik@axis.com>,
"Jesper Nilsson" <jesper.nilsson@axis.com>
Subject: [PATCH 06/15] eeprom_read()/eeprom_write() should update ppos instead of file->f_pos
Date: Fri, 20 Nov 2009 17:40:36 +0100 [thread overview]
Message-ID: <1258735245-25826-7-git-send-email-jblunck@suse.de> (raw)
In-Reply-To: <1258735245-25826-1-git-send-email-jblunck@suse.de>
eeprom_read()/eeprom_write() modify file->f_pos directly instead of the
ppos given. The VFS later updates the file->f_pos and overwrites it with
the unchanged value of ppos. Since nothing touches the struct file in
eeprom_read()/eeprom_write() now, the on stack allocated struct file in
eeprom_read_buf()/eeprom_write_buf() can be removed as well.
Signed-off-by: Jan Blunck <jblunck@suse.de>
---
arch/cris/arch-v10/drivers/eeprom.c | 34 +++++++++++++---------------------
1 files changed, 13 insertions(+), 21 deletions(-)
diff --git a/arch/cris/arch-v10/drivers/eeprom.c b/arch/cris/arch-v10/drivers/eeprom.c
index 1f2ae90..68d9e88 100644
--- a/arch/cris/arch-v10/drivers/eeprom.c
+++ b/arch/cris/arch-v10/drivers/eeprom.c
@@ -439,20 +439,18 @@ static loff_t eeprom_lseek(struct file * file, loff_t offset, int orig)
static int eeprom_read_buf(loff_t addr, char * buf, int count)
{
- struct file f;
-
- f.f_pos = addr;
- return eeprom_read(&f, buf, count, &addr);
+ return eeprom_read(NULL, buf, count, &addr);
}
/* Reads data from eeprom. */
-static ssize_t eeprom_read(struct file * file, char * buf, size_t count, loff_t *off)
+static ssize_t eeprom_read(struct file * file, char * buf, size_t count,
+ loff_t *ppos)
{
int read=0;
- unsigned long p = file->f_pos;
+ loff_t p = *ppos;
unsigned char page;
@@ -498,11 +496,9 @@ static ssize_t eeprom_read(struct file * file, char * buf, size_t count, loff_t
/* go on with the actual read */
read = read_from_eeprom( buf, count);
-
+
if(read > 0)
- {
- file->f_pos += read;
- }
+ *ppos += read;
eeprom.busy--;
wake_up_interruptible(&eeprom.wait_q);
@@ -513,18 +509,14 @@ static ssize_t eeprom_read(struct file * file, char * buf, size_t count, loff_t
static int eeprom_write_buf(loff_t addr, const char * buf, int count)
{
- struct file f;
-
- f.f_pos = addr;
-
- return eeprom_write(&f, buf, count, &addr);
+ return eeprom_write(NULL, buf, count, &addr);
}
/* Writes data to eeprom. */
static ssize_t eeprom_write(struct file * file, const char * buf, size_t count,
- loff_t *off)
+ loff_t *ppos)
{
int i, written, restart=1;
unsigned long p;
@@ -543,9 +535,9 @@ static ssize_t eeprom_write(struct file * file, const char * buf, size_t count,
{
restart = 0;
written = 0;
- p = file->f_pos;
-
-
+ p = *ppos;
+
+
while( (written < count) && (p < eeprom.size))
{
/* address the eeprom */
@@ -671,10 +663,10 @@ static ssize_t eeprom_write(struct file * file, const char * buf, size_t count,
eeprom.busy--;
wake_up_interruptible(&eeprom.wait_q);
- if (written == 0 && file->f_pos >= eeprom.size){
+ if (written == 0 && *ppos >= eeprom.size){
return -ENOSPC;
}
- file->f_pos += written;
+ *ppos += written;
return written;
}
--
1.6.4.2
next prev parent reply other threads:[~2009-11-20 16:40 UTC|newest]
Thread overview: 26+ messages / expand[flat|nested] mbox.gz Atom feed top
2009-11-20 16:40 [PATCH 00/15] Remove BKL from default_llseek() and other issues (v2) Jan Blunck
2009-11-20 16:40 ` [PATCH 01/15] Introduce noop_llseek() Jan Blunck
2009-11-20 17:05 ` Jamie Lokier
2009-11-20 17:11 ` Jan Blunck
2009-11-21 16:56 ` Arnd Bergmann
2009-11-20 16:40 ` [PATCH 02/15] osst: Use noop_llseek() instead of default_llseek() Jan Blunck
2009-11-20 17:09 ` Jamie Lokier
2009-11-20 17:25 ` Jan Blunck
2009-11-20 16:40 ` [PATCH 03/15] osst: Update ppos instead of using file->f_pos Jan Blunck
2009-11-20 17:13 ` Jamie Lokier
2009-11-20 17:16 ` Jamie Lokier
2009-11-20 16:40 ` [PATCH 04/15] s390: tape_char should update " Jan Blunck
2009-11-20 16:40 ` [PATCH 05/15] flash_read should update ppos instead of file->f_pos Jan Blunck
2009-11-20 16:40 ` Jan Blunck [this message]
2009-11-20 16:40 ` [PATCH 07/15] sched_feat_write: Update " Jan Blunck
2009-11-20 16:40 ` [PATCH 08/15] airo: Use " Jan Blunck
2009-11-20 16:40 ` [PATCH 09/15] frv: remove "struct file *" argument from sysctl ->proc_handler Jan Blunck
2009-11-20 16:40 ` [PATCH 10/15] mISDN: Remove unnecessary test on f_pos Jan Blunck
2009-11-20 16:40 ` [PATCH 11/15] zcrypt: Use nonseekable_open() Jan Blunck
2009-11-20 16:40 ` [PATCH 12/15] rtc-m41t80: " Jan Blunck
2009-11-20 16:40 ` [PATCH 13/15] Do not fallback to default_llseek() when readdir() uses BKL Jan Blunck
2009-11-20 21:27 ` Jan Kara
2009-11-21 18:03 ` Anders Larsen
2009-11-20 16:40 ` [PATCH 14/15] BKL: Remove BKL from default_llseek() Jan Blunck
2009-11-20 16:40 ` [PATCH 15/15] BKL: Update documentation on llseek( \b) Jan Blunck
2009-11-20 17:02 ` [PATCH 15/15] BKL: Update documentation on llseek(\b) Alan Cox
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1258735245-25826-7-git-send-email-jblunck@suse.de \
--to=jblunck@suse.de \
--cc=akpm@linux-foundation.org \
--cc=alan@lxorguk.ukuu.org.uk \
--cc=arnd@arndb.de \
--cc=fweisbec@gmail.com \
--cc=hch@infradead.org \
--cc=jamie@shareable.org \
--cc=jesper.nilsson@axis.com \
--cc=jkacur@redhat.com \
--cc=linux-fsdevel@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=starvik@axis.com \
--cc=tglx@linutronix.de \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).