From patchwork Sun Sep 24 14:56:21 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Linus Walleij X-Patchwork-Id: 114132 Delivered-To: patch@linaro.org Received: by 10.140.106.117 with SMTP id d108csp1645641qgf; Sun, 24 Sep 2017 08:02:11 -0700 (PDT) X-Received: by 10.84.232.199 with SMTP id x7mr4966887plm.191.1506265331836; Sun, 24 Sep 2017 08:02:11 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1506265331; cv=none; d=google.com; s=arc-20160816; b=TG2B14CHAi2qkbRBH9rSi3GKjgIs+zbl3pyxE9+Kex6gIGPIoVhFaN9ui5W6tO9GkB QxUuO0WZu15k2PjMD16wPj7cXd3d98e25I7IJEXyVza1bhX9FTZBrwArizSuwqlxd4jB /h8Emie/QyBFtK8Bya6C/jzUwmzP+PHYCgboKTuQVBrKXotPVTKmoQpym/w47ZULqe6o Gcuj1J1iYNFaLGFBbA0a0e/iHNzs4TCcSoMs1556L8s0W9yXTKjsTo0jltfSjbJCqa4R 0a9A1tUq4RMIvQ2F4x2MWGnEtU8i5GJb9/bywu0/vc0tRlV6na3pG/PgwQ7wAVrKl7O6 2Ykw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:message-id:date :subject:cc:to:from:dkim-signature:arc-authentication-results; bh=I0NEvmbxcWXA5okiDqqtuj9tm8T9ilhu7ty7iDdGUhA=; b=NKLOiMXlHjAB4iooTQ8YdRzMCHxpVZVsRsWTDE8svCzIn+oiJhbz94ItVxFia/azM5 em3fCx/UGc/g8vEItLGJ293NZzKQnvHLysYBL32SssfaRJVUOM1nBmnKhTd2kRmr6ziD jv9RmhjDj/UNlKBPJS2T1OcWTwk7pGqe/dffET9uOloFBFptzp8C6sAiSGC/265Cl5el TncyAlULVn0YpTGa8Rm/mBE+YOGNxAMcvJkSQEBe4F+9QE6AbG/SMuvim0D77N8G8GDN C3X49fdZkyh/xmIqTWvgYPfn1AOrCsvgnEm06+JD2WMDj8ybm3CK80fRINh6JFNBiHlj LGbQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=LOS6kKNZ; 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; 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 y7si2751784pgr.195.2017.09.24.08.02.11; Sun, 24 Sep 2017 08:02:11 -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=@linaro.org header.s=google header.b=LOS6kKNZ; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752677AbdIXPCJ (ORCPT + 26 others); Sun, 24 Sep 2017 11:02:09 -0400 Received: from mail-pg0-f45.google.com ([74.125.83.45]:53341 "EHLO mail-pg0-f45.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752591AbdIXPCI (ORCPT ); Sun, 24 Sep 2017 11:02:08 -0400 Received: by mail-pg0-f45.google.com with SMTP id j70so2723265pgc.10 for ; Sun, 24 Sep 2017 08:02:08 -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:in-reply-to:references; bh=I0NEvmbxcWXA5okiDqqtuj9tm8T9ilhu7ty7iDdGUhA=; b=LOS6kKNZLmmkya90eLpPL0wKT4r+X25Enx6ArhrlRdlnny7hVaUSSZLvGgpOLC+9bC icr4i2DBTUD+I+Bo8aY1CkWNL+cBdocbaWDNtEEQIviE/pPUnHqLp8GSYO6hXza2K+/R PJeN6XOnWoJkxWNc9QYPrQcLkbZOXEL89aH/E= 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:in-reply-to :references; bh=I0NEvmbxcWXA5okiDqqtuj9tm8T9ilhu7ty7iDdGUhA=; b=IORvTsgZ/Q6kh5IrnUtIuAgP8YXNgpgVfdJyXwlB7ZGy+pD1+e4Jmfz6E5omIRwRa/ /R7NNhGuwPqERNGqK0buJC6dxIDs7cls6HLQX5UEQLuet4d814diEIhXDCfDC1aaiBDV xBPl3c2Nkg3PO3tFsTVRy5086LcbfNFaRut3WvNzN73OfpHs8GYdhi3YYYz4pLiaOOWB oie8OqBMTGgBq13BrJqcw7HPTU5PChZU1IfOvv7GwNs8QaGSEvr703SyDz5HB8eDbktf 5z/kN3MsA/huV5uGZ9K+btbmlAuvA4znoFx3nv6MAdkQqH8zAsHdpojxKQ8A9+c8OIpa 5Dpg== X-Gm-Message-State: AHPjjUg9MgPDrMGIjFu+ysaRtW3c8YSyjogC9HhBDx2Ejj9IfVjBwU3u HAvbFHn3Jv48SGTqNMP9/vXiIQ== X-Google-Smtp-Source: AOwi7QBfiQx2z6+FjfQwqplh8ONEfdKGTjVz8zBFf45I4Fw7WvZBmoUk2MMWsQbRe9yGLlLQoIQCDQ== X-Received: by 10.84.131.74 with SMTP id 68mr4968870pld.227.1506265327650; Sun, 24 Sep 2017 08:02:07 -0700 (PDT) Received: from genomnajs.saswifi.com ([104.153.224.168]) by smtp.gmail.com with ESMTPSA id n83sm7386805pfi.163.2017.09.24.08.01.31 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Sun, 24 Sep 2017 08:02:07 -0700 (PDT) From: Linus Walleij To: MyungJoo Ham , Chanwoo Choi Cc: linux-kernel@vger.kernel.org, linux-gpio@vger.kernel.org, John Stultz , Mike Lockwood , Guenter Roeck , Linus Walleij Subject: [PATCH 7/8] extcon: gpio: Get connector type from device property Date: Sun, 24 Sep 2017 16:56:21 +0200 Message-Id: <20170924145622.4031-8-linus.walleij@linaro.org> X-Mailer: git-send-email 2.13.5 In-Reply-To: <20170924145622.4031-1-linus.walleij@linaro.org> References: <20170924145622.4031-1-linus.walleij@linaro.org> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org We do not use the "EXTCON_NONE" type to report this as before, use the connector type defined in the device property, from device tree or ACPI DSDT. Signed-off-by: Linus Walleij --- drivers/extcon/extcon-gpio.c | 21 ++++++++++++++------- 1 file changed, 14 insertions(+), 7 deletions(-) -- 2.13.5 diff --git a/drivers/extcon/extcon-gpio.c b/drivers/extcon/extcon-gpio.c index 8fc52631c8a2..b7353f5018b5 100644 --- a/drivers/extcon/extcon-gpio.c +++ b/drivers/extcon/extcon-gpio.c @@ -35,7 +35,8 @@ * @debounce_jiffies: Number of jiffies to wait for the GPIO to stabilize, from the debounce * value. * @gpiod: GPIO descriptor for this external connector. - * @extcon_id: The unique id of specific external connector. + * @connector_type: The connector type we're detecting on this extcon, terminated with EXTCON_NONE + * One GPIO is one cable, so one type only. * @check_on_resume: Boolean describing whether to check the state of gpio * while resuming from sleep. */ @@ -44,7 +45,7 @@ struct gpio_extcon_data { struct delayed_work work; unsigned long debounce_jiffies; struct gpio_desc *gpiod; - unsigned int extcon_id; + unsigned int connector_type[2]; bool check_on_resume; }; @@ -56,7 +57,7 @@ static void gpio_extcon_work(struct work_struct *work) work); state = gpiod_get_value_cansleep(data->gpiod); - extcon_set_state_sync(data->edev, data->extcon_id, state); + extcon_set_state_sync(data->edev, data->connector_type[0], state); } static irqreturn_t gpio_irq_handler(int irq, void *dev_id) @@ -74,6 +75,7 @@ static int gpio_extcon_probe(struct platform_device *pdev) struct device *dev = &pdev->dev; unsigned long irq_flags; u32 debounce_usecs; + u32 connector_type; int irq; int ret; @@ -81,9 +83,6 @@ static int gpio_extcon_probe(struct platform_device *pdev) if (!data) return -ENOMEM; - if (data->extcon_id > EXTCON_NONE) - return -EINVAL; - data->gpiod = devm_gpiod_get(dev, "extcon", GPIOD_IN); if (IS_ERR(data->gpiod)) return PTR_ERR(data->gpiod); @@ -102,8 +101,16 @@ static int gpio_extcon_probe(struct platform_device *pdev) else irq_flags = IRQF_TRIGGER_RISING; + ret = device_property_read_u32(dev, "extcon-connector-types", &connector_type); + if (ret || !connector_type) { + dev_err(dev, "illegal cable type or undefined cable type\n"); + return -EINVAL; + } + data->connector_type[0] = connector_type; + data->connector_type[1] = EXTCON_NONE; + /* Allocate the memory of extcon devie and register extcon device */ - data->edev = devm_extcon_dev_allocate(dev, &data->extcon_id); + data->edev = devm_extcon_dev_allocate(dev, data->connector_type); if (IS_ERR(data->edev)) { dev_err(dev, "failed to allocate extcon device\n"); return -ENOMEM;