From patchwork Thu Jul 9 17:11:58 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dmitry Osipenko X-Patchwork-Id: 1326090 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=vger.kernel.org (client-ip=23.128.96.18; helo=vger.kernel.org; envelope-from=linux-gpio-owner@vger.kernel.org; receiver=) Authentication-Results: ozlabs.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.a=rsa-sha256 header.s=20161025 header.b=dL5T5yzX; dkim-atps=neutral Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by ozlabs.org (Postfix) with ESMTP id 4B2jRf71T6z9sRR for ; Fri, 10 Jul 2020 03:13:02 +1000 (AEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728132AbgGIRMk (ORCPT ); Thu, 9 Jul 2020 13:12:40 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:43700 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726758AbgGIRMj (ORCPT ); Thu, 9 Jul 2020 13:12:39 -0400 Received: from mail-lj1-x242.google.com (mail-lj1-x242.google.com [IPv6:2a00:1450:4864:20::242]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id F1838C08C5CE; Thu, 9 Jul 2020 10:12:38 -0700 (PDT) Received: by mail-lj1-x242.google.com with SMTP id z24so3245173ljn.8; Thu, 09 Jul 2020 10:12:38 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=281uz9iaiGVo7VI6qKT+7ajuEHZDORjgoupNNobQtjM=; b=dL5T5yzX5EMhvYQoovcVbN5GsAkbwY6Tv6UtajhB8R1LolxI1i5zzLcXKe/aHi10xY DGPT/H8Mnrs8FN248T88ucJUk2R+3JIKpehl8AYJEmGCDMXbUYHjnbJXRgjq/QUyDhsi yPKv1Svd7uNhFqmHDT2JjP7V2cd3sPJMEUWzUdkSKycXsxoUcU1j+cb1E+U5bLQVNZG8 fqFP99LMqdh8lcrBTtjJTRxSXt3JISJJK7EHRMJCEaRnJg2XknfFaCwCJf4EUCjuPwR4 FbBYOCjZyeJV0d3GsKZ8qt45hdiQCMUa/qj+4dTa/WnRkNIZ+KclVDsvBoIfH49x/I2z tk9w== 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:mime-version:content-transfer-encoding; bh=281uz9iaiGVo7VI6qKT+7ajuEHZDORjgoupNNobQtjM=; b=WfxPnvwnnBLyRss2VXpvPooZ9NM7B8iwgjnhaqbII0hCOmbwIM7UEFYIBRyp5pWD1d U6cs5WA2g05TIpf/Gnod9dyabQzwVUtuVf4Mj2BUVhPnV79llIRZLmalKLhoisLrXlfT RAtxWcJOCxtPjCooAfGez/a00S9pe0r1B74xeFfE6KW5hgMdbWhjhjijrFWMJL7kVXCU 8YulvEQhaxSBsb/REZJjwx6dGAtuCkJtXl/ZtsMP43w80nKNDPwyMPN/t+s10WrGuTgF ZhkOLo7/6cQG/9dOyTezbgG9jRI5Ctf/BnKhMB01+lcfVbEHZytMghNuh8/ZRXQxWVYs +RwA== X-Gm-Message-State: AOAM5316/0EpF28OIDk5TQqVNLqCXOBN/Bjk7iRipLD1x5reZRvVk370 ypc1rbGyuQ9De29VRp/Pa7E= X-Google-Smtp-Source: ABdhPJxCoBAy+wgmz50uuC6+ftWgSFaVULLgqwWmOzjh7/32t2kf4vRVU30fWvSsyWs0sebITNZNwg== X-Received: by 2002:a2e:8046:: with SMTP id p6mr23586723ljg.100.1594314757485; Thu, 09 Jul 2020 10:12:37 -0700 (PDT) Received: from localhost.localdomain (ppp91-79-162-105.pppoe.mtu-net.ru. [91.79.162.105]) by smtp.gmail.com with ESMTPSA id y22sm998314ljn.2.2020.07.09.10.12.36 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 09 Jul 2020 10:12:36 -0700 (PDT) From: Dmitry Osipenko To: Thierry Reding , Jonathan Hunter , Laxman Dewangan , Bartosz Golaszewski , Linus Walleij , Andy Shevchenko Cc: linux-tegra@vger.kernel.org, linux-gpio@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH v4 1/6] gpio: max77620: Replace 8 with MAX77620_GPIO_NR Date: Thu, 9 Jul 2020 20:11:58 +0300 Message-Id: <20200709171203.12950-2-digetx@gmail.com> X-Mailer: git-send-email 2.26.0 In-Reply-To: <20200709171203.12950-1-digetx@gmail.com> References: <20200709171203.12950-1-digetx@gmail.com> MIME-Version: 1.0 Sender: linux-gpio-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-gpio@vger.kernel.org The MAX77620_GPIO_NR enum value represents the total number of GPIOs, let's use it instead of a raw value in order to improve the code's readability a tad. Reviewed-by: Andy Shevchenko Acked-by: Laxman Dewangan Signed-off-by: Dmitry Osipenko --- drivers/gpio/gpio-max77620.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/drivers/gpio/gpio-max77620.c b/drivers/gpio/gpio-max77620.c index 313bd02dd893..4c0c9ec2587d 100644 --- a/drivers/gpio/gpio-max77620.c +++ b/drivers/gpio/gpio-max77620.c @@ -19,8 +19,8 @@ struct max77620_gpio { struct regmap *rmap; struct device *dev; struct mutex buslock; /* irq_bus_lock */ - unsigned int irq_type[8]; - bool irq_enabled[8]; + unsigned int irq_type[MAX77620_GPIO_NR]; + bool irq_enabled[MAX77620_GPIO_NR]; }; static irqreturn_t max77620_gpio_irqhandler(int irq, void *data) @@ -38,7 +38,7 @@ static irqreturn_t max77620_gpio_irqhandler(int irq, void *data) pending = value; - for_each_set_bit(offset, &pending, 8) { + for_each_set_bit(offset, &pending, MAX77620_GPIO_NR) { unsigned int virq; virq = irq_find_mapping(gpio->gpio_chip.irq.domain, offset); From patchwork Thu Jul 9 17:11:59 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dmitry Osipenko X-Patchwork-Id: 1326088 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=vger.kernel.org (client-ip=23.128.96.18; helo=vger.kernel.org; envelope-from=linux-gpio-owner@vger.kernel.org; receiver=) Authentication-Results: ozlabs.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.a=rsa-sha256 header.s=20161025 header.b=WWQDN8WS; dkim-atps=neutral Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by ozlabs.org (Postfix) with ESMTP id 4B2jRf1jhRz9sT6 for ; Fri, 10 Jul 2020 03:13:02 +1000 (AEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728175AbgGIRMl (ORCPT ); Thu, 9 Jul 2020 13:12:41 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:43704 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728110AbgGIRMk (ORCPT ); Thu, 9 Jul 2020 13:12:40 -0400 Received: from mail-lj1-x242.google.com (mail-lj1-x242.google.com [IPv6:2a00:1450:4864:20::242]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 2F3B8C08C5CE; Thu, 9 Jul 2020 10:12:40 -0700 (PDT) Received: by mail-lj1-x242.google.com with SMTP id e8so3284780ljb.0; Thu, 09 Jul 2020 10:12:40 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=pPsaxFMPGXuMGU5xfWvs2V1FaJ6pHtqnWBB2UZa9jss=; b=WWQDN8WS7ffY7kViOBOudsX+3MPTwXEkwgebt8Ts0heK67MX/ag0axE0zMSPngNDqA C3B1FmAYr+f3ohkOHiJv810O6dtfNx4eJ1+vdiYmlV4mDhDOEqxka9JdE7rz7MWC9Gi4 +9dQpIsbB2uARwTK6lcB/iS+WOcTes0C1Egt04RM/X3AOq9e9iDhRsRl6VLdNA8VV9ZP zQeidcgxW9Yf/5RleJtDwi7rrLhOjkZ6CnH6Iyc/dhB9X/I7a88zUQdJcOaR8qMtA31K E3CPxr2yic6Bn5YlmPJ4KrOi+jwJgBw4EaJjy/tzlaa7ykumkEu5SqLFk3U37SXfPgLP 3g9Q== 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:mime-version:content-transfer-encoding; bh=pPsaxFMPGXuMGU5xfWvs2V1FaJ6pHtqnWBB2UZa9jss=; b=ksNEazePHBMTzebeLI5Ks5JbKP4gIWauXBhH/6+jEGW03ezUVFxqFrKug4ZZ9VQubW zw1eK9Df4oLFAKS40u22qfl5GpLN0Q+Pox/yr2tObSC8G4UMa/wqYC/Mm0dOsvQEoizq oJgiy8dTLIxwuL5pXko65zeiCc7TaH0D7ghZ6LxnM1zor19huJRvqc5w5GlPYu1QmJjn uAjvz5JpDpc0zklfv5IRRtvBBdQWr9mKAVQzA1Ziz5YX/UNdxhXkgH30df07WeM47jjM z4BM2RYiJZtCRZ6qkYg/7nkpnhaczu6uOWrN1c3nRm/u5lDpQN+K9yzwUtYGzGSS9cjb NIgg== X-Gm-Message-State: AOAM533VyKIRNcIRhXjAJHd84j6RgCdQ0JEOqtAuS7c7Jhv/SDyi9vL2 nixmpZSkWiWZ/tGnC7bj1RI= X-Google-Smtp-Source: ABdhPJyivzoUWxEAKZ4DmW38Uy/Ab5dtgH6ExKZAg389uvzhBUuj+dManw2W8JkbgzScuCODCd6ebQ== X-Received: by 2002:a2e:9dd6:: with SMTP id x22mr18890532ljj.199.1594314758700; Thu, 09 Jul 2020 10:12:38 -0700 (PDT) Received: from localhost.localdomain (ppp91-79-162-105.pppoe.mtu-net.ru. [91.79.162.105]) by smtp.gmail.com with ESMTPSA id y22sm998314ljn.2.2020.07.09.10.12.37 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 09 Jul 2020 10:12:38 -0700 (PDT) From: Dmitry Osipenko To: Thierry Reding , Jonathan Hunter , Laxman Dewangan , Bartosz Golaszewski , Linus Walleij , Andy Shevchenko Cc: linux-tegra@vger.kernel.org, linux-gpio@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH v4 2/6] gpio: max77620: Fix missing release of interrupt Date: Thu, 9 Jul 2020 20:11:59 +0300 Message-Id: <20200709171203.12950-3-digetx@gmail.com> X-Mailer: git-send-email 2.26.0 In-Reply-To: <20200709171203.12950-1-digetx@gmail.com> References: <20200709171203.12950-1-digetx@gmail.com> MIME-Version: 1.0 Sender: linux-gpio-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-gpio@vger.kernel.org The requested interrupt is never released by the driver. Fix this by using the resource-managed variant of request_threaded_irq(). Fixes: ab3dd9cc24d4 ("gpio: max77620: Fix interrupt handling") Cc: # 5.5+ Reviewed-by: Andy Shevchenko Acked-by: Laxman Dewangan Signed-off-by: Dmitry Osipenko --- drivers/gpio/gpio-max77620.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/drivers/gpio/gpio-max77620.c b/drivers/gpio/gpio-max77620.c index 4c0c9ec2587d..7f7e8d4bf0d3 100644 --- a/drivers/gpio/gpio-max77620.c +++ b/drivers/gpio/gpio-max77620.c @@ -305,8 +305,9 @@ static int max77620_gpio_probe(struct platform_device *pdev) gpiochip_irqchip_add_nested(&mgpio->gpio_chip, &max77620_gpio_irqchip, 0, handle_edge_irq, IRQ_TYPE_NONE); - ret = request_threaded_irq(gpio_irq, NULL, max77620_gpio_irqhandler, - IRQF_ONESHOT, "max77620-gpio", mgpio); + ret = devm_request_threaded_irq(&pdev->dev, gpio_irq, NULL, + max77620_gpio_irqhandler, IRQF_ONESHOT, + "max77620-gpio", mgpio); if (ret < 0) { dev_err(&pdev->dev, "failed to request IRQ: %d\n", ret); return ret; From patchwork Thu Jul 9 17:12:00 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dmitry Osipenko X-Patchwork-Id: 1326085 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=vger.kernel.org (client-ip=23.128.96.18; helo=vger.kernel.org; envelope-from=linux-gpio-owner@vger.kernel.org; receiver=) Authentication-Results: ozlabs.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.a=rsa-sha256 header.s=20161025 header.b=F6X3fdXB; dkim-atps=neutral Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by ozlabs.org (Postfix) with ESMTP id 4B2jRc6YT7z9sTF for ; Fri, 10 Jul 2020 03:13:00 +1000 (AEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728362AbgGIRMv (ORCPT ); Thu, 9 Jul 2020 13:12:51 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:43710 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728206AbgGIRMl (ORCPT ); Thu, 9 Jul 2020 13:12:41 -0400 Received: from mail-lj1-x243.google.com (mail-lj1-x243.google.com [IPv6:2a00:1450:4864:20::243]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 26860C08C5CE; Thu, 9 Jul 2020 10:12:41 -0700 (PDT) Received: by mail-lj1-x243.google.com with SMTP id d17so3269856ljl.3; Thu, 09 Jul 2020 10:12:41 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=nK7VbiDVUEdbT9jTj1dIkuqtQW8x+06R4ZXLtGmtTpc=; b=F6X3fdXBTPdfg/BieULkcyXl6mH1blJUakTku4OeWsLMx5xAjYM4zKCzFp/p763ASl F385TQHOCUjVDjY4omJ92gdJq/9K5qJAQeY5s8ZCIPJ+9toKNHsN3q7PUKWIWHpMatA8 TPO3FVYpip4sjf93DHRuClz/pyzd5S3yP9ogBGstGauXRzLXxaPiE937Z82KH9BWftRJ ernFRvxq2iQS/4X9M8x0EY5A3h4e/lydLXhUSa9ffPw1AdIh1Y76FJRdcWQcu5aLrqpD rCHxAKzDIhNkeQt+UrFhMz7pdF3RCzHdjVTtmhXyUwPOYN/bVAZDXARmcM6FI2ghIl4C ucYw== 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:mime-version:content-transfer-encoding; bh=nK7VbiDVUEdbT9jTj1dIkuqtQW8x+06R4ZXLtGmtTpc=; b=I2IBUKVZg2Y2ybikgxpKWWe3IianDgF5ZVX/qXm/DdwiH6eJwRrBI60CoNkM1XTW76 dbvPBirxdlnyKjZkgOwIoHuWlkHx8KYIkKSBQ4n686uigcob4B6qFT5ICQyB4FxP6nJE lFeYFqTBaTpE//nMqv17D4krGCWM/YDfelqtJmvlzSi/1WNx5YxoNFxfmhYKzbtzmeGr l/i5o3E5+YG6oVN5v2sUHH/SThK55Qfvu2gjrZFd9yditWhUFRGUypwDizQFvuLu8daV xxm8M+rR55IL0bxfhse38YkydmxJFiGXfeGc/qRQVITJnUL1b3BV6JHMVAe9lV23gcu9 qonQ== X-Gm-Message-State: AOAM533T/UBOYEb204tGxdDSiomobZ01Y4BQXlgztVybkvaoSPjiCcMv Pr6bk7Rt7hnSJ1iDC+zXBPw= X-Google-Smtp-Source: ABdhPJyvykxVIPeM4POspY9+OgMefiSs4FProlmdUWv8fN1EvCKtzrT1HG+hRCKNq0Hpxsr1TvZhfA== X-Received: by 2002:a2e:2242:: with SMTP id i63mr39532254lji.370.1594314759695; Thu, 09 Jul 2020 10:12:39 -0700 (PDT) Received: from localhost.localdomain (ppp91-79-162-105.pppoe.mtu-net.ru. [91.79.162.105]) by smtp.gmail.com with ESMTPSA id y22sm998314ljn.2.2020.07.09.10.12.38 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 09 Jul 2020 10:12:39 -0700 (PDT) From: Dmitry Osipenko To: Thierry Reding , Jonathan Hunter , Laxman Dewangan , Bartosz Golaszewski , Linus Walleij , Andy Shevchenko Cc: linux-tegra@vger.kernel.org, linux-gpio@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH v4 3/6] gpio: max77620: Don't set of_node Date: Thu, 9 Jul 2020 20:12:00 +0300 Message-Id: <20200709171203.12950-4-digetx@gmail.com> X-Mailer: git-send-email 2.26.0 In-Reply-To: <20200709171203.12950-1-digetx@gmail.com> References: <20200709171203.12950-1-digetx@gmail.com> MIME-Version: 1.0 Sender: linux-gpio-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-gpio@vger.kernel.org The gpiochip_add_data() takes care of setting the of_node to the parent's device of_node, hence there is no need to do it manually in the driver's code. This patch corrects the parent's device pointer and removes the unnecessary setting of the of_node. Suggested-by: Andy Shevchenko Reviewed-by: Andy Shevchenko Acked-by: Laxman Dewangan Signed-off-by: Dmitry Osipenko --- drivers/gpio/gpio-max77620.c | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/drivers/gpio/gpio-max77620.c b/drivers/gpio/gpio-max77620.c index 7f7e8d4bf0d3..39d431da2dbc 100644 --- a/drivers/gpio/gpio-max77620.c +++ b/drivers/gpio/gpio-max77620.c @@ -279,7 +279,7 @@ static int max77620_gpio_probe(struct platform_device *pdev) mgpio->dev = &pdev->dev; mgpio->gpio_chip.label = pdev->name; - mgpio->gpio_chip.parent = &pdev->dev; + mgpio->gpio_chip.parent = pdev->dev.parent; mgpio->gpio_chip.direction_input = max77620_gpio_dir_input; mgpio->gpio_chip.get = max77620_gpio_get; mgpio->gpio_chip.direction_output = max77620_gpio_dir_output; @@ -288,9 +288,6 @@ static int max77620_gpio_probe(struct platform_device *pdev) mgpio->gpio_chip.ngpio = MAX77620_GPIO_NR; mgpio->gpio_chip.can_sleep = 1; mgpio->gpio_chip.base = -1; -#ifdef CONFIG_OF_GPIO - mgpio->gpio_chip.of_node = pdev->dev.parent->of_node; -#endif platform_set_drvdata(pdev, mgpio); From patchwork Thu Jul 9 17:12:01 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dmitry Osipenko X-Patchwork-Id: 1326083 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=vger.kernel.org (client-ip=23.128.96.18; helo=vger.kernel.org; envelope-from=linux-gpio-owner@vger.kernel.org; receiver=) Authentication-Results: ozlabs.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.a=rsa-sha256 header.s=20161025 header.b=S+cr2shD; dkim-atps=neutral Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by ozlabs.org (Postfix) with ESMTP id 4B2jRS3JYyz9sTF for ; Fri, 10 Jul 2020 03:12:52 +1000 (AEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728347AbgGIRMu (ORCPT ); Thu, 9 Jul 2020 13:12:50 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:43712 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726758AbgGIRMm (ORCPT ); Thu, 9 Jul 2020 13:12:42 -0400 Received: from mail-lj1-x242.google.com (mail-lj1-x242.google.com [IPv6:2a00:1450:4864:20::242]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 2B7F6C08C5CE; Thu, 9 Jul 2020 10:12:42 -0700 (PDT) Received: by mail-lj1-x242.google.com with SMTP id h19so3221557ljg.13; Thu, 09 Jul 2020 10:12:42 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=MwH9OzQNprBVTkDGom8Hyzf45RK5XVVd8yNAMaPqHFg=; b=S+cr2shDb1TfOejsw++p+vI3r8B+FssUPlW8yGlPlSu1mydqtkkk+YJ0M3NPW+weLz nhCAXHnnLE6H9A6Go6Hyg+EnUUG+pk6tEqiVLEeUWCc4X77Iavm8zr8Q17qKrhSOICLq 3qQNdHwdfSlU5OAyecyitBri24mT5yjqJ61ChvTpHkFEHoUP7nR6RcfsulnaOvni0NMt ILm+txfGzhuKTfUNmLxH9ygrdd6H5we/njqYNnYqx73Tm4KcMFXd6lBwbx29sLJpdl4P XwN0C5dFo2YnbUqD1aXiTlGZ/RgXMSOviji3gTS0YNEksFQ1Y7wWsRu8tuLnEFKKja+v 1O2w== 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:mime-version:content-transfer-encoding; bh=MwH9OzQNprBVTkDGom8Hyzf45RK5XVVd8yNAMaPqHFg=; b=XxsiSkrwPfiaa0k4mXW4b3yzq+1hhg6Uhhebqpp2PASvE0bsEdF9ZoI4ugT9bwRNSh fYquISOA5fO6uBFQ+UB64YWSP7eLFaq85CqCX6WtPVe98TWIvwnnBiH+caeGSGNGMsx9 l7Ok5lDmtIqxH69nxfiodwXHZZmgO3nXyGJQ2ivvG+BYYafiYDyVb0Y7WiuO2YRUtzsj 3UkZXO6F1qzXKpoEwddmpjJtTAxBp0VGmGO43jnDE9KooblUgiScQ1JJUoePZKdvRwgb caWE5ou2qt9NImvFvtadu/9+8Q+1yRL1YXzk5OdnKDdTq3eoy02yyLPpwjO3De9rHXyg 0Qww== X-Gm-Message-State: AOAM531DDZni8D95PzremhTqzQzFnUh5rF3xyx80MtaiDPKEKRpN9rnr JQDi/x03x3DCNAB39JUJv+Y= X-Google-Smtp-Source: ABdhPJzYy6iDn63+WHVf7HB6iLM2INjD8TS6EzVQrtmpEO1Axca5+JaiB1Sqb/CzRODX661LJuwItg== X-Received: by 2002:a2e:9b87:: with SMTP id z7mr35203698lji.80.1594314760687; Thu, 09 Jul 2020 10:12:40 -0700 (PDT) Received: from localhost.localdomain (ppp91-79-162-105.pppoe.mtu-net.ru. [91.79.162.105]) by smtp.gmail.com with ESMTPSA id y22sm998314ljn.2.2020.07.09.10.12.39 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 09 Jul 2020 10:12:40 -0700 (PDT) From: Dmitry Osipenko To: Thierry Reding , Jonathan Hunter , Laxman Dewangan , Bartosz Golaszewski , Linus Walleij , Andy Shevchenko Cc: linux-tegra@vger.kernel.org, linux-gpio@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH v4 4/6] gpio: max77620: Don't shadow error code of platform_get_irq() Date: Thu, 9 Jul 2020 20:12:01 +0300 Message-Id: <20200709171203.12950-5-digetx@gmail.com> X-Mailer: git-send-email 2.26.0 In-Reply-To: <20200709171203.12950-1-digetx@gmail.com> References: <20200709171203.12950-1-digetx@gmail.com> MIME-Version: 1.0 Sender: linux-gpio-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-gpio@vger.kernel.org The platform_get_irq() returns a positive interrupt number on success and negative error code on failure (zero shouldn't ever happen in practice, it would produce a noisy warning). Hence let's return the error code directly instead of overriding it with -ENODEV. Suggested-by: Andy Shevchenko Reviewed-by: Andy Shevchenko Acked-by: Laxman Dewangan Signed-off-by: Dmitry Osipenko --- drivers/gpio/gpio-max77620.c | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/drivers/gpio/gpio-max77620.c b/drivers/gpio/gpio-max77620.c index 39d431da2dbc..9121d2507f60 100644 --- a/drivers/gpio/gpio-max77620.c +++ b/drivers/gpio/gpio-max77620.c @@ -264,12 +264,14 @@ static int max77620_gpio_probe(struct platform_device *pdev) { struct max77620_chip *chip = dev_get_drvdata(pdev->dev.parent); struct max77620_gpio *mgpio; - int gpio_irq; + unsigned int gpio_irq; int ret; - gpio_irq = platform_get_irq(pdev, 0); - if (gpio_irq <= 0) - return -ENODEV; + ret = platform_get_irq(pdev, 0); + if (ret < 0) + return ret; + + gpio_irq = ret; mgpio = devm_kzalloc(&pdev->dev, sizeof(*mgpio), GFP_KERNEL); if (!mgpio) From patchwork Thu Jul 9 17:12:02 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dmitry Osipenko X-Patchwork-Id: 1326082 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=vger.kernel.org (client-ip=23.128.96.18; helo=vger.kernel.org; envelope-from=linux-gpio-owner@vger.kernel.org; receiver=) Authentication-Results: ozlabs.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.a=rsa-sha256 header.s=20161025 header.b=civHIhjo; dkim-atps=neutral Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by ozlabs.org (Postfix) with ESMTP id 4B2jRS0lMRz9sSt for ; Fri, 10 Jul 2020 03:12:51 +1000 (AEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728110AbgGIRMu (ORCPT ); Thu, 9 Jul 2020 13:12:50 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:43718 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728268AbgGIRMn (ORCPT ); Thu, 9 Jul 2020 13:12:43 -0400 Received: from mail-lj1-x241.google.com (mail-lj1-x241.google.com [IPv6:2a00:1450:4864:20::241]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 37211C08C5DC; Thu, 9 Jul 2020 10:12:43 -0700 (PDT) Received: by mail-lj1-x241.google.com with SMTP id f5so3236075ljj.10; Thu, 09 Jul 2020 10:12:43 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=u99MosogCAS3r14WcUxt5hVcjyYNPkz9/nrq/fRZnBY=; b=civHIhjowxn4Tr7egQT7xB3THHlroD0qRyPQkzO6Pyv9BEEbtTpWgkPIWcqqQbxfAY 7Kn60aidsfiBax+WEaSGh9A0681K3OOvDQLN1Vv3w9VQBCR8f+bXt2WMkNXh4ntHnTau C5+oZY3AuYaP5SfwH07A3vk6trbj/HvmcEC/luppPZOQ7l+GDOd69wmfJeNBVdVoS+0U 7mVGnzmHE4qxTtgvX6J4ABajVb84Na57hse33Y+UwjTTfg2a3y7BFQpMcw/bHu3kTUR/ UB09EjNgXkrAbECDSr9wIL3gQE2E/cB+eAIRsh4L6+Jofrpl2DL6G/yW8tEeRWO2GxdS A55A== 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:mime-version:content-transfer-encoding; bh=u99MosogCAS3r14WcUxt5hVcjyYNPkz9/nrq/fRZnBY=; b=CVOZMW/b9lvGpACnBOOTeHsnsQhXy2iKI43GLqrDAoJA9QnoLvOjEdCBuKd5qcGm7z rw1qwQm8wf0cZMZvGf81LQo7BytjD3dkvkrdFU4MMufdxgKZfxgZ8lslPmdI+DF+vAL0 9BEeUDlIa0u8b4JZsNoKq49RXmhU7X4ZpY/nPx2mpBSF0Iqo/Fx+ns7vD+LsNOSonrYf oaaOpvz27nUmtUEpt0AHUapG/S4xXPDni+CaHqxKNsHXXQYKIxJyJigdFVgOmpEx1KD/ B7fVyeO19RPkD8BP1v1l/rtinWrjnDWIIv55NJZT5R2+Dvxce7k/+YUn0L7TjtdH4sLP mnmw== X-Gm-Message-State: AOAM530akeLEyulZF1W1nRiIXsciRo7pSqgVGwhlI1Jp0EOANdCpPYsI NG9uktC+u2gawQXUBSqKM6g= X-Google-Smtp-Source: ABdhPJx0blGxsbWIsC6VxaWTr2AqkRhDQepmakHlsYAWWALEvbwHj5E9MuRjlRWt5kYS2C1Qk8drBg== X-Received: by 2002:a2e:9ac4:: with SMTP id p4mr35848290ljj.143.1594314761759; Thu, 09 Jul 2020 10:12:41 -0700 (PDT) Received: from localhost.localdomain (ppp91-79-162-105.pppoe.mtu-net.ru. [91.79.162.105]) by smtp.gmail.com with ESMTPSA id y22sm998314ljn.2.2020.07.09.10.12.40 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 09 Jul 2020 10:12:41 -0700 (PDT) From: Dmitry Osipenko To: Thierry Reding , Jonathan Hunter , Laxman Dewangan , Bartosz Golaszewski , Linus Walleij , Andy Shevchenko Cc: linux-tegra@vger.kernel.org, linux-gpio@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH v4 5/6] gpio: max77620: Use irqchip template Date: Thu, 9 Jul 2020 20:12:02 +0300 Message-Id: <20200709171203.12950-6-digetx@gmail.com> X-Mailer: git-send-email 2.26.0 In-Reply-To: <20200709171203.12950-1-digetx@gmail.com> References: <20200709171203.12950-1-digetx@gmail.com> MIME-Version: 1.0 Sender: linux-gpio-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-gpio@vger.kernel.org This change addresses one of the GPIO-core TODOs for the MAX77620 driver which requires modern drivers to use the irqchip template. Instead of using the GPIO's irqchip-helpers for creating the IRQ domain, the gpio_irq_chip structure is now filled by the driver itself and then gpiochip_add_data() takes care of instantiating the IRQ domain for us. Suggested-by: Andy Shevchenko Reviewed-by: Andy Shevchenko Acked-by: Laxman Dewangan Signed-off-by: Dmitry Osipenko --- drivers/gpio/gpio-max77620.c | 14 ++++++-------- 1 file changed, 6 insertions(+), 8 deletions(-) diff --git a/drivers/gpio/gpio-max77620.c b/drivers/gpio/gpio-max77620.c index 9121d2507f60..6c516aa7732d 100644 --- a/drivers/gpio/gpio-max77620.c +++ b/drivers/gpio/gpio-max77620.c @@ -277,6 +277,7 @@ static int max77620_gpio_probe(struct platform_device *pdev) if (!mgpio) return -ENOMEM; + mutex_init(&mgpio->buslock); mgpio->rmap = chip->rmap; mgpio->dev = &pdev->dev; @@ -291,6 +292,11 @@ static int max77620_gpio_probe(struct platform_device *pdev) mgpio->gpio_chip.can_sleep = 1; mgpio->gpio_chip.base = -1; + mgpio->gpio_chip.irq.chip = &max77620_gpio_irqchip; + mgpio->gpio_chip.irq.default_type = IRQ_TYPE_NONE; + mgpio->gpio_chip.irq.handler = handle_edge_irq; + mgpio->gpio_chip.irq.threaded = true; + platform_set_drvdata(pdev, mgpio); ret = devm_gpiochip_add_data(&pdev->dev, &mgpio->gpio_chip, mgpio); @@ -299,11 +305,6 @@ static int max77620_gpio_probe(struct platform_device *pdev) return ret; } - mutex_init(&mgpio->buslock); - - gpiochip_irqchip_add_nested(&mgpio->gpio_chip, &max77620_gpio_irqchip, - 0, handle_edge_irq, IRQ_TYPE_NONE); - ret = devm_request_threaded_irq(&pdev->dev, gpio_irq, NULL, max77620_gpio_irqhandler, IRQF_ONESHOT, "max77620-gpio", mgpio); @@ -312,9 +313,6 @@ static int max77620_gpio_probe(struct platform_device *pdev) return ret; } - gpiochip_set_nested_irqchip(&mgpio->gpio_chip, &max77620_gpio_irqchip, - gpio_irq); - return 0; } From patchwork Thu Jul 9 17:12:03 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dmitry Osipenko X-Patchwork-Id: 1326080 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=vger.kernel.org (client-ip=23.128.96.18; helo=vger.kernel.org; envelope-from=linux-gpio-owner@vger.kernel.org; receiver=) Authentication-Results: ozlabs.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.a=rsa-sha256 header.s=20161025 header.b=DKU3CMKH; dkim-atps=neutral Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by ozlabs.org (Postfix) with ESMTP id 4B2jRK4sL3z9sRR for ; Fri, 10 Jul 2020 03:12:45 +1000 (AEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728305AbgGIRMp (ORCPT ); Thu, 9 Jul 2020 13:12:45 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:43722 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728110AbgGIRMo (ORCPT ); Thu, 9 Jul 2020 13:12:44 -0400 Received: from mail-lj1-x243.google.com (mail-lj1-x243.google.com [IPv6:2a00:1450:4864:20::243]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 5821BC08C5CE; Thu, 9 Jul 2020 10:12:44 -0700 (PDT) Received: by mail-lj1-x243.google.com with SMTP id h19so3221664ljg.13; Thu, 09 Jul 2020 10:12:44 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=NUzStD0JlDE1+lpeM+4rnfbYioBhG7w/IUJEkdm0/Vw=; b=DKU3CMKH/guvcv3nfGgGymRWfTw3P7mw/dEdLUiHeq1wNhKqBxXuKQsEOfJgeBRO65 5P3Z9zsSVaybXf9pY+SNVzD/Bn5Agev7/tMieza0uUyAfb0mUmpuYhtrrPiINM4z22b/ qpV22FW4SilWASZY/MXlAkCh0M9PU+rKHf8sJ/lPS1gOLImiM0Pco6wgFCrBhtOavrvi Iw8TkYAywqEbxa7Ky0Ao1BycccozFxm1bLuyyk66zi0tu9HDsZrW0dHsbTyq+HDUp+5l 8SEF2imCZpJuXSCNfbUMMEVFp4Mvl7qqO2GfnqR2HQ0v/ii91XOYgNPEjSHip55D7e/V +aBw== 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:mime-version:content-transfer-encoding; bh=NUzStD0JlDE1+lpeM+4rnfbYioBhG7w/IUJEkdm0/Vw=; b=ry1eo/AX43/9Z04d/J5XmSYyfYvEm9CNiJvhmCZ2j6yoZ4w0gaJmCYcQWDi0p8De8v lrt54O7ltc0/U8TkmhtXO45IB+hUEDJ9rT/en673kBflRxclMQNeaYQfLAwpLVeJ9MqX XTBugG93eveU5yBbDbRwIIzakFdVRQPkIdV/1Wc6gbmMnUcdxyqS2QMICGEZl+kBvyMG jYw2BnIt14ASAoaz+Ae5E8iypBhMLj6eePFJqGQVNB7hNYB0t9xAEGh1X0YHL4eU+SA/ LjI0P95GRbmhK/BWoPaxonfE3UlvwcMEpWdge4sZ27RWaFNtd6g/NuUf9kgDpkhqLyF6 xNXQ== X-Gm-Message-State: AOAM5309s4U5Bw7jKP1TpsAfs3hhrPuXko/Kjnfi9UXBK4fawYsy9ymz e7iteN31KPZ1XymSKKuUP1g= X-Google-Smtp-Source: ABdhPJwaQ99lPcWRXF96Ez8T787FoH+S6jQcqAmeZzmGoAr/zqbL62PN2IiIPwE04RUUCzzIPXNQCQ== X-Received: by 2002:a2e:7a03:: with SMTP id v3mr33520604ljc.141.1594314762811; Thu, 09 Jul 2020 10:12:42 -0700 (PDT) Received: from localhost.localdomain (ppp91-79-162-105.pppoe.mtu-net.ru. [91.79.162.105]) by smtp.gmail.com with ESMTPSA id y22sm998314ljn.2.2020.07.09.10.12.41 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 09 Jul 2020 10:12:42 -0700 (PDT) From: Dmitry Osipenko To: Thierry Reding , Jonathan Hunter , Laxman Dewangan , Bartosz Golaszewski , Linus Walleij , Andy Shevchenko Cc: linux-tegra@vger.kernel.org, linux-gpio@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH v4 6/6] gpio: max77620: Initialize hardware state of interrupts Date: Thu, 9 Jul 2020 20:12:03 +0300 Message-Id: <20200709171203.12950-7-digetx@gmail.com> X-Mailer: git-send-email 2.26.0 In-Reply-To: <20200709171203.12950-1-digetx@gmail.com> References: <20200709171203.12950-1-digetx@gmail.com> MIME-Version: 1.0 Sender: linux-gpio-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-gpio@vger.kernel.org I noticed on Nexus 7 that after rebooting from downstream kernel to upstream, the GPIO interrupt is triggering non-stop despite interrupts being disabled for all of GPIOs. This happens because Nexus 7 uses a soft-reboot, meaning that bootloader should take care of resetting hardware, but the bootloader doesn't do it well. As a result, GPIO interrupt may be left ON at a boot time. Let's mask all GPIO interrupts at the driver's initialization time in order to resolve the issue. Reviewed-by: Andy Shevchenko Acked-by: Laxman Dewangan Signed-off-by: Dmitry Osipenko --- drivers/gpio/gpio-max77620.c | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) diff --git a/drivers/gpio/gpio-max77620.c b/drivers/gpio/gpio-max77620.c index 6c516aa7732d..e090979659eb 100644 --- a/drivers/gpio/gpio-max77620.c +++ b/drivers/gpio/gpio-max77620.c @@ -260,6 +260,30 @@ static int max77620_gpio_set_config(struct gpio_chip *gc, unsigned int offset, return -ENOTSUPP; } +static int max77620_gpio_irq_init_hw(struct gpio_chip *gc) +{ + struct max77620_gpio *gpio = gpiochip_get_data(gc); + unsigned int i; + int err; + + /* + * GPIO interrupts may be left ON after bootloader, hence let's + * pre-initialize hardware to the expected state by disabling all + * the interrupts. + */ + for (i = 0; i < MAX77620_GPIO_NR; i++) { + err = regmap_update_bits(gpio->rmap, GPIO_REG_ADDR(i), + MAX77620_CNFG_GPIO_INT_MASK, 0); + if (err < 0) { + dev_err(gpio->dev, + "failed to disable interrupt: %d\n", err); + return err; + } + } + + return 0; +} + static int max77620_gpio_probe(struct platform_device *pdev) { struct max77620_chip *chip = dev_get_drvdata(pdev->dev.parent); @@ -295,6 +319,7 @@ static int max77620_gpio_probe(struct platform_device *pdev) mgpio->gpio_chip.irq.chip = &max77620_gpio_irqchip; mgpio->gpio_chip.irq.default_type = IRQ_TYPE_NONE; mgpio->gpio_chip.irq.handler = handle_edge_irq; + mgpio->gpio_chip.irq.init_hw = max77620_gpio_irq_init_hw, mgpio->gpio_chip.irq.threaded = true; platform_set_drvdata(pdev, mgpio);