From patchwork Wed Nov 4 19:30:44 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bartosz Golaszewski X-Patchwork-Id: 1394495 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=none (p=none dis=none) header.from=bgdev.pl Authentication-Results: ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=bgdev-pl.20150623.gappssmtp.com header.i=@bgdev-pl.20150623.gappssmtp.com header.a=rsa-sha256 header.s=20150623 header.b=CGG0ntkp; dkim-atps=neutral Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by ozlabs.org (Postfix) with ESMTP id 4CRGxG29h5z9sVS for ; Thu, 5 Nov 2020 06:31:46 +1100 (AEDT) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1731176AbgKDTa7 (ORCPT ); Wed, 4 Nov 2020 14:30:59 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:36630 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1730788AbgKDTa6 (ORCPT ); Wed, 4 Nov 2020 14:30:58 -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 7580EC0613D4 for ; Wed, 4 Nov 2020 11:30:58 -0800 (PST) Received: by mail-wr1-x442.google.com with SMTP id x7so23325493wrl.3 for ; Wed, 04 Nov 2020 11:30:58 -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=aE8AlEOJT9P+pbgFO2925Tf8enhX7i67KSrVU6g6Jdw=; b=CGG0ntkpOFV4TRjjvJFjmnJMXugj2mxhcoA30rQurHrxKNQWQDQyAFNHcioGScs7rk N5YSNXYWwfn3bsh2agO3bszdSPx8/s9FWZgzSxNQKxZ7qm7kY0AHWb5Co+Lt52QffvI0 VMaWIF7nyqLWxX3SgAnjjB59z4fQ1ILmoqizqZwMbTjo0iR2bsdFftureOZghCJ3mieR QJ6f9OfIMyCdMxxUcpps5N7lSeGtExXxv3J/c/3lcYz2rANTctfhDnSf4Q7Zn1+NIORs intdnRkQi/aOyq+PatXiPFV8c9z5OrG4zsh2llYOlYSvSlXLZiPtEOiQ79Zi5BT3JmtQ jwJA== 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=aE8AlEOJT9P+pbgFO2925Tf8enhX7i67KSrVU6g6Jdw=; b=X7pqjEQsEDaCTRA+JbU9R37UwNyxLSzvdOQLEejtNgfTroS49oV/LX/DOW4R0Lgf0Q bZTgX5koFMlYEYrwFRLLkJJmX38c+TK+jbT5JNlzCLkao/khT79+eaGkbGHD4ELv6a7m rPTdmfN+i/eSU7FU1o5/Lwp4OuAPgBCIQH1yS0PiYlYyeTfiR7aGM9hMCxw96DGcYDfs nqq0KPO/SFdN1oekgQEtz0cT7YCvhq8j2PhyIGaRl4GLr4QCkc1tzvi6ecQaCfRaWb0m CX4k2ASX7ApYN7PjBR4lHLooWn75Mmdod+0BiBOE4CX2mAPCukUnySv4qJJh1puOofgf JKYA== X-Gm-Message-State: AOAM531xpyVcQ3iKNsQQuiDr4/xuc7uZNlAS2mXqIxijmvygYUVLAHrt yAxnDRiS0AyfqpPVRUYCY7tKEw== X-Google-Smtp-Source: ABdhPJz7iWx6nLyowWVcGP/GeIV6d6ZWY4cYwwt+Tc3Zt4dxD1bTOjc9KJjirRpDMCkKnEiT2o4xww== X-Received: by 2002:adf:dd0b:: with SMTP id a11mr35765164wrm.41.1604518257130; Wed, 04 Nov 2020 11:30:57 -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 m12sm4051671wrs.92.2020.11.04.11.30.55 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 04 Nov 2020 11:30:56 -0800 (PST) From: Bartosz Golaszewski To: Linus Walleij , Andy Shevchenko , Jan Kiszka , David Laight , Mark Brown Cc: linux-gpio@vger.kernel.org, linux-kernel@vger.kernel.org, Bartosz Golaszewski , Andy Shevchenko Subject: [PATCH v2 1/8] regmap: provide regmap_assign_bits() Date: Wed, 4 Nov 2020 20:30:44 +0100 Message-Id: <20201104193051.32236-2-brgl@bgdev.pl> X-Mailer: git-send-email 2.29.1 In-Reply-To: <20201104193051.32236-1-brgl@bgdev.pl> References: <20201104193051.32236-1-brgl@bgdev.pl> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-gpio@vger.kernel.org From: Bartosz Golaszewski Add another bits helper to regmap API: this one sets given bits if value is true and clears them if it's false. Suggested-by: Andy Shevchenko Signed-off-by: Bartosz Golaszewski --- include/linux/regmap.h | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/include/linux/regmap.h b/include/linux/regmap.h index e7834d98207f..62099e7a3ed6 100644 --- a/include/linux/regmap.h +++ b/include/linux/regmap.h @@ -1148,6 +1148,15 @@ static inline int regmap_clear_bits(struct regmap *map, return regmap_update_bits_base(map, reg, bits, 0, NULL, false, false); } +static inline int regmap_assign_bits(struct regmap *map, unsigned int reg, + unsigned int bits, bool value) +{ + if (value) + return regmap_set_bits(map, reg, bits); + else + return regmap_clear_bits(map, reg, bits); +} + int regmap_test_bits(struct regmap *map, unsigned int reg, unsigned int bits); /** @@ -1554,6 +1563,13 @@ static inline int regmap_clear_bits(struct regmap *map, return -EINVAL; } +static inline int regmap_assign_bits(struct regmap *map, unsigned int reg, + unsigned int bits, bool value) +{ + WARN_ONCE(1, "regmap API is disabled"); + return -EINVAL; +} + static inline int regmap_test_bits(struct regmap *map, unsigned int reg, unsigned int bits) { From patchwork Wed Nov 4 19:30:45 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bartosz Golaszewski X-Patchwork-Id: 1394487 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=none (p=none dis=none) header.from=bgdev.pl Authentication-Results: ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=bgdev-pl.20150623.gappssmtp.com header.i=@bgdev-pl.20150623.gappssmtp.com header.a=rsa-sha256 header.s=20150623 header.b=Xc/0YLTZ; dkim-atps=neutral Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by ozlabs.org (Postfix) with ESMTP id 4CRGwR4b8hz9sTK for ; Thu, 5 Nov 2020 06:31:03 +1100 (AEDT) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1731297AbgKDTbB (ORCPT ); Wed, 4 Nov 2020 14:31:01 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:36640 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1731226AbgKDTbA (ORCPT ); Wed, 4 Nov 2020 14:31:00 -0500 Received: from mail-wm1-x342.google.com (mail-wm1-x342.google.com [IPv6:2a00:1450:4864:20::342]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 9CB6CC0613D4 for ; Wed, 4 Nov 2020 11:30:59 -0800 (PST) Received: by mail-wm1-x342.google.com with SMTP id e2so3427965wme.1 for ; Wed, 04 Nov 2020 11:30:59 -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=Xc/0YLTZPI+UQWykB4lIw3iXmFif+BleKjICzPVQtQMaG33CpdikHlBIYxI88uBhTx VzVOCxpteEdhPXq8CADPFBzLyRqFstOzccip1HzUyAW8nNRx/ZFgN/LGRMolVNd3Luyp 08AEebtbS+gSG+hrJuF3cHhYKyNnLytT5ZH2XlJrSVwq8WpcKuZk42Wnnz/qlLSrIffH 19LBzz+ORA47JecLcYmI3mNJhrABpkA+B0QLfz5luZr3mhtSdAuhawQiLEcsVm3KuuEc 5x5Bzo3WS6TSaUFzFJ5DKYFbHITmsureLqdX3Yr6uzRtZYDoFkJFBjSepfu5PCFhOaZo kDeA== 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=FlXYmsykEYXpwCWbedR1zsXoqeU8tOV/XiwjO/EGKjhbo3352Xd1dtoTrfBibc59qq GhmImiSh3VNXcoUiPrCWYvLkheD3WAYZrFHCrwagNgwy5cIEHadvLlFHZQoA3Uzp5AF2 /H1EOXsfOIiqc/Fss+WbEBYwlUH4OPNtBV4c9NAlLQCEbq+/RCVdbSDHe3DJwrOS0YLk 3md9sEpvYuddbo1tOXG+nXnQlgJRkuDZBPj3zt95+uJhgOVhOJd24Qo+qoOod2yzN8W/ GSPHgqaqJa9WvxX1KyYxX4T4l+nPt+ywjFMqhnmuCFWGeRH+Rl/eHxoSt0c5rwcSiUbk Zj3A== X-Gm-Message-State: AOAM531iHnmEbJvtlyhsvlebP2eLI3dWlKm/8j6OIjwGKBVl7tryjmMS Y0vWYw9UsZ4KkXgiPfXLORONhQ== X-Google-Smtp-Source: ABdhPJxbC0ey4Rg99lhY3yGZtCR9r7zZ57Li9DI4bUljuHc+JAs4CwW4XOl2xv8dyBpp5/NAwqsqLQ== X-Received: by 2002:a1c:35c7:: with SMTP id c190mr6063566wma.7.1604518258408; Wed, 04 Nov 2020 11:30:58 -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 m12sm4051671wrs.92.2020.11.04.11.30.57 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 04 Nov 2020 11:30:57 -0800 (PST) From: Bartosz Golaszewski To: Linus Walleij , Andy Shevchenko , Jan Kiszka , David Laight , Mark Brown Cc: linux-gpio@vger.kernel.org, linux-kernel@vger.kernel.org, Bartosz Golaszewski Subject: [PATCH v2 2/8] gpio: exar: add a newline after the copyright notice Date: Wed, 4 Nov 2020 20:30:45 +0100 Message-Id: <20201104193051.32236-3-brgl@bgdev.pl> X-Mailer: git-send-email 2.29.1 In-Reply-To: <20201104193051.32236-1-brgl@bgdev.pl> References: <20201104193051.32236-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 Wed Nov 4 19:30:46 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bartosz Golaszewski X-Patchwork-Id: 1394488 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=none (p=none dis=none) header.from=bgdev.pl Authentication-Results: ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=bgdev-pl.20150623.gappssmtp.com header.i=@bgdev-pl.20150623.gappssmtp.com header.a=rsa-sha256 header.s=20150623 header.b=X6wXiCxJ; dkim-atps=neutral Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by ozlabs.org (Postfix) with ESMTP id 4CRGwS18j8z9sTR for ; Thu, 5 Nov 2020 06:31:04 +1100 (AEDT) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1731378AbgKDTbC (ORCPT ); Wed, 4 Nov 2020 14:31:02 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:36646 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1731306AbgKDTbB (ORCPT ); Wed, 4 Nov 2020 14:31:01 -0500 Received: from mail-wr1-x441.google.com (mail-wr1-x441.google.com [IPv6:2a00:1450:4864:20::441]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id D7A17C0613D4 for ; Wed, 4 Nov 2020 11:31:00 -0800 (PST) Received: by mail-wr1-x441.google.com with SMTP id w1so23347630wrm.4 for ; Wed, 04 Nov 2020 11:31:00 -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=X6wXiCxJ19YmJynRpQiIR1GKNEXqk6HCc8AB2RqHuJ3t9U5HvHt3IO/Ijl6tIrxY32 MBMEj5rHE0elD5LzJFd6z4hQbRERvqvNUTg1Pzdpyl3fVSq5Et/8Mw1c/vhPri3zvUu2 zIcQ+n4FtDzljU7tO460QRQIP0AgrECI6b2s+3OJ9AoNxxw5q39ABQ2VnRuIe6t/D7rd akPjX/jGan+YoJJm9JLjgiY0ib8LPecB81+yis/DuYEaKCosBj2fXq0YwGklgeF7Zeqp Igtu2AZoAGZBSgP38c8eMmE+cvhPDsmJa5OkdTkoLba9FQ57Q9NVD7BTJH6gJSqTeI5R 1VFA== 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=a58RcLuGss3q9dAlCoBmcCXJh3NM2umJezm1KXsX/dqV+QewuWKC5rz1zt/BmfCSCj 0s1EGbWeUMKZFd6YpZ/1hhz6MjDt6uNfkFp6u94YNsC05GfxVegRjLdhXorPtT1KvJwO bkL5966njRDJdi0t7eCJrReW918s5nDKNKaNWnOAQAzuTzLGySSgX5AlJqWQzaecWyQ0 77C5ZmMlYefdvdolJ/p9ZPkcOJk1OtZuGekV0kFd3Z0Eunqok7k9b0KpbXt+N6M/WeKr f9I95Gobj7BoZzwKdorqIjjoBGDVdkVu9kOlf3siWwxvLEZ0OfNXZlwWMrvoWm+7XEle MQ+g== X-Gm-Message-State: AOAM530cjmrfc3+J1G0rYKq9v6FJ930mCAS2GKLt7iaDTBGTvNdJAe/6 SsTp33f5c6KqafR31a+pAaPmlQ== X-Google-Smtp-Source: ABdhPJwujp3SZEsGu7VhbaTGsgUxvo/eHznG69HLbFinR/fN8zCFPyza/HK/9iP1IkbiMaR8TO5KPA== X-Received: by 2002:adf:f101:: with SMTP id r1mr36574226wro.392.1604518259652; Wed, 04 Nov 2020 11:30:59 -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 m12sm4051671wrs.92.2020.11.04.11.30.58 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 04 Nov 2020 11:30:59 -0800 (PST) From: Bartosz Golaszewski To: Linus Walleij , Andy Shevchenko , Jan Kiszka , David Laight , Mark Brown Cc: linux-gpio@vger.kernel.org, linux-kernel@vger.kernel.org, Bartosz Golaszewski Subject: [PATCH v2 3/8] gpio: exar: include idr.h Date: Wed, 4 Nov 2020 20:30:46 +0100 Message-Id: <20201104193051.32236-4-brgl@bgdev.pl> X-Mailer: git-send-email 2.29.1 In-Reply-To: <20201104193051.32236-1-brgl@bgdev.pl> References: <20201104193051.32236-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 Wed Nov 4 19:30:47 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bartosz Golaszewski X-Patchwork-Id: 1394494 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=none (p=none dis=none) header.from=bgdev.pl Authentication-Results: ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=bgdev-pl.20150623.gappssmtp.com header.i=@bgdev-pl.20150623.gappssmtp.com header.a=rsa-sha256 header.s=20150623 header.b=LOZfyrxq; dkim-atps=neutral Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by ozlabs.org (Postfix) with ESMTP id 4CRGxD4j77z9sVN for ; Thu, 5 Nov 2020 06:31:44 +1100 (AEDT) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1731243AbgKDTbn (ORCPT ); Wed, 4 Nov 2020 14:31:43 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:36652 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1731418AbgKDTbC (ORCPT ); Wed, 4 Nov 2020 14:31:02 -0500 Received: from mail-wr1-x443.google.com (mail-wr1-x443.google.com [IPv6:2a00:1450:4864:20::443]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 6BDFCC0613D4 for ; Wed, 4 Nov 2020 11:31:02 -0800 (PST) Received: by mail-wr1-x443.google.com with SMTP id x7so23325646wrl.3 for ; Wed, 04 Nov 2020 11:31:02 -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=LOZfyrxq/o6RODMOyrU+qZOvySfL8SOerWyuvitpANZum1b/dHHL5T9VTGrvED/P7v SJbnq0ng7zQf0JTXyCeHdNGalGpL9J76qP6TXFf2rzvAysdIjIvvRGN3FtALlw7o1ijQ 0qasCP7/Nz27WzdkvNctsAdGHcnR7M6UweKTyFp3NIeONAdb8rcGAyYTlCYTRJswfdPU altYpiuR03HPGxJkkfXZ/caBPmrcGskefyx1wHlgGeGHjP6XkSRn8imRRy89Yi2MSftH gM4lP6jXoigGMQf/THIJfmcaZZIpspe1JfYLS2RNKeS88LnI8LDVBEEm/9uqk7EGNw8X JNFg== 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=C/Qg6Z3QvCxi1cSDOm7NlCIbBJNS/RsdHuPOYDm5vzwCogcG/LhcQeLEKiGQf8FDJu aQQdApo9URrpYzD60mj/5giY6mCNkcq3ZusKx8jeuteIhGnTsoc/g/AoKpCxJafNY0fD g/4dgKAravwmn4gbkEN/8cXY4Pq7V5Ez764AMC3g3AFTHennPHDQKHy5wNq+VCrUv9rs cwh/uFcYrsFsdvtiswm6tttIt7yHpz2uAt1wvde8zBn0o8vNkRxZgCWL70qPIrr6VIKJ 47fioT8PwYT4oFopH+0UYEDg6uYJjJ3rcTWk1kj9VFAh6Ij5ALm6w8Ukv9zmaWYAPG6W wrww== X-Gm-Message-State: AOAM530AMMIgIcDFZn0kFM5TlQmUvqbJyUeZ7v4KkXMzslMc8QJrjSYB zDa0RhAyCrL5XrJvFXaFGV9MgkiIEGM5Jg== X-Google-Smtp-Source: ABdhPJzmTo8yA7ign+6yiLlNRhedMA3K+hOB2l+5S9JH8N4LOgtiSZUZ5B6M4pznPp3esfra16yrwA== X-Received: by 2002:a5d:698e:: with SMTP id g14mr32482428wru.232.1604518261207; Wed, 04 Nov 2020 11:31:01 -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 m12sm4051671wrs.92.2020.11.04.11.30.59 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 04 Nov 2020 11:31:00 -0800 (PST) From: Bartosz Golaszewski To: Linus Walleij , Andy Shevchenko , Jan Kiszka , David Laight , Mark Brown Cc: linux-gpio@vger.kernel.org, linux-kernel@vger.kernel.org, Bartosz Golaszewski Subject: [PATCH v2 4/8] gpio: exar: switch to a simpler IDA interface Date: Wed, 4 Nov 2020 20:30:47 +0100 Message-Id: <20201104193051.32236-5-brgl@bgdev.pl> X-Mailer: git-send-email 2.29.1 In-Reply-To: <20201104193051.32236-1-brgl@bgdev.pl> References: <20201104193051.32236-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 Wed Nov 4 19:30:48 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bartosz Golaszewski X-Patchwork-Id: 1394489 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=none (p=none dis=none) header.from=bgdev.pl Authentication-Results: ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=bgdev-pl.20150623.gappssmtp.com header.i=@bgdev-pl.20150623.gappssmtp.com header.a=rsa-sha256 header.s=20150623 header.b=OsdPJIom; dkim-atps=neutral Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by ozlabs.org (Postfix) with ESMTP id 4CRGwW1tWYz9sVN for ; Thu, 5 Nov 2020 06:31:07 +1100 (AEDT) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1731537AbgKDTbF (ORCPT ); Wed, 4 Nov 2020 14:31:05 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:36660 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1730788AbgKDTbE (ORCPT ); Wed, 4 Nov 2020 14:31:04 -0500 Received: from mail-wr1-x444.google.com (mail-wr1-x444.google.com [IPv6:2a00:1450:4864:20::444]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 32546C0613D4 for ; Wed, 4 Nov 2020 11:31:04 -0800 (PST) Received: by mail-wr1-x444.google.com with SMTP id s9so23291815wro.8 for ; Wed, 04 Nov 2020 11:31:04 -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=PfaggvFtdrOq7HMZ8nUir6KiglSCvEmyQ3kUEaGT+6M=; b=OsdPJIomd69BhDyc9fg34yfsJj+muR6UcvOsSuGalhlbj1c91hG/Pk7tQ3DprEEVbU BtEa1i4nmIeAJawI9HvI2Nu9t+PfqSF//7VbO15EdAu6fW1fKK1sLXAHZG+yxS5o2hLD XPEhpXVbvBkjmpyHR++CudxD+yuRRwI+b2cHjpJDRUsFoKcSw4JPzZv25YYFC41CYwBh Ei8Rk4WnRZkAVA12xa+SXFzo7JZDAzZAP/mSjZSLGrkv7lzXYrmzDoaavdlTyI4U0My7 Qkf/k0NUzi21gIsEcXvcKhFfvt9kc3S9jyl3uoLk0M7b9LKKAEN11U8IhtRVM1MK6xnC uZsg== 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=PfaggvFtdrOq7HMZ8nUir6KiglSCvEmyQ3kUEaGT+6M=; b=QSZj/JQLt5ui2h1/x1Q3khiNw298gNG/Sl4xKwkohqxPcgS0k6GqeKFdIfhbd7TNXI s6a32epHe4jxFM8oSQG1YHy8PW0UrMEr9tb6LTOwJRRcluZAu36J/8F8NDwXYS9sUaLm xC9jI9SryP7JkpgTNG4ia9n3VXmeRz89lcM91xBeh1CEls3NuPVx+M6XplBHYbMACp5y xiZFLJN6dwfB33Gx6Wn7f+7UPwWQCVK4IDmc4OZqR0OrYlMb2yca4f+GuFJvF/uCuGMZ 4kfcGqNgBOrlb8WpncAjQTT/wC/F4o/j7Lo2Of33CPCWLYdI4WhZbrz5XLkICiWy5N3m DhcQ== X-Gm-Message-State: AOAM5329LJXTfD36ICSTgwZxMVNsKjt3DUt8yGeZI69QIeN6cu0c9Eo2 XBukFcSUGPxztTd5+jqyFI/2VQ== X-Google-Smtp-Source: ABdhPJyl+5LxdbZHeWV1XMmLoAnA5++zG1zykwQR0D3QUEbfi6nyl4tK2QgVIKXmf6EHP+zC74SeNw== X-Received: by 2002:adf:e5c1:: with SMTP id a1mr29328591wrn.12.1604518262880; Wed, 04 Nov 2020 11:31:02 -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 m12sm4051671wrs.92.2020.11.04.11.31.01 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 04 Nov 2020 11:31:01 -0800 (PST) From: Bartosz Golaszewski To: Linus Walleij , Andy Shevchenko , Jan Kiszka , David Laight , Mark Brown Cc: linux-gpio@vger.kernel.org, linux-kernel@vger.kernel.org, Bartosz Golaszewski Subject: [PATCH v2 5/8] gpio: exar: use a helper variable for &pdev->dev Date: Wed, 4 Nov 2020 20:30:48 +0100 Message-Id: <20201104193051.32236-6-brgl@bgdev.pl> X-Mailer: git-send-email 2.29.1 In-Reply-To: <20201104193051.32236-1-brgl@bgdev.pl> References: <20201104193051.32236-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 more elegant to use a helper local variable to store the address of the underlying struct device than to dereference pdev everywhere. It also has the benefit of avoiding unnecessary line breaks. Signed-off-by: Bartosz Golaszewski --- drivers/gpio/gpio-exar.c | 15 +++++++-------- 1 file changed, 7 insertions(+), 8 deletions(-) diff --git a/drivers/gpio/gpio-exar.c b/drivers/gpio/gpio-exar.c index 752e8437ff80..db366d85b6b4 100644 --- a/drivers/gpio/gpio-exar.c +++ b/drivers/gpio/gpio-exar.c @@ -120,7 +120,8 @@ static int exar_direction_input(struct gpio_chip *chip, unsigned int offset) static int gpio_exar_probe(struct platform_device *pdev) { - struct pci_dev *pcidev = to_pci_dev(pdev->dev.parent); + struct device *dev = &pdev->dev; + struct pci_dev *pcidev = to_pci_dev(dev->parent); struct exar_gpio_chip *exar_gpio; u32 first_pin, ngpios; void __iomem *p; @@ -134,16 +135,15 @@ static int gpio_exar_probe(struct platform_device *pdev) if (!p) return -ENOMEM; - ret = device_property_read_u32(&pdev->dev, "exar,first-pin", - &first_pin); + ret = device_property_read_u32(dev, "exar,first-pin", &first_pin); if (ret) return ret; - ret = device_property_read_u32(&pdev->dev, "ngpios", &ngpios); + ret = device_property_read_u32(dev, "ngpios", &ngpios); if (ret) return ret; - exar_gpio = devm_kzalloc(&pdev->dev, sizeof(*exar_gpio), GFP_KERNEL); + exar_gpio = devm_kzalloc(dev, sizeof(*exar_gpio), GFP_KERNEL); if (!exar_gpio) return -ENOMEM; @@ -157,7 +157,7 @@ static int gpio_exar_probe(struct platform_device *pdev) sprintf(exar_gpio->name, "exar_gpio%d", index); exar_gpio->gpio_chip.label = exar_gpio->name; - exar_gpio->gpio_chip.parent = &pdev->dev; + exar_gpio->gpio_chip.parent = dev; exar_gpio->gpio_chip.direction_output = exar_direction_output; exar_gpio->gpio_chip.direction_input = exar_direction_input; exar_gpio->gpio_chip.get_direction = exar_get_direction; @@ -169,8 +169,7 @@ static int gpio_exar_probe(struct platform_device *pdev) exar_gpio->index = index; exar_gpio->first_pin = first_pin; - ret = devm_gpiochip_add_data(&pdev->dev, - &exar_gpio->gpio_chip, exar_gpio); + ret = devm_gpiochip_add_data(dev, &exar_gpio->gpio_chip, exar_gpio); if (ret) goto err_destroy; From patchwork Wed Nov 4 19:30:49 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bartosz Golaszewski X-Patchwork-Id: 1394493 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=none (p=none dis=none) header.from=bgdev.pl Authentication-Results: ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=bgdev-pl.20150623.gappssmtp.com header.i=@bgdev-pl.20150623.gappssmtp.com header.a=rsa-sha256 header.s=20150623 header.b=oji3YSQN; dkim-atps=neutral Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by ozlabs.org (Postfix) with ESMTP id 4CRGx31174z9sVV for ; Thu, 5 Nov 2020 06:31:33 +1100 (AEDT) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729946AbgKDTbG (ORCPT ); Wed, 4 Nov 2020 14:31:06 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:36668 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729784AbgKDTbG (ORCPT ); Wed, 4 Nov 2020 14:31:06 -0500 Received: from mail-wr1-x441.google.com (mail-wr1-x441.google.com [IPv6:2a00:1450:4864:20::441]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 9AB75C0613D3 for ; Wed, 4 Nov 2020 11:31:05 -0800 (PST) Received: by mail-wr1-x441.google.com with SMTP id x7so23325789wrl.3 for ; Wed, 04 Nov 2020 11:31:05 -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=SyfsPFMi1Ol5bHDdeg25EiAHS6gH8P7QyAg8QmJ1Sho=; b=oji3YSQN0WvH6hSwnCdoH+Q3Da9CXUQwMm1VLJ1RaK1rHoeYeRpu1xM7QlPvyUS2UX zG7bFYiqklzWXlzX3lNBWhR6iDfnEPCH7EgUJTzuKQhThjLlx0Q/iiVTbWN99lLn3q8Y DgL7ZjUnnrWM98w1NnBplb8qdRxFNg06PBVYjIClricuAnRgAtylBs0jNhoydweSAGGP gEcSoyuUM4R0jlkA8FO6O/GgEsi88htn3ejCJ3/ieMmOwQuI6EQwKQvTXNJCfFittQGl f/tb7cAnU3H6ff/kt17ewinFRlTJogsRzVofi3heGGnbKlH+aEOSzBG5oLJApG1bvvkA Bhuw== 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=SyfsPFMi1Ol5bHDdeg25EiAHS6gH8P7QyAg8QmJ1Sho=; b=nlDFqDaeqObnJtVGiRMha1nLwdklb+Sdr7NPh7aqfaZapd2RqzwCLCbixlT/ZqJwH2 2fg1lbsx15eei0IDkJaXvBOQO5KY4bgJYjF7e2veGX7dy7HYM4g6Z9V8fiDFZ/IPy2PE U5+tTmCRMq2xan8XSTpgnDgYrvZ1L4ITACvhfrNtLvA3+deiPzwzrDN5pbVX9L3GCi2x 9uOg8at1dtFSiUP1DGt2wJhkwtAiSvYRt9NY51IMFM3T1lPDWmyARYVkxpAibqdI3Qb+ 9g/HvU7YvBF9DscwY5QpUpCFfPBr7gN/7V0f/xZbqu+znEBuGaaWbQ8RlTQ8TmRibjsN e/6g== X-Gm-Message-State: AOAM531hK6KwnN/aGyt2uQNLtcRweVh8Alsxsg7Pm/DQlsfb466iyLMn vB3zFpz/cePWrt/iz86bmE1bXQ== X-Google-Smtp-Source: ABdhPJzkirtxNi2CRcNJeilD4kxMLO1YF0VjZBrbmGbH4/HTs0pdCvfOr9uTCAf4fJEtr5wJP0aYLA== X-Received: by 2002:adf:fc83:: with SMTP id g3mr33802908wrr.200.1604518264314; Wed, 04 Nov 2020 11:31:04 -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 m12sm4051671wrs.92.2020.11.04.11.31.03 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 04 Nov 2020 11:31:03 -0800 (PST) From: Bartosz Golaszewski To: Linus Walleij , Andy Shevchenko , Jan Kiszka , David Laight , Mark Brown Cc: linux-gpio@vger.kernel.org, linux-kernel@vger.kernel.org, Bartosz Golaszewski Subject: [RFT PATCH v2 6/8] gpio: exar: unduplicate address and offset computation Date: Wed, 4 Nov 2020 20:30:49 +0100 Message-Id: <20201104193051.32236-7-brgl@bgdev.pl> X-Mailer: git-send-email 2.29.1 In-Reply-To: <20201104193051.32236-1-brgl@bgdev.pl> References: <20201104193051.32236-1-brgl@bgdev.pl> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-gpio@vger.kernel.org From: Bartosz Golaszewski Provide and use helpers for calculating the register address and bit offset instead of hand coding it in every function. Signed-off-by: Bartosz Golaszewski --- drivers/gpio/gpio-exar.c | 40 ++++++++++++++++++++++++++++------------ 1 file changed, 28 insertions(+), 12 deletions(-) diff --git a/drivers/gpio/gpio-exar.c b/drivers/gpio/gpio-exar.c index db366d85b6b4..28b0b4b5fa35 100644 --- a/drivers/gpio/gpio-exar.c +++ b/drivers/gpio/gpio-exar.c @@ -33,6 +33,26 @@ struct exar_gpio_chip { unsigned int first_pin; }; +static unsigned int +exar_offset_to_sel_addr(struct exar_gpio_chip *exar_gpio, unsigned int offset) +{ + return (offset + exar_gpio->first_pin) / 8 ? EXAR_OFFSET_MPIOSEL_HI + : EXAR_OFFSET_MPIOSEL_LO; +} + +static unsigned int +exar_offset_to_lvl_addr(struct exar_gpio_chip *exar_gpio, unsigned int offset) +{ + return (offset + exar_gpio->first_pin) / 8 ? EXAR_OFFSET_MPIOLVL_HI + : EXAR_OFFSET_MPIOLVL_LO; +} + +static unsigned int +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) { @@ -52,9 +72,8 @@ 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 = (offset + exar_gpio->first_pin) / 8 ? - EXAR_OFFSET_MPIOSEL_HI : EXAR_OFFSET_MPIOSEL_LO; - unsigned int bit = (offset + exar_gpio->first_pin) % 8; + 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; @@ -75,9 +94,8 @@ static int exar_get(struct gpio_chip *chip, unsigned int reg) 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 = (offset + exar_gpio->first_pin) / 8 ? - EXAR_OFFSET_MPIOSEL_HI : EXAR_OFFSET_MPIOSEL_LO; - unsigned int bit = (offset + exar_gpio->first_pin) % 8; + 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)) return GPIO_LINE_DIRECTION_IN; @@ -88,9 +106,8 @@ static int exar_get_direction(struct gpio_chip *chip, unsigned int offset) static int exar_get_value(struct gpio_chip *chip, unsigned int offset) { struct exar_gpio_chip *exar_gpio = gpiochip_get_data(chip); - unsigned int addr = (offset + exar_gpio->first_pin) / 8 ? - EXAR_OFFSET_MPIOLVL_HI : EXAR_OFFSET_MPIOLVL_LO; - unsigned int bit = (offset + exar_gpio->first_pin) % 8; + 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)); } @@ -99,9 +116,8 @@ static void exar_set_value(struct gpio_chip *chip, unsigned int offset, int value) { struct exar_gpio_chip *exar_gpio = gpiochip_get_data(chip); - unsigned int addr = (offset + exar_gpio->first_pin) / 8 ? - EXAR_OFFSET_MPIOLVL_HI : EXAR_OFFSET_MPIOLVL_LO; - unsigned int bit = (offset + exar_gpio->first_pin) % 8; + 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); } From patchwork Wed Nov 4 19:30:50 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bartosz Golaszewski X-Patchwork-Id: 1394490 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=none (p=none dis=none) header.from=bgdev.pl Authentication-Results: ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=bgdev-pl.20150623.gappssmtp.com header.i=@bgdev-pl.20150623.gappssmtp.com header.a=rsa-sha256 header.s=20150623 header.b=jROSX61w; dkim-atps=neutral Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by ozlabs.org (Postfix) with ESMTP id 4CRGwc3ns0z9sTR for ; Thu, 5 Nov 2020 06:31:12 +1100 (AEDT) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1731610AbgKDTbJ (ORCPT ); Wed, 4 Nov 2020 14:31:09 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:36676 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1731591AbgKDTbI (ORCPT ); Wed, 4 Nov 2020 14:31:08 -0500 Received: from mail-wr1-x444.google.com (mail-wr1-x444.google.com [IPv6:2a00:1450:4864:20::444]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id E16ECC0613D3 for ; Wed, 4 Nov 2020 11:31:06 -0800 (PST) Received: by mail-wr1-x444.google.com with SMTP id n18so23295906wrs.5 for ; Wed, 04 Nov 2020 11:31:06 -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=1oSX8d0s20vIvtJY9+lIFEPud2sgwrsAcD0zHkP4J58=; b=jROSX61wiGcQl/3Sr8iMkFKwo5ku/gPD2tfbkmWFGtaHr0xchnH/TmDRRe2GlOOlHu Qhc0KBr2uCH3WGajmR6vCf0dEOywr12i+LUe/99d74bfhFO1WUuK2QGUXjW/4rRBRQnQ jrng0T9Hn8mvUpDeLALigaSiEnwPGJDfln7jUi78mQpYqr43BGB2fu8So4oZSpPJBo/K Xla0b6GYdKcYHfWkxOVhR9oEZzMIH9dX/XxloYei8BVLH2cEoO26dPPiuexhMYo/ditg TT7s2JV3rQModxDxRe0H2Ke1y9nGJXITER31Vi61eRymeDva/1oSzoDdQUaonecgvNDC 9pbg== 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=1oSX8d0s20vIvtJY9+lIFEPud2sgwrsAcD0zHkP4J58=; b=RzpyYSCo+4ExNH6cKv+qlUA7+up8p04FbQuziOqp0TZey68tTYvzMMbFR0Ukp8UwC0 jeglOp4REfy6RCOTO9LfoDb6Rlb2MiPMJZFujDNDQvYdOtpdDnB4YzmePER9/lVtaKm2 H5QAGgw4i/y55eO6peKjIFD6L+rfDXSeAwYkiZUab9rRXlQpvYH9wzyL7q4RZZbbx5DZ rMmO6HdPvhfRFt/NMy8E0TMs32ntKM67hG1B2UwADjUhwsLRMqpehdHYFgwtaTH/8ciC Jl5WX+HnQ1QVsGh955I269vDd2TOIQoyYXPsvG7rrP2KTZShvCrl3ApoSzPtnX7P1M5r wq7Q== X-Gm-Message-State: AOAM532QkNwJZGJ97ZfOJgmWcsiny+sAAtx5b7T8F9KRG8xy8fRb0Ybi JKn+ArJPPciYO7uERR3NYN5x+w== X-Google-Smtp-Source: ABdhPJyqaBBx7QnlBAAw+jyikp3ziav/LSZ9syModQn7bIOgmOIPjrrwwNV6unhBCuRHw0Aj4JqxIQ== X-Received: by 2002:adf:8b15:: with SMTP id n21mr35481847wra.313.1604518265637; Wed, 04 Nov 2020 11:31:05 -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 m12sm4051671wrs.92.2020.11.04.11.31.04 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 04 Nov 2020 11:31:05 -0800 (PST) From: Bartosz Golaszewski To: Linus Walleij , Andy Shevchenko , Jan Kiszka , David Laight , Mark Brown Cc: linux-gpio@vger.kernel.org, linux-kernel@vger.kernel.org, Bartosz Golaszewski Subject: [RFT PATCH v2 7/8] gpio: exar: switch to using regmap Date: Wed, 4 Nov 2020 20:30:50 +0100 Message-Id: <20201104193051.32236-8-brgl@bgdev.pl> X-Mailer: git-send-email 2.29.1 In-Reply-To: <20201104193051.32236-1-brgl@bgdev.pl> References: <20201104193051.32236-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 | 87 ++++++++++++++++------------------------ 2 files changed, 35 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..94ef500567ef 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,39 @@ 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); + regmap_assign_bits(exar_gpio->regs, addr, BIT(bit), value); } 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 +143,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 +179,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 +187,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; } From patchwork Wed Nov 4 19:30:51 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bartosz Golaszewski X-Patchwork-Id: 1394491 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=none (p=none dis=none) header.from=bgdev.pl Authentication-Results: ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=bgdev-pl.20150623.gappssmtp.com header.i=@bgdev-pl.20150623.gappssmtp.com header.a=rsa-sha256 header.s=20150623 header.b=RaExq3uc; dkim-atps=neutral Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by ozlabs.org (Postfix) with ESMTP id 4CRGwv295Yz9sVN for ; Thu, 5 Nov 2020 06:31:27 +1100 (AEDT) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1731657AbgKDTbQ (ORCPT ); Wed, 4 Nov 2020 14:31:16 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:36682 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1731591AbgKDTbK (ORCPT ); Wed, 4 Nov 2020 14:31:10 -0500 Received: from mail-wr1-x443.google.com (mail-wr1-x443.google.com [IPv6:2a00:1450:4864:20::443]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 40535C0613D4 for ; Wed, 4 Nov 2020 11:31:08 -0800 (PST) Received: by mail-wr1-x443.google.com with SMTP id k10so21982518wrw.13 for ; Wed, 04 Nov 2020 11:31:08 -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=uGxknteRFmc8uD8KRQwE2bQfaW1TLGwQ+1UoD3santI=; b=RaExq3uc7wgceJs+w6qfXW0zxCXfChfmuBZ5fIfJU3dTl+CuEheFyuWIDdpdwwWIe7 YG1psmFGrf3PNz/aPHJie1v065Y19OUTUKIYruuL3qY0Fotesa7peV+y2WwxR3zSCDFS kYCA8MP2Juxj2G2N5j5DZMNFrn+mvrKsxQRGjV9A1RXoYoG8USzSTkFN+oG2UXEGVhKE 1Nc337PRGnV/cahRPeQfGuAIEI48jAApXf3TUEMT3yFcZWSF88MTJgeWgdHYv2LvvmLS SHTU6/xVCA1r6lTp0COmmk16T4bLd3d4s6wy3zdwTKO9Iw4XauXHEsgx/QE1JC2WASGF l4wg== 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=uGxknteRFmc8uD8KRQwE2bQfaW1TLGwQ+1UoD3santI=; b=eH6znXkGKM3/NfLICPfTMW6Tn9noMpa3Pr8JDM8RUCT3uNXzNZC2Ae0qvs5UYU2TWU ppdLomsDhP8s+56C6tGtzVS9HXfV6BYkbRtXPOcaF/xejyjax2jz9ZA8BV3ElqneEY24 2mT03+MgaXaekMwo+aG0VNSHj8z8yC7FU9l83dmoWN6jmMuPOpl0AD7TBdFvzAzNRFR5 uHFddq/cS+tbDO25pzXJeozVuwxOwslscMrqSZaeiS2aj6bkntBz2SeG/T845AK1uWcv P984mYQ+rjrLghQzlNR9mdodyvZsYT9kB5d1+ZHc3V3uJZqppm+xsqzddKJJbzo7asMG Y0yw== X-Gm-Message-State: AOAM530z+uwtVlwTBqphrVXR41+Li6YmEj2c4ncA9Xl60vyA/d6pFpFa F7cuZZnxuqwbaNzFiRVNHASc/A== X-Google-Smtp-Source: ABdhPJxNzRzC856EUc6D12iZqJpjACECxzwnA9OtvmVdnej2G06cWHMRMwspZChWQGhIav7w4CBkmw== X-Received: by 2002:a5d:4883:: with SMTP id g3mr18433798wrq.19.1604518266966; Wed, 04 Nov 2020 11:31:06 -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 m12sm4051671wrs.92.2020.11.04.11.31.05 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 04 Nov 2020 11:31:06 -0800 (PST) From: Bartosz Golaszewski To: Linus Walleij , Andy Shevchenko , Jan Kiszka , David Laight , Mark Brown Cc: linux-gpio@vger.kernel.org, linux-kernel@vger.kernel.org, Bartosz Golaszewski Subject: [PATCH v2 8/8] gpio: exar: use devm action for freeing the IDA and drop remove() Date: Wed, 4 Nov 2020 20:30:51 +0100 Message-Id: <20201104193051.32236-9-brgl@bgdev.pl> X-Mailer: git-send-email 2.29.1 In-Reply-To: <20201104193051.32236-1-brgl@bgdev.pl> References: <20201104193051.32236-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 error path in probe() and drop remove() entirely if we provide a devm action for freeing the device ID. Signed-off-by: Bartosz Golaszewski --- drivers/gpio/gpio-exar.c | 27 ++++++++++++--------------- 1 file changed, 12 insertions(+), 15 deletions(-) diff --git a/drivers/gpio/gpio-exar.c b/drivers/gpio/gpio-exar.c index 94ef500567ef..b3372279188d 100644 --- a/drivers/gpio/gpio-exar.c +++ b/drivers/gpio/gpio-exar.c @@ -108,6 +108,13 @@ static int exar_direction_input(struct gpio_chip *chip, unsigned int offset) return 0; } +static void exar_devm_ida_free(void *data) +{ + struct exar_gpio_chip *exar_gpio = data; + + ida_free(&ida_index, exar_gpio->index); +} + static const struct regmap_config exar_regmap_config = { .name = "exar-gpio", .reg_bits = 8, @@ -155,6 +162,10 @@ static int gpio_exar_probe(struct platform_device *pdev) if (index < 0) return index; + ret = devm_add_action_or_reset(dev, exar_devm_ida_free, exar_gpio); + if (ret) + return ret; + sprintf(exar_gpio->name, "exar_gpio%d", index); exar_gpio->gpio_chip.label = exar_gpio->name; exar_gpio->gpio_chip.parent = dev; @@ -171,29 +182,15 @@ static int gpio_exar_probe(struct platform_device *pdev) ret = devm_gpiochip_add_data(dev, &exar_gpio->gpio_chip, exar_gpio); if (ret) - goto err_destroy; + return ret; platform_set_drvdata(pdev, exar_gpio); - return 0; - -err_destroy: - ida_free(&ida_index, index); - return ret; -} - -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); - return 0; } static struct platform_driver gpio_exar_driver = { .probe = gpio_exar_probe, - .remove = gpio_exar_remove, .driver = { .name = DRIVER_NAME, },