Re: [PATCH v4 1/2] gpio: tps65219: add GPIO support for TPS65219 PMIC

From: jerome Neanne
Date: Tue Jun 06 2023 - 08:47:14 EST




On 30/05/2023 13:07, andy.shevchenko@xxxxxxxxx wrote:
Tue, May 30, 2023 at 09:59:59AM +0200, Jerome Neanne kirjoitti:

First of all, I have a bit of déjà vu that I have given already some comments
that left neither answered nor addressed.
Sorry for that. I did not realized that some comments on the cover letter also apply to commit message.

Add support for TPS65219 PMICs GPIO interface.

3 GPIO pins:
- GPIO0 only is IO but input mode reserved for MULTI_DEVICE_ENABLE usage
- GPIO1 and GPIO2 are Output only and referred as GPO1 and GPO2 in spec

GPIO0 is statically configured as input or output prior to Linux boot.
it is used for MULTI_DEVICE_ENABLE function.
This setting is statically configured by NVM.
GPIO0 can't be used as a generic GPIO (specification Table 8-34).
It's either a GPO when MULTI_DEVICE_EN=0 or a GPI when MULTI_DEVICE_EN=1.

Datasheet describes specific usage for non standard GPIO.
Link: https://www.ti.com/lit/ds/symlink/tps65219.pdf

Can you convert this to be a Datasheet tag? Currently even Link is *not* a tag
because there must be no blank lines in the tag block.

Co-developed-by: Jonathan Cormier <jcormier@xxxxxxxxxxxxxxxx>
Signed-off-by: Jonathan Cormier <jcormier@xxxxxxxxxxxxxxxx>
Signed-off-by: Jerome Neanne <jneanne@xxxxxxxxxxxx>

I misinterpreted this comment. I looked at wrong examples but I think I understand now that the right usage is to have all the tags grouped together into one block which is delimited by blank lines before and after the whole block.
I'll then do this and put all the Datasheet/Link into the tag block. Stop putting Links inside the commit message right after I refer to it.
https://www.kernel.org/doc/html/latest/process/5.Posting.html#patch-formatting-and-changelogs

...

+ help
+ Select this option to enable GPIO driver for the TPS65219 chip family.
+ GPIO0 is statically configured as input or output prior to Linux boot.
+ It is used for MULTI_DEVICE_ENABLE function.
+ This setting is statically configured by NVM.
+ GPIO0 can't be used as a generic GPIO.
+ It's either a GPO when MULTI_DEVICE_EN=0 or a GPI when MULTI_DEVICE_EN=1.
+
+ This driver can also be built as a module.
+ If so, the module will be called gpio_tps65219.

Random indentation. Can you use as much room as available on each line, please?
Sure for next iteration, I choosed 80 columns here to stay consistent with other configs. I kept a carriage return after the first sentence like it is done for other descriptions.
This driver can also be built as a module... is separated with a blank line as it is done in all other configs.
For all the other lines, I now keep the same line until last word strictly exceed column 80.


@@ -0,0 +1,181 @@
+// SPDX-License-Identifier: GPL-2.0
+/*
+ * GPIO driver for TI TPS65219 PMICs
+ *
+ * Copyright (C) 2022 Texas Instruments Incorporated - http://www.ti.com/
+ */
+
+#include <linux/bits.h>
+#include <linux/gpio/driver.h>
+#include <linux/mfd/tps65219.h>
+#include <linux/module.h>
+#include <linux/platform_device.h>
+#include <linux/regmap.h>

...

+static int tps65219_gpio_get(struct gpio_chip *gc, unsigned int offset)
+{
+ struct tps65219_gpio *gpio = gpiochip_get_data(gc);
+ struct device *dev = gpio->tps->dev;
+ int ret, val;
+
+ if (offset != TPS65219_GPIO0_IDX) {
+ dev_err(dev, "GPIO%d is output only, cannot get\n", offset);

+ return -EOPNOTSUPP;

This seems blind following the checkpatch false warning. The checkpatch does
not know about subsystem details, i.e. GPIOLIB uses ENOTSUPP in the callbacks.
The userspace won't see that as GPIOLIB takes care of translating it when
needed.

Thanks for explaining, I'm often in trouble for choosing the error code. I'll replace here and all other places where it's used with EOPNOTSUPP.

Regards,
Jerome