Skip to content

Commit 60aa492

Browse files
author
Jonathan Corbet
committed
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 <[email protected]> Signed-off-by: Jonathan Corbet <[email protected]>
1 parent 7639842 commit 60aa492

File tree

17 files changed

+22
-73
lines changed

17 files changed

+22
-73
lines changed

drivers/char/sonypi.c

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -888,12 +888,7 @@ static irqreturn_t sonypi_irq(int irq, void *dev_id)
888888

889889
static int sonypi_misc_fasync(int fd, struct file *filp, int on)
890890
{
891-
int retval;
892-
893-
retval = fasync_helper(fd, filp, on, &sonypi_device.fifo_async);
894-
if (retval < 0)
895-
return retval;
896-
return 0;
891+
return fasync_helper(fd, filp, on, &sonypi_device.fifo_async);
897892
}
898893

899894
static int sonypi_misc_release(struct inode *inode, struct file *file)

drivers/gpu/drm/drm_fops.c

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -337,14 +337,10 @@ int drm_fasync(int fd, struct file *filp, int on)
337337
{
338338
struct drm_file *priv = filp->private_data;
339339
struct drm_device *dev = priv->minor->dev;
340-
int retcode;
341340

342341
DRM_DEBUG("fd = %d, device = 0x%lx\n", fd,
343342
(long)old_encode_dev(priv->minor->device));
344-
retcode = fasync_helper(fd, filp, on, &dev->buf_async);
345-
if (retcode < 0)
346-
return retcode;
347-
return 0;
343+
return fasync_helper(fd, filp, on, &dev->buf_async);
348344
}
349345
EXPORT_SYMBOL(drm_fasync);
350346

drivers/hid/usbhid/hiddev.c

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -227,12 +227,9 @@ void hiddev_report_event(struct hid_device *hid, struct hid_report *report)
227227
*/
228228
static int hiddev_fasync(int fd, struct file *file, int on)
229229
{
230-
int retval;
231230
struct hiddev_list *list = file->private_data;
232231

233-
retval = fasync_helper(fd, file, on, &list->fasync);
234-
235-
return retval < 0 ? retval : 0;
232+
return fasync_helper(fd, file, on, &list->fasync);
236233
}
237234

238235

drivers/ieee1394/dv1394.c

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1325,11 +1325,7 @@ static int dv1394_fasync(int fd, struct file *file, int on)
13251325

13261326
struct video_card *video = file_to_video_card(file);
13271327

1328-
int retval = fasync_helper(fd, file, on, &video->fasync);
1329-
1330-
if (retval < 0)
1331-
return retval;
1332-
return 0;
1328+
return fasync_helper(fd, file, on, &video->fasync);
13331329
}
13341330

13351331
static ssize_t dv1394_write(struct file *file, const char __user *buffer, size_t count, loff_t *ppos)

drivers/input/evdev.c

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -94,11 +94,8 @@ static void evdev_event(struct input_handle *handle,
9494
static int evdev_fasync(int fd, struct file *file, int on)
9595
{
9696
struct evdev_client *client = file->private_data;
97-
int retval;
98-
99-
retval = fasync_helper(fd, file, on, &client->fasync);
10097

101-
return retval < 0 ? retval : 0;
98+
return fasync_helper(fd, file, on, &client->fasync);
10299
}
103100

104101
static int evdev_flush(struct file *file, fl_owner_t id)

drivers/input/joydev.c

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -159,12 +159,9 @@ static void joydev_event(struct input_handle *handle,
159159

160160
static int joydev_fasync(int fd, struct file *file, int on)
161161
{
162-
int retval;
163162
struct joydev_client *client = file->private_data;
164163

165-
retval = fasync_helper(fd, file, on, &client->fasync);
166-
167-
return retval < 0 ? retval : 0;
164+
return fasync_helper(fd, file, on, &client->fasync);
168165
}
169166

170167
static void joydev_free(struct device *dev)

drivers/input/mousedev.c

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -403,12 +403,9 @@ static void mousedev_event(struct input_handle *handle,
403403

404404
static int mousedev_fasync(int fd, struct file *file, int on)
405405
{
406-
int retval;
407406
struct mousedev_client *client = file->private_data;
408407

409-
retval = fasync_helper(fd, file, on, &client->fasync);
410-
411-
return retval < 0 ? retval : 0;
408+
return fasync_helper(fd, file, on, &client->fasync);
412409
}
413410

414411
static void mousedev_free(struct device *dev)

drivers/input/serio/serio_raw.c

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -58,10 +58,8 @@ static unsigned int serio_raw_no;
5858
static int serio_raw_fasync(int fd, struct file *file, int on)
5959
{
6060
struct serio_raw_list *list = file->private_data;
61-
int retval;
6261

63-
retval = fasync_helper(fd, file, on, &list->fasync);
64-
return retval < 0 ? retval : 0;
62+
return fasync_helper(fd, file, on, &list->fasync);
6563
}
6664

6765
static struct serio_raw *serio_raw_locate(int minor)

drivers/net/wan/cosa.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -993,8 +993,8 @@ static struct fasync_struct *fasync[256] = { NULL, };
993993
static int cosa_fasync(struct inode *inode, struct file *file, int on)
994994
{
995995
int port = iminor(inode);
996-
int rv = fasync_helper(inode, file, on, &fasync[port]);
997-
return rv < 0 ? rv : 0;
996+
997+
return fasync_helper(inode, file, on, &fasync[port]);
998998
}
999999
#endif
10001000

drivers/platform/x86/sony-laptop.c

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1917,12 +1917,7 @@ static struct sonypi_compat_s sonypi_compat = {
19171917

19181918
static int sonypi_misc_fasync(int fd, struct file *filp, int on)
19191919
{
1920-
int retval;
1921-
1922-
retval = fasync_helper(fd, filp, on, &sonypi_compat.fifo_async);
1923-
if (retval < 0)
1924-
return retval;
1925-
return 0;
1920+
return fasync_helper(fd, filp, on, &sonypi_compat.fifo_async);
19261921
}
19271922

19281923
static int sonypi_misc_release(struct inode *inode, struct file *file)

0 commit comments

Comments
 (0)