[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <aBSbKwmao-K-e1k8@smile.fi.intel.com>
Date: Fri, 2 May 2025 13:15:07 +0300
From: Andy Shevchenko <andriy.shevchenko@...el.com>
To: Mathieu Dubois-Briand <mathieu.dubois-briand@...tlin.com>
Cc: Lee Jones <lee@...nel.org>, Rob Herring <robh@...nel.org>,
Krzysztof Kozlowski <krzk+dt@...nel.org>,
Conor Dooley <conor+dt@...nel.org>,
Kamel Bouhara <kamel.bouhara@...tlin.com>,
Linus Walleij <linus.walleij@...aro.org>,
Bartosz Golaszewski <brgl@...ev.pl>,
Dmitry Torokhov <dmitry.torokhov@...il.com>,
Uwe Kleine-König <ukleinek@...nel.org>,
Michael Walle <mwalle@...nel.org>, Mark Brown <broonie@...nel.org>,
Greg Kroah-Hartman <gregkh@...uxfoundation.org>,
"Rafael J. Wysocki" <rafael@...nel.org>,
Danilo Krummrich <dakr@...nel.org>, devicetree@...r.kernel.org,
linux-kernel@...r.kernel.org, linux-gpio@...r.kernel.org,
linux-input@...r.kernel.org, linux-pwm@...r.kernel.org,
Grégory Clement <gregory.clement@...tlin.com>,
Thomas Petazzoni <thomas.petazzoni@...tlin.com>
Subject: Re: [PATCH v7 03/11] pinctrl: Add MAX7360 pinctrl driver
On Mon, Apr 28, 2025 at 01:57:21PM +0200, Mathieu Dubois-Briand wrote:
> Add driver for Maxim Integrated MAX7360 pinctrl on the PORT pins. Pins
> can be used either for GPIO, PWM or rotary encoder functionalities.
...
> +#include <linux/array_size.h>
> +#include <linux/dev_printk.h>
> +#include <linux/device.h>
> +#include <linux/device/devres.h>
Since device.h is included the other two are not strictly needed, but it's fine
to leave them explicitly included.
> +#include <linux/err.h>
> +#include <linux/init.h>
> +#include <linux/mfd/max7360.h>
> +#include <linux/module.h>
> +#include <linux/platform_device.h>
> +#include <linux/regmap.h>
> +#include <linux/slab.h>
Is it used?
...
> +struct max7360_pinctrl {
> + struct pinctrl_dev *pctldev;
> + struct pinctrl_desc pinctrl_desc;
Does`pahole` agree with your choice of layout?
> +};
...
> +static int max7360_set_mux(struct pinctrl_dev *pctldev, unsigned int selector,
> + unsigned int group)
> +{
> + struct regmap *regmap;
> + int val;
> +
> + /*
> + * GPIO and PWM functions are the same: we only need to handle the
> + * rotary encoder function, on pins 6 and 7.
> + */
> + if (max7360_groups[group].pins[0] >= 6) {
> + if (selector == MAX7360_PINCTRL_FN_ROTARY)
> + val = MAX7360_GPIO_CFG_RTR_EN;
> + else
> + val = 0;
> + regmap = dev_get_regmap(pctldev->dev->parent, NULL);
This assignment can be unified with the definition above.
> + return regmap_write_bits(regmap, MAX7360_REG_GPIOCFG, MAX7360_GPIO_CFG_RTR_EN, val);
> + }
> +
> + return 0;
> +}
...
> +static int max7360_pinctrl_probe(struct platform_device *pdev)
> +{
> + struct regmap *regmap;
> + struct pinctrl_desc *pd;
> + struct max7360_pinctrl *chip;
> + struct device *dev = &pdev->dev;
> +
> + regmap = dev_get_regmap(dev->parent, NULL);
> + if (!regmap)
> + dev_err_probe(dev, -ENODEV, "Could not get parent regmap\n");
Missing 'return'. Or...?
> + chip = devm_kzalloc(dev, sizeof(*chip), GFP_KERNEL);
> + if (!chip)
> + return -ENOMEM;
> +
> + pd = &chip->pinctrl_desc;
> +
> + pd->pctlops = &max7360_pinctrl_ops;
> + pd->pmxops = &max7360_pmxops;
> + pd->name = dev_name(dev);
> + pd->pins = max7360_pins;
> + pd->npins = MAX7360_MAX_GPIO;
> + pd->owner = THIS_MODULE;
> +
> + device_set_of_node_from_dev(dev, dev->parent);
I don't like this, but I have no better idea right now. Perhaps add a comment
on top to explain this call?
> + chip->pctldev = devm_pinctrl_register(dev, pd, chip);
> + if (IS_ERR(chip->pctldev))
> + return dev_err_probe(dev, PTR_ERR(chip->pctldev), "can't register controller\n");
> +
> + return 0;
> +}
--
With Best Regards,
Andy Shevchenko
Powered by blists - more mailing lists