mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Sander Vanheule <sander@svanheule.net>
To: Bartosz Golaszewski <brgl@kernel.org>
Cc: Lee Jones <lee@kernel.org>, Pavel Machek <pavel@kernel.org>,
	Rob Herring <robh@kernel.org>,
	Krzysztof Kozlowski <krzk+dt@kernel.org>,
	Conor Dooley	 <conor+dt@kernel.org>,
	Linus Walleij <linus.walleij@linaro.org>,
	Michael Walle	 <mwalle@kernel.org>,
	Bartosz Golaszewski <brgl@bgdev.pl>,
	 linux-leds@vger.kernel.org, devicetree@vger.kernel.org,
	 linux-kernel@vger.kernel.org, linux-gpio@vger.kernel.org
Subject: Re: [PATCH v9 4/6] pinctrl: Add RTL8231 pin control and GPIO support
Date: Fri, 19 Dec 2025 14:52:08 +0100	[thread overview]
Message-ID: <a8063a3a5eb8055bf88976f9da07175528502144.camel@svanheule.net> (raw)
In-Reply-To: <CAMRc=Mdb7CWB9PmzXJyfvGjvG0iwuwUgfLuKJuMweRFvAhAoHg@mail.gmail.com>

Hi Bartosz,

On Thu, 2025-12-18 at 01:15 -0800, Bartosz Golaszewski wrote:
> On Mon, 15 Dec 2025 18:51:12 +0100, Sander Vanheule <sander@svanheule.net>
> said:
> > This driver implements the GPIO and pin muxing features provided by the
> > RTL8231. The device should be instantiated as an MFD child, where the
> > parent device has already configured the regmap used for register
> > access.
> > 
> > Debouncing is only available for the six highest GPIOs, and must be
> > emulated when other pins are used for (button) inputs. Although
> > described in the bindings, drive strength selection is currently not
> > implemented.
> > 
> > Signed-off-by: Sander Vanheule <sander@svanheule.net>
> > Reviewed-by: Linus Walleij <linus.walleij@linaro.org>
> > ---
> 
> [snip]
> 
> > +#include <linux/bitfield.h>
> > +#include <linux/gpio/driver.h>
> > +#include <linux/gpio/regmap.h>
> > +#include <linux/module.h>
> > +#include <linux/pinctrl/pinconf.h>
> > +#include <linux/pinctrl/pinctrl.h>
> > +#include <linux/pinctrl/pinmux.h>
> > +#include <linux/platform_device.h>
> > +#include <linux/regmap.h>
> > +
> > +#include "core.h"
> > +#include "pinmux.h"
> > +#include <linux/mfd/rtl8231.h>
> 
> Please put this together with other global headers.

Updated here and in the other driver files.

> > +static const unsigned int PWM_PIN = 35;
> 
> Please use the RTL8231 prefix for all symbols.

Added the prefix here and also for a struct defined in this file (rtl8231_...).

> > +static int rtl8231_set_mux(struct pinctrl_dev *pctldev, unsigned int
> > func_selector,
> > + unsigned int group_selector)
> > +{
> > + const struct function_desc *func = pinmux_generic_get_function(pctldev,
> > func_selector);
> > + const struct rtl8231_pin_desc *desc =
> > rtl8231_pins[group_selector].drv_data;
> > + const struct rtl8231_pin_ctrl *ctrl = pinctrl_dev_get_drvdata(pctldev);
> > + enum rtl8231_pin_function func_flag = (uintptr_t) func->data;
> > + unsigned int function_mask;
> > + unsigned int gpio_function;
> 
> Can you put these on the same line here and elsewhere?

I am aware this is often done, and also mentioned in the kernel docs [1], but I
actually prefer this style and have always used it in my kernel patches.
IMHO placing these on separate lines helps with:
 * readability: every line is either [type] [name] or [type] [name] = [value]
 * reducing churn: changing the type of one variable doesn't impact other lines
 * quickly assessing code complexity: number of local variables is simply the
   number of lines

Editors aren't typically 80x24 anymore. The maximum line length has been relaxed
to 100 characters, so I feel like a developer can also be expected to have more
lines available on their display nowadays.

[1]
https://docs.kernel.org/6.18/process/maintainer-tip.html#variable-declarations

> > + /*
> > + * Set every pin that is not muxed as a GPIO to gpio-in. That
> > + * way the pin will be high impedance when it is muxed to GPIO,
> > + * preventing unwanted glitches.
> > + * The pin muxes are left as-is, so there are no signal changes.
> > + */
> > + regmap_field_write(field_dir, is_input | ~is_gpio);
> 
> This is an MDIO regmap. The operations may fail. Don't you want to check the
> return values of regmap routines?

Error checking was indeed not done consistently, so I've now added checks to all
regmap_*() calls that return an error code. Also updated in the other drivers.

> > +
> > +static int rtl8231_pinctrl_init(struct device *dev, struct rtl8231_pin_ctrl
> > *ctrl)
> > +{
> > + struct pinctrl_dev *pctldev;
> > + int err;
> > +
> > + err = devm_pinctrl_register_and_init(dev->parent, &rtl8231_pctl_desc,
> > ctrl, &pctldev);
> > + if (err) {
> > + dev_err(dev, "failed to register pin controller\n");
> > + return err;
> 
> Please use dev_err_probe() here an elsewhere.

Updated here and in the other drivers.

> > + }
> > +
> > + err = rtl8231_pinctrl_init_functions(pctldev, &rtl8231_pctl_desc);
> > + if (err)
> > + return err;
> > +
> > + err = pinctrl_enable(pctldev);
> > + if (err)
> > + dev_err(dev, "failed to enable pin controller\n");
> > +
> > + return err;
> > +}
> > +
> > +/*
> > + * GPIO controller functionality
> > + */
> > +static int rtl8231_gpio_reg_mask_xlate(struct gpio_regmap *gpio, unsigned
> > int base,
> > + unsigned int offset, unsigned int *reg, unsigned int *mask)
> 
> Can you align the start of the line with the opening bracket?

Will do.

Best,
Sander


  reply	other threads:[~2025-12-19 13:52 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-12-15 17:51 [PATCH v9 0/6] RTL8231 GPIO expander support Sander Vanheule
2025-12-15 17:51 ` [PATCH v9 1/6] dt-bindings: leds: Binding for RTL8231 scan matrix Sander Vanheule
2025-12-15 17:51 ` [PATCH v9 2/6] dt-bindings: mfd: Binding for RTL8231 Sander Vanheule
2025-12-15 17:51 ` [PATCH v9 3/6] mfd: Add RTL8231 core device Sander Vanheule
2025-12-22  8:43   ` kernel test robot
2025-12-26 11:59     ` Sander Vanheule
2025-12-26 12:19       ` Krzysztof Kozlowski
2025-12-26 14:52         ` Sander Vanheule
2025-12-15 17:51 ` [PATCH v9 4/6] pinctrl: Add RTL8231 pin control and GPIO support Sander Vanheule
2025-12-18  9:15   ` Bartosz Golaszewski
2025-12-19 13:52     ` Sander Vanheule [this message]
2025-12-15 17:51 ` [PATCH v9 5/6] leds: Add support for RTL8231 LED scan matrix Sander Vanheule
2025-12-15 17:51 ` [PATCH v9 6/6] MAINTAINERS: Add RTL8231 MFD driver Sander Vanheule

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=a8063a3a5eb8055bf88976f9da07175528502144.camel@svanheule.net \
    --to=sander@svanheule.net \
    --cc=brgl@bgdev.pl \
    --cc=brgl@kernel.org \
    --cc=conor+dt@kernel.org \
    --cc=devicetree@vger.kernel.org \
    --cc=krzk+dt@kernel.org \
    --cc=lee@kernel.org \
    --cc=linus.walleij@linaro.org \
    --cc=linux-gpio@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-leds@vger.kernel.org \
    --cc=mwalle@kernel.org \
    --cc=pavel@kernel.org \
    --cc=robh@kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®