semaphore to mutex conversions
Subsystems (15)
cover semaphore to mutex conversions
The following series converts semaphores which are semantically mutexes to real mutexes. This is part of the effort to remove init_MUTEX*
Most of the patches have been in the -rt tree for quite a while with no bad side effects.
Thanks,
tglx
PATCH 1/10 smbfs: Convert server->sem to mutex
The semaphore server->sem is used as mutex. Rename it to server->mutex and convert it to a real mutex.
--- fs/smbfs/inode.c | 2 +- include/linux/smb_fs_sb.h | 8 ++++---- 2 files changed, 5 insertions(+), 5 deletions(-)
fs/smbfs/inode.c +1 -1
@@ -530,7 +530,7 @@ static int smb_fill_super(struct super_b server->mnt =NULL ; server->sock_file =NULL ;init_waitqueue_head (&server->conn_wq); -init_MUTEX (&server->sem); +mutex_init (&server->mutex);INIT_LIST_HEAD (&server->entry);INIT_LIST_HEAD (&server->xmitq);INIT_LIST_HEAD (&server->recvq);
include/linux/smb_fs_sb.h +4 -4
@@ -57,7 +57,7 @@ struct smb_sb_info {struct smb_conn_opt opt;wait_queue_head_t conn_wq;int conn_complete; -struct semaphore sem; +struct mutex mutex;unsigned char header[SMB_HEADER_LEN +20 *2 +2 ];u32 header_len;
@@ -79,19 +79,19 @@ struct smb_sb_info {static inline int smb_lock_server_interruptible (struct smb_sb_info *server) { -return down_interruptible (&(server->sem)); +return mutex_lock_interruptible (&server->mutex); }static inline void smb_lock_server (struct smb_sb_info *server) { -down (&(server->sem)); +mutex_lock (&server->mutex); }static inline void smb_unlock_server (struct smb_sb_info *server) { -up (&(server->sem)); +mutex_unlock (&server->mutex); }#endif
Re: [patch 01/10] smbfs: Convert server->sem to mutex
Quoted 7 lines · Thomas Gleixner
The semaphore
server->semis used as mutex. Rename it toserver->mutexand convert it to a real mutex.Signed-off-by Thomas Gleixner <[email protected]>Cc Al Viro <[email protected]>Cc Jeff Layton <[email protected]>Cc Steve French <[email protected]>
Looks good,
Quoted 10 lines
static inline int
smb_lock_server_interruptible(struct smb_sb_info *server){include/linux/smb_fs_sb.h +1
-1-return down_interruptible (&(server->sem)); +return mutex_lock_interruptible (&server->mutex); }static inline void smb_lock_server (struct smb_sb_info *server) {
include/linux/smb_fs_sb.h struct smb_sb_info { · line 95
Quoted 10 lines
include/linux/smb_fs_sb.h +2
-2-down (&(server->sem)); +mutex_lock (&server->mutex); }static inline void smb_unlock_server (struct smb_sb_info *server) { -up (&(server->sem)); +mutex_unlock (&server->mutex); }
Eventually someone should also kill this useless wrappers, but let's do one thing at a time for now.
PATCH 2/10 hpfs: Convert sbi->hpfs_creation_de to mutex
In reply to Thomas GleixnerThe sbi->hpfs_creation_de semaphore is used as mutex. Convert it to a real mutex.
--- fs/hpfs/buffer.c | 4 ++-- fs/hpfs/hpfs_fn.h | 2 +- fs/hpfs/super.c | 2 +- 3 files changed, 4 insertions(+), 4 deletions(-)
fs/hpfs/buffer.c +2 -2
@@ -13,7 +13,7 @@ void hpfs_lock_creation(struct super_blo#ifdef DEBUG_LOCKS printk ("lock creation\n" );#endif -down (&hpfs_sb (s)->hpfs_creation_de); +mutex_lock (&hpfs_sb (s)->hpfs_creation_de); }void hpfs_unlock_creation (struct super_block *s)
@@ -21,7 +21,7 @@ void hpfs_unlock_creation(struct super_b#ifdef DEBUG_LOCKS printk ("unlock creation\n" );#endif -up (&hpfs_sb (s)->hpfs_creation_de); +mutex_unlock (&hpfs_sb (s)->hpfs_creation_de); }/* Map a sector into a buffer and return pointers to it and to the buffer. */
fs/hpfs/hpfs_fn.h +1 -1
@@ -87,7 +87,7 @@ struct hpfs_sb_info {unsigned *sb_bmp_dir;/* main bitmap directory */ unsigned sb_c_bitmap;/* current bitmap */ unsigned sb_max_fwd_alloc;/* max forwad allocation */ -struct semaphore hpfs_creation_de;/* when creating dirents, nobody else +struct mutex hpfs_creation_de;/* when creating dirents, nobody else can alloc blocks */ /*unsigned sb_mounting : 1;*/ int sb_timeshift;
fs/hpfs/super.c +1 -1
@@ -486,7 +486,7 @@ static int hpfs_fill_super(struct super_ sbi->sb_bmp_dir =NULL ; sbi->sb_cp_table =NULL ; -init_MUTEX (&sbi->hpfs_creation_de); +mutex_init (&sbi->hpfs_creation_de); uid =current_uid (); gid =current_gid ();
Re: [patch 02/10] hpfs: Convert sbi->hpfs_creation_de to mutex
Quoted 5 lines · Thomas Gleixner
The
sbi->hpfs_creation_desemaphore is used as mutex. Convert it to a real mutex.Signed-off-by Thomas Gleixner <[email protected]>Cc Al Viro <[email protected]>
Looks good, although it was a bit nasty to verify with the useless wrappers and conditional locking all over the place.
PATCH 3/10 hpfsplus: Convert tree_lock to mutex
In reply to Thomas GleixnerThe tree_lock semaphore is used as mutex. Convert it to a real mutex.
--- fs/hfsplus/bfind.c | 4 ++-- fs/hfsplus/btree.c | 2 +- fs/hfsplus/hfsplus_fs.h | 2 +- 3 files changed, 4 insertions(+), 4 deletions(-)
fs/hfsplus/bfind.c +2 -2
@@ -23,7 +23,7 @@ int hfs_find_init(struct hfs_btree *tree fd->search_key = ptr; fd->key = ptr + tree->max_key_len +2 ;dprint (DBG_BNODE_REFS ,"find_init: %d (%p)\n" , tree->cnid,__builtin_return_address (0 )); -down (&tree->tree_lock); +mutex_lock (&tree->tree_lock);return 0 ; }
@@ -32,7 +32,7 @@ void hfs_find_exit(struct hfs_find_datahfs_bnode_put (fd->bnode);kfree (fd->search_key);dprint (DBG_BNODE_REFS ,"find_exit: %d (%p)\n" , fd->tree->cnid,__builtin_return_address (0 )); -up (&fd->tree->tree_lock); +mutex_unlock (&fd->tree->tree_lock); fd->tree =NULL ; }
fs/hfsplus/btree.c +1 -1
@@ -30,7 +30,7 @@ struct hfs_btree *hfs_btree_open(structif (!tree)return NULL ; -init_MUTEX (&tree->tree_lock); +mutex_init (&tree->tree_lock);spin_lock_init (&tree->hash_lock); tree->sb = sb; tree->cnid = id;
fs/hfsplus/hfsplus_fs.h +1 -1
@@ -62,7 +62,7 @@ struct hfs_btree {unsigned int depth;//unsigned int map1_size, map_size; -struct semaphore tree_lock; +struct mutex tree_lock;unsigned int pages_per_bnode;spinlock_t hash_lock;
Re: [patch 03/10] hpfsplus: Convert tree_lock to mutex
Quoted 10 lines · Thomas Gleixner
The
tree_locksemaphore is used as mutex. Convert it to a real mutex.Signed-off-by Thomas Gleixner <[email protected]>Cc Al Viro <[email protected]>--- fs/hfsplus/bfind.c | 4 ++-- fs/hfsplus/btree.c | 2 +- fs/hfsplus/hfsplus_fs.h | 2 +- 3 files changed, 4 insertions(+), 4 deletions(-)
Looks good,
PATCH 4/10 hfs: Convert tree_lock to mutex
In reply to Thomas GleixnerThe tree_lock semaphore is used as mutex. Convert it to a real mutex.
--- fs/hfs/bfind.c | 4 ++-- fs/hfs/btree.c | 2 +- fs/hfs/btree.h | 2 +- 3 files changed, 4 insertions(+), 4 deletions(-)
fs/hfs/bfind.c +2 -2
@@ -23,7 +23,7 @@ int hfs_find_init(struct hfs_btree *tree fd->search_key = ptr; fd->key = ptr + tree->max_key_len +2 ;dprint (DBG_BNODE_REFS ,"find_init: %d (%p)\n" , tree->cnid,__builtin_return_address (0 )); -down (&tree->tree_lock); +mutex_lock (&tree->tree_lock);return 0 ; }
@@ -32,7 +32,7 @@ void hfs_find_exit(struct hfs_find_datahfs_bnode_put (fd->bnode);kfree (fd->search_key);dprint (DBG_BNODE_REFS ,"find_exit: %d (%p)\n" , fd->tree->cnid,__builtin_return_address (0 )); -up (&fd->tree->tree_lock); +mutex_unlock (&fd->tree->tree_lock); fd->tree =NULL ; }
fs/hfs/btree.c +1 -1
@@ -26,7 +26,7 @@ struct hfs_btree *hfs_btree_open(structif (!tree)return NULL ; -init_MUTEX (&tree->tree_lock); +mutex_init (&tree->tree_lock);spin_lock_init (&tree->hash_lock);/* Set the correct compare function */ tree->sb = sb;
fs/hfs/btree.h +1 -1
@@ -33,7 +33,7 @@ struct hfs_btree {unsigned int depth;//unsigned int map1_size, map_size; -struct semaphore tree_lock; +struct mutex tree_lock;unsigned int pages_per_bnode;spinlock_t hash_lock;
Re: [patch 04/10] hfs: Convert tree_lock to mutex
Quoted 4 lines · Thomas Gleixner
The
tree_locksemaphore is used as mutex. Convert it to a real mutex.Signed-off-by Thomas Gleixner <[email protected]>Cc Al Viro <[email protected]>
Looks good,
PATCH 5/10 cifs: convert semaphore to mutex
In reply to Thomas GleixnerpSesInfo->sesSem is used as mutex. Rename it to session_mutex and convert it to a real mutex.
--- fs/cifs/cifsglob.h | 2 +- fs/cifs/cifssmb.c | 12 ++++++------ fs/cifs/connect.c | 8 ++++---- fs/cifs/misc.c | 2 +- 4 files changed, 12 insertions(+), 12 deletions(-)
fs/cifs/cifsglob.h +1 -1
@@ -204,7 +204,7 @@ struct cifsUidInfo {struct cifsSesInfo {struct list_head smb_ses_list;struct list_head tcon_list; -struct semaphore sesSem; +struct mutex session_mutex;#if 0 struct cifsUidInfo *uidInfo;/* pointer to user info */ #endif
fs/cifs/cifssmb.c +6 -6
@@ -170,19 +170,19 @@ cifs_reconnect_tcon(struct cifsTconInfo* need to prevent multiple threads trying to simultaneously * reconnect the same SMB session */ -down (&ses->sesSem); +mutex_lock (&ses->session_mutex);if (ses->need_reconnect) rc =cifs_setup_session (0 , ses, nls_codepage);/* do we need to reconnect tcon? */ if (rc || !tcon->need_reconnect) { -up (&ses->sesSem); +mutex_unlock (&ses->session_mutex); goto out; }mark_open_files_invalid (tcon); rc =CIFSTCon (0 , ses, tcon->treeName, tcon, nls_codepage); -up (&ses->sesSem); +mutex_unlock (&ses->session_mutex);cFYI (1 , ("reconnect tcon rc = %d" , rc));if (rc)
@@ -700,13 +700,13 @@ CIFSSMBLogoff(const int xid, struct cifsif (!ses || !ses->server)return -EIO ; -down (&ses->sesSem); +mutex_lock (&ses->session_mutex);if (ses->need_reconnect) goto session_already_dead;/* no need to send SMBlogoff if uid already closed due to reconnect */ rc =small_smb_init (SMB_COM_LOGOFF_ANDX ,2 ,NULL , (void **)&pSMB);if (rc) { -up (&ses->sesSem); +mutex_unlock (&ses->session_mutex);return rc; }
@@ -721,7 +721,7 @@ CIFSSMBLogoff(const int xid, struct cifs pSMB->AndXCommand =0xFF ; rc =SendReceiveNoRsp (xid, ses, (struct smb_hdr *) pSMB,0 ); session_already_dead: -up (&ses->sesSem); +mutex_unlock (&ses->session_mutex);/* if session dead then we do not need to do ulogoff, since server closed smb session, no sense reporting
fs/cifs/connect.c +4 -4
@@ -2366,13 +2366,13 @@ try_mount_again:*/ cifs_put_tcp_session (srvTcp); -down (&pSesInfo->sesSem); +mutex_lock (&pSesInfo->session_mutex);if (pSesInfo->need_reconnect) {cFYI (1 , ("Session needs reconnect" )); rc =cifs_setup_session (xid, pSesInfo, cifs_sb->local_nls); } -up (&pSesInfo->sesSem); +mutex_unlock (&pSesInfo->session_mutex); }else if (!rc) {cFYI (1 , ("Existing smb sess not found" )); pSesInfo =sesInfoAlloc ();
@@ -2415,12 +2415,12 @@ try_mount_again: } pSesInfo->linux_uid = volume_info->linux_uid; pSesInfo->overrideSecFlg = volume_info->secFlg; -down (&pSesInfo->sesSem); +mutex_lock (&pSesInfo->session_mutex);/* BB FIXME need to pass vol->secFlgs BB */ rc =cifs_setup_session (xid, pSesInfo, cifs_sb->local_nls); -up (&pSesInfo->sesSem); +mutex_unlock (&pSesInfo->session_mutex); }/* search for existing tcon to this server share */
fs/cifs/misc.c +1 -1
@@ -79,7 +79,7 @@ sesInfoAlloc(void) ++ret_buf->ses_count;INIT_LIST_HEAD (&ret_buf->smb_ses_list);INIT_LIST_HEAD (&ret_buf->tcon_list); -init_MUTEX (&ret_buf->sesSem); +mutex_init (&ret_buf->session_mutex); }return ret_buf; }
Re: [patch 05/10] cifs: convert semaphore to mutex
Quoted 6 lines · Thomas Gleixner
pSesInfo->sesSemis used as mutex. Rename it tosession_mutexand convert it to a real mutex.Signed-off-by Thomas Gleixner <[email protected]>Cc Jeff Layton <[email protected]>Cc Steve French <[email protected]>
Looks good, but I'm pretty sure I've seen an equivalent patch on the linux-cifs-client list before.
PATCH 6/10 affs: Convert semaphores to mutexes
In reply to Thomas GleixnerThese semaphores are plain mutexes. Convert them to struct mutex.
Map affs_[un]lock_dir() to affs_[un]lock_ext() instead of the "#define i_hash_lock i_ext_lock" magic.
--- fs/affs/affs.h | 26 +++++++++----------------- fs/affs/super.c | 4 ++-- 2 files changed, 11 insertions(+), 19 deletions(-)
fs/affs/affs.h +9 -17
@@ -50,9 +50,8 @@ struct affs_ext_key {*/ struct affs_inode_info {atomic_t i_opencnt; -struct semaphore i_link_lock;/* Protects internal inode access. */ -struct semaphore i_ext_lock;/* Protects internal inode access. */ -#define i_hash_lock i_ext_lock +struct mutex i_link_lock;/* Protects internal inode access. */ +struct mutex i_ext_lock;/* Protects internal inode access. */ u32 i_blkcnt;/* block count */ u32 i_extcnt;/* extended block count */ u32 *i_lc;/* linear cache of extended blocks */
@@ -275,30 +274,23 @@ affs_adjust_bitmapchecksum(struct bufferstatic inline void affs_lock_link (struct inode *inode) { -down (&AFFS_I (inode)->i_link_lock); +mutex_lock (&AFFS_I (inode)->i_link_lock); }static inline void affs_unlock_link (struct inode *inode) { -up (&AFFS_I (inode)->i_link_lock); -} -static inline void -affs_lock_dir (struct inode *inode) -{ -down (&AFFS_I (inode)->i_hash_lock); -} -static inline void -affs_unlock_dir (struct inode *inode) -{ -up (&AFFS_I (inode)->i_hash_lock); +mutex_unlock (&AFFS_I (inode)->i_link_lock); }static inline void affs_lock_ext (struct inode *inode) { -down (&AFFS_I (inode)->i_ext_lock); +mutex_lock (&AFFS_I (inode)->i_ext_lock); }static inline void affs_unlock_ext (struct inode *inode) { -up (&AFFS_I (inode)->i_ext_lock); +mutex_unlock (&AFFS_I (inode)->i_ext_lock); } + +#define affs_lock_dir (i) affs_lock_ext(i) +#define affs_unlock_dir (i) affs_unlock_ext(i)
fs/affs/super.c +2 -2
@@ -113,8 +113,8 @@ static void init_once(void *foo) {struct affs_inode_info *ei = (struct affs_inode_info *) foo; -init_MUTEX (&ei->i_link_lock); -init_MUTEX (&ei->i_ext_lock); +mutex_init (&ei->i_link_lock); +mutex_init (&ei->i_ext_lock);inode_init_once (&ei->vfs_inode); }
Re: [patch 06/10] affs: Convert semaphores to mutexes
Quoted 7 lines · Thomas Gleixner
These semaphores are plain mutexes. Convert them to struct mutex.
Map affs_[un]lock_dir() to affs_[un]lock_ext() instead of the "#define
i_hash_locki_ext_lock" magic.Signed-off-by Thomas Gleixner <[email protected]>Cc Al Viro <[email protected]>
Umm... I'm not ready to sign off on that one without serious analysis; there might be dragons.
Re: [patch 06/10] affs: Convert semaphores to mutexes
In reply to Thomas GleixnerQuoted 1 line · Thomas Gleixner
These semaphores are plain mutexes. Convert them to struct mutex.
Looks good.
Quoted 2 lines
Map affs_[un]lock_dir() to affs_[un]lock_ext() instead of the "#define
i_hash_locki_ext_lock" magic.
I'm not sure which of the remapping tricks is the worth one..
Btw, if we don't want lockdep to complain we'll need annotations on affs_lock_dir as it's taken both on parent and child.
Re: [patch 06/10] affs: Convert semaphores to mutexes
Quoted 5 lines · Christoph Hellwig
Quoted 1 line · Thomas Gleixner
These semaphores are plain mutexes. Convert them to struct mutex.
Looks good.
Quoted 7 lines
Quoted 2 lines
Map affs_[un]lock_dir() to affs_[un]lock_ext() instead of the "#define
i_hash_locki_ext_lock" magic.I'm not sure which of the remapping tricks is the worth one..
Btw, if we don't want lockdep to complain we'll need annotations on
affs_lock_diras it's taken both on parent and child.
Can we postpone this to the point where an actual affs user runs with lockdep enabled ?
Thanks,
tglx
Re: [patch 06/10] affs: Convert semaphores to mutexes
In reply to Christoph HellwigQuoted 5 lines · Christoph Hellwig
Quoted 1 line · Thomas Gleixner
These semaphores are plain mutexes. Convert them to struct mutex.
Looks good.
Quoted 7 lines
Quoted 2 lines
Map affs_[un]lock_dir() to affs_[un]lock_ext() instead of the "#define
i_hash_locki_ext_lock" magic.I'm not sure which of the remapping tricks is the worth one..
Btw, if we don't want lockdep to complain we'll need annotations on
affs_lock_diras it's taken both on parent and child.
OK, I've recalled what's going on in there.
AFFS has really crappy layout. What happens:
* each file and each directory have on-disk entry that acts more
or less like an inode.
* when file has N links, there are N-1 additional on-disk entries
with a linked list going through them and primary.
* directory has a bunch of linked lists going through entries of
directory elements (primaries or add-ons). Choice of list depends on entry name (i.e. it's a hash).
* there's even worse mess we fortunately do not support at all
(hardlinks to directories, years after everyone knew that it can't work).
Now imagine what has to happen on e.g. overwriting cross-directory rename() when victim happens to be primary with several more links. Draw the objects and pointers involved, then draw the changes needed. No, really - do that.
The worst part of PITA comes from the need to change unrelated (and unpredictable) directory. Primary _must_ remain linked from some directory. So if some links are still around, we must choose some add-on, transplant the primary in its place in whatever directory list it's on and then free the orphaned add-on.
So we have two kinds of locks in addition to normal VFS one (i_mutex). One protects the list of add-ons ("link" lock), another - directory lists ("hash" lock). Link lock is taken outside of any hash locks.
lookup and readdir take hash lock on directory.
create, symlink, mkdir and link are identical wrt locking - they take link lock on object being added to directory, then hash lock on directory itself. Only link(2) needs both locks, obviously, but it's really not worth complicating the common helper.
rmdir and unlink use the same helper; it
* takes link lock on victim
* takes hash lock on parent
* if it's a directory
* take hash lock on victim
* check that it's empty
* drop hash lock on victim
* evicts the victim from the directory list
* unlocks parent
* if the victim is primary and there are extra links
* grab hash lock on parent of another link [*]
* transplant the victim into the directory list that used to hold an alias, evicting the alias from it
* drop hash lock
* evict victim (or substitute victim) from the link list
* drop link lock.
rename... is interesting. First of all, if the target exist, it's killed off a-la unlink(). Error recovery? What error recovery? Then we grab hash lock on old parent, remove the object from directory list, unlock old parent, grab hash lock on new parent, put the object into directory list in new place and unlock new parent. No error recovery again. Trying to add aforementioned error recovery would make locking even more interesting, of course.
Trying to make the thing reasonably robust in case of a crash... forget about it.
The bottom line: it is safe to convert to mutex, so ACK on that patch. As for the lockdep, it should treat emptiness check in affs_remove_header() as "nested, known to be safe" since we already hold i_mutex on both and no other operation holds hash lock on more than one inode.
[*] Yes, it does mean bringing it in-core if it hadn't been there already. Essentially with iget(). Isn't life wonderful? Good thing we don't have NFS exports for that wonder of software engineering...
PATCH 7/10 usb: gadgetfs: Convert semaphore to mutex
In reply to Thomas GleixnerThe semaphore data->lock is semantically a mutex. Convert it to a real mutex.
--- drivers/usb/gadget/inode.c | 39 +++++++++++++++++++++------------------ 1 file changed, 21 insertions(+), 18 deletions(-)
drivers/usb/gadget/inode.c +21 -18
@@ -194,7 +194,7 @@ enum ep_state { };struct ep_data { -struct semaphore lock; +struct mutex lock;enum ep_state state;atomic_t count;struct dev_data *dev;
@@ -298,10 +298,10 @@ get_ready_ep (unsigned f_flags, struct eint val;if (f_flags &O_NONBLOCK ) { -if (down_trylock (&epdata->lock) !=0 ) +if (!mutex_trylock (&epdata->lock)) goto nonblock;if (epdata->state !=STATE_EP_ENABLED ) { -up (&epdata->lock); +mutex_unlock (&epdata->lock); nonblock: val = -EAGAIN ; }else
@@ -309,7 +309,8 @@ nonblock:return val; } -if ((val =down_interruptible (&epdata->lock)) <0 ) + val =mutex_lock_interruptible (&epdata->lock); +if (val <0 )return val;switch (epdata->state) {
@@ -323,7 +324,7 @@ nonblock:// FALLTHROUGH case STATE_EP_UNBOUND :/* clean disconnect */ val = -ENODEV ; -up (&epdata->lock); +mutex_unlock (&epdata->lock); }return val; }
@@ -393,7 +394,7 @@ ep_read (struct file *fd, char __user *bif (likely (data->ep !=NULL ))usb_ep_set_halt (data->ep);spin_unlock_irq (&data->dev->lock); -up (&data->lock); +mutex_unlock (&data->lock);return -EBADMSG ; }
@@ -411,7 +412,7 @@ ep_read (struct file *fd, char __user *b value = -EFAULT ; free1: -up (&data->lock); +mutex_unlock (&data->lock);kfree (kbuf);return value; }
@@ -436,7 +437,7 @@ ep_write (struct file *fd, const char __if (likely (data->ep !=NULL ))usb_ep_set_halt (data->ep);spin_unlock_irq (&data->dev->lock); -up (&data->lock); +mutex_unlock (&data->lock);return -EBADMSG ; }
@@ -455,7 +456,7 @@ ep_write (struct file *fd, const char __VDEBUG (data->dev,"%s write %zu IN, status %d\n" , data->name, len, (int ) value); free1: -up (&data->lock); +mutex_unlock (&data->lock);kfree (kbuf);return value; }
@@ -466,7 +467,8 @@ ep_release (struct inode *inode, structstruct ep_data *data = fd->private_data;int value; -if ((value =down_interruptible (&data->lock)) <0 ) + value =mutex_lock_interruptible (&data->lock); +if (value <0 )return value;/* clean up if this can be reopened */
@@ -476,7 +478,7 @@ ep_release (struct inode *inode, struct data->hs_desc.bDescriptorType =0 ;usb_ep_disable (data->ep); } -up (&data->lock); +mutex_unlock (&data->lock);put_ep (data);return 0 ; }
@@ -507,7 +509,7 @@ static long ep_ioctl(struct file *fd, un }else status = -ENODEV ;spin_unlock_irq (&data->dev->lock); -up (&data->lock); +mutex_unlock (&data->lock);return status; }
@@ -673,7 +675,7 @@ fail: value = -ENODEV ;spin_unlock_irq (&epdata->dev->lock); -up (&epdata->lock); +mutex_unlock (&epdata->lock);if (unlikely (value)) {kfree (priv);
@@ -765,7 +767,8 @@ ep_config (struct file *fd, const char _u32 tag;int value, length = len; -if ((value =down_interruptible (&data->lock)) <0 ) + value =mutex_lock_interruptible (&data->lock); +if (value <0 )return value;if (data->state !=STATE_EP_READY ) {
@@ -854,7 +857,7 @@ fail: data->desc.bDescriptorType =0 ; data->hs_desc.bDescriptorType =0 ; } -up (&data->lock); +mutex_unlock (&data->lock);return value; fail0: value = -EINVAL ;
@@ -870,7 +873,7 @@ ep_open (struct inode *inode, struct filstruct ep_data *data = inode->i_private;int value = -EBUSY ; -if (down_interruptible (&data->lock) !=0 ) +if (mutex_lock_interruptible (&data->lock) !=0 )return -EINTR ;spin_lock_irq (&data->dev->lock);if (data->dev->state ==STATE_DEV_UNBOUND )
@@ -885,7 +888,7 @@ ep_open (struct inode *inode, struct filDBG (data->dev,"%s state %d\n" , data->name, data->state);spin_unlock_irq (&data->dev->lock); -up (&data->lock); +mutex_unlock (&data->lock);return value; }
@@ -1631,7 +1634,7 @@ static int activate_ep_files (struct devif (!data) goto enomem0; data->state =STATE_EP_DISABLED ; -init_MUTEX (&data->lock); +mutex_init (&data->lock);init_waitqueue_head (&data->wait);strncpy (data->name, ep->name,sizeof (data->name) -1 );
Re: [patch 07/10] usb: gadgetfs: Convert semaphore to mutex
Quoted 5 lines · Thomas Gleixner
The semaphore
data->lockis semantically a mutex. Convert it to a real mutex.Signed-off-by Thomas Gleixner <[email protected]>Cc Greg Kroah-Hartman <[email protected]>
Re: [patch 07/10] usb: gadgetfs: Convert semaphore to mutex
Quoted 8 lines · Greg KH
Quoted 5 lines · Thomas Gleixner
The semaphore
data->lockis semantically a mutex. Convert it to a real mutex.Signed-off-by Thomas Gleixner <[email protected]>Cc Greg Kroah-Hartman <[email protected]>
Can you take that via your usb tree or do you want me to push it linuswards for .34 ?
Thanks,
tglx
Re: [patch 07/10] usb: gadgetfs: Convert semaphore to mutex
Quoted 6 lines · Thomas Gleixner
Quoted 4 lines · Greg KH
Quoted 3 lines · Thomas Gleixner
The semaphore
data->lockis semantically a mutex. Convert it to a real mutex.
Quoted 7 lines
Quoted 4 lines
Quoted 2 lines
Signed-off-by Thomas Gleixner <[email protected]>Cc Greg Kroah-Hartman <[email protected]>Can you take that via your usb tree or do you want me to push it linuswards for .34 ?
I tried to do this last time the patches were posted, but the core mutex changes were not in Linus's tree yet, so I could not as it broke my build.
Has this changed? If so, I would be glad to do so. If not, I can't :(
thanks,
greg k-h
Re: [patch 07/10] usb: gadgetfs: Convert semaphore to mutex
Quoted 12 lines · Greg KH
Quoted 11 lines · Thomas Gleixner
Quoted 8 lines · Greg KH
Quoted 5 lines · Thomas Gleixner
The semaphore
data->lockis semantically a mutex. Convert it to a real mutex.Signed-off-by Thomas Gleixner <[email protected]>Cc Greg Kroah-Hartman <[email protected]>
Quoted 8 lines
Quoted 2 lines
Can you take that via your usb tree or do you want me to push it linuswards for .34 ?
I tried to do this last time the patches were posted, but the core mutex changes were not in Linus's tree yet, so I could not as it broke my build.
Has this changed? If so, I would be glad to do so. If not, I can't :(
The two patches have no dependencies on anything else. They just convert to the existing mutex infrastructure.
Thanks,
tglx
Re: [patch 07/10] usb: gadgetfs: Convert semaphore to mutex
Quoted 17 lines · Thomas Gleixner
Quoted 15 lines · Greg KH
Quoted 13 lines · Thomas Gleixner
Quoted 8 lines · Greg KH
Quoted 5 lines · Thomas Gleixner
The semaphore
data->lockis semantically a mutex. Convert it to a real mutex.Signed-off-by Thomas Gleixner <[email protected]>Cc Greg Kroah-Hartman <[email protected]>Can you take that via your usb tree or do you want me to push it linuswards for .34 ?
Quoted 8 lines
Quoted 5 lines
I tried to do this last time the patches were posted, but the core mutex changes were not in Linus's tree yet, so I could not as it broke my build.
Has this changed? If so, I would be glad to do so. If not, I can't :(
The two patches have no dependencies on anything else. They just convert to the existing mutex infrastructure.
Oops, I was thinking this was the same as the last type of patches that went out. I'll queue these up in my tree and send them to Linus for .34.
thanks,
greg k-h
PATCH 8/10 drivers/base: Convert dev->sem to mutex
In reply to Thomas GleixnerThe semaphore is semantically a mutex. Convert it to a real mutex and clean up all users outside of drivers/base as well.
--- drivers/base/bus.c | 20 ++++++++++---------- drivers/base/core.c | 3 +-- drivers/base/dd.c | 38 +++++++++++++++++++------------------- drivers/base/power/main.c | 20 ++++++++++---------- drivers/firewire/core-device.c | 4 ++-- drivers/ieee1394/nodemgr.c | 4 ++-- drivers/net/mlx4/mlx4.h | 1 + drivers/pci/bus.c | 4 ++-- drivers/pci/pci.c | 4 ++-- drivers/pcmcia/ds.c | 8 ++++---- drivers/usb/core/driver.c | 4 ++-- drivers/usb/core/usb.c | 2 +- drivers/uwb/umc-bus.c | 4 ++-- drivers/uwb/uwb-internal.h | 4 ++-- include/linux/device.h | 5 ++--- include/linux/usb.h | 6 +++--- 16 files changed, 65 insertions(+), 66 deletions(-)
drivers/base/bus.c +10 -10
@@ -173,10 +173,10 @@ static ssize_t driver_unbind(struct devi dev =bus_find_device_by_name (bus,NULL , buf);if (dev && dev->driver == drv) {if (dev->parent)/* Needed for USB */ -down (&dev->parent->sem); +mutex_lock (&dev->parent->mutex);device_release_driver (dev);if (dev->parent) -up (&dev->parent->sem); +mutex_unlock (&dev->parent->mutex); err = count; }put_device (dev);
@@ -200,12 +200,12 @@ static ssize_t driver_bind(struct device dev =bus_find_device_by_name (bus,NULL , buf);if (dev && dev->driver ==NULL &&driver_match_device (drv, dev)) {if (dev->parent)/* Needed for USB */ -down (&dev->parent->sem); -down (&dev->sem); +mutex_lock (&dev->parent->mutex); +mutex_lock (&dev->mutex); err =driver_probe_device (drv, dev); -up (&dev->sem); +mutex_unlock (&dev->mutex);if (dev->parent) -up (&dev->parent->sem); +mutex_unlock (&dev->parent->mutex);if (err >0 ) {/* success */
@@ -744,10 +744,10 @@ static int __must_check bus_rescan_devicif (!dev->driver) {if (dev->parent)/* Needed for USB */ -down (&dev->parent->sem); +mutex_lock (&dev->parent->mutex); ret =device_attach (dev);if (dev->parent) -up (&dev->parent->sem); +mutex_unlock (&dev->parent->mutex); }return ret <0 ? ret :0 ; }
@@ -779,10 +779,10 @@ int device_reprobe(struct device *dev) {if (dev->driver) {if (dev->parent)/* Needed for USB */ -down (&dev->parent->sem); +mutex_lock (&dev->parent->mutex);device_release_driver (dev);if (dev->parent) -up (&dev->parent->sem); +mutex_unlock (&dev->parent->mutex); }return bus_rescan_devices_helper (dev,NULL ); }
drivers/base/core.c +1 -2
@@ -20,7 +20,6 @@#include <linux/notifier.h> #include <linux/genhd.h> #include <linux/kallsyms.h> -#include <linux/semaphore.h> #include <linux/mutex.h> #include <linux/async.h>
@@ -564,7 +563,7 @@ void device_initialize(struct device *de dev->kobj.kset = devices_kset;kobject_init (&dev->kobj, &device_ktype);INIT_LIST_HEAD (&dev->dma_pools); -init_MUTEX (&dev->sem); +mutex_init (&dev->mutex);spin_lock_init (&dev->devres_lock);INIT_LIST_HEAD (&dev->devres_head);device_init_wakeup (dev,0 );
drivers/base/dd.c +19 -19
@@ -85,7 +85,7 @@ static void driver_sysfs_remove(struct d* for before calling this. (It is ok to call with no other effort * from a driver's probe() method.) * -* This function must be called with @dev->sem held. +* This function must be called with @dev->mutex held. */ int device_bind_driver (struct device *dev) {
@@ -190,8 +190,8 @@ EXPORT_SYMBOL_GPL(wait_for_device_probe)* This function returns -ENODEV if the device is not registered, * 1 if the device is bound successfully and 0 otherwise. * -* This function must be called with @dev->sem held. When called for a -* USB interface, @dev->parent->sem must be held as well. +* This function must be called with @dev->mutex held. When called for a +* USB interface, @dev->parent->mutex must be held as well. */ int driver_probe_device (struct device_driver *drv,struct device *dev) {
@@ -233,13 +233,13 @@ static int __device_attach(struct device* 0 if no matching driver was found; * -ENODEV if the device is not registered. * -* When called for a USB interface, @dev->parent->sem must be held. +* When called for a USB interface, @dev->parent->mutex must be held. */ int device_attach (struct device *dev) {int ret =0 ; -down (&dev->sem); +mutex_lock (&dev->mutex);if (dev->driver) { ret =device_bind_driver (dev);if (ret ==0 )
@@ -253,7 +253,7 @@ int device_attach(struct device *dev) ret =bus_for_each_drv (dev->bus,NULL , dev, __device_attach);pm_runtime_put_sync (dev); } -up (&dev->sem); +mutex_unlock (&dev->mutex);return ret; }EXPORT_SYMBOL_GPL (device_attach);
@@ -276,13 +276,13 @@ static int __driver_attach(struct devicereturn 0 ;if (dev->parent)/* Needed for USB */ -down (&dev->parent->sem); -down (&dev->sem); +mutex_lock (&dev->parent->mutex); +mutex_lock (&dev->mutex);if (!dev->driver)driver_probe_device (drv, dev); -up (&dev->sem); +mutex_unlock (&dev->mutex);if (dev->parent) -up (&dev->parent->sem); +mutex_unlock (&dev->parent->mutex);return 0 ; }
@@ -303,8 +303,8 @@ int driver_attach(struct device_driver *EXPORT_SYMBOL_GPL (driver_attach);/* -* __device_release_driver() must be called with @dev->sem held. -* When called for a USB interface, @dev->parent->sem must be held as well. +* __device_release_driver() must be called with @dev->mutex held. +* When called for a USB interface, @dev->parent->mutex must be held as well. */ static void __device_release_driver (struct device *dev) {
@@ -343,7 +343,7 @@ static void __device_release_driver(stru* @dev: device. * * Manually detach device from driver. -* When called for a USB interface, @dev->parent->sem must be held. +* When called for a USB interface, @dev->parent->mutex must be held. */ void device_release_driver (struct device *dev) {
@@ -352,9 +352,9 @@ void device_release_driver(struct device* within their ->remove callback for the same device, they * will deadlock right here. */ -down (&dev->sem); +mutex_lock (&dev->mutex);__device_release_driver (dev); -up (&dev->sem); +mutex_unlock (&dev->mutex); }EXPORT_SYMBOL_GPL (device_release_driver);
@@ -381,13 +381,13 @@ void driver_detach(struct device_driverspin_unlock (&drv->p->klist_devices.k_lock);if (dev->parent)/* Needed for USB */ -down (&dev->parent->sem); -down (&dev->sem); +mutex_lock (&dev->parent->mutex); +mutex_lock (&dev->mutex);if (dev->driver == drv)__device_release_driver (dev); -up (&dev->sem); +mutex_unlock (&dev->mutex);if (dev->parent) -up (&dev->parent->sem); +mutex_unlock (&dev->parent->mutex);put_device (dev); } }
drivers/base/power/main.c +10 -10
@@ -34,8 +34,8 @@* because children are guaranteed to be discovered after parents, and * are inserted at the back of the list on discovery. * -* Since device_pm_add() may be called with a device semaphore held, -* we must never try to acquire a device semaphore while holding +* Since device_pm_add() may be called with a device mutex held, +* we must never try to acquire a device mutex while holding * dpm_list_mutex. */
@@ -476,7 +476,7 @@ static int device_resume(struct device *TRACE_DEVICE (dev);TRACE_RESUME (0 ); -down (&dev->sem); +mutex_lock (&dev->mutex);if (dev->bus) {if (dev->bus->pm) {
@@ -509,7 +509,7 @@ static int device_resume(struct device * } } End: -up (&dev->sem); +mutex_unlock (&dev->mutex);TRACE_RESUME (error);return error;
@@ -564,7 +564,7 @@ static void dpm_resume(pm_message_t stat*/ static void device_complete (struct device *dev,pm_message_t state) { -down (&dev->sem); +mutex_lock (&dev->mutex);if (dev->class && dev->class->pm && dev->class->pm->complete) {pm_dev_dbg (dev, state,"completing class " );
@@ -581,7 +581,7 @@ static void device_complete(struct devic dev->bus->pm->complete (dev); } -up (&dev->sem); +mutex_unlock (&dev->mutex); }/**
@@ -740,7 +740,7 @@ static int device_suspend(struct device {int error =0 ; -down (&dev->sem); +mutex_lock (&dev->mutex);if (dev->class) {if (dev->class->pm) {
@@ -773,7 +773,7 @@ static int device_suspend(struct device } } End: -up (&dev->sem); +mutex_unlock (&dev->mutex);return error; }
@@ -828,7 +828,7 @@ static int device_prepare(struct device {int error =0 ; -down (&dev->sem); +mutex_lock (&dev->mutex);if (dev->bus && dev->bus->pm && dev->bus->pm->prepare) {pm_dev_dbg (dev, state,"preparing " );
@@ -852,7 +852,7 @@ static int device_prepare(struct devicesuspend_report_result (dev->class->pm->prepare, error); } End: -up (&dev->sem); +mutex_unlock (&dev->mutex);return error; }
drivers/firewire/core-device.c +2 -2
@@ -762,9 +762,9 @@ static int update_unit(struct device *destruct fw_driver *driver = (struct fw_driver *)dev->driver;if (is_fw_unit (dev) && driver !=NULL && driver->update !=NULL ) { -down (&dev->sem); +mutex_lock (&dev->mutex); driver->update (unit); -up (&dev->sem); +mutex_unlock (&dev->mutex); }return 0 ;
drivers/ieee1394/nodemgr.c +2 -2
@@ -1397,9 +1397,9 @@ static int update_pdrv(struct device *de pdrv = container_of(drv, struct hpsb_protocol_driver, driver);if (pdrv->update) { -down (&ud->device.sem); +mutex_lock (&ud->device.mutex); error = pdrv->update (ud); -up (&ud->device.sem); +mutex_unlock (&ud->device.mutex); }if (error)device_release_driver (&ud->device);
drivers/net/mlx4/mlx4.h +1 -0
@@ -40,6 +40,7 @@#include <linux/mutex.h> #include <linux/radix-tree.h> #include <linux/timer.h> +#include <linux/semaphore.h> #include <linux/workqueue.h> #include <linux/mlx4/device.h>
drivers/pci/bus.c +2 -2
@@ -240,9 +240,9 @@ void pci_walk_bus(struct pci_bus *top, i next = dev->bus_list.next;/* Run device routines with the device locked */ -down (&dev->dev.sem); +mutex_lock (&dev->dev.mutex); retval =cb (dev, userdata); -up (&dev->dev.sem); +mutex_unlock (&dev->dev.mutex);if (retval)break ; }
drivers/pci/pci.c +2 -2
@@ -2304,7 +2304,7 @@ static int pci_dev_reset(struct pci_devif (!probe) {pci_block_user_cfg_access (dev);/* block PM suspend, driver probe, etc. */ -down (&dev->dev.sem); +mutex_lock (&dev->dev.mutex); } rc =pci_dev_specific_reset (dev, probe);
@@ -2326,7 +2326,7 @@ static int pci_dev_reset(struct pci_dev rc =pci_parent_bus_reset (dev, probe); done:if (!probe) { -up (&dev->dev.sem); +mutex_unlock (&dev->dev.mutex);pci_unblock_user_cfg_access (dev); }
drivers/pcmcia/ds.c +4 -4
@@ -964,9 +964,9 @@ static int runtime_suspend(struct device {int rc; -down (&dev->sem); +mutex_lock (&dev->mutex); rc =pcmcia_dev_suspend (dev,PMSG_SUSPEND ); -up (&dev->sem); +mutex_unlock (&dev->mutex);return rc; }
@@ -974,9 +974,9 @@ static void runtime_resume(struct device {int rc; -down (&dev->sem); +mutex_lock (&dev->mutex); rc =pcmcia_dev_resume (dev); -up (&dev->sem); +mutex_unlock (&dev->mutex); }/************************ per-device sysfs output ***************************/
drivers/usb/core/driver.c +2 -2
@@ -470,10 +470,10 @@ void usb_driver_release_interface(structif (device_is_registered (dev)) {device_release_driver (dev); }else { -down (&dev->sem); +mutex_lock (&dev->mutex);usb_unbind_interface (dev); dev->driver =NULL ; -up (&dev->sem); +mutex_unlock (&dev->mutex); } }EXPORT_SYMBOL_GPL (usb_driver_release_interface);
drivers/usb/core/usb.c +1 -1
@@ -601,7 +601,7 @@ int usb_lock_device_for_reset(struct usb iface->condition == USB_INTERFACE_UNBOUND))return -EINTR ; -while (usb_trylock_device (udev) !=0 ) { +while (!usb_trylock_device (udev)) {/* If we can't acquire the lock after waiting one second, * we're probably deadlocked */
drivers/uwb/umc-bus.c +2 -2
@@ -62,12 +62,12 @@ int umc_controller_reset(struct umc_devstruct device *parent = umc->dev.parent;int ret =0 ; -if (down_trylock (&parent->sem)) +if (!mutex_trylock (&parent->mutex))return -EAGAIN ; ret =device_for_each_child (parent, parent, umc_bus_pre_reset_helper);if (ret >=0 ) ret =device_for_each_child (parent, parent, umc_bus_post_reset_helper); -up (&parent->sem); +mutex_unlock (&parent->mutex);return ret; }
drivers/uwb/uwb-internal.h +2 -2
@@ -366,12 +366,12 @@ struct dentry *uwb_dbg_create_pal_dir(ststatic inline void uwb_dev_lock (struct uwb_dev *uwb_dev) { -down (&uwb_dev->dev.sem); +mutex_lock (&uwb_dev->dev.mutex); }static inline void uwb_dev_unlock (struct uwb_dev *uwb_dev) { -up (&uwb_dev->dev.sem); +mutex_unlock (&uwb_dev->dev.mutex); }#endif /* #ifndef __UWB_INTERNAL_H__ */
include/linux/device.h +2 -3
@@ -22,7 +22,6 @@#include <linux/types.h> #include <linux/module.h> #include <linux/pm.h> -#include <linux/semaphore.h> #include <asm/atomic.h> #include <asm/device.h>
@@ -106,7 +105,7 @@ extern int bus_unregister_notifier(struc/* All 4 notifers below get called with the target struct device * * as an argument. Note that those functions are likely to be called -* with the device semaphore held in the core, so be careful. +* with the device mutex held in the core, so be careful. */ #define BUS_NOTIFY_ADD_DEVICE 0x00000001/* device added */ #define BUS_NOTIFY_DEL_DEVICE 0x00000002/* device removed */
@@ -385,7 +384,7 @@ struct device {const char *init_name;/* initial name of the device */ struct device_type *type; -struct semaphore sem;/* semaphore to synchronize calls to +struct mutex mutex;/* mutex to synchronize calls to * its driver. */
include/linux/usb.h +3 -3
@@ -527,9 +527,9 @@ extern struct usb_device *usb_get_dev(stextern void usb_put_dev (struct usb_device *dev);/* USB device locking */ -#define usb_lock_device (udev) down(&(udev)->dev.sem) -#define usb_unlock_device (udev) up(&(udev)->dev.sem) -#define usb_trylock_device (udev) down_trylock(&(udev)->dev.sem) +#define usb_lock_device (udev) mutex_lock(&(udev)->dev.mutex) +#define usb_unlock_device (udev) mutex_unlock(&(udev)->dev.mutex) +#define usb_trylock_device (udev) mutex_trylock(&(udev)->dev.mutex)extern int usb_lock_device_for_reset (struct usb_device *udev,const struct usb_interface *iface);
Re: [patch 08/10] drivers/base: Convert dev->sem to mutex
Quoted 5 lines · Thomas Gleixner
The semaphore is semantically a mutex. Convert it to a real mutex and clean up all users outside of
drivers/baseas well.Signed-off-by Thomas Gleixner <[email protected]>Cc Greg Kroah-Hartman <[email protected]>
Re: [patch 08/10] drivers/base: Convert dev->sem to mutex
Quoted 8 lines · Greg KH
Quoted 5 lines · Thomas Gleixner
The semaphore is semantically a mutex. Convert it to a real mutex and clean up all users outside of
drivers/baseas well.Signed-off-by Thomas Gleixner <[email protected]>Cc Greg Kroah-Hartman <[email protected]>
Can you take that via your drivers tree or do you want me to push it linuswards for .34 ?
Thanks,
tglx
Re: [patch 08/10] drivers/base: Convert dev->sem to mutex
Quoted 6 lines · Thomas Gleixner
Quoted 4 lines · Greg KH
Quoted 3 lines · Thomas Gleixner
The semaphore is semantically a mutex. Convert it to a real mutex and clean up all users outside of
drivers/baseas well.
Quoted 7 lines
Quoted 4 lines
Quoted 2 lines
Signed-off-by Thomas Gleixner <[email protected]>Cc Greg Kroah-Hartman <[email protected]>Can you take that via your drivers tree or do you want me to push it linuswards for .34 ?
I will take it.
thanks,
greg k-h
PATCH 9/10 block: drbd: Convert semaphore to mutex
In reply to Thomas GleixnerThe bm_change semaphore is semantically a mutex. Convert it to a real mutex.
--- drivers/block/drbd/drbd_bitmap.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-)
drivers/block/drbd/drbd_bitmap.c +5 -5
@@ -66,7 +66,7 @@ struct drbd_bitmap {size_t bm_words;size_t bm_number_of_pages;sector_t bm_dev_capacity; -struct semaphore bm_change;/* serializes resize operations */ +struct mutex bm_change;/* serializes resize operations */ atomic_t bm_async_io;wait_queue_head_t bm_io_wait;
@@ -114,7 +114,7 @@ void drbd_bm_lock(struct drbd_conf *mdevreturn ; } - trylock_failed =down_trylock (&b->bm_change); + trylock_failed = !mutex_trylock (&b->bm_change);if (trylock_failed) { dev_warn(DEV, "%s going to '%s' but bitmap already locked for '%s' by %s\n",
@@ -125,7 +125,7 @@ void drbd_bm_lock(struct drbd_conf *mdev b->bm_task == mdev->receiver.task ?"receiver" : b->bm_task == mdev->asender.task ?"asender" : b->bm_task == mdev->worker.task ? "worker" : "?"); -down (&b->bm_change); +mutex_lock (&b->bm_change); }if (__test_and_set_bit (BM_LOCKED , &b->bm_flags))dev_err (DEV ,"FIXME bitmap already locked in bm_lock\n" );
@@ -147,7 +147,7 @@ void drbd_bm_unlock(struct drbd_conf *md b->bm_why =NULL ; b->bm_task =NULL ; -up (&b->bm_change); +mutex_unlock (&b->bm_change); }/* word offset to long pointer */
@@ -295,7 +295,7 @@ int drbd_bm_init(struct drbd_conf *mdev)if (!b)return -ENOMEM ;spin_lock_init (&b->bm_lock); -init_MUTEX (&b->bm_change); +mutex_init (&b->bm_change);init_waitqueue_head (&b->bm_io_wait); mdev->bitmap = b;
PATCH 10/10 hwmon: s3c-hwmon: Convert semaphore to mutex
In reply to Thomas Gleixnerhwmon->lock is used as a mutex. Make it a real mutex.
--- drivers/hwmon/s3c-hwmon.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-)
Index: linux-2.6-tip/drivers/hwmon/s3c-hwmon.c =================================--- linux-2.6-tip.orig/drivers/hwmon/s3c-hwmon.c +++ linux-2.6-tip/drivers/hwmon/s3c-hwmon.c
@@ -51,7 +51,7 @@ struct s3c_hwmon_attr {
* @attr: The holders for the channel attributes.
*/
struct s3c_hwmon {
- struct semaphore lock;
+ struct mutex lock;
struct s3c_adc_client *client;
struct device *hwmon_dev;
@@ -73,14 +73,14 @@ static int s3c_hwmon_read_ch(struct devi
{
int ret;
- ret = down_interruptible(&hwmon->lock);
+ ret = mutex_lock_interruptible(&hwmon->lock);
if (ret < 0)
return ret;
dev_dbg(dev, "reading channel %d\n", channel);
ret = s3c_adc_read(hwmon->client, channel);
- up(&hwmon->lock);
+ mutex_unlock(&hwmon->lock);
return ret;
}
@@ -296,7 +296,7 @@ static int __devinit s3c_hwmon_probe(str
platform_set_drvdata(dev, hwmon);
- init_MUTEX(&hwmon->lock);
+ mutex_init(&hwmon->lock);
/* Register with the core ADC driver. */
_______________________________________________
lm-sensors mailing list
[email protected]
http://lists.lm-sensors.org/mailman/listinfo/lm-sensors