[1/2] gpiolib: drop tabs from local variable declarations
Commit Message
From: Bartosz Golaszewski <bartosz.golaszewski@linaro.org>
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'.
Signed-off-by: Bartosz Golaszewski <bartosz.golaszewski@linaro.org>
---
drivers/gpio/gpiolib.c | 40 ++++++++++++++++++++--------------------
1 file changed, 20 insertions(+), 20 deletions(-)
Comments
On Tue, Dec 19, 2023 at 03:23:22PM +0100, Bartosz Golaszewski wrote:
> From: Bartosz Golaszewski <bartosz.golaszewski@linaro.org>
>
> 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 <andriy.shevchenko@linux.intel.com>
...
> + 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.
...
> + bool ret = false;
> + unsigned long flags;
> + struct gpio_chip *gc;
Ditto.
...
> + struct gpio_chip *gc = gdev->chip;
> + struct gpio_desc *desc;
(okay with above, but...)
> + unsigned int gpio = gdev->base;
> + int value;
Ditto.
> + bool is_out;
> + bool is_irq;
> + bool active_low;
And ditto.
On Tue, Dec 19, 2023 at 4:06 PM Andy Shevchenko
<andriy.shevchenko@linux.intel.com> wrote:
>
> On Tue, Dec 19, 2023 at 03:23:22PM +0100, Bartosz Golaszewski wrote:
> > From: Bartosz Golaszewski <bartosz.golaszewski@linaro.org>
> >
> > 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 <andriy.shevchenko@linux.intel.com>
>
> ...
>
> > + 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
> ...
>
> > + bool ret = false;
> > + unsigned long flags;
> > + struct gpio_chip *gc;
>
> Ditto.
>
> ...
>
> > + struct gpio_chip *gc = gdev->chip;
> > + struct gpio_desc *desc;
>
> (okay with above, but...)
>
> > + unsigned int gpio = gdev->base;
>
> > + int value;
>
> Ditto.
>
> > + bool is_out;
> > + bool is_irq;
> > + bool active_low;
>
> And ditto.
>
> --
> With Best Regards,
> Andy Shevchenko
>
>
On Tue, Dec 19, 2023 at 08:59:12PM +0100, Bartosz Golaszewski wrote:
> On Tue, Dec 19, 2023 at 4:06 PM Andy Shevchenko
> <andriy.shevchenko@linux.intel.com> wrote:
> > On Tue, Dec 19, 2023 at 03:23:22PM +0100, Bartosz Golaszewski wrote:
...
> > > + 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.
@@ -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 *des
static 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 value
static 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)) {