Skip to contentSkip to conversation

gpio: tps65219: don't use CONFIG_DEBUG_GPIO

PATCH In review Bartosz Golaszewski 3 participants 4 messages Dec 21, 2023 – Dec 27, 2023

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 gpio: tps65219: don't use CONFIG_DEBUG_GPIO

From: Bartosz Golaszewski <[email protected]>

CONFIG_DEBUG_GPIO should only be used to enable debug log messages and for core GPIOLIB debugging. Don't use it to control the execution of potentially buggy code. Just put it under an always-false #if.

---
 drivers/gpio/gpio-tps65219.c | 18 +++++++++---------
 1 file changed, 9 insertions(+), 9 deletions(-)
drivers/gpio/gpio-tps65219.c +9 -9
index 7b38aa360112..cd1f17041f8c 100644
@@ -96,16 +96,16 @@ static int tps65219_gpio_change_direction(struct gpio_chip *gc, unsigned int off
 	 * Below can be used for test purpose only.
 	 */
 
-	if (IS_ENABLED(CONFIG_DEBUG_GPIO)) {
-		int ret = regmap_update_bits(gpio->tps->regmap, TPS65219_REG_MFP_1_CONFIG,
-					     TPS65219_GPIO0_DIR_MASK, direction);
-		if (ret) {
-			dev_err(dev,
-				"GPIO DEBUG enabled: Fail to change direction to %u for GPIO%d.\n",
-				direction, offset);
-			return ret;
-		}
+#if 0
+	int ret = regmap_update_bits(gpio->tps->regmap, TPS65219_REG_MFP_1_CONFIG,
+				     TPS65219_GPIO0_DIR_MASK, direction);
+	if (ret) {
+		dev_err(dev,
+			"GPIO DEBUG enabled: Fail to change direction to %u for GPIO%d.\n",
+			direction, offset);
+		return ret;
 	}
+#endif
 
 	dev_err(dev,
 		"GPIO%d direction set by NVM, change to %u failed, not allowed by specification\n",
Signature · 1 line
2.40.1
Reviewed-by on v1 1/1
#1 lore raw
Quoted 6 lines · Bartosz Golaszewski

From: Bartosz Golaszewski <[email protected]>

CONFIG_DEBUG_GPIO should only be used to enable debug log messages and for core GPIOLIB debugging. Don't use it to control the execution of potentially buggy code. Just put it under an always-false #if.

Signature · 2 lines
With Best Regards,
Andy Shevchenko
Acked-by on v1 1/1
#2 lore raw
In reply to Bartosz Golaszewski
Quoted 7 lines · Bartosz Golaszewski

From: Bartosz Golaszewski <[email protected]>

CONFIG_DEBUG_GPIO should only be used to enable debug log messages and for core GPIOLIB debugging. Don't use it to control the execution of potentially buggy code. Just put it under an always-false #if.

Maybe I would have simply deleted the code, but OK. I bet some static analyzers will promptly return complaints about "no #if 0 in the kernel" :/ In this case it's an OK compromise.

Yours,
Linus Walleij

#3 lore raw
In reply to Bartosz Golaszewski
Quoted 43 lines · Bartosz Golaszewski

From: Bartosz Golaszewski <[email protected]>

CONFIG_DEBUG_GPIO should only be used to enable debug log messages and for core GPIOLIB debugging. Don't use it to control the execution of potentially buggy code. Just put it under an always-false #if.

---
 drivers/gpio/gpio-tps65219.c | 18 +++++++++---------
 1 file changed, 9 insertions(+), 9 deletions(-)
drivers/gpio/gpio-tps65219.c +9 -10
index 7b38aa360112..cd1f17041f8c 100644
@@ -96,16 +96,16 @@ static int tps65219_gpio_change_direction(struct gpio_chip *gc, unsigned int off
         * Below can be used for test purpose only.
         */
 
-       if (IS_ENABLED(CONFIG_DEBUG_GPIO)) {
-               int ret = regmap_update_bits(gpio->tps->regmap, TPS65219_REG_MFP_1_CONFIG,
-                                            TPS65219_GPIO0_DIR_MASK, direction);
-               if (ret) {
-                       dev_err(dev,
-                               "GPIO DEBUG enabled: Fail to change direction to %u for GPIO%d.\n",
-                               direction, offset);
-                       return ret;
-               }
+#if 0
+       int ret = regmap_update_bits(gpio->tps->regmap, TPS65219_REG_MFP_1_CONFIG,
+                                    TPS65219_GPIO0_DIR_MASK, direction);
+       if (ret) {
+               dev_err(dev,
+                       "GPIO DEBUG enabled: Fail to change direction to %u for GPIO%d.\n",
+                       direction, offset);
+               return ret;
        }
+#endif
 
        dev_err(dev,
                "GPIO%d direction set by NVM, change to %u failed, not allowed by specification\n",
--
Quoted 2 lines

2.40.1

Patch applied.

Bart