Received: by 2002:a05:6a10:206:0:0:0:0 with SMTP id 6csp45434pxj; Mon, 17 May 2021 20:29:55 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzUI1iH1GTsHcS6FWICEoIYmb52ANKXxBXC0Ue0my+oXqQ/hmLIxHdBmoVvy4lsJQH8eGUd X-Received: by 2002:a02:7110:: with SMTP id n16mr3220178jac.69.1621308594857; Mon, 17 May 2021 20:29:54 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1621308594; cv=none; d=google.com; s=arc-20160816; b=fs1K+TbJV5ZYZ3fw5etOZKmuNOnlVVGTdekEWYxkxpbnmoenWrPyfm1xeR9eH9EWPJ +D5Fm/cDSRWab8HTzT5RVkljDGCaUcBvoOUbCRYGYdHmAP7iXzyD8COsHb5ukPkBSiq8 tX3tFHbx2oRFV+RBWmzjpcP1k5jjyp6DP2DfgM9L8rMJDaRv5VDKfmWgN0undogKaFYD P5mwi88Pjl3864goOMK+JZ3fCl1qDjMsthP9q350rcx8G6aRQngrHZ/Ee7jSLhgtGaNh EU8eBj4p6SBUs4QfHHTIJY5eBOfiHQtuX75VLHYDBdQ5fGQqvQAqZcGfiL6nQMcdEBeH 1ygA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=MJaIzRhZ1gYRUyEDpGVWmqFrM9brap0ox+ym1fFOasI=; b=xEtehDxUG8mfjxF4VHGF1Lun30b4tnyZmA3pKWv26Kwtzfs5SNQFQmyxrytFJ3pMsU kqnMWhX8K87o07PSg3RdiuAOtCTZrDBIfu/TkQyn9R4yLFKsvn31eG4pC9gkQbBUYsWd 940aSOYl/u+V8PLU4zKm4+H4F1KjFM6sK/nZJbJMVJDurqxW7XHzQnOFXnhmRr8jmvGs 1JoRsYTdaDJmCx8eM08EyMw4l4v7EGrEG16IIuCBkq+xLOQY3nhGEpbkMjCVrPmjRkW/ xeEZLwY5mdCEFWRCr0h2cicAHlRHotobo8dxA0hGhD/GFOs1DcAHnU/3CKNM/9MJ4PD3 RNsQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b="MS/zySna"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id s16si18973794jas.113.2021.05.17.20.29.39; Mon, 17 May 2021 20:29:54 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b="MS/zySna"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S236247AbhEQOkV (ORCPT + 99 others); Mon, 17 May 2021 10:40:21 -0400 Received: from mail.kernel.org ([198.145.29.99]:60372 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S240544AbhEQOep (ORCPT ); Mon, 17 May 2021 10:34:45 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id 3D347613EC; Mon, 17 May 2021 14:16:49 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1621261009; bh=MIvY5FmrqMXuwwvYDoseKKYf9f7cpLAd6tgjeFexTCc=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=MS/zySna6EVMPz83U4udcrgjRwjfm1aIu1Fw9LsIR7Eakfj8SfPwxVjvUiZhcfkz9 CHRKatvFp2r0yfNiQ29XeVM0i+bstPHrfYQ/kHKzL8MJ5cJU7OcYG4R1Ho3ojNqpIH zz8d5S/yh506lS8+0e3zWp0tp7Bzn+phNmYxZLfw= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Alexandru Ardelean , =?UTF-8?q?Nuno=20S=C3=A1?= , Paul Cercueil , Linus Walleij , Jonathan Cameron , Sasha Levin Subject: [PATCH 5.12 289/363] iio: core: return ENODEV if ioctl is unknown Date: Mon, 17 May 2021 16:02:35 +0200 Message-Id: <20210517140312.374745966@linuxfoundation.org> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20210517140302.508966430@linuxfoundation.org> References: <20210517140302.508966430@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Alexandru Ardelean [ Upstream commit af0670b0bf1b116fd729b1b1011cf814bc34e12e ] 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") Signed-off-by: Alexandru Ardelean Reviewed-by: Nuno Sá Tested-by: Paul Cercueil Reviewed-by: Linus Walleij Signed-off-by: Jonathan Cameron Signed-off-by: Sasha Levin --- 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 7db761afa578..2050d341746b 100644 --- a/drivers/iio/industrialio-core.c +++ b/drivers/iio/industrialio-core.c @@ -1734,7 +1734,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) @@ -1742,7 +1741,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(&indio_dev->info_exist_lock); -- 2.30.2