From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-15.5 required=3.0 tests=BAYES_00,INCLUDES_CR_TRAILER, INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,USER_AGENT_SANE_2 autolearn=unavailable autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 9DD63C433B4 for ; Sat, 8 May 2021 15:15:49 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 72DC36141F for ; Sat, 8 May 2021 15:15:49 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229552AbhEHPQt (ORCPT ); Sat, 8 May 2021 11:16:49 -0400 Received: from mail.kernel.org ([198.145.29.99]:51762 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229500AbhEHPQt (ORCPT ); Sat, 8 May 2021 11:16:49 -0400 Received: from jic23-huawei (cpc108967-cmbg20-2-0-cust86.5-4.cable.virginm.net [81.101.6.87]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 5A0B2613F2; Sat, 8 May 2021 15:15:45 +0000 (UTC) Date: Sat, 8 May 2021 16:16:43 +0100 From: Jonathan Cameron To: Alexandru Ardelean Cc: linux-iio@vger.kernel.org, linux-kernel@vger.kernel.org, lars@metafoo.de, Linus Walleij , Paul Cercueil , Nuno Sa Subject: Re: [PATCH] iio: core: return ENODEV if ioctl is unknown Message-ID: <20210508161643.5990ec15@jic23-huawei> In-Reply-To: <20210503144350.7496-1-aardelean@deviqon.com> References: <20210503144350.7496-1-aardelean@deviqon.com> X-Mailer: Claws Mail 3.17.8 (GTK+ 2.24.33; x86_64-pc-linux-gnu) MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit Precedence: bulk List-ID: X-Mailing-List: linux-iio@vger.kernel.org On Mon, 3 May 2021 17:43:50 +0300 Alexandru Ardelean wrote: > When the ioctl() mechanism was introduced in IIO core to centralize the > registration of all ioctls in one place via commit 8dedcc3eee3ac ("iio: > core: centralize ioctl() calls to the main chardev"), the return code was > changed from ENODEV to EINVAL, when the ioctl code isn't known. > > This was done by accident. > > This change reverts back to the old behavior, where if the ioctl() code > isn't known, ENODEV is returned (vs EINVAL). > > This was brought into perspective by this patch: > https://lore.kernel.org/linux-iio/20210428150815.136150-1-paul@crapouillou.net/ > > Fixes: 8dedcc3eee3ac ("iio: core: centralize ioctl() calls to the main chardev") > Cc: Linus Walleij > Cc: Paul Cercueil > Cc: Nuno Sa > Signed-off-by: Alexandru Ardelean This is going to be a little messy to apply as lots of churn in that file. What I've done for now is pulled the fixes-togreg branch forwards onto current staging/staging-linus but I'll do that again after staging/staging-linus moves onto an rc1 or similar base. Anyhow, applied to that tree which is going to have more than it's normal share of rebases this cycle. Thanks, Jonathan > --- > drivers/iio/industrialio-core.c | 3 +-- > 1 file changed, 1 insertion(+), 2 deletions(-) > > diff --git a/drivers/iio/industrialio-core.c b/drivers/iio/industrialio-core.c > index efb4cf91c9e4..9a3a83211a90 100644 > --- a/drivers/iio/industrialio-core.c > +++ b/drivers/iio/industrialio-core.c > @@ -1803,7 +1803,6 @@ static long iio_ioctl(struct file *filp, unsigned int cmd, unsigned long arg) > if (!indio_dev->info) > goto out_unlock; > > - ret = -EINVAL; > list_for_each_entry(h, &iio_dev_opaque->ioctl_handlers, entry) { > ret = h->ioctl(indio_dev, filp, cmd, arg); > if (ret != IIO_IOCTL_UNHANDLED) > @@ -1811,7 +1810,7 @@ static long iio_ioctl(struct file *filp, unsigned int cmd, unsigned long arg) > } > > if (ret == IIO_IOCTL_UNHANDLED) > - ret = -EINVAL; > + ret = -ENODEV; > > out_unlock: > mutex_unlock(&iio_dev_opaque->info_exist_lock);