lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Date:   Wed, 25 Jan 2017 16:34:21 +0100
From:   Bartosz Golaszewski <bgolaszewski@...libre.com>
To:     Linus Walleij <linus.walleij@...aro.org>,
        Alexandre Courbot <gnurou@...il.com>,
        Bamvor Jian Zhang <bamvor.zhangjian@...aro.org>
Cc:     linux-gpio@...r.kernel.org, linux-kernel@...r.kernel.org,
        Bartosz Golaszewski <bgolaszewski@...libre.com>
Subject: [PATCH 7/7] gpio: mockup: readability tweaks

Add some newlines and use a temporary pointer in mockup_gpio_add().

Signed-off-by: Bartosz Golaszewski <bgolaszewski@...libre.com>
---
 drivers/gpio/gpio-mockup.c | 38 ++++++++++++++++++++------------------
 1 file changed, 20 insertions(+), 18 deletions(-)

diff --git a/drivers/gpio/gpio-mockup.c b/drivers/gpio/gpio-mockup.c
index dabf3ec..4289bbd 100644
--- a/drivers/gpio/gpio-mockup.c
+++ b/drivers/gpio/gpio-mockup.c
@@ -78,6 +78,7 @@ static int mockup_gpio_dirout(struct gpio_chip *gc, unsigned int offset,
 
 	mockup_gpio_set(gc, offset, value);
 	cntr->stats[offset].dir = OUT;
+
 	return 0;
 }
 
@@ -86,6 +87,7 @@ static int mockup_gpio_dirin(struct gpio_chip *gc, unsigned int offset)
 	struct mockup_gpio_controller *cntr = gpiochip_get_data(gc);
 
 	cntr->stats[offset].dir = IN;
+
 	return 0;
 }
 
@@ -174,21 +176,22 @@ static int mockup_gpio_add(struct device *dev,
 			   struct mockup_gpio_controller *cntr,
 			   const char *name, int base, int ngpio)
 {
+	struct gpio_chip *gc = &cntr->gc;
 	char **names;
 	int ret, i;
 
-	cntr->gc.base = base;
-	cntr->gc.ngpio = ngpio;
-	cntr->gc.label = name;
-	cntr->gc.owner = THIS_MODULE;
-	cntr->gc.parent = dev;
-	cntr->gc.get = mockup_gpio_get;
-	cntr->gc.set = mockup_gpio_set;
-	cntr->gc.direction_output = mockup_gpio_dirout;
-	cntr->gc.direction_input = mockup_gpio_dirin;
-	cntr->gc.get_direction = mockup_gpio_get_direction;
-	cntr->gc.mockup = true;
-	cntr->stats = devm_kzalloc(dev, sizeof(*cntr->stats) * cntr->gc.ngpio,
+	gc->base = base;
+	gc->ngpio = ngpio;
+	gc->label = name;
+	gc->owner = THIS_MODULE;
+	gc->parent = dev;
+	gc->get = mockup_gpio_get;
+	gc->set = mockup_gpio_set;
+	gc->direction_output = mockup_gpio_dirout;
+	gc->direction_input = mockup_gpio_dirin;
+	gc->get_direction = mockup_gpio_get_direction;
+	gc->mockup = true;
+	cntr->stats = devm_kzalloc(dev, sizeof(*cntr->stats) * gc->ngpio,
 				   GFP_KERNEL);
 	if (!cntr->stats) {
 		ret = -ENOMEM;
@@ -197,26 +200,25 @@ static int mockup_gpio_add(struct device *dev,
 
 	if (gpio_mockup_named_lines) {
 		names = devm_kzalloc(dev,
-				     sizeof(char *) * cntr->gc.ngpio,
-				     GFP_KERNEL);
+				     sizeof(char *) * gc->ngpio, GFP_KERNEL);
 		if (!names) {
 			ret = -ENOMEM;
 			goto err;
 		}
 
-		for (i = 0; i < cntr->gc.ngpio; i++) {
+		for (i = 0; i < gc->ngpio; i++) {
 			names[i] = devm_kasprintf(dev, GFP_KERNEL,
-						  "%s-%d", cntr->gc.label, i);
+						  "%s-%d", gc->label, i);
 			if (!names[i]) {
 				ret = -ENOMEM;
 				goto err;
 			}
 		}
 
-		cntr->gc.names = (const char *const*)names;
+		gc->names = (const char *const*)names;
 	}
 
-	ret = devm_gpiochip_add_data(dev, &cntr->gc, cntr);
+	ret = devm_gpiochip_add_data(dev, gc, cntr);
 	if (ret)
 		goto err;
 
-- 
2.9.3

Powered by blists - more mailing lists