Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

nvme: merge nvme_ns_ioctl into nvme_ioctl

Merge the two functions to make future changes a little easier.

Signed-off-by: Christoph Hellwig <hch@lst.de>
Reviewed-by: Keith Busch <keith.busch@intel.com>
Reviewed-by: Chaitanya Kulkarni <chaitanya.kulkarni@wdc.com>

authored by

Christoph Hellwig and committed by
Keith Busch
90ec611a 3f98bcc5

+24 -23
+24 -23
drivers/nvme/host/core.c
··· 1382 1382 srcu_read_unlock(&head->srcu, idx); 1383 1383 } 1384 1384 1385 - static int nvme_ns_ioctl(struct nvme_ns *ns, unsigned cmd, unsigned long arg) 1386 - { 1387 - switch (cmd) { 1388 - case NVME_IOCTL_ID: 1389 - force_successful_syscall_return(); 1390 - return ns->head->ns_id; 1391 - case NVME_IOCTL_ADMIN_CMD: 1392 - return nvme_user_cmd(ns->ctrl, NULL, (void __user *)arg); 1393 - case NVME_IOCTL_IO_CMD: 1394 - return nvme_user_cmd(ns->ctrl, ns, (void __user *)arg); 1395 - case NVME_IOCTL_SUBMIT_IO: 1396 - return nvme_submit_io(ns, (void __user *)arg); 1397 - default: 1398 - if (ns->ndev) 1399 - return nvme_nvm_ioctl(ns, cmd, arg); 1400 - if (is_sed_ioctl(cmd)) 1401 - return sed_ioctl(ns->ctrl->opal_dev, cmd, 1402 - (void __user *) arg); 1403 - return -ENOTTY; 1404 - } 1405 - } 1406 - 1407 1385 static int nvme_ioctl(struct block_device *bdev, fmode_t mode, 1408 1386 unsigned int cmd, unsigned long arg) 1409 1387 { 1410 1388 struct nvme_ns_head *head = NULL; 1389 + void __user *argp = (void __user *)arg; 1411 1390 struct nvme_ns *ns; 1412 1391 int srcu_idx, ret; 1413 1392 ··· 1394 1415 if (unlikely(!ns)) 1395 1416 return -EWOULDBLOCK; 1396 1417 1397 - ret = nvme_ns_ioctl(ns, cmd, arg); 1418 + switch (cmd) { 1419 + case NVME_IOCTL_ID: 1420 + force_successful_syscall_return(); 1421 + ret = ns->head->ns_id; 1422 + break; 1423 + case NVME_IOCTL_ADMIN_CMD: 1424 + ret = nvme_user_cmd(ns->ctrl, NULL, argp); 1425 + break; 1426 + case NVME_IOCTL_IO_CMD: 1427 + ret = nvme_user_cmd(ns->ctrl, ns, argp); 1428 + break; 1429 + case NVME_IOCTL_SUBMIT_IO: 1430 + ret = nvme_submit_io(ns, argp); 1431 + break; 1432 + default: 1433 + if (ns->ndev) 1434 + ret = nvme_nvm_ioctl(ns, cmd, arg); 1435 + else if (is_sed_ioctl(cmd)) 1436 + ret = sed_ioctl(ns->ctrl->opal_dev, cmd, argp); 1437 + else 1438 + ret = -ENOTTY; 1439 + } 1440 + 1398 1441 nvme_put_ns_from_disk(head, srcu_idx); 1399 1442 return ret; 1400 1443 }