From: Nathan Lynch <ntl@pobox.com>
To: Jens Osterkamp <jens@de.ibm.com>
Cc: maxim@de.ibm.com, linuxppc-dev@ozlabs.org,
Paul Mackerras <paulus@samba.org>,
cbe-oss-dev@ozlabs.org
Subject: Re: [PATCH] RTAS - adapt procfs interface
Date: Tue, 1 Apr 2008 15:04:04 -0500 [thread overview]
Message-ID: <20080401200404.GS7137@localdomain> (raw)
In-Reply-To: <20080401163504.GP7137@localdomain>
Nathan Lynch wrote:
>
> One could argue that the real problem is using the proc_dir_entry's
> reference count to enforce exclusive open.
I think this is better... the way these files are used is lame, but
this should preserve the existing behavior. I haven't yet tested
this, can you?
diff --git a/arch/powerpc/kernel/rtas_flash.c b/arch/powerpc/kernel/rtas_flash.c
index f227659..00bc308 100644
--- a/arch/powerpc/kernel/rtas_flash.c
+++ b/arch/powerpc/kernel/rtas_flash.c
@@ -139,7 +139,7 @@ struct rtas_validate_flash_t
unsigned int update_results; /* Update results token */
};
-static DEFINE_SPINLOCK(flash_file_open_lock);
+static atomic_t open_count = ATOMIC_INIT(0);
static struct proc_dir_entry *firmware_flash_pde;
static struct proc_dir_entry *firmware_update_pde;
static struct proc_dir_entry *validate_pde;
@@ -216,7 +216,7 @@ static int rtas_flash_release(struct inode *inode, struct file *file)
uf->flist = NULL;
}
- atomic_dec(&dp->count);
+ atomic_dec(&open_count);
return 0;
}
@@ -352,26 +352,17 @@ static ssize_t rtas_flash_write(struct file *file, const char __user *buffer,
static int rtas_excl_open(struct inode *inode, struct file *file)
{
- struct proc_dir_entry *dp = PDE(inode);
-
- /* Enforce exclusive open with use count of PDE */
- spin_lock(&flash_file_open_lock);
- if (atomic_read(&dp->count) > 1) {
- spin_unlock(&flash_file_open_lock);
+ if (atomic_inc_return(&open_count) > 1) {
+ atomic_dec(&open_count);
return -EBUSY;
}
- atomic_inc(&dp->count);
- spin_unlock(&flash_file_open_lock);
-
return 0;
}
static int rtas_excl_release(struct inode *inode, struct file *file)
{
- struct proc_dir_entry *dp = PDE(inode);
-
- atomic_dec(&dp->count);
+ atomic_dec(&open_count);
return 0;
}
@@ -580,7 +571,7 @@ static int validate_flash_release(struct inode *inode, struct file *file)
}
/* The matching atomic_inc was in rtas_excl_open() */
- atomic_dec(&dp->count);
+ atomic_dec(&open_count);
return 0;
}
next prev parent reply other threads:[~2008-04-01 20:04 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2008-04-01 13:12 [PATCH] RTAS - adapt procfs interface Jens Osterkamp
2008-04-01 16:35 ` Nathan Lynch
2008-04-01 20:04 ` Nathan Lynch [this message]
2008-04-02 11:34 ` Jens Osterkamp
2008-04-02 11:48 ` Paul Mackerras
2008-04-02 18:54 ` Nathan Lynch
2008-04-02 11:33 ` Jens Osterkamp
2008-04-04 0:12 ` Christoph Hellwig
2008-04-04 5:39 ` [Cbe-oss-dev] " Arnd Bergmann
2008-04-04 9:15 ` Christoph Hellwig
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=20080401200404.GS7137@localdomain \
--to=ntl@pobox.com \
--cc=cbe-oss-dev@ozlabs.org \
--cc=jens@de.ibm.com \
--cc=linuxppc-dev@ozlabs.org \
--cc=maxim@de.ibm.com \
--cc=paulus@samba.org \
/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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.