diff mbox series

[v5,04/17] gpiolib: Add temporary variable to gpiod_set_transitory() for cleaner code

Message ID 20201109205332.19592-5-andriy.shevchenko@linux.intel.com
State New
Headers show
Series gpiolib: acpi: pin configuration fixes | expand

Commit Message

Andy Shevchenko Nov. 9, 2020, 8:53 p.m. UTC
Temporary variable that keeps mode allows to neat the code a bit.
It will also help for the future changes.

Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
---
 drivers/gpio/gpiolib.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

Comments

Mika Westerberg Nov. 11, 2020, 3:32 p.m. UTC | #1
On Mon, Nov 09, 2020 at 10:53:19PM +0200, Andy Shevchenko wrote:
> Temporary variable that keeps mode allows to neat the code a bit.
> It will also help for the future changes.
> 
> Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>

Not really sure if this is good change or not. Instead of constant you
now introduce a useless variable just to get them to the same line.

To me this looks better and reads easier:

	packed = pinconf_to_config_packed(PIN_CONFIG_PERSIST_STATE, !transitory);

But not insisting so if GPIO maintainers are fine then no objections :)
Andy Shevchenko Nov. 11, 2020, 3:40 p.m. UTC | #2
On Wed, Nov 11, 2020 at 5:33 PM Mika Westerberg
<mika.westerberg@linux.intel.com> wrote:
>
> On Mon, Nov 09, 2020 at 10:53:19PM +0200, Andy Shevchenko wrote:
> > Temporary variable that keeps mode allows to neat the code a bit.
> > It will also help for the future changes.
> >
> > Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
>
> Not really sure if this is good change or not. Instead of constant you
> now introduce a useless variable just to get them to the same line.

No, it's useful in a patch in the series as promised in the commit
message. That variable reduces a line length a lot there.

> To me this looks better and reads easier:
>
>         packed = pinconf_to_config_packed(PIN_CONFIG_PERSIST_STATE, !transitory);
>
> But not insisting so if GPIO maintainers are fine then no objections :)
Andy Shevchenko Nov. 11, 2020, 7:24 p.m. UTC | #3
On Wed, Nov 11, 2020 at 05:40:16PM +0200, Andy Shevchenko wrote:
> On Wed, Nov 11, 2020 at 5:33 PM Mika Westerberg
> <mika.westerberg@linux.intel.com> wrote:
> > On Mon, Nov 09, 2020 at 10:53:19PM +0200, Andy Shevchenko wrote:

...

> > To me this looks better and reads easier:
> >
> >         packed = pinconf_to_config_packed(PIN_CONFIG_PERSIST_STATE, !transitory);
> >
> > But not insisting so if GPIO maintainers are fine then no objections :)

I have dropped this patch.
diff mbox series

Patch

diff --git a/drivers/gpio/gpiolib.c b/drivers/gpio/gpiolib.c
index 87bb73991337..134f11a84b91 100644
--- a/drivers/gpio/gpiolib.c
+++ b/drivers/gpio/gpiolib.c
@@ -2374,6 +2374,7 @@  EXPORT_SYMBOL_GPL(gpiod_set_debounce);
  */
 int gpiod_set_transitory(struct gpio_desc *desc, bool transitory)
 {
+	enum pin_config_param mode = PIN_CONFIG_PERSIST_STATE;
 	struct gpio_chip *gc;
 	unsigned long packed;
 	int gpio;
@@ -2391,8 +2392,7 @@  int gpiod_set_transitory(struct gpio_desc *desc, bool transitory)
 	if (!gc->set_config)
 		return 0;
 
-	packed = pinconf_to_config_packed(PIN_CONFIG_PERSIST_STATE,
-					  !transitory);
+	packed = pinconf_to_config_packed(mode, !transitory);
 	gpio = gpio_chip_hwgpio(desc);
 	rc = gpio_do_set_config(gc, gpio, packed);
 	if (rc == -ENOTSUPP) {