From patchwork Wed Jan 25 15:34:20 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bartosz Golaszewski X-Patchwork-Id: 92467 Delivered-To: patch@linaro.org Received: by 10.182.3.34 with SMTP id 2csp2237725obz; Wed, 25 Jan 2017 07:34:59 -0800 (PST) X-Received: by 10.84.210.8 with SMTP id z8mr4508357plh.94.1485358499131; Wed, 25 Jan 2017 07:34:59 -0800 (PST) Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id f9si1892835plk.180.2017.01.25.07.34.59; Wed, 25 Jan 2017 07:34:59 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-gpio-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=neutral (body hash did not verify) header.i=@baylibre-com.20150623.gappssmtp.com; spf=pass (google.com: best guess record for domain of linux-gpio-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-gpio-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751879AbdAYPey (ORCPT + 4 others); Wed, 25 Jan 2017 10:34:54 -0500 Received: from mail-wm0-f54.google.com ([74.125.82.54]:34192 "EHLO mail-wm0-f54.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751878AbdAYPeq (ORCPT ); Wed, 25 Jan 2017 10:34:46 -0500 Received: by mail-wm0-f54.google.com with SMTP id f73so52862232wmf.1 for ; Wed, 25 Jan 2017 07:34:40 -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=dgJhgHCm+EEUIQ1sce9EF83+QcIAtfgF4ykDEdD/BoE=; b=e/fkLc752ZRBiGkpvnw71D702PjyX356xsnEBS1+fSM3RNM2x37pyFGSBH4Rtpk6Li VXaymR+y1/tMcMcvOp7KP608lGm+j3RESVr1BlqIN6mye9CKQSKOz+UF8dwjQq4kp7IA wHoknNYVgWa1iNlpCdh1lGln5zecmcYaLm320/SxZkIsmM7JB9NoRafGqCUMX9F3o5mh BdzEmPZwSWlULPmHnlCO2GH5B9w3y2lq5HkTeQitGQdKj4uvV43SuxgE/p7BQp+NWWHu kY1lVjKClhrsxKo4a+NY7t+goYupLPXz7tWItxfClsmSIeozGN1AU2sWmawksceKpWXP bj+g== 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=dgJhgHCm+EEUIQ1sce9EF83+QcIAtfgF4ykDEdD/BoE=; b=LK7to5Uy3/bvish+bO+tPiwB5DlWhGOse3/QgGMY2U+6DPjjef9LBgjlYny0IwsPDl 6rB3bwXp/6I0XK9V2MTLqq6WdaeV3iWBE5D1CQDdYvGIIl/Z/mVQs0gQhfdGstV7yEPt +lw1OJpGxN0AEZ9YJU+f/fj2l+MNHGhsv2wiyLBgSxHYicjxHNOX6cRm1h9RUiekdZh0 tpfcDUKK9YFa6TXj1+odtxEsckQkqx+4BW9/pIRCDV/wo5bYt8icBxRI5BthV+w+zchP UdvFuKFFJKh2gv8IcAQgc7yhQ1xpidbrxkV4brrftgJz8MdpXLz3VBrdxLqt9IrBGF6s JPHw== X-Gm-Message-State: AIkVDXIaGTJ1sTAQmfKN4QjZti8zydjjow0ej02NbkI2xADbbK+R+uFeDFwx25xv+zELumRB X-Received: by 10.28.215.200 with SMTP id o191mr22474608wmg.118.1485358474782; Wed, 25 Jan 2017 07:34:34 -0800 (PST) Received: from localhost.localdomain ([90.63.244.31]) by smtp.gmail.com with ESMTPSA id 33sm2462760wrd.34.2017.01.25.07.34.33 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Wed, 25 Jan 2017 07:34:34 -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 6/7] gpio: mockup: implement naming the GPIO lines Date: Wed, 25 Jan 2017 16:34:20 +0100 Message-Id: <1485358461-24070-7-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-gpio-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-gpio@vger.kernel.org Implement a new boolean module argument that indicates that the mockup lines should be named. The names are created by appending the line offset to the chip label. Signed-off-by: Bartosz Golaszewski --- drivers/gpio/gpio-mockup.c | 30 +++++++++++++++++++++++++++++- 1 file changed, 29 insertions(+), 1 deletion(-) -- 2.9.3 -- To unsubscribe from this list: send the line "unsubscribe linux-gpio" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html diff --git a/drivers/gpio/gpio-mockup.c b/drivers/gpio/gpio-mockup.c index c5eb530..dabf3ec 100644 --- a/drivers/gpio/gpio-mockup.c +++ b/drivers/gpio/gpio-mockup.c @@ -17,6 +17,7 @@ #include #include #include +#include #include "gpiolib.h" @@ -48,6 +49,10 @@ static int gpio_mockup_ranges[MAX_GC << 1]; static int gpio_mockup_params_nr; module_param_array(gpio_mockup_ranges, int, &gpio_mockup_params_nr, 0400); +static bool gpio_mockup_named_lines; +module_param_named(gpio_mockup_named_lines, + gpio_mockup_named_lines, bool, 0400); + static const char pins_name_start = 'A'; static struct dentry *dbg_dir; @@ -169,7 +174,8 @@ static int mockup_gpio_add(struct device *dev, struct mockup_gpio_controller *cntr, const char *name, int base, int ngpio) { - int ret; + char **names; + int ret, i; cntr->gc.base = base; cntr->gc.ngpio = ngpio; @@ -188,6 +194,28 @@ static int mockup_gpio_add(struct device *dev, ret = -ENOMEM; goto err; } + + if (gpio_mockup_named_lines) { + names = devm_kzalloc(dev, + sizeof(char *) * cntr->gc.ngpio, + GFP_KERNEL); + if (!names) { + ret = -ENOMEM; + goto err; + } + + for (i = 0; i < cntr->gc.ngpio; i++) { + names[i] = devm_kasprintf(dev, GFP_KERNEL, + "%s-%d", cntr->gc.label, i); + if (!names[i]) { + ret = -ENOMEM; + goto err; + } + } + + cntr->gc.names = (const char *const*)names; + } + ret = devm_gpiochip_add_data(dev, &cntr->gc, cntr); if (ret) goto err;