History

Merge branch 'timer-fixes-for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/tip/linux-2.6-tip

* 'timer-fixes-for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/tip/linux-2.6-tip: RTC: rtc-omap: Fix a leak of the IRQ during init failure posix clocks: Replace mutex with reader/writer semaphore

Linus Torvalds committed 15 years ago

Commit 4ae0ff12 parents 96ad999 2dd93c43 files · +13 −18Browse files

Showing the changes to kernel (1 of 3 files). Show all

Unified · Split

kernel/time/posix-clock.c+9−15
@@ -19,7 +19,6 @@ · 18 unmodified lines
1919 */
2020 #include <linux/device.h>
2121 #include <linux/file.h>
22−#include <linux/mutex.h>
2322 #include <linux/posix-clock.h>
2423 #include <linux/slab.h>
2524 #include <linux/syscalls.h>
@@ -34,19 +33,19 @@ static struct posix_clock *get_posix_clock(struct file *fp) · 8 unmodified lines
3433 {
3534 struct posix_clock *clk = fp->private_data;
3635
37− mutex_lock(&clk->mutex);
36+ down_read(&clk->rwsem);
3837
3938 if (!clk->zombie)
4039 return clk;
4140
42− mutex_unlock(&clk->mutex);
41+ up_read(&clk->rwsem);
4342
4443 return NULL;
4544 }
4645
4746 static void put_posix_clock(struct posix_clock *clk)
4847 {
49− mutex_unlock(&clk->mutex);
48+ up_read(&clk->rwsem);
5049 }
5150
5251 static ssize_t posix_clock_read(struct file *fp, char __user *buf,
@@ -156,7 +155,7 @@ static int posix_clock_open(struct inode *inode, struct file *fp) · 103 unmodified lines
156155 struct posix_clock *clk =
157156 container_of(inode->i_cdev, struct posix_clock, cdev);
158157
159− mutex_lock(&clk->mutex);
158+ down_read(&clk->rwsem);
160159
161160 if (clk->zombie) {
162161 err = -ENODEV;
@@ -172,7 +171,7 @@ static int posix_clock_open(struct inode *inode, struct file *fp) · 9 unmodified lines
172171 fp->private_data = clk;
173172 }
174173 out:
175− mutex_unlock(&clk->mutex);
174+ up_read(&clk->rwsem);
176175 return err;
177176 }
178177
@@ -211,25 +210,20 @@ int posix_clock_register(struct posix_clock *clk, dev_t devid) · 32 unmodified lines
211210 int err;
212211
213212 kref_init(&clk->kref);
214− mutex_init(&clk->mutex);
213+ init_rwsem(&clk->rwsem);
215214
216215 cdev_init(&clk->cdev, &posix_clock_file_operations);
217216 clk->cdev.owner = clk->ops.owner;
218217 err = cdev_add(&clk->cdev, devid, 1);
219− if (err)
220− goto no_cdev;
221218
222219 return err;
223−no_cdev:
224− mutex_destroy(&clk->mutex);
225− return err;
226220 }
227221 EXPORT_SYMBOL_GPL(posix_clock_register);
228222
229223 static void delete_clock(struct kref *kref)
230224 {
231225 struct posix_clock *clk = container_of(kref, struct posix_clock, kref);
232− mutex_destroy(&clk->mutex);
226+
233227 if (clk->release)
234228 clk->release(clk);
235229 }
@@ -238,9 +232,9 @@ void posix_clock_unregister(struct posix_clock *clk) · 2 unmodified lines
238232 {
239233 cdev_del(&clk->cdev);
240234
241− mutex_lock(&clk->mutex);
235+ down_write(&clk->rwsem);
242236 clk->zombie = true;
243− mutex_unlock(&clk->mutex);
237+ up_write(&clk->rwsem);
244238
245239 kref_put(&clk->kref, delete_clock);
246240 }

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t