From patchwork Tue Nov 10 12:34:00 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bartosz Golaszewski X-Patchwork-Id: 321472 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-12.7 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID, HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_PATCH, MAILING_LIST_MULTI, SIGNED_OFF_BY,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 7768DC388F7 for ; Tue, 10 Nov 2020 12:34:15 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 24F0B2076E for ; Tue, 10 Nov 2020 12:34:15 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=bgdev-pl.20150623.gappssmtp.com header.i=@bgdev-pl.20150623.gappssmtp.com header.b="YNLSIvUU" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1730150AbgKJMeO (ORCPT ); Tue, 10 Nov 2020 07:34:14 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:42450 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1730097AbgKJMeO (ORCPT ); Tue, 10 Nov 2020 07:34:14 -0500 Received: from mail-wr1-x442.google.com (mail-wr1-x442.google.com [IPv6:2a00:1450:4864:20::442]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 27C8DC0613D3 for ; Tue, 10 Nov 2020 04:34:14 -0800 (PST) Received: by mail-wr1-x442.google.com with SMTP id b8so12488974wrn.0 for ; Tue, 10 Nov 2020 04:34:14 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bgdev-pl.20150623.gappssmtp.com; s=20150623; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=A7Q6GcsOlUvCk0TynHXF9lujyUa3NnBo8eWmuL6l7+w=; b=YNLSIvUUwisHGw+RC6XKvE+BhDiciuwkRe6AZRbgFVSha/tzd2j25GLZ2T+T6RxMTF YTBMINnyIe2dPa0bXmlQMk2aHLpiW0Dhsu+xstWxREuY5MEqP8nfhs3GzT2UxmnlARno IYzAjVXEC2cYy8kEawTGA+6iNvLUSirjsXi1++fg5XRVgo7MutwyAN999W83tZXrlh8j Jza/bDCHm5cuOxu4SVtPPWuYReecVYQHZOTx2qOHzHnWOtctcfK1/yeCmOCfWuYhCHi/ quH9tZocCUuQJ5BL6HVB6DmiDoldTBxH+OTMmtS+pvRTYZ0Ohcoc9Arzrpu74ha2YMkw alwA== 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=A7Q6GcsOlUvCk0TynHXF9lujyUa3NnBo8eWmuL6l7+w=; b=cyNcwCw8dywYXFonzYr/kmi8EgEM0Y72sXFPczSb42EgUN74roHOS6YGq4OMwMu8Gu igIrEJjZE33CJjjxVYAec7jNUPQWusshKw+yJMqFSv5X4susOEdnnWFWR6E2+Gdo4orV TWMzCEIahTROEpgZJkrQyGn66AFxmkiWmxNQ1npZvdsvtEmiAqA9hh/+8xA7e/wQP+PE G9po6ays10xRr6FU1rzOG6UVFplx5rzKaSyun3+hRisS/NxzhSbHpUwq8LBpR5+v5OB/ TJt8kmxMUL4yniHeeJMpJo2t52/BS/TYs+CpdfHoorI1auSRQbKh4Ny0P4uLEcOSYqMN Gs9Q== X-Gm-Message-State: AOAM5314Hudov9Hdc89LTP2rXFj+3m4/fWICCQW5FsDJX0R6S1KX94/T sh3EAwzPHAmIY65JNHvz1dKsksrf3TLCQw== X-Google-Smtp-Source: ABdhPJwn7B7uq4jKzi0eyC5tcY6YnHEsniitzEUttwi4qn76aOaWKYDvA4GVfPwskO/Pm04skEdoZQ== X-Received: by 2002:adf:fec6:: with SMTP id q6mr3805845wrs.168.1605011652952; Tue, 10 Nov 2020 04:34:12 -0800 (PST) Received: from debian-brgl.home (amarseille-656-1-4-167.w90-8.abo.wanadoo.fr. [90.8.158.167]) by smtp.gmail.com with ESMTPSA id s8sm12942217wrn.33.2020.11.10.04.34.11 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 10 Nov 2020 04:34:12 -0800 (PST) From: Bartosz Golaszewski To: Linus Walleij , Andy Shevchenko , Jan Kiszka , David Laight Cc: linux-gpio@vger.kernel.org, linux-kernel@vger.kernel.org, Bartosz Golaszewski Subject: [PATCH v3 1/7] gpio: exar: add a newline after the copyright notice Date: Tue, 10 Nov 2020 13:34:00 +0100 Message-Id: <20201110123406.3261-2-brgl@bgdev.pl> X-Mailer: git-send-email 2.29.1 In-Reply-To: <20201110123406.3261-1-brgl@bgdev.pl> References: <20201110123406.3261-1-brgl@bgdev.pl> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-gpio@vger.kernel.org From: Bartosz Golaszewski It's customary to have a newline between the copyright header and the includes. Add one to gpio-exar. Signed-off-by: Bartosz Golaszewski --- drivers/gpio/gpio-exar.c | 1 + 1 file changed, 1 insertion(+) diff --git a/drivers/gpio/gpio-exar.c b/drivers/gpio/gpio-exar.c index b1accfba017d..4202dd363a11 100644 --- a/drivers/gpio/gpio-exar.c +++ b/drivers/gpio/gpio-exar.c @@ -4,6 +4,7 @@ * * Copyright (C) 2015 Sudip Mukherjee */ + #include #include #include From patchwork Tue Nov 10 12:34:01 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bartosz Golaszewski X-Patchwork-Id: 321470 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-12.7 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID, HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_PATCH, MAILING_LIST_MULTI, SIGNED_OFF_BY,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED,USER_AGENT_GIT autolearn=unavailable autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id C3FB6C56201 for ; Tue, 10 Nov 2020 12:34:43 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 6920220795 for ; Tue, 10 Nov 2020 12:34:43 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=bgdev-pl.20150623.gappssmtp.com header.i=@bgdev-pl.20150623.gappssmtp.com header.b="hKkxFUBe" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1730378AbgKJMeQ (ORCPT ); Tue, 10 Nov 2020 07:34:16 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:42458 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1730375AbgKJMeP (ORCPT ); Tue, 10 Nov 2020 07:34:15 -0500 Received: from mail-wr1-x442.google.com (mail-wr1-x442.google.com [IPv6:2a00:1450:4864:20::442]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 53343C0613CF for ; Tue, 10 Nov 2020 04:34:15 -0800 (PST) Received: by mail-wr1-x442.google.com with SMTP id 33so12475286wrl.7 for ; Tue, 10 Nov 2020 04:34:15 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bgdev-pl.20150623.gappssmtp.com; s=20150623; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=t/9DP21Y/K7Z/VraeZB1byIXgPmUm3+JNNTaYKuJoag=; b=hKkxFUBeGtofgNXK5OXRrh+vsnz7Thn/3XUvECCmtbNszHbpSYac2sNL38IpmJ5prk q2m6bm63ecpHW3vLayRdGzaYTNGjA6xq42M0umpIPYQVC5RMBJgHHHmlUVI/KITnjDvX yxQDpa1fM3QTybTNc4f8QkhrWnEUs8uQpl9W4dYQEGcep5Q3D2QEXLjPs/TF5vJ8Z1Bk W5dx5T2S30yKaR3tQEYQ2cbDGbz4qq7GfILKYY7pQaKFj0GkdG8bd48wB4OjgrciJnJp QKWXjJvqA5XnfJy35tDvaLTj7pVIcXlFFWS7bjU8Qga8m/lzykpz3s7OcHXbehSjaurP WJBw== 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=t/9DP21Y/K7Z/VraeZB1byIXgPmUm3+JNNTaYKuJoag=; b=O6UIpyarSgjSAIs+ts0l+ZVQNM7IDTjyg9uoN/1tqroobVCkAvmTyylxBv+Z9HW803 3UroP1Qjm8vHk+fFT1VMZNXnu02zbV6cKg0+1FdftwG3o1oeDGDJmQhnJQG7bX3NjJys Yo/By/nMH6RleqOxvKIjuMz2W3T2DIYtb385pM4XuUbqpAjLoSBvkYUCbQ5Vd3q3SOA+ kRd4TsWN4P+rID+xIlzO4+GAdxv+WRRDkO80HomyIR/jnwf5PV2l6/6wIoR1mVODYvVe +3Z8Sf7cJCH8fqZKpzkEaUwd3tvGTATk5HQhEPLw3IHYJ0+6jAd8tjqX4M/bANMnMHdr NV5A== X-Gm-Message-State: AOAM532jKjO0T5gsKbbahC4f4JE1HMJ4WGQCjw5Y/r6XDv1onhzO3ka0 QobdMqTLL7jAY/LLYJUfzPYsTA== X-Google-Smtp-Source: ABdhPJxu0VeDcAVI6R6UoqvguHg90OWMt8azWYcvtBkbHOKQQv0bF55jq/CC96lwNVR4zhVtqSgwAw== X-Received: by 2002:a5d:42c9:: with SMTP id t9mr10112703wrr.13.1605011654162; Tue, 10 Nov 2020 04:34:14 -0800 (PST) Received: from debian-brgl.home (amarseille-656-1-4-167.w90-8.abo.wanadoo.fr. [90.8.158.167]) by smtp.gmail.com with ESMTPSA id s8sm12942217wrn.33.2020.11.10.04.34.13 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 10 Nov 2020 04:34:13 -0800 (PST) From: Bartosz Golaszewski To: Linus Walleij , Andy Shevchenko , Jan Kiszka , David Laight Cc: linux-gpio@vger.kernel.org, linux-kernel@vger.kernel.org, Bartosz Golaszewski Subject: [PATCH v3 2/7] gpio: exar: include idr.h Date: Tue, 10 Nov 2020 13:34:01 +0100 Message-Id: <20201110123406.3261-3-brgl@bgdev.pl> X-Mailer: git-send-email 2.29.1 In-Reply-To: <20201110123406.3261-1-brgl@bgdev.pl> References: <20201110123406.3261-1-brgl@bgdev.pl> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-gpio@vger.kernel.org From: Bartosz Golaszewski This driver uses IDA APIs but doesn't include the relevant header. This fixes it. Signed-off-by: Bartosz Golaszewski --- drivers/gpio/gpio-exar.c | 1 + 1 file changed, 1 insertion(+) diff --git a/drivers/gpio/gpio-exar.c b/drivers/gpio/gpio-exar.c index 4202dd363a11..1941ae533418 100644 --- a/drivers/gpio/gpio-exar.c +++ b/drivers/gpio/gpio-exar.c @@ -8,6 +8,7 @@ #include #include #include +#include #include #include #include From patchwork Tue Nov 10 12:34:02 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bartosz Golaszewski X-Patchwork-Id: 321469 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-12.7 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID, HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_PATCH, MAILING_LIST_MULTI, SIGNED_OFF_BY,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED,USER_AGENT_GIT autolearn=unavailable autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 6C4B2C55ABD for ; Tue, 10 Nov 2020 12:34:47 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id F3810207D3 for ; Tue, 10 Nov 2020 12:34:46 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=bgdev-pl.20150623.gappssmtp.com header.i=@bgdev-pl.20150623.gappssmtp.com header.b="sV3UVxEX" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1730473AbgKJMen (ORCPT ); Tue, 10 Nov 2020 07:34:43 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:42466 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1730407AbgKJMeR (ORCPT ); Tue, 10 Nov 2020 07:34:17 -0500 Received: from mail-wm1-x341.google.com (mail-wm1-x341.google.com [IPv6:2a00:1450:4864:20::341]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 8C5BCC0613D1 for ; Tue, 10 Nov 2020 04:34:16 -0800 (PST) Received: by mail-wm1-x341.google.com with SMTP id a3so1514292wmb.5 for ; Tue, 10 Nov 2020 04:34:16 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bgdev-pl.20150623.gappssmtp.com; s=20150623; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=lQQN2ZXT/G4B3VsGNJyIkmXWhvmT1sWJqpvE2SPt6Is=; b=sV3UVxEXouoK63lYQ3sZ8dzWkxLMl3GBy4cA9l5fOi9UnJ7e2ZWBTsTS7IMQr8Ws7H KraWsioS8ciUm8VPNhI5vs8fpEzYIgmc4l+/ukScdTQtTPuGmmRAMFrL3u0KqgYFsW+l Kg69pZmfAlLceFCKcOoH3ZmZD4Doq7dO8/pwCUDwEi4Nzb9tSLHun4YXIPc97RdRqyAA ojYkq1bnFVeELxsqRRKxRwDJhmqG8pzzYKhRdGM2GR5uoHMTl1xQKJc1SNB2qZxpXrCd 8n+nudelBCerotlnuDXJjLbQ49lCPgjEba3H7Ymwv0MGKLj41pL1vTrTMhdL/w0Jikse fFCw== 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=lQQN2ZXT/G4B3VsGNJyIkmXWhvmT1sWJqpvE2SPt6Is=; b=SEahyhtONney7GC/oBfFtq8RgfcXUpUhDi3W9oxbuEvIMU6o31JParkVpu8UFoBwWW iM8erNUu+59StOOzjyGjODP1tiwJPTc4EZBAu+TrGbE7rCdguEvR/dqv3BVTy9PAYD9w 98m4TXok06qadPwjXI2BIl3V99+yBMR1uYrIM/lY3fznyEgq0FkPT6Aksq7hmwdNYNsl jGs58zjiH7yj+uTdabixeVFyRpJrwcuUKcvPTRJ/tXd5zxBZOOOvyq/kLBAHhcAO/D7f 6Z8yO2tVRNGxaaD1r1pXYpCFY3aNkgusIeOr6u1pGln7cVZCxsI1M0CbcTCzJ9P+NOik Dlxg== X-Gm-Message-State: AOAM532/Hq7rcZKs4FnIZm23NA8xnVLkNzCWKLpAyQe8ANm/OdcLfnNu 9DMJyXX17zFwMT3ukjtF7UOWBQ== X-Google-Smtp-Source: ABdhPJwmFQn6uwkVRA6amIfnVciBMRYDqwjaxLrEq637PklqtLdfEcnYhTbbi12bVmMFTFpbQIZvMg== X-Received: by 2002:a1c:35c7:: with SMTP id c190mr4553794wma.146.1605011655289; Tue, 10 Nov 2020 04:34:15 -0800 (PST) Received: from debian-brgl.home (amarseille-656-1-4-167.w90-8.abo.wanadoo.fr. [90.8.158.167]) by smtp.gmail.com with ESMTPSA id s8sm12942217wrn.33.2020.11.10.04.34.14 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 10 Nov 2020 04:34:14 -0800 (PST) From: Bartosz Golaszewski To: Linus Walleij , Andy Shevchenko , Jan Kiszka , David Laight Cc: linux-gpio@vger.kernel.org, linux-kernel@vger.kernel.org, Bartosz Golaszewski Subject: [PATCH v3 3/7] gpio: exar: switch to a simpler IDA interface Date: Tue, 10 Nov 2020 13:34:02 +0100 Message-Id: <20201110123406.3261-4-brgl@bgdev.pl> X-Mailer: git-send-email 2.29.1 In-Reply-To: <20201110123406.3261-1-brgl@bgdev.pl> References: <20201110123406.3261-1-brgl@bgdev.pl> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-gpio@vger.kernel.org From: Bartosz Golaszewski We don't need to specify any ranges when allocating IDs so we can switch to ida_alloc() and ida_free() instead of the ida_simple_ counterparts. ida_simple_get(ida, 0, 0, gfp) is equivalent to ida_alloc_range(ida, 0, UINT_MAX, gfp) which is equivalent to ida_alloc(ida, gfp). Note: IDR will never actually allocate an ID larger than INT_MAX. Signed-off-by: Bartosz Golaszewski --- drivers/gpio/gpio-exar.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/drivers/gpio/gpio-exar.c b/drivers/gpio/gpio-exar.c index 1941ae533418..752e8437ff80 100644 --- a/drivers/gpio/gpio-exar.c +++ b/drivers/gpio/gpio-exar.c @@ -149,7 +149,7 @@ static int gpio_exar_probe(struct platform_device *pdev) mutex_init(&exar_gpio->lock); - index = ida_simple_get(&ida_index, 0, 0, GFP_KERNEL); + index = ida_alloc(&ida_index, GFP_KERNEL); if (index < 0) { ret = index; goto err_mutex_destroy; @@ -179,7 +179,7 @@ static int gpio_exar_probe(struct platform_device *pdev) return 0; err_destroy: - ida_simple_remove(&ida_index, index); + ida_free(&ida_index, index); err_mutex_destroy: mutex_destroy(&exar_gpio->lock); return ret; @@ -189,7 +189,7 @@ static int gpio_exar_remove(struct platform_device *pdev) { struct exar_gpio_chip *exar_gpio = platform_get_drvdata(pdev); - ida_simple_remove(&ida_index, exar_gpio->index); + ida_free(&ida_index, exar_gpio->index); mutex_destroy(&exar_gpio->lock); return 0; From patchwork Tue Nov 10 12:34:05 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bartosz Golaszewski X-Patchwork-Id: 321471 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-12.7 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID, HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_PATCH, MAILING_LIST_MULTI, SIGNED_OFF_BY,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED,USER_AGENT_GIT autolearn=unavailable autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 6D981C388F7 for ; Tue, 10 Nov 2020 12:34:42 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 1276120795 for ; Tue, 10 Nov 2020 12:34:42 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=bgdev-pl.20150623.gappssmtp.com header.i=@bgdev-pl.20150623.gappssmtp.com header.b="U/Y/yQOE" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1730590AbgKJMeY (ORCPT ); Tue, 10 Nov 2020 07:34:24 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:42488 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1730542AbgKJMeU (ORCPT ); Tue, 10 Nov 2020 07:34:20 -0500 Received: from mail-wm1-x344.google.com (mail-wm1-x344.google.com [IPv6:2a00:1450:4864:20::344]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 08D5EC0613D1 for ; Tue, 10 Nov 2020 04:34:20 -0800 (PST) Received: by mail-wm1-x344.google.com with SMTP id d142so2827386wmd.4 for ; Tue, 10 Nov 2020 04:34:19 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bgdev-pl.20150623.gappssmtp.com; s=20150623; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=xXkyfLrBZRJrErHtr2bqBIYeiQvyVwQuf/DgPi3APEY=; b=U/Y/yQOEbgnTM3Jkw110ASaMkq28gpx/BQ87lY59I6lLOL/usnPyX0oZwamiq+YwIi WnkARFstsDlwmY6TAKKwF3k2l1srtFRk5HXfLdVr+R4Uk8D0JxCUJu7B7ikUsBJIRCUR PnJ0SF2ypLhcng6QrmoqnFg6DJE6AaC2/ntwTOWjjNaxhVn+DJeqAsbSMcatZvtaCkoj DaRfnXT+taNy/VZXtnhOv/cCfc/drIW8QXNny+u3WwDa1SdgYJ4SwuiVV2qGSUIXqcTf 84DSUVPCaJW465W1QscHsEuPtYd9kEkqzTI2mRpkqeWLx3OfN0apONuNA8O0irCstaVm kBcA== 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=xXkyfLrBZRJrErHtr2bqBIYeiQvyVwQuf/DgPi3APEY=; b=fu8zsgJgIgJaIKhPi7Afa0OuulXn/vD65NTiWYE4dU0D72hdy9DWd9OsuhhImx5ktJ kAbGoG0Wu4Og+R9ShuIygZMXKPOhcgt2w6SO99fZnOUIm1b37lcNEMiFOgBMuq5umapw UaYZF6gwL7AsnW6A3lA2b+PunVFx97DdCUIGjSAhdndbO012adwd8Ne84zie3PK0/XQX 239OdpkzVl3B9Y7bUScJjPPXB5OabUNNsxFeY3bYZvabjbygKYAyq8a388FcTk7ifAhv C0IT/xuxZd5mLGNR5I8FHPPBtfIBdm/xPgPW5FsbvzBzpOEKdf8750nWuJrLRCRKb7yS UNNA== X-Gm-Message-State: AOAM533/j10Ybrdnw8p/B0Y7HJ9ssoSGlUqYBOenxu73vt+6Zlv3ZJwV sXistWy6z4I5wpSa/dx7XSE8mg== X-Google-Smtp-Source: ABdhPJwp5OaImM8MdLBmdjebMREmgGh7/sRhmSH1JVet+Ix4TxRX/7JeYC5IUnDNFxeAjbtjSGdZTg== X-Received: by 2002:a05:600c:4147:: with SMTP id h7mr4318969wmm.146.1605011658685; Tue, 10 Nov 2020 04:34:18 -0800 (PST) Received: from debian-brgl.home (amarseille-656-1-4-167.w90-8.abo.wanadoo.fr. [90.8.158.167]) by smtp.gmail.com with ESMTPSA id s8sm12942217wrn.33.2020.11.10.04.34.17 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 10 Nov 2020 04:34:18 -0800 (PST) From: Bartosz Golaszewski To: Linus Walleij , Andy Shevchenko , Jan Kiszka , David Laight Cc: linux-gpio@vger.kernel.org, linux-kernel@vger.kernel.org, Bartosz Golaszewski Subject: [PATCH v3 6/7] gpio: exar: switch to using regmap Date: Tue, 10 Nov 2020 13:34:05 +0100 Message-Id: <20201110123406.3261-7-brgl@bgdev.pl> X-Mailer: git-send-email 2.29.1 In-Reply-To: <20201110123406.3261-1-brgl@bgdev.pl> References: <20201110123406.3261-1-brgl@bgdev.pl> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-gpio@vger.kernel.org From: Bartosz Golaszewski We can simplify the code in gpio-exar by using regmap. This allows us to drop the mutex (regmap provides its own locking) and we can also reuse regmap's bit operations instead of implementing our own update function. Signed-off-by: Bartosz Golaszewski --- drivers/gpio/Kconfig | 1 + drivers/gpio/gpio-exar.c | 90 +++++++++++++++++----------------------- 2 files changed, 38 insertions(+), 53 deletions(-) diff --git a/drivers/gpio/Kconfig b/drivers/gpio/Kconfig index 5d4de5cd6759..253a61ec9645 100644 --- a/drivers/gpio/Kconfig +++ b/drivers/gpio/Kconfig @@ -255,6 +255,7 @@ config GPIO_EP93XX config GPIO_EXAR tristate "Support for GPIO pins on XR17V352/354/358" depends on SERIAL_8250_EXAR + select REGMAP_MMIO help Selecting this option will enable handling of GPIO pins present on Exar XR17V352/354/358 chips. diff --git a/drivers/gpio/gpio-exar.c b/drivers/gpio/gpio-exar.c index 28b0b4b5fa35..a2d324c513f8 100644 --- a/drivers/gpio/gpio-exar.c +++ b/drivers/gpio/gpio-exar.c @@ -14,6 +14,7 @@ #include #include #include +#include #define EXAR_OFFSET_MPIOLVL_LO 0x90 #define EXAR_OFFSET_MPIOSEL_LO 0x93 @@ -26,9 +27,8 @@ static DEFINE_IDA(ida_index); struct exar_gpio_chip { struct gpio_chip gpio_chip; - struct mutex lock; + struct regmap *regs; int index; - void __iomem *regs; char name[20]; unsigned int first_pin; }; @@ -53,51 +53,13 @@ exar_offset_to_bit(struct exar_gpio_chip *exar_gpio, unsigned int offset) return (offset + exar_gpio->first_pin) % 8; } -static void exar_update(struct gpio_chip *chip, unsigned int reg, int val, - unsigned int offset) -{ - struct exar_gpio_chip *exar_gpio = gpiochip_get_data(chip); - int temp; - - mutex_lock(&exar_gpio->lock); - temp = readb(exar_gpio->regs + reg); - temp &= ~BIT(offset); - if (val) - temp |= BIT(offset); - writeb(temp, exar_gpio->regs + reg); - mutex_unlock(&exar_gpio->lock); -} - -static int exar_set_direction(struct gpio_chip *chip, int direction, - unsigned int offset) -{ - struct exar_gpio_chip *exar_gpio = gpiochip_get_data(chip); - unsigned int addr = exar_offset_to_sel_addr(exar_gpio, offset); - unsigned int bit = exar_offset_to_bit(exar_gpio, offset); - - exar_update(chip, addr, direction, bit); - return 0; -} - -static int exar_get(struct gpio_chip *chip, unsigned int reg) -{ - struct exar_gpio_chip *exar_gpio = gpiochip_get_data(chip); - int value; - - mutex_lock(&exar_gpio->lock); - value = readb(exar_gpio->regs + reg); - mutex_unlock(&exar_gpio->lock); - - return value; -} - static int exar_get_direction(struct gpio_chip *chip, unsigned int offset) { struct exar_gpio_chip *exar_gpio = gpiochip_get_data(chip); unsigned int addr = exar_offset_to_sel_addr(exar_gpio, offset); unsigned int bit = exar_offset_to_bit(exar_gpio, offset); - if (exar_get(chip, addr) & BIT(bit)) + if (regmap_test_bits(exar_gpio->regs, addr, BIT(bit))) return GPIO_LINE_DIRECTION_IN; return GPIO_LINE_DIRECTION_OUT; @@ -109,7 +71,7 @@ static int exar_get_value(struct gpio_chip *chip, unsigned int offset) unsigned int addr = exar_offset_to_lvl_addr(exar_gpio, offset); unsigned int bit = exar_offset_to_bit(exar_gpio, offset); - return !!(exar_get(chip, addr) & BIT(bit)); + return !!(regmap_test_bits(exar_gpio->regs, addr, BIT(bit))); } static void exar_set_value(struct gpio_chip *chip, unsigned int offset, @@ -119,21 +81,42 @@ static void exar_set_value(struct gpio_chip *chip, unsigned int offset, unsigned int addr = exar_offset_to_lvl_addr(exar_gpio, offset); unsigned int bit = exar_offset_to_bit(exar_gpio, offset); - exar_update(chip, addr, value, bit); + if (value) + regmap_set_bits(exar_gpio->regs, addr, BIT(bit)); + else + regmap_clear_bits(exar_gpio->regs, addr, BIT(bit)); } static int exar_direction_output(struct gpio_chip *chip, unsigned int offset, int value) { + struct exar_gpio_chip *exar_gpio = gpiochip_get_data(chip); + unsigned int addr = exar_offset_to_sel_addr(exar_gpio, offset); + unsigned int bit = exar_offset_to_bit(exar_gpio, offset); + exar_set_value(chip, offset, value); - return exar_set_direction(chip, 0, offset); + regmap_clear_bits(exar_gpio->regs, addr, BIT(bit)); + + return 0; } static int exar_direction_input(struct gpio_chip *chip, unsigned int offset) { - return exar_set_direction(chip, 1, offset); + struct exar_gpio_chip *exar_gpio = gpiochip_get_data(chip); + unsigned int addr = exar_offset_to_sel_addr(exar_gpio, offset); + unsigned int bit = exar_offset_to_bit(exar_gpio, offset); + + regmap_set_bits(exar_gpio->regs, addr, BIT(bit)); + + return 0; } +static const struct regmap_config exar_regmap_config = { + .name = "exar-gpio", + .reg_bits = 8, + .val_bits = 8, +}; + static int gpio_exar_probe(struct platform_device *pdev) { struct device *dev = &pdev->dev; @@ -163,13 +146,17 @@ static int gpio_exar_probe(struct platform_device *pdev) if (!exar_gpio) return -ENOMEM; - mutex_init(&exar_gpio->lock); + /* + * We don't need to check the return values of mmio regmap operations (unless + * the regmap has a clock attached which is not the case here). + */ + exar_gpio->regs = devm_regmap_init_mmio(dev, p, &exar_regmap_config); + if (IS_ERR(exar_gpio->regs)) + return PTR_ERR(exar_gpio->regs); index = ida_alloc(&ida_index, GFP_KERNEL); - if (index < 0) { - ret = index; - goto err_mutex_destroy; - } + if (index < 0) + return index; sprintf(exar_gpio->name, "exar_gpio%d", index); exar_gpio->gpio_chip.label = exar_gpio->name; @@ -195,8 +182,6 @@ static int gpio_exar_probe(struct platform_device *pdev) err_destroy: ida_free(&ida_index, index); -err_mutex_destroy: - mutex_destroy(&exar_gpio->lock); return ret; } @@ -205,7 +190,6 @@ static int gpio_exar_remove(struct platform_device *pdev) struct exar_gpio_chip *exar_gpio = platform_get_drvdata(pdev); ida_free(&ida_index, exar_gpio->index); - mutex_destroy(&exar_gpio->lock); return 0; }