From patchwork Wed May 29 10:13:42 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ard Biesheuvel X-Patchwork-Id: 165370 Delivered-To: patch@linaro.org Received: by 2002:a92:9e1a:0:0:0:0:0 with SMTP id q26csp9672649ili; Wed, 29 May 2019 03:14:05 -0700 (PDT) X-Google-Smtp-Source: APXvYqwSOcrRALJi3sNxskMjAtsnjI7As+ZPJT/wNWtxzvtSpbhCG6QkoSSXoJbj+w8MdqZphkZm X-Received: by 2002:a17:902:a508:: with SMTP id s8mr120166127plq.186.1559124844936; Wed, 29 May 2019 03:14:04 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1559124844; cv=none; d=google.com; s=arc-20160816; b=RipyBylgudmrQsaWBhk2M23ksZvkrMALxo8oJ4wd+yChJN6SSOjJc5cu8hV5PhhfIW jdQo3QvhtnD+3gzyY/I486HrLtHd7Zj4WW2A0v+dgnuR0+75PseMNNlLu0bx1aHClHTF yRglpVs6ZAFwPJAyigU+vval3pEBlUnWwAbNEgl06DoCDe4EkvtJQOWsGHigvqpvPxlR PwexghDEWi7liafT5Fe8sLvauJnkmI5+guqNdQ9U+K4a3icW7r7scGPFKfeUnXAIO35i wa073vanyzdcsr8olCNCOQZx35ORurq6J90iHAzPUkdv+fi8QWwgcMBw/ys3sudYCOyk h46A== 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 :message-id:date:subject:cc:to:from:dkim-signature; bh=l67SUiLhnHbZC+GGf53I8mLvwJKgD1LNbRPrFrC0N7s=; b=c5JVZio6zfgZl18Y6FNOVLYCmDt/M+Qd1zhMQ+3mYKz1EGR3z+lQG//oogjS4pellZ pg1ZKrcWaT3nVEoooQPv5UQ7mZTffzhTH8LCQIPMWY4MkwMDJ+X8v3I/v7nuwPSQLg7o Nrk1yrF4PuURsDxWSRAuWQ3x39dxR7XVcTk+zadA3p6GELu+YZDhiI18APJRO46q0Vky u9bCm4NsERxhfHZ9gsaVlJzVRnxZqQ+tgfd3CyFFSkuZkgWSdwJVAB/Jh61Rs92XQbXJ iuCPkocWOSceL7USz7Ex8oz3psr8ZIQWgUwyu9WELHECOhxXsWp5cN1VuV5pQXYrfuZ3 SWig== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=DVai3SyH; spf=pass (google.com: best guess record for domain of linux-acpi-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-acpi-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id l27si23310979pgm.172.2019.05.29.03.14.04; Wed, 29 May 2019 03:14:04 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-acpi-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=@linaro.org header.s=google header.b=DVai3SyH; spf=pass (google.com: best guess record for domain of linux-acpi-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-acpi-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1725990AbfE2KOE (ORCPT + 9 others); Wed, 29 May 2019 06:14:04 -0400 Received: from mail-wr1-f65.google.com ([209.85.221.65]:35718 "EHLO mail-wr1-f65.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725874AbfE2KOE (ORCPT ); Wed, 29 May 2019 06:14:04 -0400 Received: by mail-wr1-f65.google.com with SMTP id m3so1334609wrv.2 for ; Wed, 29 May 2019 03:14:03 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=l67SUiLhnHbZC+GGf53I8mLvwJKgD1LNbRPrFrC0N7s=; b=DVai3SyHuj37o+9DQ9ge6eqxTqMJXJ1dPA/pexA/z3yFqx209mZbdR5Dv6CnhStwnX BUGJltoZAKQtmmPSCvH6oSiM6/I3ag9LVeyOJ1sfCYHTtb6Z7wNPHdVOT+XS9lso6mFs sG2Vl811ndRPbP8vtxe4BlAEMOx1lnv2wYE8SrLBX2G0ZwsSnM2nlpstISt9tbMdx82v u8XEH70Jd/36jB+mavgmK/MAPGxOOX6uvkSclphdbZhoV+A7lWmAryOCF4GHH5GONHkV 8k9CbnKk76/fLlrvaDUQanuzAg3WWFaDnbb5fZe7c642o4dHDGiOfSfMUfdG1CW1umcp 5+9w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=l67SUiLhnHbZC+GGf53I8mLvwJKgD1LNbRPrFrC0N7s=; b=OmtQdZxVglA3gnSRTDl0BWKSQlC1g1axaLZclLdhbKA7oXJSwUiqWOAJWVCG23QB92 Lw7zerPc9T8vmHkjVPmZ/hVHy6KLBRZZb1BNMNnuNrg16EhIMLrH44Qm75/lO0ecm6k0 jSCO6RVOwyueH52GTcgkdOA10jFgG2R124OmsqvTCXYyR7s3576+FeXPeOeemlyofzV1 Fb1NAKuBDjEaB7zI7HTE8qT1IplIl81OZ/gdQxSMiapKbP7pONmmGaQPAkZUaGE673iy ulYH+lHZpDSPngUWgayChq6e0U7T5Fsy35j5dS5Nhw0Dn5mGbCmvLnxttNvRneDhZvLQ GVrw== X-Gm-Message-State: APjAAAW8kj01SkyLhfdD1Ls74HRS764ZKe4lh7wdV7onZphIAZIgJJe7 mDjyHv0QrsJLgtTIz8XakiZpxQ== X-Received: by 2002:adf:db8e:: with SMTP id u14mr43828118wri.190.1559124842396; Wed, 29 May 2019 03:14:02 -0700 (PDT) Received: from sudo.home ([2a01:cb1d:112:6f00:c225:e9ff:fe2e:ea8]) by smtp.gmail.com with ESMTPSA id f18sm2028040wrt.21.2019.05.29.03.14.01 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 29 May 2019 03:14:01 -0700 (PDT) From: Ard Biesheuvel To: linux-gpio@vger.kernel.org Cc: linux-acpi@vger.kernel.org, mika.westerberg@linux.intel.com, andriy.shevchenko@linux.intel.com, linus.walleij@linaro.org, rjw@rjwysocki.net, jarkko.nikula@linux.intel.com, Ard Biesheuvel Subject: [RFC PATCH] gpio/acpi: set direction for ACPI OpRegion GPIOs Date: Wed, 29 May 2019 12:13:42 +0200 Message-Id: <20190529101342.30673-1-ard.biesheuvel@linaro.org> X-Mailer: git-send-email 2.20.1 MIME-Version: 1.0 Sender: linux-acpi-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-acpi@vger.kernel.org The ACPI GPIO OpRegion code never sets the direction for GPIOs that it configures from scratch, leaving unconfigured GPIOs to be left at the default direction, which is typically input not output. So set the direction and default value explicitly. Signed-off-by: Ard Biesheuvel --- drivers/gpio/gpiolib-acpi.c | 6 ++++++ 1 file changed, 6 insertions(+) -- 2.20.1 diff --git a/drivers/gpio/gpiolib-acpi.c b/drivers/gpio/gpiolib-acpi.c index c9fc9e232aaf..02a2bc7fe18b 100644 --- a/drivers/gpio/gpiolib-acpi.c +++ b/drivers/gpio/gpiolib-acpi.c @@ -966,6 +966,12 @@ acpi_gpio_adr_space_handler(u32 function, acpi_physical_address address, goto out; } + if (function == ACPI_WRITE) + gpiod_direction_output(desc, + !!((1 << i) & *value)); + else + gpiod_direction_input(desc); + conn->pin = pin; conn->desc = desc; list_add_tail(&conn->node, &achip->conns);