From patchwork Wed Jan 25 15:34:21 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bartosz Golaszewski X-Patchwork-Id: 92466 Delivered-To: patch@linaro.org Received: by 10.182.3.34 with SMTP id 2csp2237619obz; Wed, 25 Jan 2017 07:34:47 -0800 (PST) X-Received: by 10.84.176.1 with SMTP id u1mr4556509plb.71.1485358487153; Wed, 25 Jan 2017 07:34:47 -0800 (PST) Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id r17si20243879pgd.173.2017.01.25.07.34.46; Wed, 25 Jan 2017 07:34:47 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@baylibre-com.20150623.gappssmtp.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751874AbdAYPeo (ORCPT + 25 others); Wed, 25 Jan 2017 10:34:44 -0500 Received: from mail-wm0-f47.google.com ([74.125.82.47]:37123 "EHLO mail-wm0-f47.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751838AbdAYPem (ORCPT ); Wed, 25 Jan 2017 10:34:42 -0500 Received: by mail-wm0-f47.google.com with SMTP id c206so37099098wme.0 for ; Wed, 25 Jan 2017 07:34:41 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=baylibre-com.20150623.gappssmtp.com; s=20150623; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=l9WMJNr8mTg7AQydVzKufltoOz3itPNMNa4zzMLHkN8=; b=gYvZosmtCsVU7lA/lajsSJs4ZEbAVdhm/j9B+XKOmcdFEraTbogSpDxniUWd2E8300 OlvJ09HOOO8gLOlC8hwksoh3x0pd88cdHwLd8+S/kEUZs2rYf444bVXo/WUAUMZPI9L7 4sOQkvZbRVIPabU0S4czFFsmlETlyn1cZ8Wh0iUFY1ivXXpXmImagRVIH8t7RwuJI7La 9dV50eS2s32+NgtEO1cTcHhE7orT/vgLiafP4glo/ECkvvkS9dJuaJI5NarcBg5vjZod 6QhS4Mvh3mjXSqmkEIcESGrIdWaCA0e5XtBbmNrbr8RUdyycO1DpjALGNlzhrIU4iGXS 58kw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=l9WMJNr8mTg7AQydVzKufltoOz3itPNMNa4zzMLHkN8=; b=EUF+cINkFivxbwhA6TQwA9pkPDAQzRIIIizFFTn/QnKoBzjAp5DU1UVlp1nz77IWjh onZNiHpePy5RsNy1xE5x7rKGHtJ8Ss3MtALVeUKm4OP83FNE9pSA5kLOCIXtjpZTjeyT RIdq4DPpATRM7YlNswR4UFm68lL9xErnRy/D0xqstRJ44iujJBXQrnsgOPN4t/W2rgVo j2NhBSftWCXYPiX8y3Z2VCZjbFBl+AIBj5+KVUjwHpb+m/stuSLMqFTr845y2rElOJz7 qEJAeCRn73SKBldEFyZUgN0WGI3v7J2VYAyJtKoCe8by6APW/5+urCHDxr3ZSw8iZR3Q Xcxw== X-Gm-Message-State: AIkVDXKFgEfWc8D2DWiSOTHjHophW049nFCeDsbhBiGD1tWd2xmgFaCu1qJ+MyvkEO/9Q8DG X-Received: by 10.223.178.87 with SMTP id y23mr32446275wra.91.1485358475692; Wed, 25 Jan 2017 07:34:35 -0800 (PST) Received: from localhost.localdomain ([90.63.244.31]) by smtp.gmail.com with ESMTPSA id 33sm2462760wrd.34.2017.01.25.07.34.34 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Wed, 25 Jan 2017 07:34:35 -0800 (PST) From: Bartosz Golaszewski To: Linus Walleij , Alexandre Courbot , Bamvor Jian Zhang Cc: linux-gpio@vger.kernel.org, linux-kernel@vger.kernel.org, Bartosz Golaszewski Subject: [PATCH 7/7] gpio: mockup: readability tweaks Date: Wed, 25 Jan 2017 16:34:21 +0100 Message-Id: <1485358461-24070-8-git-send-email-bgolaszewski@baylibre.com> X-Mailer: git-send-email 2.1.4 In-Reply-To: <1485358461-24070-1-git-send-email-bgolaszewski@baylibre.com> References: <1485358461-24070-1-git-send-email-bgolaszewski@baylibre.com> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Add some newlines and use a temporary pointer in mockup_gpio_add(). Signed-off-by: Bartosz Golaszewski --- drivers/gpio/gpio-mockup.c | 38 ++++++++++++++++++++------------------ 1 file changed, 20 insertions(+), 18 deletions(-) -- 2.9.3 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;