Skip to content

Commit

Permalink
block: remove __blkdev_driver_ioctl
Browse files Browse the repository at this point in the history
Just open code it in the few callers.

Signed-off-by: Christoph Hellwig <[email protected]>
Signed-off-by: Jens Axboe <[email protected]>
  • Loading branch information
Christoph Hellwig authored and axboe committed Nov 16, 2020
1 parent 98f49b6 commit a7cb3d2
Show file tree
Hide file tree
Showing 5 changed files with 16 additions and 27 deletions.
25 changes: 5 additions & 20 deletions block/ioctl.c
Original file line number Diff line number Diff line change
Expand Up @@ -219,23 +219,6 @@ static int compat_put_ulong(compat_ulong_t __user *argp, compat_ulong_t val)
}
#endif

int __blkdev_driver_ioctl(struct block_device *bdev, fmode_t mode,
unsigned cmd, unsigned long arg)
{
struct gendisk *disk = bdev->bd_disk;

if (disk->fops->ioctl)
return disk->fops->ioctl(bdev, mode, cmd, arg);

return -ENOTTY;
}
/*
* For the record: _GPL here is only because somebody decided to slap it
* on the previous export. Sheer idiocy, since it wasn't copyrightable
* at all and could be open-coded without any exports by anybody who cares.
*/
EXPORT_SYMBOL_GPL(__blkdev_driver_ioctl);

#ifdef CONFIG_COMPAT
/*
* This is the equivalent of compat_ptr_ioctl(), to be used by block
Expand Down Expand Up @@ -594,10 +577,12 @@ int blkdev_ioctl(struct block_device *bdev, fmode_t mode, unsigned cmd,
}

ret = blkdev_common_ioctl(bdev, mode, cmd, arg, argp);
if (ret == -ENOIOCTLCMD)
return __blkdev_driver_ioctl(bdev, mode, cmd, arg);
if (ret != -ENOIOCTLCMD)
return ret;

return ret;
if (!bdev->bd_disk->fops->ioctl)
return -ENOTTY;
return bdev->bd_disk->fops->ioctl(bdev, mode, cmd, arg);
}
EXPORT_SYMBOL_GPL(blkdev_ioctl); /* for /dev/raw */

Expand Down
6 changes: 4 additions & 2 deletions drivers/block/pktcdvd.c
Original file line number Diff line number Diff line change
Expand Up @@ -2584,9 +2584,11 @@ static int pkt_ioctl(struct block_device *bdev, fmode_t mode, unsigned int cmd,
case CDROM_LAST_WRITTEN:
case CDROM_SEND_PACKET:
case SCSI_IOCTL_SEND_COMMAND:
ret = __blkdev_driver_ioctl(pd->bdev, mode, cmd, arg);
if (!bdev->bd_disk->fops->ioctl)
ret = -ENOTTY;
else
ret = bdev->bd_disk->fops->ioctl(bdev, mode, cmd, arg);
break;

default:
pkt_dbg(2, pd, "Unknown ioctl (%x)\n", cmd);
ret = -ENOTTY;
Expand Down
5 changes: 3 additions & 2 deletions drivers/md/bcache/request.c
Original file line number Diff line number Diff line change
Expand Up @@ -1230,8 +1230,9 @@ static int cached_dev_ioctl(struct bcache_device *d, fmode_t mode,

if (dc->io_disable)
return -EIO;

return __blkdev_driver_ioctl(dc->bdev, mode, cmd, arg);
if (!dc->bdev->bd_disk->fops->ioctl)
return -ENOTTY;
return dc->bdev->bd_disk->fops->ioctl(dc->bdev, mode, cmd, arg);
}

void bch_cached_dev_request_init(struct cached_dev *dc)
Expand Down
5 changes: 4 additions & 1 deletion drivers/md/dm.c
Original file line number Diff line number Diff line change
Expand Up @@ -570,7 +570,10 @@ static int dm_blk_ioctl(struct block_device *bdev, fmode_t mode,
}
}

r = __blkdev_driver_ioctl(bdev, mode, cmd, arg);
if (!bdev->bd_disk->fops->ioctl)
r = -ENOTTY;
else
r = bdev->bd_disk->fops->ioctl(bdev, mode, cmd, arg);
out:
dm_unprepare_ioctl(md, srcu_idx);
return r;
Expand Down
2 changes: 0 additions & 2 deletions include/linux/blkdev.h
Original file line number Diff line number Diff line change
Expand Up @@ -1867,8 +1867,6 @@ extern int blkdev_compat_ptr_ioctl(struct block_device *, fmode_t,
#define blkdev_compat_ptr_ioctl NULL
#endif

extern int __blkdev_driver_ioctl(struct block_device *, fmode_t, unsigned int,
unsigned long);
extern int bdev_read_page(struct block_device *, sector_t, struct page *);
extern int bdev_write_page(struct block_device *, sector_t, struct page *,
struct writeback_control *);
Expand Down

0 comments on commit a7cb3d2

Please sign in to comment.