Received: by 2002:a25:8b12:0:0:0:0:0 with SMTP id i18csp5237894ybl; Tue, 27 Aug 2019 01:19:58 -0700 (PDT) X-Google-Smtp-Source: APXvYqwxKWPeoRN3FrXx0iys2coCjq+CHYkrxD6Zvn8YqxUnQuymO5IkWS0AQbTtsY9W2zSZjgsq X-Received: by 2002:a17:90a:a610:: with SMTP id c16mr23211661pjq.54.1566893998803; Tue, 27 Aug 2019 01:19:58 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1566893998; cv=none; d=google.com; s=arc-20160816; b=iOEeSJwJ2TB0pVK+gF/319PxuVdnuK640ZTBAJa3jJDE2PIdLrspT4Eq86N3TC+g/+ g/CGhNGo1sFAdZquPgQxxYSHwfxdlqgCzSZddgTRIF1yUbGZQ9pXA4ZjSOdrvmXmrTao XAlWZ6KX56CWnGRxZqrXqd44VMZiSUermQEMBq5RVgHN0fas7Vk5tJbm0OZdQKa8Y8Se CYAGHETkWxn3TZ6FWrneU+nMciR0OJPwIaIWl4QuJ78t+gZeroHMdXa69ZIO/JM4Tfz+ dH5FmfjfBLzHhvzIgFZYRcHnAXbCE09sZyky7NfJexEf8o4GhgRumh6ntKM0cntHuBUh Fj+A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=3clar4dmPzsZk/Sv+vvEneDaoMR3HwBioABBU8fkVd4=; b=VXCbMCsNESgPzapCAzpYUier+SYTnxKNkTS1YfTqNtkyqy4sK4rV5jaEC1Tj0hi0Lp KcgTysuGNxk+nGmn61NnV0S2+eqyYxqqeUqp2rLoaAI1acCUCncYGEIB5rpkdQmJMSIj wfj4tm7paCrAY231Wu5B3RHqSft86QVMR4P0n4LwF0vb/k3D8O5spd8G4kcfweYm7Z0f +K4GwelZYnZRzTQenmvq3MmHMINB2mNKP1WJXUxffmVhMiL/LIUrv87ZmNkGHNdn42+q sV3ptY5GPqnyyIe2fb21s5RQvF0/dFCIbAysFIyJxEAUOxLiHoEREZyn5iPJemJ1/Bx/ TjpA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=HJDLeGJ9; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id n16si3055672pff.23.2019.08.27.01.19.43; Tue, 27 Aug 2019 01:19:58 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=HJDLeGJ9; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1730992AbfH0IQw (ORCPT + 99 others); Tue, 27 Aug 2019 04:16:52 -0400 Received: from mail.kernel.org ([198.145.29.99]:44842 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725811AbfH0HxX (ORCPT ); Tue, 27 Aug 2019 03:53:23 -0400 Received: from localhost (83-86-89-107.cable.dynamic.v4.ziggo.nl [83.86.89.107]) (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 71CD3206BA; Tue, 27 Aug 2019 07:53:22 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1566892403; bh=Jie4Z5NXgR+SZsUsabxqaQqBZME0D+RudUPlaEOqIY8=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=HJDLeGJ9vPvsM0M0kmxoLvzVNXFllYG1orTjOcbE79AkT6d/UU4rcTdgxwXlVRUaL VJ+GUFuPmCO/zhQuqIm7zbSv92j6N+9kanjsFrPLFcyHwASuHtW727SH6teyxChIhD n0EdQY64DvPSaKDUk8dxkpNs7Dpc2JhWJHqNAayc= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Bartosz Golaszewski , Linus Walleij Subject: [PATCH 4.14 42/62] gpiolib: never report open-drain/source lines as input to user-space Date: Tue, 27 Aug 2019 09:50:47 +0200 Message-Id: <20190827072703.032244937@linuxfoundation.org> X-Mailer: git-send-email 2.23.0 In-Reply-To: <20190827072659.803647352@linuxfoundation.org> References: <20190827072659.803647352@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Bartosz Golaszewski commit 2c60e6b5c9241b24b8b523fefd3e44fb85622cda upstream. If the driver doesn't support open-drain/source config options, we emulate this behavior when setting the direction by calling gpiod_direction_input() if the default value is 0 (open-source) or 1 (open-drain), thus not actively driving the line in those cases. This however clears the FLAG_IS_OUT bit for the GPIO line descriptor and makes the LINEINFO ioctl() incorrectly report this line's mode as 'input' to user-space. This commit modifies the ioctl() to always set the GPIOLINE_FLAG_IS_OUT bit in the lineinfo structure's flags field. Since it's impossible to use the input mode and open-drain/source options at the same time, we can be sure the reported information will be correct. Fixes: 521a2ad6f862 ("gpio: add userspace ABI for GPIO line information") Cc: stable Signed-off-by: Bartosz Golaszewski Link: https://lore.kernel.org/r/20190806114151.17652-1-brgl@bgdev.pl Signed-off-by: Linus Walleij Signed-off-by: Greg Kroah-Hartman --- drivers/gpio/gpiolib.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) --- a/drivers/gpio/gpiolib.c +++ b/drivers/gpio/gpiolib.c @@ -971,9 +971,11 @@ static long gpio_ioctl(struct file *filp if (test_bit(FLAG_ACTIVE_LOW, &desc->flags)) lineinfo.flags |= GPIOLINE_FLAG_ACTIVE_LOW; if (test_bit(FLAG_OPEN_DRAIN, &desc->flags)) - lineinfo.flags |= GPIOLINE_FLAG_OPEN_DRAIN; + lineinfo.flags |= (GPIOLINE_FLAG_OPEN_DRAIN | + GPIOLINE_FLAG_IS_OUT); if (test_bit(FLAG_OPEN_SOURCE, &desc->flags)) - lineinfo.flags |= GPIOLINE_FLAG_OPEN_SOURCE; + lineinfo.flags |= (GPIOLINE_FLAG_OPEN_SOURCE | + GPIOLINE_FLAG_IS_OUT); if (copy_to_user(ip, &lineinfo, sizeof(lineinfo))) return -EFAULT;