diff mbox

mtd: blktrans: use better error code for unimplemented ioctl()

Message ID 20150521175431.GC11598@ld-irv-0074
State Accepted
Commit c4a3f13c2ab997617eaf7020af33b057a68285fd
Headers show

Commit Message

Brian Norris May 21, 2015, 5:54 p.m. UTC
In commit 50183936254b ("mtd: blktrans: change blktrans_getgeo return
value") we fixed the problem that ioctl(HDIO_GETGEO) might return 0
(success) for mtdblock devices which did not implement the feature and
would leave a blank (zero) result.

But now, let's get the error code right. Other code paths on this ioctl
tend to use -ENOTTY to notify the user that the ioctl() is not supported
for the device, so let's use that instead of -EOPNOTSUPP.

Suggested-by: Richard Weinberger <richard@nod.at>
Signed-off-by: Brian Norris <computersforpeace@gmail.com>
---
Against l2-mtd.git (linux-next)

 drivers/mtd/mtd_blkdevs.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

Comments

Brian Norris May 27, 2015, 7:15 p.m. UTC | #1
On Thu, May 21, 2015 at 10:54:31AM -0700, Brian Norris wrote:
> In commit 50183936254b ("mtd: blktrans: change blktrans_getgeo return
> value") we fixed the problem that ioctl(HDIO_GETGEO) might return 0
> (success) for mtdblock devices which did not implement the feature and
> would leave a blank (zero) result.
> 
> But now, let's get the error code right. Other code paths on this ioctl
> tend to use -ENOTTY to notify the user that the ioctl() is not supported
> for the device, so let's use that instead of -EOPNOTSUPP.
> 
> Suggested-by: Richard Weinberger <richard@nod.at>
> Signed-off-by: Brian Norris <computersforpeace@gmail.com>
> ---
> Against l2-mtd.git (linux-next)

Applied.
diff mbox

Patch

diff --git a/drivers/mtd/mtd_blkdevs.c b/drivers/mtd/mtd_blkdevs.c
index c545c9325acf..41acc507b22e 100644
--- a/drivers/mtd/mtd_blkdevs.c
+++ b/drivers/mtd/mtd_blkdevs.c
@@ -278,7 +278,7 @@  static int blktrans_getgeo(struct block_device *bdev, struct hd_geometry *geo)
 	if (!dev->mtd)
 		goto unlock;
 
-	ret = dev->tr->getgeo ? dev->tr->getgeo(dev, geo) : -EOPNOTSUPP;
+	ret = dev->tr->getgeo ? dev->tr->getgeo(dev, geo) : -ENOTTY;
 unlock:
 	mutex_unlock(&dev->lock);
 	blktrans_dev_put(dev);