Received: by 2002:ac0:a582:0:0:0:0:0 with SMTP id m2-v6csp1040513imm; Tue, 2 Oct 2018 01:28:01 -0700 (PDT) X-Google-Smtp-Source: ACcGV61FjS78mum+r1b6BeYZm5gOPUPTWTf7s/DdZ1L6us4PEQ4k6sIpgh+/IT0kXL5jGI7i8lU0 X-Received: by 2002:a63:6f45:: with SMTP id k66-v6mr13238349pgc.360.1538468881550; Tue, 02 Oct 2018 01:28:01 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1538468881; cv=none; d=google.com; s=arc-20160816; b=GlYnMfBJ8pahSbNX3NTX28vhz6EtMdeiBI91BB3eD6Sy6QtoqitvUiyxkpBXQ7Vspb 6PpSu1/WofvIT43DVTz6MtPhTCRJVWFx08WIroUqJ93ZSapcphctGWmds5763cExoKFf /BVndDBPwk/79n5SGQOdWOjfqvXxDduWPtA2FzFH+zr1SF6/FqaqazgP+8ZDDmt06+C+ Y0TR8Q6d0zQkpM/JxR53+n06VM++1kWXMQn+LY01doUk6j9US4v73uGFOZz4ou1H5HtG FnFcdhf2ndyzfiGeRopbbbu25I/NLeF2gw9/slBaShJDBlQQ+Kg0jDb0kNsQ4qT7TTYz qEcQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=Vur/nZx57X35xCVeK+GvGWS7rgTTqrCBUYltbYz91FM=; b=t4cPZISFr+4BnVFP9LPED8wG8JJ5EJg14ULbwBlMpMzTClfIMJ3icVG3+kfJaOSgN7 VWhWWWXC4L8/ssMxe0JPTPgE6+kZaKD6ou01y6NvWMfk/VXlFK7T6WV81ZN08mnmRZVo u6e5gd2lyCPh+8215MgzOtUJ1NEkqhY1TQjeP3k59vyfZu4P0JJ/YWJ0TLUZBsgQulqG vDf9qWkG4yorb5/bVDP2ZpQwZ6L+LQSRFkgxCbajSe/1r/FjziPBJI+iYnPc+v12Mj5H 6sEiM7odrpTmZ9SvCbzggzpIFeuvPuydMeNsTISAql2IkCaOTjVRObsSIEAqwbw9ynMj y+kQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=XbXr9E95; 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; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id h69-v6si14474595pfc.121.2018.10.02.01.27.47; Tue, 02 Oct 2018 01:28:01 -0700 (PDT) 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=pass header.i=@gmail.com header.s=20161025 header.b=XbXr9E95; 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; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727572AbeJBPJo (ORCPT + 99 others); Tue, 2 Oct 2018 11:09:44 -0400 Received: from mail-lf1-f66.google.com ([209.85.167.66]:35427 "EHLO mail-lf1-f66.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727006AbeJBPJn (ORCPT ); Tue, 2 Oct 2018 11:09:43 -0400 Received: by mail-lf1-f66.google.com with SMTP id r191-v6so783779lff.2; Tue, 02 Oct 2018 01:27:37 -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=Vur/nZx57X35xCVeK+GvGWS7rgTTqrCBUYltbYz91FM=; b=XbXr9E95kd+StqYEioLGstUrfM0Do5qLwR6m7SSdTQgjp+ip0LE/cqnqq7Hm0T8Z8a 87+12Xmwl8539NPdKQmZ9adYHFiGqehZgHLubys4NDo8MsGcvgKI7RTD+pTCruRnr4yS ydujA7o8KZtXQlH8oX9iYq1VHrJFEn4L4E3xkVpvoOqJPBM14/RpitMaUGwCSJVttS/a CphvN05bCk/Cbc9iNnd4BdgRpsY8xiLMVjU3PXsKNVwNlTFjRowSDFz3UGYxOsZfM4Kl wUG3I0AISpeuyKP7P0XsUSBfij0EuZPUoUU0UehlcXJKNPSa8nfhkJVZe8BaDI2ZS4iy 7asg== 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=Vur/nZx57X35xCVeK+GvGWS7rgTTqrCBUYltbYz91FM=; b=SEBYXnRnYn3ZTRVK28tpNMyfiIvlhBCu+J85q5OtHBi7Z4l07YvsgMX9NMdQm8Cnin SwzHSB7mD6yc6UUXucYWXtQT8KTSdnWDZ1ttg2HO0f5hn4PvrYfeez11ouZ0MijF0/kA UrtwLBTtQ7NKpqSrW1OO5qBODAXYnyHrnN5kWo4HSmhDrGlD30ZAhUNk+SXYQv39Fu+r ziPbR0Ysk7k665SrSobuLRMaZnwAjxhFrVf4HnYcm1hp2eVYCrcl/rry+W9ZLFUYTWeN 3rGhArw5IGRoA11lQRHhgQdztEXvCsaWsRbcfim+/nvhL+Ymu1EHNCIBCphkcrOumCFL 83cA== X-Gm-Message-State: ABuFfoj4x6p+wklsVlrLqKdOg1CNaWZyrAD1oM1+51VUeTH5tSXF9SbW qrVZw42VAmTsTfGTbM9t0As= X-Received: by 2002:a19:d906:: with SMTP id q6-v6mr7488442lfg.62.1538468856559; Tue, 02 Oct 2018 01:27:36 -0700 (PDT) Received: from neopili.qtec.com (cpe.xe-3-0-1-778.vbrnqe10.dk.customer.tdc.net. [80.197.57.18]) by smtp.gmail.com with ESMTPSA id p11-v6sm1493531lji.87.2018.10.02.01.27.34 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 02 Oct 2018 01:27:34 -0700 (PDT) From: Ricardo Ribalda Delgado To: Linus Walleij , Timur Tabi , swboyd@chromium.org, linux-gpio@vger.kernel.org, LKML , Jeffrey Hugo Cc: Ricardo Ribalda Delgado Subject: [PATCH v3 2/3] pinctrl: msm: Use init_valid_mask exported function Date: Tue, 2 Oct 2018 10:27:30 +0200 Message-Id: <20181002082731.20141-2-ricardo.ribalda@gmail.com> X-Mailer: git-send-email 2.19.0 In-Reply-To: <20181002082731.20141-1-ricardo.ribalda@gmail.com> References: <20181002082731.20141-1-ricardo.ribalda@gmail.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org The current code produces XPU violation if get_direction is called just after the initialization. Signed-off-by: Ricardo Ribalda Delgado --- drivers/pinctrl/qcom/pinctrl-msm.c | 79 ++++++++++++++---------------- 1 file changed, 37 insertions(+), 42 deletions(-) diff --git a/drivers/pinctrl/qcom/pinctrl-msm.c b/drivers/pinctrl/qcom/pinctrl-msm.c index 5d72ffad32c2..ce1ade47ea37 100644 --- a/drivers/pinctrl/qcom/pinctrl-msm.c +++ b/drivers/pinctrl/qcom/pinctrl-msm.c @@ -566,6 +566,42 @@ static void msm_gpio_dbg_show(struct seq_file *s, struct gpio_chip *chip) #define msm_gpio_dbg_show NULL #endif +static int msm_gpio_init_valid_mask(struct gpio_chip *chip) +{ + struct msm_pinctrl *pctrl = gpiochip_get_data(chip); + int ret; + unsigned int len, i; + unsigned int max_gpios = pctrl->soc->ngpios; + u16 *tmp; + + /* The number of GPIOs in the ACPI tables */ + len = ret = device_property_read_u16_array(pctrl->dev, "gpios", NULL, + 0); + if (ret < 0) + return 0; + + if (ret > max_gpios) + return -EINVAL; + + tmp = kmalloc_array(len, sizeof(*tmp), GFP_KERNEL); + if (!tmp) + return -ENOMEM; + + ret = device_property_read_u16_array(pctrl->dev, "gpios", tmp, len); + if (ret < 0) { + dev_err(pctrl->dev, "could not read list of GPIOs\n"); + goto out; + } + + bitmap_zero(chip->valid_mask, max_gpios); + for (i = 0; i < len; i++) + set_bit(tmp[i], chip->valid_mask); + +out: + kfree(tmp); + return ret; +} + static const struct gpio_chip msm_gpio_template = { .direction_input = msm_gpio_direction_input, .direction_output = msm_gpio_direction_output, @@ -575,6 +611,7 @@ static const struct gpio_chip msm_gpio_template = { .request = gpiochip_generic_request, .free = gpiochip_generic_free, .dbg_show = msm_gpio_dbg_show, + .init_valid_mask = msm_gpio_init_valid_mask, }; /* For dual-edge interrupts in software, since some hardware has no @@ -855,41 +892,6 @@ static void msm_gpio_irq_handler(struct irq_desc *desc) chained_irq_exit(chip, desc); } -static int msm_gpio_init_valid_mask(struct gpio_chip *chip, - struct msm_pinctrl *pctrl) -{ - int ret; - unsigned int len, i; - unsigned int max_gpios = pctrl->soc->ngpios; - u16 *tmp; - - /* The number of GPIOs in the ACPI tables */ - len = ret = device_property_read_u16_array(pctrl->dev, "gpios", NULL, 0); - if (ret < 0) - return 0; - - if (ret > max_gpios) - return -EINVAL; - - tmp = kmalloc_array(len, sizeof(*tmp), GFP_KERNEL); - if (!tmp) - return -ENOMEM; - - ret = device_property_read_u16_array(pctrl->dev, "gpios", tmp, len); - if (ret < 0) { - dev_err(pctrl->dev, "could not read list of GPIOs\n"); - goto out; - } - - bitmap_zero(chip->valid_mask, max_gpios); - for (i = 0; i < len; i++) - set_bit(tmp[i], chip->valid_mask); - -out: - kfree(tmp); - return ret; -} - static bool msm_gpio_needs_valid_mask(struct msm_pinctrl *pctrl) { return device_property_read_u16_array(pctrl->dev, "gpios", NULL, 0) > 0; @@ -926,13 +928,6 @@ static int msm_gpio_init(struct msm_pinctrl *pctrl) return ret; } - ret = msm_gpio_init_valid_mask(chip, pctrl); - if (ret) { - dev_err(pctrl->dev, "Failed to setup irq valid bits\n"); - gpiochip_remove(&pctrl->chip); - return ret; - } - /* * For DeviceTree-supported systems, the gpio core checks the * pinctrl's device node for the "gpio-ranges" property. -- 2.19.0