aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJonathan Corbet <corbet@lwn.net>2009-02-01 16:52:56 -0500
committerJonathan Corbet <corbet@lwn.net>2009-03-16 10:34:35 -0400
commit60aa49243d09afc873f082567d2e3c16634ced84 (patch)
treebb7c8d9668b35a3aa4e90d0a62500ac9d3e67f7f
parent76398425bb06b07cc3a3b1ce169c67dc9d6874ed (diff)
Rationalize fasync return values
Most fasync implementations do something like: return fasync_helper(...); But fasync_helper() will return a positive value at times - a feature used in at least one place. Thus, a number of other drivers do: err = fasync_helper(...); if (err < 0) return err; return 0; In the interests of consistency and more concise code, it makes sense to map positive return values onto zero where ->fasync() is called. Cc: Al Viro <viro@ZenIV.linux.org.uk> Signed-off-by: Jonathan Corbet <corbet@lwn.net>
-rw-r--r--drivers/char/sonypi.c7
-rw-r--r--drivers/gpu/drm/drm_fops.c6
-rw-r--r--drivers/hid/usbhid/hiddev.c5
-rw-r--r--drivers/ieee1394/dv1394.c6
-rw-r--r--drivers/input/evdev.c5
-rw-r--r--drivers/input/joydev.c5
-rw-r--r--drivers/input/mousedev.c5
-rw-r--r--drivers/input/serio/serio_raw.c4
-rw-r--r--drivers/net/wan/cosa.c4
-rw-r--r--drivers/platform/x86/sony-laptop.c7
-rw-r--r--drivers/scsi/sg.c4
-rw-r--r--fs/fcntl.c2
-rw-r--r--fs/ioctl.c2
-rw-r--r--fs/pipe.c16
-rw-r--r--sound/core/control.c7
-rw-r--r--sound/core/pcm_native.c4
-rw-r--r--sound/core/timer.c6
17 files changed, 22 insertions, 73 deletions
diff --git a/drivers/char/sonypi.c b/drivers/char/sonypi.c
index f4374437a033..fd3dced97776 100644
--- a/drivers/char/sonypi.c
+++ b/drivers/char/sonypi.c
@@ -888,12 +888,7 @@ found:
888 888
889static int sonypi_misc_fasync(int fd, struct file *filp, int on) 889static int sonypi_misc_fasync(int fd, struct file *filp, int on)
890{ 890{
891 int retval; 891 return fasync_helper(fd, filp, on, &sonypi_device.fifo_async);
892
893 retval = fasync_helper(fd, filp, on, &sonypi_device.fifo_async);
894 if (retval < 0)
895 return retval;
896 return 0;
897} 892}
898 893
899static int sonypi_misc_release(struct inode *inode, struct file *file) 894static int sonypi_misc_release(struct inode *inode, struct file *file)
diff --git a/drivers/gpu/drm/drm_fops.c b/drivers/gpu/drm/drm_fops.c
index f52663ebe016..e13cb62bbaee 100644
--- a/drivers/gpu/drm/drm_fops.c
+++ b/drivers/gpu/drm/drm_fops.c
@@ -337,14 +337,10 @@ int drm_fasync(int fd, struct file *filp, int on)
337{ 337{
338 struct drm_file *priv = filp->private_data; 338 struct drm_file *priv = filp->private_data;
339 struct drm_device *dev = priv->minor->dev; 339 struct drm_device *dev = priv->minor->dev;
340 int retcode;
341 340
342 DRM_DEBUG("fd = %d, device = 0x%lx\n", fd, 341 DRM_DEBUG("fd = %d, device = 0x%lx\n", fd,
343 (long)old_encode_dev(priv->minor->device)); 342 (long)old_encode_dev(priv->minor->device));
344 retcode = fasync_helper(fd, filp, on, &dev->buf_async); 343 return fasync_helper(fd, filp, on, &dev->buf_async);
345 if (retcode < 0)
346 return retcode;
347 return 0;
348} 344}
349EXPORT_SYMBOL(drm_fasync); 345EXPORT_SYMBOL(drm_fasync);
350 346
diff --git a/drivers/hid/usbhid/hiddev.c b/drivers/hid/usbhid/hiddev.c
index 4940e4d70c2d..3a7b4fe192a3 100644
--- a/drivers/hid/usbhid/hiddev.c
+++ b/drivers/hid/usbhid/hiddev.c
@@ -227,12 +227,9 @@ void hiddev_report_event(struct hid_device *hid, struct hid_report *report)
227 */ 227 */
228static int hiddev_fasync(int fd, struct file *file, int on) 228static int hiddev_fasync(int fd, struct file *file, int on)
229{ 229{
230 int retval;
231 struct hiddev_list *list = file->private_data; 230 struct hiddev_list *list = file->private_data;
232 231
233 retval = fasync_helper(fd, file, on, &list->fasync); 232 return fasync_helper(fd, file, on, &list->fasync);
234
235 return retval < 0 ? retval : 0;
236} 233}
237 234
238 235
diff --git a/drivers/ieee1394/dv1394.c b/drivers/ieee1394/dv1394.c
index 3838bc4acaba..cb15bfa38d70 100644
--- a/drivers/ieee1394/dv1394.c
+++ b/drivers/ieee1394/dv1394.c
@@ -1325,11 +1325,7 @@ static int dv1394_fasync(int fd, struct file *file, int on)
1325 1325
1326 struct video_card *video = file_to_video_card(file); 1326 struct video_card *video = file_to_video_card(file);
1327 1327
1328 int retval = fasync_helper(fd, file, on, &video->fasync); 1328 return fasync_helper(fd, file, on, &video->fasync);
1329
1330 if (retval < 0)
1331 return retval;
1332 return 0;
1333} 1329}
1334 1330
1335static ssize_t dv1394_write(struct file *file, const char __user *buffer, size_t count, loff_t *ppos) 1331static ssize_t dv1394_write(struct file *file, const char __user *buffer, size_t count, loff_t *ppos)
diff --git a/drivers/input/evdev.c b/drivers/input/evdev.c
index ed8baa0aec3c..7a7a026ba712 100644
--- a/drivers/input/evdev.c
+++ b/drivers/input/evdev.c
@@ -94,11 +94,8 @@ static void evdev_event(struct input_handle *handle,
94static int evdev_fasync(int fd, struct file *file, int on) 94static int evdev_fasync(int fd, struct file *file, int on)
95{ 95{
96 struct evdev_client *client = file->private_data; 96 struct evdev_client *client = file->private_data;
97 int retval;
98
99 retval = fasync_helper(fd, file, on, &client->fasync);
100 97
101 return retval < 0 ? retval : 0; 98 return fasync_helper(fd, file, on, &client->fasync);
102} 99}
103 100
104static int evdev_flush(struct file *file, fl_owner_t id) 101static int evdev_flush(struct file *file, fl_owner_t id)
diff --git a/drivers/input/joydev.c b/drivers/input/joydev.c
index 6f2366220a50..4224f0112849 100644
--- a/drivers/input/joydev.c
+++ b/drivers/input/joydev.c
@@ -159,12 +159,9 @@ static void joydev_event(struct input_handle *handle,
159 159
160static int joydev_fasync(int fd, struct file *file, int on) 160static int joydev_fasync(int fd, struct file *file, int on)
161{ 161{
162 int retval;
163 struct joydev_client *client = file->private_data; 162 struct joydev_client *client = file->private_data;
164 163
165 retval = fasync_helper(fd, file, on, &client->fasync); 164 return fasync_helper(fd, file, on, &client->fasync);
166
167 return retval < 0 ? retval : 0;
168} 165}
169 166
170static void joydev_free(struct device *dev) 167static void joydev_free(struct device *dev)
diff --git a/drivers/input/mousedev.c b/drivers/input/mousedev.c
index ef99a7e6d40c..17fd6d46d082 100644
--- a/drivers/input/mousedev.c
+++ b/drivers/input/mousedev.c
@@ -403,12 +403,9 @@ static void mousedev_event(struct input_handle *handle,
403 403
404static int mousedev_fasync(int fd, struct file *file, int on) 404static int mousedev_fasync(int fd, struct file *file, int on)
405{ 405{
406 int retval;
407 struct mousedev_client *client = file->private_data; 406 struct mousedev_client *client = file->private_data;
408 407
409 retval = fasync_helper(fd, file, on, &client->fasync); 408 return fasync_helper(fd, file, on, &client->fasync);
410
411 return retval < 0 ? retval : 0;
412} 409}
413 410
414static void mousedev_free(struct device *dev) 411static void mousedev_free(struct device *dev)
diff --git a/drivers/input/serio/serio_raw.c b/drivers/input/serio/serio_raw.c
index 06bbd0e74c6f..b03009bb7468 100644
--- a/drivers/input/serio/serio_raw.c
+++ b/drivers/input/serio/serio_raw.c
@@ -58,10 +58,8 @@ static unsigned int serio_raw_no;
58static int serio_raw_fasync(int fd, struct file *file, int on) 58static int serio_raw_fasync(int fd, struct file *file, int on)
59{ 59{
60 struct serio_raw_list *list = file->private_data; 60 struct serio_raw_list *list = file->private_data;
61 int retval;
62 61
63 retval = fasync_helper(fd, file, on, &list->fasync); 62 return fasync_helper(fd, file, on, &list->fasync);
64 return retval < 0 ? retval : 0;
65} 63}
66 64
67static struct serio_raw *serio_raw_locate(int minor) 65static struct serio_raw *serio_raw_locate(int minor)
diff --git a/drivers/net/wan/cosa.c b/drivers/net/wan/cosa.c
index d80b72e22dea..ce753e9c576b 100644
--- a/drivers/net/wan/cosa.c
+++ b/drivers/net/wan/cosa.c
@@ -993,8 +993,8 @@ static struct fasync_struct *fasync[256] = { NULL, };
993static int cosa_fasync(struct inode *inode, struct file *file, int on) 993static int cosa_fasync(struct inode *inode, struct file *file, int on)
994{ 994{
995 int port = iminor(inode); 995 int port = iminor(inode);
996 int rv = fasync_helper(inode, file, on, &fasync[port]); 996
997 return rv < 0 ? rv : 0; 997 return fasync_helper(inode, file, on, &fasync[port]);
998} 998}
999#endif 999#endif
1000 1000
diff --git a/drivers/platform/x86/sony-laptop.c b/drivers/platform/x86/sony-laptop.c
index 537959d07148..bc8996c849ac 100644
--- a/drivers/platform/x86/sony-laptop.c
+++ b/drivers/platform/x86/sony-laptop.c
@@ -1917,12 +1917,7 @@ static struct sonypi_compat_s sonypi_compat = {
1917 1917
1918static int sonypi_misc_fasync(int fd, struct file *filp, int on) 1918static int sonypi_misc_fasync(int fd, struct file *filp, int on)
1919{ 1919{
1920 int retval; 1920 return fasync_helper(fd, filp, on, &sonypi_compat.fifo_async);
1921
1922 retval = fasync_helper(fd, filp, on, &sonypi_compat.fifo_async);
1923 if (retval < 0)
1924 return retval;
1925 return 0;
1926} 1921}
1927 1922
1928static int sonypi_misc_release(struct inode *inode, struct file *file) 1923static int sonypi_misc_release(struct inode *inode, struct file *file)
diff --git a/drivers/scsi/sg.c b/drivers/scsi/sg.c
index 516925d8b570..b4ef2f84ea32 100644
--- a/drivers/scsi/sg.c
+++ b/drivers/scsi/sg.c
@@ -1154,7 +1154,6 @@ sg_poll(struct file *filp, poll_table * wait)
1154static int 1154static int
1155sg_fasync(int fd, struct file *filp, int mode) 1155sg_fasync(int fd, struct file *filp, int mode)
1156{ 1156{
1157 int retval;
1158 Sg_device *sdp; 1157 Sg_device *sdp;
1159 Sg_fd *sfp; 1158 Sg_fd *sfp;
1160 1159
@@ -1163,8 +1162,7 @@ sg_fasync(int fd, struct file *filp, int mode)
1163 SCSI_LOG_TIMEOUT(3, printk("sg_fasync: %s, mode=%d\n", 1162 SCSI_LOG_TIMEOUT(3, printk("sg_fasync: %s, mode=%d\n",
1164 sdp->disk->disk_name, mode)); 1163 sdp->disk->disk_name, mode));
1165 1164
1166 retval = fasync_helper(fd, filp, mode, &sfp->async_qp); 1165 return fasync_helper(fd, filp, mode, &sfp->async_qp);
1167 return (retval < 0) ? retval : 0;
1168} 1166}
1169 1167
1170static int 1168static int
diff --git a/fs/fcntl.c b/fs/fcntl.c
index 431bb6459273..d865ca66ccba 100644
--- a/fs/fcntl.c
+++ b/fs/fcntl.c
@@ -184,6 +184,8 @@ static int setfl(int fd, struct file * filp, unsigned long arg)
184 error = filp->f_op->fasync(fd, filp, (arg & FASYNC) != 0); 184 error = filp->f_op->fasync(fd, filp, (arg & FASYNC) != 0);
185 if (error < 0) 185 if (error < 0)
186 goto out; 186 goto out;
187 if (error > 0)
188 error = 0;
187 } 189 }
188 spin_lock(&filp->f_lock); 190 spin_lock(&filp->f_lock);
189 filp->f_flags = (arg & SETFL_MASK) | (filp->f_flags & ~SETFL_MASK); 191 filp->f_flags = (arg & SETFL_MASK) | (filp->f_flags & ~SETFL_MASK);
diff --git a/fs/ioctl.c b/fs/ioctl.c
index e8e89edba576..ac2d47e43926 100644
--- a/fs/ioctl.c
+++ b/fs/ioctl.c
@@ -432,7 +432,7 @@ static int ioctl_fioasync(unsigned int fd, struct file *filp,
432 else 432 else
433 error = -ENOTTY; 433 error = -ENOTTY;
434 } 434 }
435 return error; 435 return error < 0 ? error : 0;
436} 436}
437 437
438static int ioctl_fsfreeze(struct file *filp) 438static int ioctl_fsfreeze(struct file *filp)
diff --git a/fs/pipe.c b/fs/pipe.c
index 14f502b89cf5..94ad15967cf9 100644
--- a/fs/pipe.c
+++ b/fs/pipe.c
@@ -667,10 +667,7 @@ pipe_read_fasync(int fd, struct file *filp, int on)
667 retval = fasync_helper(fd, filp, on, &inode->i_pipe->fasync_readers); 667 retval = fasync_helper(fd, filp, on, &inode->i_pipe->fasync_readers);
668 mutex_unlock(&inode->i_mutex); 668 mutex_unlock(&inode->i_mutex);
669 669
670 if (retval < 0) 670 return retval;
671 return retval;
672
673 return 0;
674} 671}
675 672
676 673
@@ -684,10 +681,7 @@ pipe_write_fasync(int fd, struct file *filp, int on)
684 retval = fasync_helper(fd, filp, on, &inode->i_pipe->fasync_writers); 681 retval = fasync_helper(fd, filp, on, &inode->i_pipe->fasync_writers);
685 mutex_unlock(&inode->i_mutex); 682 mutex_unlock(&inode->i_mutex);
686 683
687 if (retval < 0) 684 return retval;
688 return retval;
689
690 return 0;
691} 685}
692 686
693 687
@@ -706,11 +700,7 @@ pipe_rdwr_fasync(int fd, struct file *filp, int on)
706 fasync_helper(-1, filp, 0, &pipe->fasync_readers); 700 fasync_helper(-1, filp, 0, &pipe->fasync_readers);
707 } 701 }
708 mutex_unlock(&inode->i_mutex); 702 mutex_unlock(&inode->i_mutex);
709 703 return retval;
710 if (retval < 0)
711 return retval;
712
713 return 0;
714} 704}
715 705
716 706
diff --git a/sound/core/control.c b/sound/core/control.c
index 636b3b52ef8b..4b20fa2b7e6d 100644
--- a/sound/core/control.c
+++ b/sound/core/control.c
@@ -1373,12 +1373,9 @@ EXPORT_SYMBOL(snd_ctl_unregister_ioctl_compat);
1373static int snd_ctl_fasync(int fd, struct file * file, int on) 1373static int snd_ctl_fasync(int fd, struct file * file, int on)
1374{ 1374{
1375 struct snd_ctl_file *ctl; 1375 struct snd_ctl_file *ctl;
1376 int err; 1376
1377 ctl = file->private_data; 1377 ctl = file->private_data;
1378 err = fasync_helper(fd, file, on, &ctl->fasync); 1378 return fasync_helper(fd, file, on, &ctl->fasync);
1379 if (err < 0)
1380 return err;
1381 return 0;
1382} 1379}
1383 1380
1384/* 1381/*
diff --git a/sound/core/pcm_native.c b/sound/core/pcm_native.c
index a789efc9df39..a75c194e629e 100644
--- a/sound/core/pcm_native.c
+++ b/sound/core/pcm_native.c
@@ -3246,9 +3246,7 @@ static int snd_pcm_fasync(int fd, struct file * file, int on)
3246 err = fasync_helper(fd, file, on, &runtime->fasync); 3246 err = fasync_helper(fd, file, on, &runtime->fasync);
3247out: 3247out:
3248 unlock_kernel(); 3248 unlock_kernel();
3249 if (err < 0) 3249 return err;
3250 return err;
3251 return 0;
3252} 3250}
3253 3251
3254/* 3252/*
diff --git a/sound/core/timer.c b/sound/core/timer.c
index 796532081e81..3f0050d0b71e 100644
--- a/sound/core/timer.c
+++ b/sound/core/timer.c
@@ -1825,13 +1825,9 @@ static long snd_timer_user_ioctl(struct file *file, unsigned int cmd,
1825static int snd_timer_user_fasync(int fd, struct file * file, int on) 1825static int snd_timer_user_fasync(int fd, struct file * file, int on)
1826{ 1826{
1827 struct snd_timer_user *tu; 1827 struct snd_timer_user *tu;
1828 int err;
1829 1828
1830 tu = file->private_data; 1829 tu = file->private_data;
1831 err = fasync_helper(fd, file, on, &tu->fasync); 1830 return fasync_helper(fd, file, on, &tu->fasync);
1832 if (err < 0)
1833 return err;
1834 return 0;
1835} 1831}
1836 1832
1837static ssize_t snd_timer_user_read(struct file *file, char __user *buffer, 1833static ssize_t snd_timer_user_read(struct file *file, char __user *buffer,