Skip to content

Commit

Permalink
Merge tag 'stream_open-5.2' of https://lab.nexedi.com/kirr/linux
Browse files Browse the repository at this point in the history
Pull stream_open conversion from Kirill Smelkov:

 - remove unnecessary double nonseekable_open from drivers/char/dtlk.c
   as noticed by Pavel Machek while reviewing nonseekable_open ->
   stream_open mass conversion.

 - the mass conversion patch promised in commit 10dce8a ("fs:
   stream_open - opener for stream-like files so that read and write can
   run simultaneously without deadlock") and is automatically generated
   by running

        $ make coccicheck MODE=patch COCCI=scripts/coccinelle/api/stream_open.cocci

   I've verified each generated change manually - that it is correct to
   convert - and each other nonseekable_open instance left - that it is
   either not correct to convert there, or that it is not converted due
   to current stream_open.cocci limitations. More details on this in the
   patch.

 - finally, change VFS to pass ppos=NULL into .read/.write for files
   that declare themselves streams. It was suggested by Rasmus Villemoes
   and makes sure that if ppos starts to be erroneously used in a stream
   file, such bug won't go unnoticed and will produce an oops instead of
   creating illusion of position change being taken into account.

   Note: this patch does not conflict with "fuse: Add FOPEN_STREAM to
   use stream_open()" that will be hopefully coming via FUSE tree,
   because fs/fuse/ uses new-style .read_iter/.write_iter, and for these
   accessors position is still passed as non-pointer kiocb.ki_pos .

* tag 'stream_open-5.2' of https://lab.nexedi.com/kirr/linux:
  vfs: pass ppos=NULL to .read()/.write() of FMODE_STREAM files
  *: convert stream-like files from nonseekable_open -> stream_open
  dtlk: remove double call to nonseekable_open
  • Loading branch information
torvalds committed May 7, 2019
2 parents aa26690 + 438ab72 commit 41bc10c
Show file tree
Hide file tree
Showing 105 changed files with 179 additions and 158 deletions.
2 changes: 1 addition & 1 deletion arch/powerpc/platforms/52xx/mpc52xx_gpt.c
Original file line number Diff line number Diff line change
Expand Up @@ -628,7 +628,7 @@ static int mpc52xx_wdt_open(struct inode *inode, struct file *file)
}

file->private_data = mpc52xx_gpt_wdt;
return nonseekable_open(inode, file);
return stream_open(inode, file);
}

static int mpc52xx_wdt_release(struct inode *inode, struct file *file)
Expand Down
2 changes: 1 addition & 1 deletion arch/powerpc/platforms/cell/spufs/file.c
Original file line number Diff line number Diff line change
Expand Up @@ -588,7 +588,7 @@ static int spufs_pipe_open(struct inode *inode, struct file *file)
struct spufs_inode_info *i = SPUFS_I(inode);
file->private_data = i->i_ctx;

return nonseekable_open(inode, file);
return stream_open(inode, file);
}

/*
Expand Down
2 changes: 1 addition & 1 deletion arch/um/drivers/harddog_kern.c
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ static int harddog_open(struct inode *inode, struct file *file)
timer_alive = 1;
spin_unlock(&lock);
mutex_unlock(&harddog_mutex);
return nonseekable_open(inode, file);
return stream_open(inode, file);
err:
spin_unlock(&lock);
mutex_unlock(&harddog_mutex);
Expand Down
2 changes: 1 addition & 1 deletion arch/x86/kernel/cpu/microcode/core.c
Original file line number Diff line number Diff line change
Expand Up @@ -428,7 +428,7 @@ static int do_microcode_update(const void __user *buf, size_t size)

static int microcode_open(struct inode *inode, struct file *file)
{
return capable(CAP_SYS_RAWIO) ? nonseekable_open(inode, file) : -EPERM;
return capable(CAP_SYS_RAWIO) ? stream_open(inode, file) : -EPERM;
}

static ssize_t microcode_write(struct file *file, const char __user *buf,
Expand Down
2 changes: 1 addition & 1 deletion drivers/char/ds1620.c
Original file line number Diff line number Diff line change
Expand Up @@ -212,7 +212,7 @@ static void ds1620_read_state(struct therm *therm)

static int ds1620_open(struct inode *inode, struct file *file)
{
return nonseekable_open(inode, file);
return stream_open(inode, file);
}

static ssize_t
Expand Down
3 changes: 1 addition & 2 deletions drivers/char/dtlk.c
Original file line number Diff line number Diff line change
Expand Up @@ -298,12 +298,11 @@ static int dtlk_open(struct inode *inode, struct file *file)
{
TRACE_TEXT("(dtlk_open");

nonseekable_open(inode, file);
switch (iminor(inode)) {
case DTLK_MINOR:
if (dtlk_busy)
return -EBUSY;
return nonseekable_open(inode, file);
return stream_open(inode, file);

default:
return -ENXIO;
Expand Down
2 changes: 1 addition & 1 deletion drivers/char/ipmi/ipmi_watchdog.c
Original file line number Diff line number Diff line change
Expand Up @@ -837,7 +837,7 @@ static int ipmi_open(struct inode *ino, struct file *filep)
* first heartbeat.
*/
ipmi_start_timer_on_heartbeat = 1;
return nonseekable_open(ino, filep);
return stream_open(ino, filep);

default:
return (-ENODEV);
Expand Down
2 changes: 1 addition & 1 deletion drivers/char/pcmcia/cm4000_cs.c
Original file line number Diff line number Diff line change
Expand Up @@ -1682,7 +1682,7 @@ static int cmm_open(struct inode *inode, struct file *filp)
link->open = 1; /* only one open per device */

DEBUGP(2, dev, "<- cmm_open\n");
ret = nonseekable_open(inode, filp);
ret = stream_open(inode, filp);
out:
mutex_unlock(&cmm_mutex);
return ret;
Expand Down
2 changes: 1 addition & 1 deletion drivers/char/pcmcia/scr24x_cs.c
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ static int scr24x_open(struct inode *inode, struct file *filp)
kref_get(&dev->refcnt);
filp->private_data = dev;

return nonseekable_open(inode, filp);
return stream_open(inode, filp);
}

static int scr24x_release(struct inode *inode, struct file *filp)
Expand Down
2 changes: 1 addition & 1 deletion drivers/char/tb0219.c
Original file line number Diff line number Diff line change
Expand Up @@ -243,7 +243,7 @@ static int tanbac_tb0219_open(struct inode *inode, struct file *file)
case 16 ... 23:
case 32 ... 39:
case 48 ... 55:
return nonseekable_open(inode, file);
return stream_open(inode, file);
default:
break;
}
Expand Down
2 changes: 1 addition & 1 deletion drivers/firewire/nosy.c
Original file line number Diff line number Diff line change
Expand Up @@ -303,7 +303,7 @@ nosy_open(struct inode *inode, struct file *file)

file->private_data = client;

return nonseekable_open(inode, file);
return stream_open(inode, file);
fail:
kfree(client);
lynx_put(lynx);
Expand Down
2 changes: 1 addition & 1 deletion drivers/gnss/core.c
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ static int gnss_open(struct inode *inode, struct file *file)

get_device(&gdev->dev);

nonseekable_open(inode, file);
stream_open(inode, file);
file->private_data = gdev;

down_write(&gdev->rwsem);
Expand Down
2 changes: 1 addition & 1 deletion drivers/hid/uhid.c
Original file line number Diff line number Diff line change
Expand Up @@ -632,7 +632,7 @@ static int uhid_char_open(struct inode *inode, struct file *file)
INIT_WORK(&uhid->worker, uhid_device_add_worker);

file->private_data = uhid;
nonseekable_open(inode, file);
stream_open(inode, file);

return 0;
}
Expand Down
2 changes: 1 addition & 1 deletion drivers/hwmon/fschmd.c
Original file line number Diff line number Diff line change
Expand Up @@ -837,7 +837,7 @@ static int watchdog_open(struct inode *inode, struct file *filp)
watchdog_trigger(data);
filp->private_data = data;

return nonseekable_open(inode, filp);
return stream_open(inode, filp);
}

static int watchdog_release(struct inode *inode, struct file *filp)
Expand Down
2 changes: 1 addition & 1 deletion drivers/hwmon/w83793.c
Original file line number Diff line number Diff line change
Expand Up @@ -1341,7 +1341,7 @@ static int watchdog_open(struct inode *inode, struct file *filp)
/* Store pointer to data into filp's private data */
filp->private_data = data;

return nonseekable_open(inode, filp);
return stream_open(inode, filp);
}

static int watchdog_close(struct inode *inode, struct file *filp)
Expand Down
2 changes: 1 addition & 1 deletion drivers/infiniband/core/ucm.c
Original file line number Diff line number Diff line change
Expand Up @@ -1175,7 +1175,7 @@ static int ib_ucm_open(struct inode *inode, struct file *filp)
file->filp = filp;
file->device = container_of(inode->i_cdev, struct ib_ucm_device, cdev);

return nonseekable_open(inode, filp);
return stream_open(inode, filp);
}

static int ib_ucm_close(struct inode *inode, struct file *filp)
Expand Down
2 changes: 1 addition & 1 deletion drivers/infiniband/core/ucma.c
Original file line number Diff line number Diff line change
Expand Up @@ -1744,7 +1744,7 @@ static int ucma_open(struct inode *inode, struct file *filp)
filp->private_data = file;
file->filp = filp;

return nonseekable_open(inode, filp);
return stream_open(inode, filp);
}

static int ucma_close(struct inode *inode, struct file *filp)
Expand Down
2 changes: 1 addition & 1 deletion drivers/infiniband/core/user_mad.c
Original file line number Diff line number Diff line change
Expand Up @@ -985,7 +985,7 @@ static int ib_umad_open(struct inode *inode, struct file *filp)

list_add_tail(&file->port_list, &port->file_list);

nonseekable_open(inode, filp);
stream_open(inode, filp);
out:
mutex_unlock(&port->file_mutex);
return ret;
Expand Down
2 changes: 1 addition & 1 deletion drivers/infiniband/core/uverbs_main.c
Original file line number Diff line number Diff line change
Expand Up @@ -1132,7 +1132,7 @@ static int ib_uverbs_open(struct inode *inode, struct file *filp)

setup_ufile_idr_uobject(file);

return nonseekable_open(inode, filp);
return stream_open(inode, filp);

err_module:
module_put(ib_dev->owner);
Expand Down
2 changes: 1 addition & 1 deletion drivers/input/evdev.c
Original file line number Diff line number Diff line change
Expand Up @@ -524,7 +524,7 @@ static int evdev_open(struct inode *inode, struct file *file)
goto err_free_client;

file->private_data = client;
nonseekable_open(inode, file);
stream_open(inode, file);

return 0;

Expand Down
2 changes: 1 addition & 1 deletion drivers/input/joydev.c
Original file line number Diff line number Diff line change
Expand Up @@ -279,7 +279,7 @@ static int joydev_open(struct inode *inode, struct file *file)
goto err_free_client;

file->private_data = client;
nonseekable_open(inode, file);
stream_open(inode, file);

return 0;

Expand Down
2 changes: 1 addition & 1 deletion drivers/input/misc/uinput.c
Original file line number Diff line number Diff line change
Expand Up @@ -398,7 +398,7 @@ static int uinput_open(struct inode *inode, struct file *file)
newdev->state = UIST_NEW_DEVICE;

file->private_data = newdev;
nonseekable_open(inode, file);
stream_open(inode, file);

return 0;
}
Expand Down
2 changes: 1 addition & 1 deletion drivers/isdn/capi/capi.c
Original file line number Diff line number Diff line change
Expand Up @@ -960,7 +960,7 @@ static int capi_open(struct inode *inode, struct file *file)
list_add_tail(&cdev->list, &capidev_list);
mutex_unlock(&capidev_list_lock);

return nonseekable_open(inode, file);
return stream_open(inode, file);
}

static int capi_release(struct inode *inode, struct file *file)
Expand Down
2 changes: 1 addition & 1 deletion drivers/leds/uleds.c
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ static int uleds_open(struct inode *inode, struct file *file)
udev->state = ULEDS_STATE_UNKNOWN;

file->private_data = udev;
nonseekable_open(inode, file);
stream_open(inode, file);

return 0;
}
Expand Down
2 changes: 1 addition & 1 deletion drivers/media/rc/lirc_dev.c
Original file line number Diff line number Diff line change
Expand Up @@ -195,7 +195,7 @@ static int ir_lirc_open(struct inode *inode, struct file *file)
list_add(&fh->list, &dev->lirc_fh);
spin_unlock_irqrestore(&dev->lirc_fh_lock, flags);

nonseekable_open(inode, file);
stream_open(inode, file);

return 0;
out_kfifo:
Expand Down
2 changes: 1 addition & 1 deletion drivers/pci/switch/switchtec.c
Original file line number Diff line number Diff line change
Expand Up @@ -390,7 +390,7 @@ static int switchtec_dev_open(struct inode *inode, struct file *filp)
return PTR_ERR(stuser);

filp->private_data = stuser;
nonseekable_open(inode, filp);
stream_open(inode, filp);

dev_dbg(&stdev->dev, "%s: %p\n", __func__, stuser);

Expand Down
2 changes: 1 addition & 1 deletion drivers/platform/chrome/cros_ec_debugfs.c
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,7 @@ static int cros_ec_console_log_open(struct inode *inode, struct file *file)
{
file->private_data = inode->i_private;

return nonseekable_open(inode, file);
return stream_open(inode, file);
}

static ssize_t cros_ec_console_log_read(struct file *file, char __user *buf,
Expand Down
2 changes: 1 addition & 1 deletion drivers/rtc/rtc-ds1374.c
Original file line number Diff line number Diff line change
Expand Up @@ -467,7 +467,7 @@ static int ds1374_wdt_open(struct inode *inode, struct file *file)
*/
wdt_is_open = 1;
mutex_unlock(&ds1374->mutex);
return nonseekable_open(inode, file);
return stream_open(inode, file);
}
return -ENODEV;
}
Expand Down
2 changes: 1 addition & 1 deletion drivers/rtc/rtc-m41t80.c
Original file line number Diff line number Diff line change
Expand Up @@ -802,7 +802,7 @@ static int wdt_open(struct inode *inode, struct file *file)
*/
wdt_is_open = 1;
mutex_unlock(&m41t80_rtc_mutex);
return nonseekable_open(inode, file);
return stream_open(inode, file);
}
return -ENODEV;
}
Expand Down
2 changes: 1 addition & 1 deletion drivers/s390/char/fs3270.c
Original file line number Diff line number Diff line change
Expand Up @@ -486,7 +486,7 @@ fs3270_open(struct inode *inode, struct file *filp)
raw3270_del_view(&fp->view);
goto out;
}
nonseekable_open(inode, filp);
stream_open(inode, filp);
filp->private_data = fp;
out:
mutex_unlock(&fs3270_mutex);
Expand Down
2 changes: 1 addition & 1 deletion drivers/s390/char/tape_char.c
Original file line number Diff line number Diff line change
Expand Up @@ -290,7 +290,7 @@ tapechar_open (struct inode *inode, struct file *filp)
rc = tape_open(device);
if (rc == 0) {
filp->private_data = device;
nonseekable_open(inode, filp);
stream_open(inode, filp);
} else
tape_put_device(device);

Expand Down
2 changes: 1 addition & 1 deletion drivers/s390/char/zcore.c
Original file line number Diff line number Diff line change
Expand Up @@ -191,7 +191,7 @@ static ssize_t zcore_reipl_write(struct file *filp, const char __user *buf,

static int zcore_reipl_open(struct inode *inode, struct file *filp)
{
return nonseekable_open(inode, filp);
return stream_open(inode, filp);
}

static int zcore_reipl_release(struct inode *inode, struct file *filp)
Expand Down
2 changes: 1 addition & 1 deletion drivers/s390/crypto/zcrypt_api.c
Original file line number Diff line number Diff line change
Expand Up @@ -525,7 +525,7 @@ static int zcrypt_open(struct inode *inode, struct file *filp)
filp->private_data = (void *) perms;

atomic_inc(&zcrypt_open_count);
return nonseekable_open(inode, filp);
return stream_open(inode, filp);
}

/**
Expand Down
2 changes: 1 addition & 1 deletion drivers/spi/spidev.c
Original file line number Diff line number Diff line change
Expand Up @@ -593,7 +593,7 @@ static int spidev_open(struct inode *inode, struct file *filp)

spidev->users++;
filp->private_data = spidev;
nonseekable_open(inode, filp);
stream_open(inode, filp);

mutex_unlock(&device_list_lock);
return 0;
Expand Down
2 changes: 1 addition & 1 deletion drivers/staging/pi433/pi433_if.c
Original file line number Diff line number Diff line change
Expand Up @@ -971,7 +971,7 @@ static int pi433_open(struct inode *inode, struct file *filp)

/* instance data as context */
filp->private_data = instance;
nonseekable_open(inode, filp);
stream_open(inode, filp);

return 0;
}
Expand Down
2 changes: 1 addition & 1 deletion drivers/usb/misc/ldusb.c
Original file line number Diff line number Diff line change
Expand Up @@ -307,7 +307,7 @@ static int ld_usb_open(struct inode *inode, struct file *file)
int retval;
struct usb_interface *interface;

nonseekable_open(inode, file);
stream_open(inode, file);
subminor = iminor(inode);

interface = usb_find_interface(&ld_usb_driver, subminor);
Expand Down
2 changes: 1 addition & 1 deletion drivers/watchdog/acquirewdt.c
Original file line number Diff line number Diff line change
Expand Up @@ -200,7 +200,7 @@ static int acq_open(struct inode *inode, struct file *file)

/* Activate */
acq_keepalive();
return nonseekable_open(inode, file);
return stream_open(inode, file);
}

static int acq_close(struct inode *inode, struct file *file)
Expand Down
2 changes: 1 addition & 1 deletion drivers/watchdog/advantechwdt.c
Original file line number Diff line number Diff line change
Expand Up @@ -199,7 +199,7 @@ static int advwdt_open(struct inode *inode, struct file *file)
*/

advwdt_ping();
return nonseekable_open(inode, file);
return stream_open(inode, file);
}

static int advwdt_close(struct inode *inode, struct file *file)
Expand Down
2 changes: 1 addition & 1 deletion drivers/watchdog/alim1535_wdt.c
Original file line number Diff line number Diff line change
Expand Up @@ -249,7 +249,7 @@ static int ali_open(struct inode *inode, struct file *file)

/* Activate */
ali_start();
return nonseekable_open(inode, file);
return stream_open(inode, file);
}

/*
Expand Down
2 changes: 1 addition & 1 deletion drivers/watchdog/alim7101_wdt.c
Original file line number Diff line number Diff line change
Expand Up @@ -214,7 +214,7 @@ static int fop_open(struct inode *inode, struct file *file)
return -EBUSY;
/* Good, fire up the show */
wdt_startup();
return nonseekable_open(inode, file);
return stream_open(inode, file);
}

static int fop_close(struct inode *inode, struct file *file)
Expand Down
2 changes: 1 addition & 1 deletion drivers/watchdog/ar7_wdt.c
Original file line number Diff line number Diff line change
Expand Up @@ -163,7 +163,7 @@ static int ar7_wdt_open(struct inode *inode, struct file *file)
ar7_wdt_enable_wdt();
expect_close = 0;

return nonseekable_open(inode, file);
return stream_open(inode, file);
}

static int ar7_wdt_release(struct inode *inode, struct file *file)
Expand Down
2 changes: 1 addition & 1 deletion drivers/watchdog/at91rm9200_wdt.c
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,7 @@ static int at91_wdt_open(struct inode *inode, struct file *file)
return -EBUSY;

at91_wdt_start();
return nonseekable_open(inode, file);
return stream_open(inode, file);
}

/*
Expand Down
2 changes: 1 addition & 1 deletion drivers/watchdog/ath79_wdt.c
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,7 @@ static int ath79_wdt_open(struct inode *inode, struct file *file)
clear_bit(WDT_FLAGS_EXPECT_CLOSE, &wdt_flags);
ath79_wdt_enable();

return nonseekable_open(inode, file);
return stream_open(inode, file);
}

static int ath79_wdt_release(struct inode *inode, struct file *file)
Expand Down
Loading

0 comments on commit 41bc10c

Please sign in to comment.