Received: by 10.223.185.116 with SMTP id b49csp4240144wrg; Mon, 19 Feb 2018 13:57:55 -0800 (PST) X-Google-Smtp-Source: AH8x225MuX108/CwYYSO7oRc/fQ4eCU9KS36h3hvF8pkb4JjcRZnBzEKWM/rcgDnS6WkRBLhj5f2 X-Received: by 10.99.146.3 with SMTP id o3mr13409372pgd.309.1519077475845; Mon, 19 Feb 2018 13:57:55 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1519077475; cv=none; d=google.com; s=arc-20160816; b=oOEwr4AgXpPqvrEgi9PeVYYrORmsWNmTLVSH5xSnoBPtUJPjXwzzoTgjYJtej9ZcpB 37TxBOAu6wkxIk/O40rIrm0EXtbl2sPCYfxHkC81imFKGjqUkfGD2THPqFRS0D9GqXfo tu2z6RaJ1GlUFQ5Jny9P26eLnlKSrlR1RU71EIZoA+dFeRxOjnJStkG5CjteDEaOYjh9 mGNcdGyhWOhhif79X2l+Ruv4ey5Wpx4clj94s8RC3cDBg/wRl5IZ7niPq1wa5Yvtj3kO 6ickIxE1YRlbznU6RchXQWnyDkW7UL6zFfLcTU5Oj7aVx3WgUMQqlFnsyprlUVt6bxCU VEWg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:message-id:date:subject:cc:to:from :dkim-signature:arc-authentication-results; bh=DD2/QswzeGSf9uoRscODm3HgwJDKQAdrcWUI2zrfYy8=; b=Uhoz51W0iXOL8qjU+mKHyPycN9TmUmtyZWUK8ijztU1k4gC89zdUDAW0rLUXdPjoAc 6QPRayTnbCfROrexQ4A7SFiMJUihMGiQH5lc+bZ7O3t5HvlNuCck6Tp5PCH+dFEGF3JG za1gSR1ryjR8wnSY5a7tVKEJQb8oln1w41BicCuBaLkaZnoJLh1JiGlyXfGTYdnEtlwu LxHA115u64qQSbBwdqd1UX4P0BsP00HybKE+ATcMtV6qKI6B4/fdJkhG6GLnaqCS0W2D HFYqB+c3PevYflSYmvYQCMfCtLMrgwNkdXzt9gigjYtTZGWc56NjNH4ofCRzgdpx74aa L19A== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@lechnology.com header.s=default header.b=gXzOvsVC; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id 19si339789pfa.127.2018.02.19.13.57.40; Mon, 19 Feb 2018 13:57:55 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=fail header.i=@lechnology.com header.s=default header.b=gXzOvsVC; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S932140AbeBSV5C (ORCPT + 99 others); Mon, 19 Feb 2018 16:57:02 -0500 Received: from vern.gendns.com ([206.190.152.46]:33549 "EHLO vern.gendns.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S932089AbeBSV5B (ORCPT ); Mon, 19 Feb 2018 16:57:01 -0500 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lechnology.com; s=default; h=Message-Id:Date:Subject:Cc:To:From:Sender: Reply-To:MIME-Version:Content-Type:Content-Transfer-Encoding:Content-ID: Content-Description:Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc :Resent-Message-ID:In-Reply-To:References:List-Id:List-Help:List-Unsubscribe: List-Subscribe:List-Post:List-Owner:List-Archive; bh=DD2/QswzeGSf9uoRscODm3HgwJDKQAdrcWUI2zrfYy8=; b=gXzOvsVCRWYy7TQx58VMoFVDiT gaY670J2te6II2paIKej3nXs9U+gzpRo2AzukJGHCZNRPUQzni8VimpV1VbuOwJn4RtqebdV8HK6f KqGEKDsxL4uwcSqw3bJ/CPRYL45+Z2/JFxActHZKgmB1DZHLJboEGhiNe++DPhDw5B5Puse1+7cIy uu2IecftTYXc2D5RWXmVE+8Y5aH1VnRkEfSS1XeNpz5ThBX4h+S/UYvnNvodgk9oP74LgrSzMuQcN yr0BxeDz4mnGcXylAU6XHKkPXHRoOd4uA25OIRgXQpvDt4jQuv54aggiEObVVSjoEGnLiDiHFCY4C ztuRJHKg==; Received: from 108-198-5-147.lightspeed.okcbok.sbcglobal.net ([108.198.5.147]:49968 helo=freyr.lechnology.com) by vern.gendns.com with esmtpsa (TLSv1.2:ECDHE-RSA-AES128-SHA256:128) (Exim 4.89_1) (envelope-from ) id 1entPQ-004Bli-D5; Mon, 19 Feb 2018 16:55:40 -0500 From: David Lechner To: linux-arm-kernel@lists.infradead.org, linux-omap@vger.kernel.org, linux-gpio@vger.kernel.org Cc: David Lechner , linux-kernel@vger.kernel.org, Tony Lindgren , Haojian Zhuang , Linus Walleij Subject: [PATCH v2] pinctrl: pinctrl-single: Fix pcs_request_gpio() when bits_per_mux != 0 Date: Mon, 19 Feb 2018 15:57:07 -0600 Message-Id: <1519077427-30165-1-git-send-email-david@lechnology.com> X-Mailer: git-send-email 2.7.4 X-AntiAbuse: This header was added to track abuse, please include it with any abuse report X-AntiAbuse: Primary Hostname - vern.gendns.com X-AntiAbuse: Original Domain - vger.kernel.org X-AntiAbuse: Originator/Caller UID/GID - [47 12] / [47 12] X-AntiAbuse: Sender Address Domain - lechnology.com X-Get-Message-Sender-Via: vern.gendns.com: authenticated_id: davidmain+lechnology.com/only user confirmed/virtual account not confirmed X-Authenticated-Sender: vern.gendns.com: davidmain@lechnology.com X-Source: X-Source-Args: X-Source-Dir: Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org This fixes pcs_request_gpio() in the pinctrl-single driver when bits_per_mux != 0. It appears this was overlooked when the multiple pins per register feature was added. Fixes: 4e7e8017a80e ("pinctrl: pinctrl-single: enhance to configure multiple pins of different modules") Signed-off-by: David Lechner --- v2 changes: - don't wrap Fixes: line in commit message since it is a special machine- readable line. There was some discussion in v1 about using DIV_ROUND_UP(), etc. macros, but the consensus was to leave it as-is since it matches existing code and that macros can be introduced in another patch. drivers/pinctrl/pinctrl-single.c | 22 +++++++++++++++++++--- 1 file changed, 19 insertions(+), 3 deletions(-) diff --git a/drivers/pinctrl/pinctrl-single.c b/drivers/pinctrl/pinctrl-single.c index cec7537..a7c5eb3 100644 --- a/drivers/pinctrl/pinctrl-single.c +++ b/drivers/pinctrl/pinctrl-single.c @@ -391,9 +391,25 @@ static int pcs_request_gpio(struct pinctrl_dev *pctldev, || pin < frange->offset) continue; mux_bytes = pcs->width / BITS_PER_BYTE; - data = pcs->read(pcs->base + pin * mux_bytes) & ~pcs->fmask; - data |= frange->gpiofunc; - pcs->write(data, pcs->base + pin * mux_bytes); + + if (pcs->bits_per_mux) { + int byte_num, offset, pin_shift; + + byte_num = (pcs->bits_per_pin * pin) / BITS_PER_BYTE; + offset = (byte_num / mux_bytes) * mux_bytes; + pin_shift = pin % (pcs->width / pcs->bits_per_pin) * + pcs->bits_per_pin; + + data = pcs->read(pcs->base + offset); + data &= ~(pcs->fmask << pin_shift); + data |= frange->gpiofunc << pin_shift; + pcs->write(data, pcs->base + offset); + } else { + data = pcs->read(pcs->base + pin * mux_bytes); + data &= ~pcs->fmask; + data |= frange->gpiofunc; + pcs->write(data, pcs->base + pin * mux_bytes); + } break; } return 0; -- 2.7.4