gpiolib: drop tabs from local variable declarations
PATCH 1/2 gpiolib: drop tabs from local variable declarations
From: Bartosz Golaszewski <[email protected]>
Older code has an annoying habit of putting tabs between the type and the name of the variable. This doesn't really add to readability and newer code doesn't do it so make the entire file consistent.
While at it: convert 'unsigned' to 'unsigned int'.
--- drivers/gpio/gpiolib.c | 40 ++++++++++++++++++++-------------------- 1 file changed, 20 insertions(+), 20 deletions(-)
drivers/gpio/gpiolib.c +20 -20
@@ -1049,8 +1049,8 @@ EXPORT_SYMBOL_GPL(gpiochip_add_data_with_key);void gpiochip_remove (struct gpio_chip *gc) {struct gpio_device *gdev = gc->gpiodev; -unsigned long flags; -unsigned int i; +unsigned long flags; +unsigned int i;down_write (&gdev->sem);
@@ -2186,10 +2186,10 @@ EXPORT_SYMBOL_GPL(gpiochip_remove_pin_ranges);*/ static int gpiod_request_commit (struct gpio_desc *desc,const char *label) { -struct gpio_chip *gc = desc->gdev->chip; -int ret; -unsigned long flags; -unsigned offset; +struct gpio_chip *gc = desc->gdev->chip; +int ret; +unsigned long flags; +unsigned int offset;if (label) { label =kstrdup_const (label,GFP_KERNEL );
@@ -2301,9 +2301,9 @@ int gpiod_request(struct gpio_desc *desc, const char *label)static bool gpiod_free_commit (struct gpio_desc *desc) { -bool ret = false; -unsigned long flags; -struct gpio_chip *gc; +bool ret = false; +unsigned long flags; +struct gpio_chip *gc;might_sleep ();
@@ -2577,8 +2577,8 @@ int gpio_set_debounce_timeout(struct gpio_desc *desc, unsigned int debounce)*/ int gpiod_direction_input (struct gpio_desc *desc) { -struct gpio_chip *gc; -int ret =0 ; +struct gpio_chip *gc; +int ret =0 ;VALIDATE_DESC (desc); gc = desc->gdev->chip;
@@ -2927,7 +2927,7 @@ static int gpio_chip_get_value(struct gpio_chip *gc, const struct gpio_desc *desstatic int gpiod_get_raw_value_commit (const struct gpio_desc *desc) { -struct gpio_chip *gc; +struct gpio_chip *gc;int value; gc = desc->gdev->chip;
@@ -3222,7 +3222,7 @@ static void gpio_set_open_source_value_commit(struct gpio_desc *desc, bool valuestatic void gpiod_set_raw_value_commit (struct gpio_desc *desc,bool value) { -struct gpio_chip *gc; +struct gpio_chip *gc; gc = desc->gdev->chip;trace_gpio_value (desc_to_gpio (desc),0 , value);
@@ -4709,13 +4709,13 @@ core_initcall(gpiolib_dev_init);static void gpiolib_dbg_show (struct seq_file *s,struct gpio_device *gdev) { -struct gpio_chip *gc = gdev->chip; -struct gpio_desc *desc; -unsigned gpio = gdev->base; -int value; -bool is_out; -bool is_irq; -bool active_low; +struct gpio_chip *gc = gdev->chip; +struct gpio_desc *desc; +unsigned int gpio = gdev->base; +int value; +bool is_out; +bool is_irq; +bool active_low;for_each_gpio_desc (gc, desc) {if (test_bit (FLAG_REQUESTED , &desc->flags)) {
Signature · 1 line
2.40.1
PATCH 2/2 gpio: sysfs: drop tabs from local variable declarations
From: Bartosz Golaszewski <[email protected]>
Older code has an annoying habit of putting tabs between the type and the name of the variable. This doesn't really add to readability and newer code doesn't do it so make the entire file consistent.
--- drivers/gpio/gpiolib-sysfs.c | 50 ++++++++++++++++++------------------ 1 file changed, 25 insertions(+), 25 deletions(-)
drivers/gpio/gpiolib-sysfs.c +25 -25
@@ -165,10 +165,10 @@ static irqreturn_t gpio_sysfs_irq(int irq, void *priv)/* Caller holds gpiod-data mutex. */ static int gpio_sysfs_request_irq (struct device *dev,unsigned char flags) { -struct gpiod_data *data =dev_get_drvdata (dev); -struct gpio_desc *desc = data->desc; -unsigned long irq_flags; -int ret; +struct gpiod_data *data =dev_get_drvdata (dev); +struct gpio_desc *desc = data->desc; +unsigned long irq_flags; +int ret; data->irq =gpiod_to_irq (desc);if (data->irq <0 )
@@ -259,7 +259,7 @@ static ssize_t edge_store(struct device *dev, struct device_attribute *attr, const char *buf, size_t size) { struct gpiod_data *data = dev_get_drvdata(dev); -ssize_t status = size; +ssize_t status = size;int flags; flags =sysfs_match_string (trigger_names, buf);
@@ -292,8 +292,8 @@ static DEVICE_ATTR_RW(edge);/* Caller holds gpiod-data mutex. */ static int gpio_sysfs_set_active_low (struct device *dev,int value) { -struct gpiod_data *data =dev_get_drvdata (dev); -struct gpio_desc *desc = data->desc; +struct gpiod_data *data =dev_get_drvdata (dev); +struct gpio_desc *desc = data->desc;int status =0 ;unsigned int flags = data->irq_flags;
@@ -331,9 +331,9 @@ static ssize_t active_low_show(struct device *dev,static ssize_t active_low_store (struct device *dev,struct device_attribute *attr,const char *buf,size_t size) { -struct gpiod_data *data =dev_get_drvdata (dev); -ssize_t status; -long value; +struct gpiod_data *data =dev_get_drvdata (dev); +ssize_t status; +long value; status =kstrtol (buf,0 , &value);if (status)
@@ -399,7 +399,7 @@ static const struct attribute_group *gpio_groups[] = {static ssize_t base_show (struct device *dev,struct device_attribute *attr,char *buf) { -const struct gpio_chip *chip =dev_get_drvdata (dev); +const struct gpio_chip *chip =dev_get_drvdata (dev);return sysfs_emit (buf,"%d\n" , chip->base); }
@@ -408,7 +408,7 @@ static DEVICE_ATTR_RO(base);static ssize_t label_show (struct device *dev,struct device_attribute *attr,char *buf) { -const struct gpio_chip *chip =dev_get_drvdata (dev); +const struct gpio_chip *chip =dev_get_drvdata (dev);return sysfs_emit (buf,"%s\n" , chip->label ?:"" ); }
@@ -417,7 +417,7 @@ static DEVICE_ATTR_RO(label);static ssize_t ngpio_show (struct device *dev,struct device_attribute *attr,char *buf) { -const struct gpio_chip *chip =dev_get_drvdata (dev); +const struct gpio_chip *chip =dev_get_drvdata (dev);return sysfs_emit (buf,"%u\n" , chip->ngpio); }
@@ -441,10 +441,10 @@ static ssize_t export_store(const struct class *class,const struct class_attribute *attr, const char *buf, size_t len) { - long gpio; -struct gpio_desc *desc; -int status; -struct gpio_chip *gc; + long gpio; +struct gpio_desc *desc; +int status; +struct gpio_chip *gc;int offset; status =kstrtol (buf,0 , &gpio);
@@ -493,9 +493,9 @@ static ssize_t unexport_store(const struct class *class,const struct class_attribute *attr, const char *buf, size_t len) { - long gpio; -struct gpio_desc *desc; -int status; + long gpio; +struct gpio_desc *desc; +int status; status =kstrtol (buf,0 , &gpio);if (status <0 )
@@ -556,9 +556,9 @@ static struct class gpio_class = {*/ int gpiod_export (struct gpio_desc *desc,bool direction_may_change) { -struct gpio_chip *chip; -struct gpio_device *gdev; -struct gpiod_data *data; +struct gpio_chip *chip; +struct gpio_device *gdev; +struct gpiod_data *data;unsigned long flags;int status;const char *ioname =NULL ;
@@ -730,8 +730,8 @@ EXPORT_SYMBOL_GPL(gpiod_unexport);int gpiochip_sysfs_register (struct gpio_device *gdev) { -struct device *dev; -struct device *parent; +struct device *dev; +struct device *parent;struct gpio_chip *chip = gdev->chip;/*
Signature · 1 line
2.40.1
Re: [PATCH 2/2] gpio: sysfs: drop tabs from local variable declarations
Quoted 5 lines · Bartosz Golaszewski
From: Bartosz Golaszewski <[email protected]>
Older code has an annoying habit of putting tabs between the type and the name of the variable. This doesn't really add to readability and newer code doesn't do it so make the entire file consistent.
Besides similar comments as per previous patch, see below.
...
drivers/gpio/gpiolib-sysfs.c static DEVICE_ATTR_RW(edge); · line 298
Quoted 4 lines
drivers/gpio/gpiolib-sysfs.c +2
-0+struct gpiod_data *data =dev_get_drvdata (dev); +struct gpio_desc *desc = data->desc;int status =0 ;unsigned int flags = data->irq_flags;
???
...
drivers/gpio/gpiolib-sysfs.c static struct class gpio_class = { · line 564
Quoted 5 lines
drivers/gpio/gpiolib-sysfs.c +2
-0+struct gpio_device *gdev; +struct gpiod_data *data;unsigned long flags;int status;const char *ioname =NULL ;
???
Signature · 2 lines
With Best Regards, Andy Shevchenko
Re: [PATCH 2/2] gpio: sysfs: drop tabs from local variable declarations
Quoted 21 lines · Andy Shevchenko
Quoted 5 lines · Bartosz Golaszewski
From: Bartosz Golaszewski <[email protected]>
Older code has an annoying habit of putting tabs between the type and the name of the variable. This doesn't really add to readability and newer code doesn't do it so make the entire file consistent.
Besides similar comments as per previous patch, see below.
...
drivers/gpio/gpiolib-sysfs.c static DEVICE_ATTR_RW(edge); · line 298
Quoted 4 lines
drivers/gpio/gpiolib-sysfs.c +2
-0+struct gpiod_data *data =dev_get_drvdata (dev); +struct gpio_desc *desc = data->desc;int status =0 ;unsigned int flags = data->irq_flags;???
...
Quoted 8 lines
drivers/gpio/gpiolib-sysfs.c static struct class gpio_class = { · line 564
Quoted 5 lines
drivers/gpio/gpiolib-sysfs.c +2
-0+struct gpio_device *gdev; +struct gpiod_data *data;unsigned long flags;int status;const char *ioname =NULL ;???
Thanks, should have not trusted my regex blindly.
Bart
Quoted 5 lines
--
With Best Regards,
Andy Shevchenko
Quoted 7 lines · Bartosz Golaszewski
From: Bartosz Golaszewski <[email protected]>
Older code has an annoying habit of putting tabs between the type and the name of the variable. This doesn't really add to readability and newer code doesn't do it so make the entire file consistent.
While at it: convert 'unsigned' to 'unsigned int'.
Not a big change to be a burden for backporting I suppose. Code wise looks good to me,
...
drivers/gpio/gpiolib.c EXPORT_SYMBOL_GPL(gpiochip_remove_pin_ranges); · line 2192
Quoted 4 lines
drivers/gpio/gpiolib.c +4
-0+struct gpio_chip *gc = desc->gdev->chip; +int ret; +unsigned long flags; +unsigned int offset;
I'm wondering if you can make it reversed xmas tree order. This will make it even more consistent between functions.
...
drivers/gpio/gpiolib.c int gpiod_request(struct gpio_desc *desc, const char *label) · line 2306
Quoted 3 lines
drivers/gpio/gpiolib.c +3
-0+bool ret = false; +unsigned long flags; +struct gpio_chip *gc;
Ditto.
...
drivers/gpio/gpiolib.c core_initcall(gpiolib_dev_init); · line 4713
Quoted 2 lines
drivers/gpio/gpiolib.c +2
-0+struct gpio_chip *gc = gdev->chip; +struct gpio_desc *desc;
(okay with above, but...)
drivers/gpio/gpiolib.c core_initcall(gpiolib_dev_init);
Quoted 3 lines
drivers/gpio/gpiolib.c +2
-0+unsigned int gpio = gdev->base; +int value;
Ditto.
drivers/gpio/gpiolib.c core_initcall(gpiolib_dev_init); · line 4718
Quoted 3 lines
drivers/gpio/gpiolib.c +3
-0+bool is_out; +bool is_irq; +bool active_low;
And ditto.
Signature · 2 lines
With Best Regards, Andy Shevchenko
Quoted 16 lines · Andy Shevchenko
Quoted 7 lines · Bartosz Golaszewski
From: Bartosz Golaszewski <[email protected]>
Older code has an annoying habit of putting tabs between the type and the name of the variable. This doesn't really add to readability and newer code doesn't do it so make the entire file consistent.
While at it: convert 'unsigned' to 'unsigned int'.
Not a big change to be a burden for backporting I suppose. Code wise looks good to me,
Reviewed-by Andy Shevchenko <[email protected]>...
Quoted 8 lines
drivers/gpio/gpiolib.c EXPORT_SYMBOL_GPL(gpiochip_remove_pin_ranges); · line 2192
Quoted 4 lines
drivers/gpio/gpiolib.c +4
-0+struct gpio_chip *gc = desc->gdev->chip; +int ret; +unsigned long flags; +unsigned int offset;I'm wondering if you can make it reversed xmas tree order. This will make it even more consistent between functions.
Sure but we'd have to update all functions across gpiolib.c. Let's take it one thing at a time.
Bart
Quoted 32 lines
...
drivers/gpio/gpiolib.c int gpiod_request(struct gpio_desc *desc, const char *label) · line 2306
Quoted 3 lines
drivers/gpio/gpiolib.c +3
-0+bool ret = false; +unsigned long flags; +struct gpio_chip *gc;Ditto.
...
drivers/gpio/gpiolib.c core_initcall(gpiolib_dev_init); · line 4713
Quoted 2 lines
drivers/gpio/gpiolib.c +2
-0+struct gpio_chip *gc = gdev->chip; +struct gpio_desc *desc;(okay with above, but...)
drivers/gpio/gpiolib.c core_initcall(gpiolib_dev_init);
Quoted 3 lines
drivers/gpio/gpiolib.c +2
-0+unsigned int gpio = gdev->base; +int value;Ditto.
drivers/gpio/gpiolib.c core_initcall(gpiolib_dev_init); · line 4718
Quoted 3 lines
drivers/gpio/gpiolib.c +3
-0+bool is_out; +bool is_irq; +bool active_low;And ditto.
--
With Best Regards,
Andy Shevchenko
Quoted 3 lines · Bartosz Golaszewski
Quoted 1 line · Andy Shevchenko
On Tue, Dec 19, 2023 at 03:23:22PM +0100, Bartosz Golaszewski wrote:
...
Quoted 10 lines
Quoted 7 lines
drivers/gpio/gpiolib.c EXPORT_SYMBOL_GPL(gpiochip_remove_pin_ranges); · line 2192
Quoted 4 lines
drivers/gpio/gpiolib.c +4
-0+struct gpio_chip *gc = desc->gdev->chip; +int ret; +unsigned long flags; +unsigned int offset;I'm wondering if you can make it reversed xmas tree order. This will make it even more consistent between functions.
Sure but we'd have to update all functions across
gpiolib.c. Let's take it one thing at a time.
The point is to do this for the lines you modified to avoid additional churn and burden for backport. At least these two things (removing TABs and shuffling the order) are kinda of the same family of the logical changes. I do not see the problem doing this in one patch for the lines you modified. Yet, for the rest it might be another patch, but I don't think it worth doing it.
Signature · 2 lines
With Best Regards, Andy Shevchenko