Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > linux.kernel > #1666588
| Path | csiph.com!aioe.org!news.servidellagleba.it!bofh.it!news.nic.it!robomod |
|---|---|
| From | Andy Shevchenko <andy.shevchenko@gmail.com> |
| Newsgroups | linux.kernel |
| Subject | Re: [PATCH v1 1/1] gpio: gpio-wcove: Fix GPIO control register offset calculation |
| Date | Thu, 15 Jun 2017 11:10:02 +0200 |
| Message-ID | <tSyWS-yc-29@gated-at.bofh.it> (permalink) |
| References | <tSob8-22d-9@gated-at.bofh.it> |
| X-Original-To | Kuppuswamy Sathyanarayanan <sathyanarayanan.kuppuswamy@linux.intel.com> |
| Dkim-Signature | v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:in-reply-to:references:from:date:message-id:subject:to :cc; bh=I8N96dtFw4lWwaAksZxJ46+bAz7c8hkuY69KcfOdw40=; b=oyUMoUVFQ3GYWPhYNrEywSK6QcGFpXgvJ1bojdf+ZEey8kpuHa6gPgXm7eAFOgkOn0 b8g9LqfvbiQVjFk3+rs8bFLC8F3AE1hP5olJE2xsS+T0ymry5zohGWCIBSNBBwxshvPE IN1dxFteKSLGnYJl8cjJFr2KCv+bYhho1t+4MRtacqJvwFiCpCeycto+uqFtqOcQSYXI R/lrkG/XgHwnSwV7OHff/Wkfk2iNQI81mCRNcSWZm5pa0QQFd2ZdI9sNE/+GH4+Lh2d6 D+W8Nu1AtTImoy5ZhS+wswvERxfiqFd71kJPewTSCXvie/XrwszjkaXAtBrWD4sqNNHV LbyQ== |
| X-Google-Dkim-Signature | v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:in-reply-to:references:from:date :message-id:subject:to:cc; bh=I8N96dtFw4lWwaAksZxJ46+bAz7c8hkuY69KcfOdw40=; b=f8Tp2Znl+hf3Zn7EENRPkScGyN23Io2zu2fchO546JnMEY3ATpMQwFRl1I52xceDWN SJRDhDRUIzp7CChmTTobdmlCs73McQPYiehCbT10tV6v6ESssrEeBeCTv6gOuQm9LcJ/ jVlKSJyQl0CMeIH9NIrehVbjYlt08G+VUs0QrduidOMC6qcr65A39xsf0jq28E9J6FfL ZsBHld4Tdis5C3VuOKLfBgQ6MwFvjvcL/ZCFq1vpaUs66AOBfZNw5GZ7/prurZ8xAVP9 SM3Q8q4zVusin6LEQHSQsz+udDdb9TwgQQ/MlSGYZzNy8oXXOzeK9S9nYlWWevkbgWUn Io7g== |
| X-Gm-Message-State | AKS2vOxfFDltViw66K1fOA4QQCOdQPeLG4SuqySQ7HVxDO6k+QJ1aLxg WFskd5Byan74+ztGJnFQI26HLUh57hSP |
| X-Received | by 10.237.55.3 with SMTP id i3mr5104393qtb.16.1497517602140; Thu, 15 Jun 2017 02:06:42 -0700 (PDT) |
| MIME-Version | 1.0 |
| Content-Type | text/plain; charset="UTF-8" |
| Sender | robomod@news.nic.it |
| List-ID | <linux-kernel.vger.kernel.org> |
| X-Mailing-List | linux-kernel@vger.kernel.org |
| Approved | robomod@news.nic.it |
| Lines | 188 |
| Organization | linux.* mail to news gateway |
| X-Original-Cc | Linus Walleij <linus.walleij@linaro.org>, "linux-gpio@vger.kernel.org" <linux-gpio@vger.kernel.org>, "linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>, Sathyanarayanan Kuppuswamy Natarajan <sathyaosid@gmail.com> |
| X-Original-Date | Thu, 15 Jun 2017 12:06:41 +0300 |
| X-Original-Message-ID | <CAHp75Vd1w9FXF_Yfo0+mBAS3+JZmCv7O8tKCWvyAvTdjAcJn0A@mail.gmail.com> |
| X-Original-References | <c3bed7faffed058b1363ff5fdd35b6f107b83a78.1497476287.git.sathyanarayanan.kuppuswamy@linux.intel.com> |
| X-Original-Sender | linux-kernel-owner@vger.kernel.org |
| Xref | csiph.com linux.kernel:1666588 |
Show key headers only | View raw
On Thu, Jun 15, 2017 at 12:39 AM,
<sathyanarayanan.kuppuswamy@linux.intel.com> wrote:
> From: Kuppuswamy Sathyanarayanan <sathyanarayanan.kuppuswamy@linux.intel.com>
>
> According to Whiskey Cove PMIC GPIO controller specification, for GPIO
> pins 0-12, GPIO input and output register control address range from,
>
> 0x4e44-0x4e50 for GPIO outputs control register
>
> 0x4e51-0x4e5d for GPIO input control register
>
> But, currently when calculating the GPIO register offsets in to_reg()
> function, all GPIO pins in the same bank uses the same GPIO control
> register address. This logic is incorrect. This patch fixes this
> issue.
>
> This patch also adds support to selectively skip register modification
> for virtual GPIOs.
>
> In case of Whiskey Cove PMIC, ACPI code may use up 94 virtual GPIOs.
> These virtual GPIOs are used by the ACPI code as means to access various
> non GPIO bits of PMIC. So for these virtual GPIOs, we don't need to
> manipulate the physical GPIO pin register. A similar patch has been
> merged recently by Hans for Crystal Cove PMIC GPIO driver. You can
> find more details about it in Commit 9a752b4c9ab9 ("gpio: crystalcove:
> Do not write regular gpio registers for virtual GPIOs")
>
> Signed-off-by: Kuppuswamy Sathyanarayanan <sathyanarayanan.kuppuswamy@linux.intel.com>
> Reported-by: Jukka Laitinen <jukka.laitinen@intel.com>
It seems it should have a Fixes tag.
> static inline unsigned int to_reg(int gpio, enum ctrl_register reg_type)
> {
> unsigned int reg;
> - int bank;
>
> - if (gpio < BANK0_NR_PINS)
> - bank = 0;
> - else if (gpio < BANK0_NR_PINS + BANK1_NR_PINS)
> - bank = 1;
> - else
> - bank = 2;
> + if (gpio >= WCOVE_GPIO_NUM)
> + return -EOPNOTSUPP;
How this can happen?
>
> if (reg_type == CTRL_IN)
> - reg = GPIO_IN_CTRL_BASE + bank;
> + /*
> + * GPIO input control registers
> + * (one per pin): 0x4e51 - 0x4e5d
> + */
Noise.
> + reg = GPIO_IN_CTRL_BASE + gpio;
> else
> - reg = GPIO_OUT_CTRL_BASE + bank;
> + /* GPIO output control registers
> + * (one per pin): 0x4e44 - 0x4e50
> + */
Wrong multi-line comment and noise overall.
If you wish to leave the comments, put them on top of the function as
its description.
> + reg = GPIO_OUT_CTRL_BASE + gpio;
>
> return reg;
> }
> @@ -145,7 +147,10 @@ static void wcove_update_irq_mask(struct wcove_gpio *wg, int gpio)
>
> static void wcove_update_irq_ctrl(struct wcove_gpio *wg, int gpio)
> {
> - unsigned int reg = to_reg(gpio, CTRL_IN);
> + int reg = to_reg(gpio, CTRL_IN);
> +
> + if (reg < 0)
> + return;
Since above comment this change would gone.
> + int reg = to_reg(gpio, CTRL_OUT);
> +
> + if (reg < 0)
> + return 0;
>
> - return regmap_write(wg->regmap, to_reg(gpio, CTRL_OUT),
> - CTLO_INPUT_SET);
> + return regmap_write(wg->regmap, reg, CTLO_INPUT_SET);
Ditto.
> + int reg = to_reg(gpio, CTRL_OUT);
>
> - return regmap_write(wg->regmap, to_reg(gpio, CTRL_OUT),
> - CTLO_OUTPUT_SET | value);
> + if (reg < 0)
> + return 0;
> +
> + return regmap_write(wg->regmap, reg, CTLO_OUTPUT_SET | value);
Ditto.
> + int ret, reg = to_reg(gpio, CTRL_OUT);
Don't fit such variable on one line.
> +
> + if (reg < 0)
> + return 0;
>
> - ret = regmap_read(wg->regmap, to_reg(gpio, CTRL_OUT), &val);
> + ret = regmap_read(wg->regmap, reg, &val);
This would gone after addressing first comment.
> - int ret;
> + int ret, reg = to_reg(gpio, CTRL_IN);
> +
> + if (reg < 0)
> + return 0;
>
> - ret = regmap_read(wg->regmap, to_reg(gpio, CTRL_IN), &val);
> + ret = regmap_read(wg->regmap, reg, &val);
Ditto.
> + int reg = to_reg(gpio, CTRL_OUT);
> +
> + if (reg < 0)
> + return;
>
> if (value)
> - regmap_update_bits(wg->regmap, to_reg(gpio, CTRL_OUT), 1, 1);
> + regmap_update_bits(wg->regmap, reg, 1, 1);
> else
> - regmap_update_bits(wg->regmap, to_reg(gpio, CTRL_OUT), 1, 0);
> + regmap_update_bits(wg->regmap, reg, 1, 0);
Ditto.
> + int reg = to_reg(gpio, CTRL_OUT);
> +
> + if (reg < 0)
> + return 0;
>
> switch (pinconf_to_config_param(config)) {
> case PIN_CONFIG_DRIVE_OPEN_DRAIN:
> - return regmap_update_bits(wg->regmap, to_reg(gpio, CTRL_OUT),
> - CTLO_DRV_MASK, CTLO_DRV_OD);
> + return regmap_update_bits(wg->regmap, reg, CTLO_DRV_MASK,
> + CTLO_DRV_OD);
> case PIN_CONFIG_DRIVE_PUSH_PULL:
> - return regmap_update_bits(wg->regmap, to_reg(gpio, CTRL_OUT),
> - CTLO_DRV_MASK, CTLO_DRV_CMOS);
> + return regmap_update_bits(wg->regmap, reg, CTLO_DRV_MASK,
> + CTLO_DRV_CMOS);
Ditto.
> + if (data->hwirq >= WCOVE_GPIO_NUM)
> + return 0;
> +
How could it happen?
> + if (data->hwirq >= WCOVE_GPIO_NUM)
> + return;
Ditto.
> + if (data->hwirq >= WCOVE_GPIO_NUM)
> + return;
Ditto.
--
With Best Regards,
Andy Shevchenko
Back to linux.kernel | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread
[PATCH v1 1/1] gpio: gpio-wcove: Fix GPIO control register offset calculation sathyanarayanan.kuppuswamy@linux.intel.com - 2017-06-14 23:40 +0200
Re: [PATCH v1 1/1] gpio: gpio-wcove: Fix GPIO control register offset calculation Andy Shevchenko <andy.shevchenko@gmail.com> - 2017-06-15 11:10 +0200
Re: [PATCH v1 1/1] gpio: gpio-wcove: Fix GPIO control register offset calculation sathyanarayanan kuppuswamy <sathyanarayanan.kuppuswamy@linux.intel.com> - 2017-06-15 23:00 +0200
csiph-web