Received: by 2002:a05:6a10:8c0a:0:0:0:0 with SMTP id go10csp1832803pxb; Mon, 8 Mar 2021 07:26:54 -0800 (PST) X-Google-Smtp-Source: ABdhPJyX+FTeqObm465v6VAHZtpX4bcV+J1Cg/CRLKdJc9KDUAhxenn6LiJUZBVedBMvHxAA65Tl X-Received: by 2002:a17:906:3917:: with SMTP id f23mr15622907eje.186.1615217213825; Mon, 08 Mar 2021 07:26:53 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1615217213; cv=none; d=google.com; s=arc-20160816; b=H6tO0GuNj/izEN6VDyhLcVUsCUfr6mGwK4MnlccvLoQ0H6bEmLWU1+d5RSClQrlver Xa0cVH7N28pR+WJJmS8AX6Gb3kJVLUdWnv9f4XbIlJiTCMw3kMQSUb/fgXqddNdkyjbg YyXYUhllVe9oSzeGmMQIEHbFeCFm954loIuBY8B3H6z9616HtH1JaTJRORtQH2+1nUhh 1KCUTrcFZQ8iQzNxs1KopPM2qS3jFhNVqW9wkM2ok9+++JUV22b1x8QAYJ8e+yBCyJGU SUbatAEyvQSsbtWgtYT3KaeyksY76NFec3FzixAxkp3U51r3F96GFkpNc1vDEihB6Fp3 yQnA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :message-id:date:subject:cc:to:from:dkim-signature; bh=Fb49KXRWPSJi42ztaavXoYPspVtYhsjrcySTJoONhEo=; b=p51RQ4gXpw4xJzPrN2f5aenpQ4EGG+afRiWhXPFOWhoakAO3WPKExnrRWIqU43ApgF h/WNxCUGyyB/AqZIXzg1jmQmul/f1rghHC8dcQI7k7SZTr9pQ75UlkSWa4DvqV9Tu89X WpIMWxyjOBLA/SXw0iTdAKtnlu8jH4nvylTeeZwhVXZyTouCwVv2T1CqehbbFlL/fMTH l/Z0ud2nLC5oZar6ERJ+2cL38iSbP7uLymGpyDxSHayH9Mf/jlshaYVmEj/A78cms5U/ pq8nNqWWQGEaZMj91N3/N70KMmXSkydoMlyUoyrwnsLuPiKhX44bYG4Ft0oiDhHxPGzC oUXA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b="rBsc/nkx"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id s10si7452080ejv.67.2021.03.08.07.26.29; Mon, 08 Mar 2021 07:26:53 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b="rBsc/nkx"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231265AbhCHPZb (ORCPT + 99 others); Mon, 8 Mar 2021 10:25:31 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:40952 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230458AbhCHPZM (ORCPT ); Mon, 8 Mar 2021 10:25:12 -0500 Received: from mail-ej1-x62d.google.com (mail-ej1-x62d.google.com [IPv6:2a00:1450:4864:20::62d]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 46CD9C06174A; Mon, 8 Mar 2021 07:25:12 -0800 (PST) Received: by mail-ej1-x62d.google.com with SMTP id ox4so5536035ejb.11; Mon, 08 Mar 2021 07:25:12 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=Fb49KXRWPSJi42ztaavXoYPspVtYhsjrcySTJoONhEo=; b=rBsc/nkxlErn6sb8I2v8ZZmrC8Ef58RjQGLt8YHSyQ7AL+kMWfSTbx4rnTr8fGMMth eL/2ZSflVwUdq6b83/XDhGarNt6nwhaQgV+9CmLSpR0kpbPNKCXKuHxxVKT0zhe96pG0 NsX2/3jiPvav7hKOGDG+Z7IYcdklTMH8fp0q5ExNDx/pSMf6Ka5rH1NVrucjea+07dJZ +GLn3IuNLkC6GhX5D65SHBOXsgtEFwWYI2k7dUQDQ6+tM2DdxIeDP7nTlfKl3Uc7dO6l TOUemE2NIw9JRxedVq8PCPi/QpItvhU8ly1iTpi2UMfPBzaWyWU86vtNPwlT5PtsdEak 5ZTw== 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:mime-version :content-transfer-encoding; bh=Fb49KXRWPSJi42ztaavXoYPspVtYhsjrcySTJoONhEo=; b=hcTjNPZzX7vsIavJePyVUygqMeRfymBQxzTgU9KWeywQb9ZqxJ2Z52xcJz8DnNNciT xiZAyIlWgN1l0Q7aeQhEoxpKTi1avS+b9E0Jf140kZtzGdCb/RuYJz6mqpXBM3NbxSd/ cpA8xJvFsLsj/rpO1Bw4PSALURSsdNKreRv3fd8h0jBHwbcc3mK++p2dNDw1M/hIzywB whj+m/wMpEyTgG0PcStble7wQDRhb/d5UlkCSzg6rsCuVvu6ydB9DBUUoHSPPEaLakGR 2bGLuIEmP7UyedoZtf9ap1WOIubg0eGFmdZb4a0IPK54pCiJ6y9ztfdJKcsC/0qcBK6I ySHQ== X-Gm-Message-State: AOAM5335O+W2pVGpHO/oQCpcazLk5Oogo6hch/9GK21pzg9o+ZaWKDy8 7cNYiQdi/Mr8h/8bbKV58jo= X-Received: by 2002:a17:906:b6c8:: with SMTP id ec8mr15729105ejb.223.1615217111014; Mon, 08 Mar 2021 07:25:11 -0800 (PST) Received: from xws.localdomain ([37.58.58.229]) by smtp.gmail.com with ESMTPSA id u15sm6738227ejy.48.2021.03.08.07.25.09 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 08 Mar 2021 07:25:10 -0800 (PST) From: Maximilian Luz To: Andy Shevchenko Cc: Maximilian Luz , Mika Westerberg , Linus Walleij , Daniel Scally , linux-gpio@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH] Revert "pinctrl: intel: Split intel_pinctrl_add_padgroups() for better maintenance" Date: Mon, 8 Mar 2021 16:25:05 +0100 Message-Id: <20210308152505.3762055-1-luzmaximilian@gmail.com> X-Mailer: git-send-email 2.30.1 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Following commit 036e126c72eb ("pinctrl: intel: Split intel_pinctrl_add_padgroups() for better maintenance"), gpiochip_get_desc() is broken on some Kaby Lake R devices (specifically a Microsoft Surface Book 2), returning -EINVAL for GPIOs that in reality should be there (they are defined in ACPI and have been accessible previously). Due to this, gpiod_get() fails with -ENOENT. Reverting this commit fixes that issue and the GPIOs in question are accessible again. Signed-off-by: Maximilian Luz --- There is probably a better option than straight up reverting this, so consider this more of a bug-report. Regards, Max --- drivers/pinctrl/intel/pinctrl-intel.c | 60 +++++++++------------------ 1 file changed, 20 insertions(+), 40 deletions(-) diff --git a/drivers/pinctrl/intel/pinctrl-intel.c b/drivers/pinctrl/intel/pinctrl-intel.c index 8085782cd8f9..0fe6caf98a8a 100644 --- a/drivers/pinctrl/intel/pinctrl-intel.c +++ b/drivers/pinctrl/intel/pinctrl-intel.c @@ -1331,19 +1331,34 @@ static int intel_gpio_probe(struct intel_pinctrl *pctrl, int irq) return 0; } -static int intel_pinctrl_add_padgroups_by_gpps(struct intel_pinctrl *pctrl, - struct intel_community *community) +static int intel_pinctrl_add_padgroups(struct intel_pinctrl *pctrl, + struct intel_community *community) { struct intel_padgroup *gpps; + unsigned int npins = community->npins; unsigned int padown_num = 0; - size_t i, ngpps = community->ngpps; + size_t ngpps, i; + + if (community->gpps) + ngpps = community->ngpps; + else + ngpps = DIV_ROUND_UP(community->npins, community->gpp_size); gpps = devm_kcalloc(pctrl->dev, ngpps, sizeof(*gpps), GFP_KERNEL); if (!gpps) return -ENOMEM; for (i = 0; i < ngpps; i++) { - gpps[i] = community->gpps[i]; + if (community->gpps) { + gpps[i] = community->gpps[i]; + } else { + unsigned int gpp_size = community->gpp_size; + + gpps[i].reg_num = i; + gpps[i].base = community->pin_base + i * gpp_size; + gpps[i].size = min(gpp_size, npins); + npins -= gpps[i].size; + } if (gpps[i].size > 32) return -EINVAL; @@ -1361,38 +1376,6 @@ static int intel_pinctrl_add_padgroups_by_gpps(struct intel_pinctrl *pctrl, break; } - gpps[i].padown_num = padown_num; - padown_num += DIV_ROUND_UP(gpps[i].size * 4, 32); - } - - community->gpps = gpps; - - return 0; -} - -static int intel_pinctrl_add_padgroups_by_size(struct intel_pinctrl *pctrl, - struct intel_community *community) -{ - struct intel_padgroup *gpps; - unsigned int npins = community->npins; - unsigned int padown_num = 0; - size_t i, ngpps = DIV_ROUND_UP(npins, community->gpp_size); - - if (community->gpp_size > 32) - return -EINVAL; - - gpps = devm_kcalloc(pctrl->dev, ngpps, sizeof(*gpps), GFP_KERNEL); - if (!gpps) - return -ENOMEM; - - for (i = 0; i < ngpps; i++) { - unsigned int gpp_size = community->gpp_size; - - gpps[i].reg_num = i; - gpps[i].base = community->pin_base + i * gpp_size; - gpps[i].size = min(gpp_size, npins); - npins -= gpps[i].size; - gpps[i].padown_num = padown_num; /* @@ -1529,10 +1512,7 @@ static int intel_pinctrl_probe(struct platform_device *pdev, community->regs = regs; community->pad_regs = regs + offset; - if (community->gpps) - ret = intel_pinctrl_add_padgroups_by_gpps(pctrl, community); - else - ret = intel_pinctrl_add_padgroups_by_size(pctrl, community); + ret = intel_pinctrl_add_padgroups(pctrl, community); if (ret) return ret; } -- 2.30.1