From patchwork Tue Sep 29 10:09:55 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bartosz Golaszewski X-Patchwork-Id: 285658 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-12.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID, HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_PATCH, MAILING_LIST_MULTI, SIGNED_OFF_BY,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED,USER_AGENT_GIT autolearn=unavailable autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id DEAAFC4727C for ; Tue, 29 Sep 2020 10:11:04 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 733FE208FE for ; Tue, 29 Sep 2020 10:11:04 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=bgdev-pl.20150623.gappssmtp.com header.i=@bgdev-pl.20150623.gappssmtp.com header.b="dYn7ozws" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727787AbgI2KKS (ORCPT ); Tue, 29 Sep 2020 06:10:18 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:52704 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727468AbgI2KKR (ORCPT ); Tue, 29 Sep 2020 06:10:17 -0400 Received: from mail-wr1-x442.google.com (mail-wr1-x442.google.com [IPv6:2a00:1450:4864:20::442]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id CE94EC061755 for ; Tue, 29 Sep 2020 03:10:16 -0700 (PDT) Received: by mail-wr1-x442.google.com with SMTP id g4so4706918wrs.5 for ; Tue, 29 Sep 2020 03:10:16 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bgdev-pl.20150623.gappssmtp.com; s=20150623; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=6Ji8d51UZNthiwaFwQiiDA22tNDSUGquN8QOwnTBLMs=; b=dYn7ozwsu9fg/NjCG2J03XJS8gkymmXk+ZLjMvvFMy5YAsZb7wz4hUSy3iEQiWZQNP RPpxTHq0AyQ5etyPB+k11seysp+LrevA+87AsjBF3FqrCGsmj3s64V0FgPDhy1PKgCYT PTg/9yqwPbDzNxGWjzyaaqR7bGsGdliYQiuT7d2nKEIF6b6LTlgSDShNDZZZtI9Y10OC wrX6We+gzKz3zE5uBusmtL1fvrmkEoYQueI8AqPPHMo81IApcB7Wg2DprCiAJB/jt+eU z3f4tbHfi24RzvVJIJQRJ402fGnxI49OIYXPnDOu7IypL3hhhNnQIwQpo3l23Spad2/T XxAw== 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:mime-version:content-transfer-encoding; bh=6Ji8d51UZNthiwaFwQiiDA22tNDSUGquN8QOwnTBLMs=; b=jKqdV+6f0hLgsYa8OwIYWLCEs+Ky9K3RwS41RcLAEmqR3OB7CXb6sP+8KLihUOuTwi 47H+j7W6Z8gZACA+CPSqzAJ1gr7mZkZ/4JfhU3saR+11FTgEEGIP6hIJUF3o985Vlhp3 Zs809bV5eEJaaBtRJh8jz140DGp6LlUqtdtBM08lq6din9KYABdqkX0g+ywV6fXjb3Pe kKkmeK+wNcNqqzwKkT3oQc7dxdH6jfVs8nLX/uJEUkpmy1tHd7RJnCg8F+r2nKlYTLqC vaJSUApU3h4quBARV4WCPutr7mJmfVyd7ULZD48oFfQVLdjS8l3EgOhnTEiVtctVkiyn 1h9g== X-Gm-Message-State: AOAM532B34NIV6a/S2IHiNeUCPiblMQxLUAnKqx96R3pJnMZoeoK1j4p /pTskJnBSMkBysZAQbIrP9wHPA== X-Google-Smtp-Source: ABdhPJxMbY4zNLxYSqL/hs2GeeOd4gbGIk3Je7AqtBA5FUlPfloGghminqaN+JIdSsNscq6TH9/Wpw== X-Received: by 2002:adf:f34a:: with SMTP id e10mr3315435wrp.91.1601374215541; Tue, 29 Sep 2020 03:10:15 -0700 (PDT) Received: from localhost.localdomain (amontpellier-652-1-68-189.w109-210.abo.wanadoo.fr. [109.210.51.189]) by smtp.gmail.com with ESMTPSA id x19sm3380680wmj.48.2020.09.29.03.10.14 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 29 Sep 2020 03:10:14 -0700 (PDT) From: Bartosz Golaszewski To: Linus Walleij , Jonathan Corbet , Andy Shevchenko , Kent Gibson Cc: linux-gpio@vger.kernel.org, linux-doc@vger.kernel.org, linux-kernel@vger.kernel.org, Bartosz Golaszewski Subject: [PATCH v3 01/10] lib: string_helpers: provide kfree_strarray() Date: Tue, 29 Sep 2020 12:09:55 +0200 Message-Id: <20200929101004.20288-2-brgl@bgdev.pl> X-Mailer: git-send-email 2.26.1 In-Reply-To: <20200929101004.20288-1-brgl@bgdev.pl> References: <20200929101004.20288-1-brgl@bgdev.pl> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-gpio@vger.kernel.org From: Bartosz Golaszewski There's a common pattern of dynamically allocating an array of char pointers and then also dynamically allocating each string in this array. Provide a helper for freeing such a string array with one call. Signed-off-by: Bartosz Golaszewski Reviewed-by: Andy Shevchenko --- include/linux/string_helpers.h | 2 ++ lib/string_helpers.c | 24 ++++++++++++++++++++++++ 2 files changed, 26 insertions(+) diff --git a/include/linux/string_helpers.h b/include/linux/string_helpers.h index 86f150c2a6b6..fa06dcdc481e 100644 --- a/include/linux/string_helpers.h +++ b/include/linux/string_helpers.h @@ -94,4 +94,6 @@ char *kstrdup_quotable(const char *src, gfp_t gfp); char *kstrdup_quotable_cmdline(struct task_struct *task, gfp_t gfp); char *kstrdup_quotable_file(struct file *file, gfp_t gfp); +void kfree_strarray(char **array, size_t n); + #endif diff --git a/lib/string_helpers.c b/lib/string_helpers.c index 963050c0283e..efeee2353613 100644 --- a/lib/string_helpers.c +++ b/lib/string_helpers.c @@ -649,3 +649,27 @@ char *kstrdup_quotable_file(struct file *file, gfp_t gfp) return pathname; } EXPORT_SYMBOL_GPL(kstrdup_quotable_file); + +/** + * kfree_strarray - free a number of dynamically allocated strings contained + * in an array and the array itself + * + * @array: Dynamically allocated array of strings to free. If NULL - the + * function does nothing. + * @n: Number of strings (starting from the beginning of the array) to free. + * + * Passing a non-null @array and @n == 0 as well as NULL @array are valid + * use-cases. + */ +void kfree_strarray(char **array, size_t n) +{ + unsigned int i; + + if (!array) + return; + + for (i = 0; i < n; i++) + kfree(array[i]); + kfree(array); +} +EXPORT_SYMBOL_GPL(kfree_strarray); From patchwork Tue Sep 29 10:09:56 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bartosz Golaszewski X-Patchwork-Id: 254304 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-12.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID, HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_PATCH, MAILING_LIST_MULTI, SIGNED_OFF_BY,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 26C4BC4727F for ; Tue, 29 Sep 2020 10:10:22 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id DE7A3208FE for ; Tue, 29 Sep 2020 10:10:21 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=bgdev-pl.20150623.gappssmtp.com header.i=@bgdev-pl.20150623.gappssmtp.com header.b="Vlwp5g8n" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727995AbgI2KKV (ORCPT ); Tue, 29 Sep 2020 06:10:21 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:52712 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725554AbgI2KKS (ORCPT ); Tue, 29 Sep 2020 06:10:18 -0400 Received: from mail-wr1-x442.google.com (mail-wr1-x442.google.com [IPv6:2a00:1450:4864:20::442]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id D5F73C0613D3 for ; Tue, 29 Sep 2020 03:10:17 -0700 (PDT) Received: by mail-wr1-x442.google.com with SMTP id x14so4663953wrl.12 for ; Tue, 29 Sep 2020 03:10:17 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bgdev-pl.20150623.gappssmtp.com; s=20150623; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=BgQC3n53i35n7GC4c6lOV6W434EKfBGkaRy/2vzORco=; b=Vlwp5g8nq3clh05VTdk4D5/6nGKS3gJzlJ6Qci4WMXVDpaFe8+w3bNqKKyH9PvhJdk r8iaxDY20JE2VFOz6Rbwu5mNGhNb9M70UvPINute+KCs8x8ypMcLpzeATeXYQOq9VzIB lsUTEPPx/2Eq8OjjBMOWCFSjKGWd3rPNiyqMAwPIbR17ZkMobYn7mroG5P5/6kMOanLz +5o1kcZPT5HY55Zr6p4WvjLzaYqZocoapIMFdhc8QYuuwl48MK1Q/+AvCHHImITeUZus +qkHUPLnyA355BMsYiV+BzZxEVNwYpNKSj9Vzgcf6Rqz0E6F+J+PNneZRlBvocb5pEFq cA7w== 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:mime-version:content-transfer-encoding; bh=BgQC3n53i35n7GC4c6lOV6W434EKfBGkaRy/2vzORco=; b=M2a9E1dPQtHlgpZsEV5IWjWmHCyQziMutsXOkGB3U0RW9aFIJlLX3gJe7czRdRMABV wYmbqidhdYpoopHrevr1GFAAPREGPMyyyjhYxPeIPtm+H0OUnI+VnStYSNFdDo/morZR kG11jxL+lIhaidkmIBanT9jQOltfRGPr53tUvSDAgpci/M1PYyOjmVSIGLjiemW6jJ5o iyw1w/V/X/OSbYVsM1MjV3aMRoj0b8gvvUqUH5nNwCH/KotzfZ/gqhnQNiJJ5I982rbM ta06q1cUu+6cDkfETPo9yzQWIMmW0bJCwo5ir46qp+RKW+u4akXDycg4yP6rCupFE5EI b2SA== X-Gm-Message-State: AOAM532xaZFzQt64tXDgmDOCf+ExDavz8dT4Y3jDSLb2KqNUcWCptXZR k0NZVkpFDuO6oEkIXBwyR9qJOw== X-Google-Smtp-Source: ABdhPJyuFk9oLj8oeKx5P1cDeMQ/VsotouQuatcO5DStHJNiJydDu3sx3SxN+GryFbyn4Eb0Q3HxXw== X-Received: by 2002:adf:f106:: with SMTP id r6mr3453748wro.106.1601374216544; Tue, 29 Sep 2020 03:10:16 -0700 (PDT) Received: from localhost.localdomain (amontpellier-652-1-68-189.w109-210.abo.wanadoo.fr. [109.210.51.189]) by smtp.gmail.com with ESMTPSA id x19sm3380680wmj.48.2020.09.29.03.10.15 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 29 Sep 2020 03:10:16 -0700 (PDT) From: Bartosz Golaszewski To: Linus Walleij , Jonathan Corbet , Andy Shevchenko , Kent Gibson Cc: linux-gpio@vger.kernel.org, linux-doc@vger.kernel.org, linux-kernel@vger.kernel.org, Bartosz Golaszewski Subject: [PATCH v3 02/10] Documentation: gpio: add documentation for gpio-mockup Date: Tue, 29 Sep 2020 12:09:56 +0200 Message-Id: <20200929101004.20288-3-brgl@bgdev.pl> X-Mailer: git-send-email 2.26.1 In-Reply-To: <20200929101004.20288-1-brgl@bgdev.pl> References: <20200929101004.20288-1-brgl@bgdev.pl> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-gpio@vger.kernel.org From: Bartosz Golaszewski There's some documentation for gpio-mockup's debugfs interface in the driver's source but it's not much. Add proper documentation for this testing module. Signed-off-by: Bartosz Golaszewski Reviewed-by: Andy Shevchenko --- .../admin-guide/gpio/gpio-mockup.rst | 50 +++++++++++++++++++ 1 file changed, 50 insertions(+) create mode 100644 Documentation/admin-guide/gpio/gpio-mockup.rst diff --git a/Documentation/admin-guide/gpio/gpio-mockup.rst b/Documentation/admin-guide/gpio/gpio-mockup.rst new file mode 100644 index 000000000000..9fa1618b3adc --- /dev/null +++ b/Documentation/admin-guide/gpio/gpio-mockup.rst @@ -0,0 +1,50 @@ +.. SPDX-License-Identifier: GPL-2.0-only + +GPIO Testing Driver +=================== + +The GPIO Testing Driver (gpio-mockup) provides a way to create simulated GPIO +chips for testing purposes. The lines exposed by these chips can be accessed +using the standard GPIO character device interface as well as manipulated +using the dedicated debugfs directory structure. + +Creating simulated chips using module params +-------------------------------------------- + +When loading the gpio-mockup driver a number of parameters can be passed to the +module. + + gpio_mockup_ranges + + This parameter takes an argument in the form of an array of integer + pairs. Each pair defines the base GPIO number (if any) and the number + of lines exposed by the chip. If the base GPIO is -1, the gpiolib + will assign it automatically. + + Example: gpio_mockup_ranges=-1,8,-1,16,405,4 + + The line above creates three chips. The first one will expose 8 lines, + the second 16 and the third 4. The base GPIO for the third chip is set + to 405 while for two first chips it will be assigned automatically. + + gpio_named_lines + + This parameter doesn't take any arguments. It lets the driver know that + GPIO lines exposed by it should be named. + + The name format is: gpio-mockup-X-Y where X is mockup chip's ID + and Y is the line offset. + +Manipulating simulated lines +---------------------------- + +Each mockup chip creates its own subdirectory in /sys/kernel/debug/gpio-mockup/. +The directory is named after the chip's label. A symlink is also created, named +after the chip's name, which points to the label directory. + +Inside each subdirectory, there's a separate attribute for each GPIO line. The +name of the attribute represents the line's offset in the chip. + +Reading from a line attribute returns the current value. Writing to it (0 or 1) +changes the configuration of the simulated pull-up/pull-down resistor +(1 - pull-up, 0 - pull-down). From patchwork Tue Sep 29 10:09:57 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bartosz Golaszewski X-Patchwork-Id: 254300 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-12.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID, HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_PATCH, MAILING_LIST_MULTI, SIGNED_OFF_BY,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED,USER_AGENT_GIT autolearn=unavailable autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 92955C4727C for ; Tue, 29 Sep 2020 10:10:59 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 44ABA216C4 for ; Tue, 29 Sep 2020 10:10:59 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=bgdev-pl.20150623.gappssmtp.com header.i=@bgdev-pl.20150623.gappssmtp.com header.b="QfhLhbUT" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728251AbgI2KK5 (ORCPT ); Tue, 29 Sep 2020 06:10:57 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:52720 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727982AbgI2KKV (ORCPT ); Tue, 29 Sep 2020 06:10:21 -0400 Received: from mail-wm1-x344.google.com (mail-wm1-x344.google.com [IPv6:2a00:1450:4864:20::344]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 224B5C061755 for ; Tue, 29 Sep 2020 03:10:19 -0700 (PDT) Received: by mail-wm1-x344.google.com with SMTP id a9so4189699wmm.2 for ; Tue, 29 Sep 2020 03:10:19 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bgdev-pl.20150623.gappssmtp.com; s=20150623; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=zg75WLPDLUTD/dO6gE79rZ4YNo3MHudSB6Cl7I/Dq3Q=; b=QfhLhbUTjHIj3Y7HomIRD7VAgcGMp0d2n7WMsx6Q22a3oTDfO6dk05l7urMoiHN3j0 V3FfN4skAT9KLDxqtBq6d3dSb32H7Qke+AoW2cytasaKVGrCa65anDtNcHUZqV5EMN7P y77oYrSv2wFtz02+uwletmwVhZG7UXc2XhJ33F3IFhnOuGSWs3MIXRtpDiXz2mwNjPNU RHwugBiCMmn4j6QXz6nGHwmlvE6tsvecoG46385WJqqLdgpHMtFpAT95ynU7KVNAAOjm 7JTyTRZItvug/gEmtziOmFJDPm+niFcPOVsv2UAvTQu7KIHDNmJ9zrLpHkGkbbC5SctR YR3w== 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:mime-version:content-transfer-encoding; bh=zg75WLPDLUTD/dO6gE79rZ4YNo3MHudSB6Cl7I/Dq3Q=; b=dPOJ2FiBg1BOsqFdzOLES+Zz8r8B7GzW3icOd4PevK5rPney8252fjHT9fu6aqEjir HL3lncBjULcu3U1Ba2zmihuDTixsZ7VoYxhGzUix2fkngav/2PtmUXz9pZ7S7pqIPoDN VAQR7+yDIM5ofrJAsvRS2NB29BSHQ/zTGClIb1nIguFA1ej6e46NeymL7QVkqyV8MC+p MavFTyQIhawbi+wbYVsLLZJgDdWvN5wXP7k98W53wSLlzQZ5xDnJJ+28UBeuaqNP7cbv bxYdkCuqjGnTHFQ0oCpQtQlDoHMTcCgQF1jvBQ6QujCDdppLKSvaUcV9+7DCboGnzGpn JNuQ== X-Gm-Message-State: AOAM531l7+jbQIbnARldtvOmzsDzK51XOjZL6k4hnoOeNJDfmdWHwqcL TAy/oIpqi7Hv2hPfnS5lkBGx/A== X-Google-Smtp-Source: ABdhPJzhsHf0g1n07jxfN66y7RG66yrbDXd6Rtj9KiqrOmYuW3ZxG/bURwo9Ua+mGtpFIE5NpFsmkA== X-Received: by 2002:a1c:2cc2:: with SMTP id s185mr3843472wms.77.1601374217688; Tue, 29 Sep 2020 03:10:17 -0700 (PDT) Received: from localhost.localdomain (amontpellier-652-1-68-189.w109-210.abo.wanadoo.fr. [109.210.51.189]) by smtp.gmail.com with ESMTPSA id x19sm3380680wmj.48.2020.09.29.03.10.16 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 29 Sep 2020 03:10:17 -0700 (PDT) From: Bartosz Golaszewski To: Linus Walleij , Jonathan Corbet , Andy Shevchenko , Kent Gibson Cc: linux-gpio@vger.kernel.org, linux-doc@vger.kernel.org, linux-kernel@vger.kernel.org, Bartosz Golaszewski Subject: [PATCH v3 03/10] gpio: mockup: drop unneeded includes Date: Tue, 29 Sep 2020 12:09:57 +0200 Message-Id: <20200929101004.20288-4-brgl@bgdev.pl> X-Mailer: git-send-email 2.26.1 In-Reply-To: <20200929101004.20288-1-brgl@bgdev.pl> References: <20200929101004.20288-1-brgl@bgdev.pl> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-gpio@vger.kernel.org From: Bartosz Golaszewski This module doesn't need gpio/consumer.h - it's a provider. It also doesn't use any symbols from init.h so let's remove both includes. Signed-off-by: Bartosz Golaszewski Reviewed-by: Andy Shevchenko --- drivers/gpio/gpio-mockup.c | 2 -- 1 file changed, 2 deletions(-) diff --git a/drivers/gpio/gpio-mockup.c b/drivers/gpio/gpio-mockup.c index 1652897fdf90..c5092773afd8 100644 --- a/drivers/gpio/gpio-mockup.c +++ b/drivers/gpio/gpio-mockup.c @@ -8,9 +8,7 @@ */ #include -#include #include -#include #include #include #include From patchwork Tue Sep 29 10:09:58 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bartosz Golaszewski X-Patchwork-Id: 285659 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-12.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID, HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_PATCH, MAILING_LIST_MULTI, SIGNED_OFF_BY,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED,USER_AGENT_GIT autolearn=unavailable autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id E8A72C4346E for ; Tue, 29 Sep 2020 10:10:57 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 9AD9820C09 for ; Tue, 29 Sep 2020 10:10:57 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=bgdev-pl.20150623.gappssmtp.com header.i=@bgdev-pl.20150623.gappssmtp.com header.b="B4TDcjbD" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1725779AbgI2KK4 (ORCPT ); Tue, 29 Sep 2020 06:10:56 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:52730 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728054AbgI2KKW (ORCPT ); Tue, 29 Sep 2020 06:10:22 -0400 Received: from mail-wr1-x442.google.com (mail-wr1-x442.google.com [IPv6:2a00:1450:4864:20::442]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 42F1CC0613D3 for ; Tue, 29 Sep 2020 03:10:20 -0700 (PDT) Received: by mail-wr1-x442.google.com with SMTP id g4so4707154wrs.5 for ; Tue, 29 Sep 2020 03:10:20 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bgdev-pl.20150623.gappssmtp.com; s=20150623; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=3rBuEbcYA2LHM9EtzTttUwU6XI5h8fPFHgRL7rmnAS0=; b=B4TDcjbDnwRc0wOOOY4XKP5zejDGwyrEibnQWSD5KUxjuu+fUXiaIUFaVq+2udfjQc SqDWumSaxoC0F25U/b6c7xtVCkbHqBOaB9lvRmhH5h7OrZdiKMI+EP9jEz+uQ9zj+h05 ScfcZGTKfew/MOWfT1n89KJ3MWcSAfNNBPFurdh1eMruQm4xG5lGBVoo98XUm6SGEBBX zTWQweO8LlfUV5QfTIxOnvFFrsMljDs027RRiWUGA7C7oedi7tZpPidc94r3hJs3PPZA 1xDpMulgeWPdphlK/ZzPR4qy3IsHKp24qNfdckY4Zov1ScqSzry9fbuqU0kkJMM7CBRA 9rhQ== 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:mime-version:content-transfer-encoding; bh=3rBuEbcYA2LHM9EtzTttUwU6XI5h8fPFHgRL7rmnAS0=; b=dN85TxcyNL+ZE32Jy4dB0Y4k2KR4Cd7HXxnduzQDhqy/emAERuF7p3bRZAsmteRlix V/vtxFRL0Dkvn35k9UWlkpc3bYSLdKEh9X6SbGWNTQORVERGbWPAjDzgkwJcSKgRLZE+ 1xXpqf7m+ux1JVh3ARhtf6Uy0O7H4THsxdifE10bYnkvKElRE9774rdYdL5po4FSURyh BbO9ICKmJzJ9hLvCgNhraqPXwTTg0cvavpU92Cxu6OiqJ0o66TQDTUPBwceyQL5H2H65 irtCx2yExxZXqVgweiHSwxbcnWblH32w/yyqN0yN8LqBBUHNBvdjCbZmUaayRwLdOM7A 0kjQ== X-Gm-Message-State: AOAM532UXf82gcSB8KXZbhMy4PirlKt08PhFtKV4L19NLAlbfrXOIuyQ cTgn9afqwXiHMTwqhGAT4ZV1Gw== X-Google-Smtp-Source: ABdhPJzG1lzz3E8liFeu2XnZVZrjcbtNNl1WiaXfuepg9mtIdQtiP1yiwEIOvrujpjXpodYLtEZ3DQ== X-Received: by 2002:adf:de11:: with SMTP id b17mr3371840wrm.82.1601374218978; Tue, 29 Sep 2020 03:10:18 -0700 (PDT) Received: from localhost.localdomain (amontpellier-652-1-68-189.w109-210.abo.wanadoo.fr. [109.210.51.189]) by smtp.gmail.com with ESMTPSA id x19sm3380680wmj.48.2020.09.29.03.10.18 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 29 Sep 2020 03:10:18 -0700 (PDT) From: Bartosz Golaszewski To: Linus Walleij , Jonathan Corbet , Andy Shevchenko , Kent Gibson Cc: linux-gpio@vger.kernel.org, linux-doc@vger.kernel.org, linux-kernel@vger.kernel.org, Bartosz Golaszewski Subject: [PATCH v3 04/10] gpio: mockup: use KBUILD_MODNAME Date: Tue, 29 Sep 2020 12:09:58 +0200 Message-Id: <20200929101004.20288-5-brgl@bgdev.pl> X-Mailer: git-send-email 2.26.1 In-Reply-To: <20200929101004.20288-1-brgl@bgdev.pl> References: <20200929101004.20288-1-brgl@bgdev.pl> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-gpio@vger.kernel.org From: Bartosz Golaszewski Drop the definition for the driver name. Let's use KBUILD_MODNAME for the log format and use the "gpio-mockup" value directly in the only place where it's relevant: in the name of the device. Signed-off-by: Bartosz Golaszewski Reviewed-by: Andy Shevchenko --- drivers/gpio/gpio-mockup.c | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/drivers/gpio/gpio-mockup.c b/drivers/gpio/gpio-mockup.c index c5092773afd8..90a1d6c2775f 100644 --- a/drivers/gpio/gpio-mockup.c +++ b/drivers/gpio/gpio-mockup.c @@ -21,7 +21,6 @@ #include "gpiolib.h" -#define GPIO_MOCKUP_NAME "gpio-mockup" #define GPIO_MOCKUP_MAX_GC 10 /* * We're storing two values per chip: the GPIO base and the number @@ -31,7 +30,7 @@ /* Maximum of three properties + the sentinel. */ #define GPIO_MOCKUP_MAX_PROP 4 -#define gpio_mockup_err(...) pr_err(GPIO_MOCKUP_NAME ": " __VA_ARGS__) +#define gpio_mockup_err(...) pr_err(KBUILD_MODNAME ": " __VA_ARGS__) /* * struct gpio_pin_status - structure describing a GPIO status @@ -500,7 +499,7 @@ static int gpio_mockup_probe(struct platform_device *pdev) static struct platform_driver gpio_mockup_driver = { .driver = { - .name = GPIO_MOCKUP_NAME, + .name = "gpio-mockup", }, .probe = gpio_mockup_probe, }; @@ -572,7 +571,7 @@ static int __init gpio_mockup_init(void) properties[prop++] = PROPERTY_ENTRY_BOOL( "named-gpio-lines"); - pdevinfo.name = GPIO_MOCKUP_NAME; + pdevinfo.name = "gpio-mockup"; pdevinfo.id = i; pdevinfo.properties = properties; From patchwork Tue Sep 29 10:09:59 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bartosz Golaszewski X-Patchwork-Id: 285662 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-12.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID, HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_PATCH, MAILING_LIST_MULTI, SIGNED_OFF_BY,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 0AB46C4727C for ; Tue, 29 Sep 2020 10:10:24 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id B487120C09 for ; Tue, 29 Sep 2020 10:10:23 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=bgdev-pl.20150623.gappssmtp.com header.i=@bgdev-pl.20150623.gappssmtp.com header.b="BZuGgwad" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728076AbgI2KKW (ORCPT ); Tue, 29 Sep 2020 06:10:22 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:52722 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728033AbgI2KKW (ORCPT ); Tue, 29 Sep 2020 06:10:22 -0400 Received: from mail-wm1-x343.google.com (mail-wm1-x343.google.com [IPv6:2a00:1450:4864:20::343]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 96A3CC0613D5 for ; Tue, 29 Sep 2020 03:10:21 -0700 (PDT) Received: by mail-wm1-x343.google.com with SMTP id q9so4033259wmj.2 for ; Tue, 29 Sep 2020 03:10:21 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bgdev-pl.20150623.gappssmtp.com; s=20150623; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=9OHLxj5LKThNKX3AdZ96/ghdViR26xgQsL7zhp/+aDs=; b=BZuGgwadXaSNJ0fa1uippIDzhqOLjbeb9FgyTrtyrgpBQjSH45CLsUmQouRsfS97a0 5bOk3SkHJBBxbdRxKsH5VwRmrvK1gP/g2Zg2zTGEMiOpfJtRJQwgy8Xg/BPJ7VciAcDG l7nAKNICuVtEGlU15pZH7CyWvleAYYKrDrPIn5woRBIbO2ZVmZDZhGZ5eeSqhP4SNpO+ rmHqBXFa2EEMJvqoD/LQnN1IW8AjGm5zsyuDhymkvqBCllnMldcwLw8mfP3qGJXVgqkr rsP4lzq89+H6lSqqKe4sZy6XAhjdpqov8JthxwaNlYnFdTVcJIy9KXQR8/M02cwZnBiz tp5Q== 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:mime-version:content-transfer-encoding; bh=9OHLxj5LKThNKX3AdZ96/ghdViR26xgQsL7zhp/+aDs=; b=Ux0zlOLJkQBmcIVUt9cKwONkq6mZc5tt8p50+5RHV+gp8otg6+6r7AcQTot4kfCrC/ 1f2GsEfx8ArRR0vib3N6QPNQ+yuC0r88uIMcR2qJX3UbGLRL43ATgIF23ZU0g/8DSss9 S4014pY/oLtKDYG0s/aWMn8NpzSUXL+MfHuWIXBJg+OlMO7wFXpRnbrE95gMc81N/ypY t6ff9ZGerD5w6RL49RrmdwBc6FqRgABORD1z7Kiq4WSr+V5FRLX4Y5mvKX+hViw0tQh+ OzLb3pjIBXoZZ7TZZ/yevIT7Sj977dhzIw6trWP2Szy/AzRPddBW+4rgyW66vNS7gb5B Wyeg== X-Gm-Message-State: AOAM531BK+y3oHyzGrDvTBwj8t1gxiFJ5bJnc0bWdpfFWsz2j3/rJGxm CvFpRlCum81pukk3Jx+pTLuK3Ot+L+Ef8w== X-Google-Smtp-Source: ABdhPJymFLPEX90CJCwGTe7wRhVPkhnu0ySlwgt8SOAnmBrD5LtGzssgnERRKB+sdkC671d85cGhYQ== X-Received: by 2002:a1c:b388:: with SMTP id c130mr3679478wmf.175.1601374220344; Tue, 29 Sep 2020 03:10:20 -0700 (PDT) Received: from localhost.localdomain (amontpellier-652-1-68-189.w109-210.abo.wanadoo.fr. [109.210.51.189]) by smtp.gmail.com with ESMTPSA id x19sm3380680wmj.48.2020.09.29.03.10.19 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 29 Sep 2020 03:10:19 -0700 (PDT) From: Bartosz Golaszewski To: Linus Walleij , Jonathan Corbet , Andy Shevchenko , Kent Gibson Cc: linux-gpio@vger.kernel.org, linux-doc@vger.kernel.org, linux-kernel@vger.kernel.org, Bartosz Golaszewski Subject: [PATCH v3 05/10] gpio: mockup: use pr_fmt() Date: Tue, 29 Sep 2020 12:09:59 +0200 Message-Id: <20200929101004.20288-6-brgl@bgdev.pl> X-Mailer: git-send-email 2.26.1 In-Reply-To: <20200929101004.20288-1-brgl@bgdev.pl> References: <20200929101004.20288-1-brgl@bgdev.pl> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-gpio@vger.kernel.org From: Bartosz Golaszewski We don't need a custom logging helper. Let's use the standard pr_fmt() macro which allows us to use all pr_*() routines with custom format. Signed-off-by: Bartosz Golaszewski Reviewed-by: Andy Shevchenko --- drivers/gpio/gpio-mockup.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/drivers/gpio/gpio-mockup.c b/drivers/gpio/gpio-mockup.c index 90a1d6c2775f..c2b2f7d5ff34 100644 --- a/drivers/gpio/gpio-mockup.c +++ b/drivers/gpio/gpio-mockup.c @@ -7,6 +7,8 @@ * Copyright (C) 2017 Bartosz Golaszewski */ +#define pr_fmt(fmt) KBUILD_MODNAME ": " fmt + #include #include #include @@ -30,8 +32,6 @@ /* Maximum of three properties + the sentinel. */ #define GPIO_MOCKUP_MAX_PROP 4 -#define gpio_mockup_err(...) pr_err(KBUILD_MODNAME ": " __VA_ARGS__) - /* * struct gpio_pin_status - structure describing a GPIO status * @dir: Configures direction of gpio as "in" or "out" @@ -548,7 +548,7 @@ static int __init gpio_mockup_init(void) err = platform_driver_register(&gpio_mockup_driver); if (err) { - gpio_mockup_err("error registering platform driver\n"); + pr_err("error registering platform driver\n"); debugfs_remove_recursive(gpio_mockup_dbg_dir); return err; } @@ -577,7 +577,7 @@ static int __init gpio_mockup_init(void) pdev = platform_device_register_full(&pdevinfo); if (IS_ERR(pdev)) { - gpio_mockup_err("error registering device"); + pr_err("error registering device"); platform_driver_unregister(&gpio_mockup_driver); gpio_mockup_unregister_pdevs(); debugfs_remove_recursive(gpio_mockup_dbg_dir); From patchwork Tue Sep 29 10:10:00 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bartosz Golaszewski X-Patchwork-Id: 254301 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-12.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID, HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_PATCH, MAILING_LIST_MULTI, SIGNED_OFF_BY,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED,USER_AGENT_GIT autolearn=unavailable autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 6CA5BC4727C for ; Tue, 29 Sep 2020 10:10:49 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 1C38A216C4 for ; Tue, 29 Sep 2020 10:10:49 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=bgdev-pl.20150623.gappssmtp.com header.i=@bgdev-pl.20150623.gappssmtp.com header.b="ge2csPM7" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728112AbgI2KKi (ORCPT ); Tue, 29 Sep 2020 06:10:38 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:52720 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728120AbgI2KKY (ORCPT ); Tue, 29 Sep 2020 06:10:24 -0400 Received: from mail-wr1-x442.google.com (mail-wr1-x442.google.com [IPv6:2a00:1450:4864:20::442]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id BC446C0613D0 for ; Tue, 29 Sep 2020 03:10:22 -0700 (PDT) Received: by mail-wr1-x442.google.com with SMTP id x14so4664214wrl.12 for ; Tue, 29 Sep 2020 03:10:22 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bgdev-pl.20150623.gappssmtp.com; s=20150623; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=1YXp6sKFkcXTnpolw457jZq5A6kI2Z1eojr6/yOZQYQ=; b=ge2csPM7d7wiy+ReKUocCYslodvdh3SSXOALUd8ycsfl0rZtLzeSFE2dUrDD32GwF6 vp8RJ+qdV3WQUrAyI/x8+P+De7X8f0sDguglqoR+aH7v1gLVsrW2NHm2NYXvnYRvZV19 ypwxsKd7wGuCA9B6xwjLYZvogu6KOdeT6jLO9LfgmjwA7NAV4Cqi61c5S06Glmay/dgz nZhvYzjZKvzHlho6c3VE5bSQm6S8j8IdrPmVqpN8bttA0MYKhwcE50qRuY3ui7DwhuZ8 UC3mwppiKSzb19Dr84/F3BTcoc4kg6SyGaZ9sGFVYd0dEYWGdmW/gWyLKn3wSy1Nfb+W n7/A== 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:mime-version:content-transfer-encoding; bh=1YXp6sKFkcXTnpolw457jZq5A6kI2Z1eojr6/yOZQYQ=; b=nPA2vHOs9hHPe/xcrw65vKK5n7Ite91ZjIG6PIWsQe8Lz9B7ER2PikP8blWlrFwzpf I+B5RViXIIX7+pjO0QZB2IpjALcsRy+FSr3We0qUVl52RbU2gvBy7U+RuagXQYTpAoXW mxYe8hAHAOVqXGdpNtq8BzC7esbt72A7C7rh30xbpWX2UMrZRlh2+5gSX1vmTvHTbawd UibOVN/KAWVC+IPVUP2scxZNU4YmdoyR4+bF6NmK+NQRCq6ubYkgm3PGm4qUdZLeZSsN DQMN95K26iAaO7j/FJU5XLgXAC+ONcyHXpRaSdBBBIW3rltL09EcYTrRtMK/dhQoiO+b vPkw== X-Gm-Message-State: AOAM53117Rh9ZtAmJtTt4/Wg7SkjhSe99ExwUcmvW/9iFlmKaosRqeSF DGRYL7j2UVrmJ65kFCiSQtUDHA== X-Google-Smtp-Source: ABdhPJzr+SMqMXUVznjXpDoZixQSjynbGp17eZgZW2xiWb7SeLlO4WpMUbvk0t9wdmsawJSm6npr7A== X-Received: by 2002:adf:f5c7:: with SMTP id k7mr3518386wrp.246.1601374221447; Tue, 29 Sep 2020 03:10:21 -0700 (PDT) Received: from localhost.localdomain (amontpellier-652-1-68-189.w109-210.abo.wanadoo.fr. [109.210.51.189]) by smtp.gmail.com with ESMTPSA id x19sm3380680wmj.48.2020.09.29.03.10.20 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 29 Sep 2020 03:10:20 -0700 (PDT) From: Bartosz Golaszewski To: Linus Walleij , Jonathan Corbet , Andy Shevchenko , Kent Gibson Cc: linux-gpio@vger.kernel.org, linux-doc@vger.kernel.org, linux-kernel@vger.kernel.org, Bartosz Golaszewski Subject: [PATCH v3 06/10] gpio: mockup: remove unneeded return statement Date: Tue, 29 Sep 2020 12:10:00 +0200 Message-Id: <20200929101004.20288-7-brgl@bgdev.pl> X-Mailer: git-send-email 2.26.1 In-Reply-To: <20200929101004.20288-1-brgl@bgdev.pl> References: <20200929101004.20288-1-brgl@bgdev.pl> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-gpio@vger.kernel.org From: Bartosz Golaszewski There's a return; at the end of a void function. This is not needed so remove it. Signed-off-by: Bartosz Golaszewski Reviewed-by: Andy Shevchenko --- drivers/gpio/gpio-mockup.c | 2 -- 1 file changed, 2 deletions(-) diff --git a/drivers/gpio/gpio-mockup.c b/drivers/gpio/gpio-mockup.c index c2b2f7d5ff34..de778b52f355 100644 --- a/drivers/gpio/gpio-mockup.c +++ b/drivers/gpio/gpio-mockup.c @@ -372,8 +372,6 @@ static void gpio_mockup_debugfs_setup(struct device *dev, debugfs_create_file(name, 0200, chip->dbg_dir, priv, &gpio_mockup_debugfs_ops); } - - return; } static int gpio_mockup_name_lines(struct device *dev, From patchwork Tue Sep 29 10:10:01 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bartosz Golaszewski X-Patchwork-Id: 254303 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-12.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID, HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_PATCH, MAILING_LIST_MULTI, SIGNED_OFF_BY,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED,USER_AGENT_GIT autolearn=unavailable autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id A0ED4C4727F for ; Tue, 29 Sep 2020 10:10:37 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 62085216C4 for ; Tue, 29 Sep 2020 10:10:37 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=bgdev-pl.20150623.gappssmtp.com header.i=@bgdev-pl.20150623.gappssmtp.com header.b="2LoGJ8ys" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728165AbgI2KK3 (ORCPT ); Tue, 29 Sep 2020 06:10:29 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:52744 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728129AbgI2KKZ (ORCPT ); Tue, 29 Sep 2020 06:10:25 -0400 Received: from mail-wr1-x443.google.com (mail-wr1-x443.google.com [IPv6:2a00:1450:4864:20::443]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id E5434C0613D3 for ; Tue, 29 Sep 2020 03:10:23 -0700 (PDT) Received: by mail-wr1-x443.google.com with SMTP id c18so4676736wrm.9 for ; Tue, 29 Sep 2020 03:10:23 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bgdev-pl.20150623.gappssmtp.com; s=20150623; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=WG5zf7DvZQOhoUaWAWxCAUvO9e/SXwl5eObguJAORVY=; b=2LoGJ8yszSO9fl3T0PyqgH5dQ/VJ+zpmH4mLhSSOEMQK5TeNrtVPQRzwzwbxBkLW7J HJUWKvpWCJj9zS6PkVb+20w6Q4GjxJeofFRLj9JTpJ+6j4p7Rq+f2rJ3iUuvd2LKevCN 4Wa4fZW3rgK2yChkdxN9KQTiKP6V5TMMXPRlsriVCdf/8QmKVv+TmrOlce/fhyHUw8Ez 2RhHJGWzIQ9l+UL03A1/fgLBP3h/NrXbxlFehKRAXxqjZzxJWNIARUNNX8qPorlSgFRN 3NPNv2oAxGkhBoOsoQJLpDLfYp6tLL3qmvt4dfQqd46c4XNfQImFOj2mps2kgUA5wT8K z4BQ== 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:mime-version:content-transfer-encoding; bh=WG5zf7DvZQOhoUaWAWxCAUvO9e/SXwl5eObguJAORVY=; b=d+vj/lWwPMvqrOiMDw+c4oPwXwTNUEJVvyCa9oqf2rwowNZ47AO765o4dyGGwnOKx+ gXh7cn/qd+1rNRaz7fkSHwwMRbZkxWxgqYbisGEagpMuX6j4jLRuO8n6+5dz6MXRWXVf 8m5zbi+JoDe3KCMk1o/tjIXbZBCYCQ/UtByxH3HJ3yP+U4EqE10o9HV0oT5p5d7XXYKk gQse03h7QrudsgIotml7jtB5cLFbk9w0kJJyo/MdyIcff5j91iemx5qn3OOsvVILIqUY ux8PhSqLMRx+n9q4erf1WvCDub3f5VuMwbgXkBdsu0q9SzdzoVFbOyTJ4BBUn/M5QMUX 2nAw== X-Gm-Message-State: AOAM533l9bMtzuTZUcC0dfw3Bkglcky7GNNLQL2JaT1Hw0UYLxJpjcto u60iG5orf9VNUlPlqb/888ROjsgzbHAxHw== X-Google-Smtp-Source: ABdhPJw8O3X676rw4vniTLN5qe+I8t/BMSRgbYRyw4A3jOc7H2ziiWxoZPkP827QAfX/q+YnEUdbhQ== X-Received: by 2002:a5d:554c:: with SMTP id g12mr3411577wrw.294.1601374222677; Tue, 29 Sep 2020 03:10:22 -0700 (PDT) Received: from localhost.localdomain (amontpellier-652-1-68-189.w109-210.abo.wanadoo.fr. [109.210.51.189]) by smtp.gmail.com with ESMTPSA id x19sm3380680wmj.48.2020.09.29.03.10.21 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 29 Sep 2020 03:10:22 -0700 (PDT) From: Bartosz Golaszewski To: Linus Walleij , Jonathan Corbet , Andy Shevchenko , Kent Gibson Cc: linux-gpio@vger.kernel.org, linux-doc@vger.kernel.org, linux-kernel@vger.kernel.org, Bartosz Golaszewski Subject: [PATCH v3 07/10] gpio: mockup: increase the number of supported device properties Date: Tue, 29 Sep 2020 12:10:01 +0200 Message-Id: <20200929101004.20288-8-brgl@bgdev.pl> X-Mailer: git-send-email 2.26.1 In-Reply-To: <20200929101004.20288-1-brgl@bgdev.pl> References: <20200929101004.20288-1-brgl@bgdev.pl> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-gpio@vger.kernel.org From: Bartosz Golaszewski The driver actually supports 4 properties but we only ever set up up to three. This will change however in upcoming patches so increase the number of really (as in: the number the property array can hold) supported properties to 4. Signed-off-by: Bartosz Golaszewski Reviewed-by: Andy Shevchenko --- drivers/gpio/gpio-mockup.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/drivers/gpio/gpio-mockup.c b/drivers/gpio/gpio-mockup.c index de778b52f355..856ba5da1e8c 100644 --- a/drivers/gpio/gpio-mockup.c +++ b/drivers/gpio/gpio-mockup.c @@ -29,8 +29,8 @@ * of GPIO lines. */ #define GPIO_MOCKUP_MAX_RANGES (GPIO_MOCKUP_MAX_GC * 2) -/* Maximum of three properties + the sentinel. */ -#define GPIO_MOCKUP_MAX_PROP 4 +/* Maximum of four properties + the sentinel. */ +#define GPIO_MOCKUP_MAX_PROP 5 /* * struct gpio_pin_status - structure describing a GPIO status From patchwork Tue Sep 29 10:10:02 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bartosz Golaszewski X-Patchwork-Id: 254302 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-12.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID, HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_PATCH, MAILING_LIST_MULTI, SIGNED_OFF_BY,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED,USER_AGENT_GIT autolearn=unavailable autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id D7C70C4741F for ; Tue, 29 Sep 2020 10:10:38 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 97649216C4 for ; Tue, 29 Sep 2020 10:10:38 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=bgdev-pl.20150623.gappssmtp.com header.i=@bgdev-pl.20150623.gappssmtp.com header.b="JXc/8RJh" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728126AbgI2KKi (ORCPT ); Tue, 29 Sep 2020 06:10:38 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:52756 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728140AbgI2KKZ (ORCPT ); Tue, 29 Sep 2020 06:10:25 -0400 Received: from mail-wr1-x444.google.com (mail-wr1-x444.google.com [IPv6:2a00:1450:4864:20::444]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 76984C0613D7 for ; Tue, 29 Sep 2020 03:10:25 -0700 (PDT) Received: by mail-wr1-x444.google.com with SMTP id w5so4683257wrp.8 for ; Tue, 29 Sep 2020 03:10:25 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bgdev-pl.20150623.gappssmtp.com; s=20150623; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=phntrgnCeepxMe1Wdlpj5QWGZ7tKYeInWBovaO/TaFE=; b=JXc/8RJh1lusF2I0iw3khGo/dO8pv1/TNjPfhH6pcbNwCf7PSCJre5vB3wzDZnAmLo vV84UAqdfInBgDj/6df9pA5/CIqJTu8Tf1/rDQRzCoLqmQIo+6a6d5YX1t0pCtWOVuhd dA7u0nRgDVXky8fVIFOpYVMMtseCeitUFTi7czQb0coJxQGwjMtRNiScQYhyQXycvqJM vdCIsz7vX/qbm/tfLvnbMV7CZGhZyqAnrWri3Ml9EcsOJQTSLpqFzuYOkELDm1Q5m/Qo 7Bw2cPLUBPNuk65xTfu/vp065Bs6UfrY2HzwXGhmSk02sBaqw4ilNR3mzPTCxa9mwNmG TRaQ== 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:mime-version:content-transfer-encoding; bh=phntrgnCeepxMe1Wdlpj5QWGZ7tKYeInWBovaO/TaFE=; b=R53meC7u34pOyOzp10ZoqHfgUEWSjxwXBH9AktWXveTrzNaQ+KNDlVkxA6OCH+j6I3 /XgKvablqacvNiAN43iekngEA4RBxYsiq9hBKl7WyAYuUiMq1abonCjkU0HJmUM11cFt oHv2Wwqs1tr0z6T3beXUesAYs3WmS0KyRwYofYegQfTEwK7Z6Exao8QBbBrCE+ugmEFW 5bIJKVRNSbHtHfvDDiamHZxPlLoA4AFmapfG9gOtROz+EF/cJsBrDOyX9hC0ixv7eRgy 6QYjsyR9v9MmxkL+oGzioy7YgfC6gVi7tGQLeVjstH6cLFtAzOi8nJPLuCqE7XZH90HO Ohag== X-Gm-Message-State: AOAM530NLI0nQg03VeGMwKbcXG6VG3WOkvV1l9td5yT62YPR1dQCD3Fw +r3vllrwljlFWEvizW1bGTazRQ== X-Google-Smtp-Source: ABdhPJz6v4FwPTusQcod2iJJLQ4tN4Upb+tkpwWZmdqvj8rDLeQAl3l7asD47AC95qxevt2mQXydOw== X-Received: by 2002:adf:e58b:: with SMTP id l11mr3609258wrm.210.1601374224157; Tue, 29 Sep 2020 03:10:24 -0700 (PDT) Received: from localhost.localdomain (amontpellier-652-1-68-189.w109-210.abo.wanadoo.fr. [109.210.51.189]) by smtp.gmail.com with ESMTPSA id x19sm3380680wmj.48.2020.09.29.03.10.22 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 29 Sep 2020 03:10:23 -0700 (PDT) From: Bartosz Golaszewski To: Linus Walleij , Jonathan Corbet , Andy Shevchenko , Kent Gibson Cc: linux-gpio@vger.kernel.org, linux-doc@vger.kernel.org, linux-kernel@vger.kernel.org, Bartosz Golaszewski Subject: [PATCH v3 08/10] gpio: mockup: pass the chip label as device property Date: Tue, 29 Sep 2020 12:10:02 +0200 Message-Id: <20200929101004.20288-9-brgl@bgdev.pl> X-Mailer: git-send-email 2.26.1 In-Reply-To: <20200929101004.20288-1-brgl@bgdev.pl> References: <20200929101004.20288-1-brgl@bgdev.pl> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-gpio@vger.kernel.org From: Bartosz Golaszewski While we do check the "chip-name" property in probe(), we never actually use it. Let's pass the chip label to the driver using device properties as we'll want to allow users to define their own once dynamically created chips are supported. The property is renamed to "chip-label" to not cause any confusion with the actual chip name which is of the form: "gpiochipX". If the "chip-label" property is missing, let's do what most devices in drivers/gpio/ do and use dev_name(). Signed-off-by: Bartosz Golaszewski Reviewed-by: Andy Shevchenko --- drivers/gpio/gpio-mockup.c | 17 ++++++++--------- 1 file changed, 8 insertions(+), 9 deletions(-) diff --git a/drivers/gpio/gpio-mockup.c b/drivers/gpio/gpio-mockup.c index 856ba5da1e8c..1466f480aacd 100644 --- a/drivers/gpio/gpio-mockup.c +++ b/drivers/gpio/gpio-mockup.c @@ -429,21 +429,14 @@ static int gpio_mockup_probe(struct platform_device *pdev) if (rv) return rv; - rv = device_property_read_string(dev, "chip-name", &name); + rv = device_property_read_string(dev, "chip-label", &name); if (rv) - name = NULL; + name = dev_name(dev); chip = devm_kzalloc(dev, sizeof(*chip), GFP_KERNEL); if (!chip) return -ENOMEM; - if (!name) { - name = devm_kasprintf(dev, GFP_KERNEL, - "%s-%c", pdev->name, pdev->id + 'A'); - if (!name) - return -ENOMEM; - } - mutex_init(&chip->lock); gc = &chip->gc; @@ -523,6 +516,7 @@ static int __init gpio_mockup_init(void) int i, prop, num_chips, err = 0, base; struct platform_device_info pdevinfo; struct platform_device *pdev; + char chip_label[32]; u16 ngpio; if ((gpio_mockup_num_ranges < 2) || @@ -556,6 +550,11 @@ static int __init gpio_mockup_init(void) memset(&pdevinfo, 0, sizeof(pdevinfo)); prop = 0; + snprintf(chip_label, sizeof(chip_label), + "gpio-mockup-%c", i + 'A'); + properties[prop++] = PROPERTY_ENTRY_STRING("chip-label", + chip_label); + base = gpio_mockup_range_base(i); if (base >= 0) properties[prop++] = PROPERTY_ENTRY_U32("gpio-base", From patchwork Tue Sep 29 10:10:03 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bartosz Golaszewski X-Patchwork-Id: 285660 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-12.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID, HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_PATCH, MAILING_LIST_MULTI, SIGNED_OFF_BY,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 8F020C47423 for ; Tue, 29 Sep 2020 10:10:38 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 3FFBC208FE for ; Tue, 29 Sep 2020 10:10:38 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=bgdev-pl.20150623.gappssmtp.com header.i=@bgdev-pl.20150623.gappssmtp.com header.b="N8jeGR+8" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728070AbgI2KKh (ORCPT ); Tue, 29 Sep 2020 06:10:37 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:52748 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728126AbgI2KK2 (ORCPT ); Tue, 29 Sep 2020 06:10:28 -0400 Received: from mail-wm1-x344.google.com (mail-wm1-x344.google.com [IPv6:2a00:1450:4864:20::344]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id D3567C061755 for ; Tue, 29 Sep 2020 03:10:26 -0700 (PDT) Received: by mail-wm1-x344.google.com with SMTP id a9so4190119wmm.2 for ; Tue, 29 Sep 2020 03:10:26 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bgdev-pl.20150623.gappssmtp.com; s=20150623; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=5qQDilT3y+n2e7orjLtQr7y3ivdCr40o5nxvBAQH2pM=; b=N8jeGR+80RDEID6XklAcnFTzZawT2bhdku5p9RFEQV+di6rgCovEBGHTsfkmNtnShb zBJ7h4bKzOF9trfrVtL8fq3jz0nOoHH8Z4oNU2HLWX+OI5NiJyEg5s46j3syUCRi7ftX WgLQcKaOPX/i4fHvGcQjBiDy2IALZNaGXqFEa6J63OZeQvhiMq+J8aV/K1oEbwnNsrwa fpGvNgXQawbYb50Vus3ssvqWsI6dPY3qjDkWiavvMumRpnLoeCYmqLc+M3iDPyUa2WNF qjchwXN/rKaDue00bFzhfdytYJwKnHluKsL64gZ4Z0Mke+oEirZo/Gt1ZnNI3RnecgDq as+w== 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:mime-version:content-transfer-encoding; bh=5qQDilT3y+n2e7orjLtQr7y3ivdCr40o5nxvBAQH2pM=; b=Mg7iKjh9kC/OVAe201Jnx73SYuzIMT5IGEJFkrLPAvtUufWjcp6GmdXvqM60USfO2a Dzlu0vClteGYu9PCZd7BYUWsU8e4yrGqKdwl6BKSEHTfXh8jARJhFwTc7Cxdliw40VwU lNIDOAltNHx/PagQN5Pjcejwd3M848Q2XwJ8M3q4a/8EJI4479lmmAfYrJ2e7e/LAgyq uraNde+vPjxpCy7E9HcrDQHF44ETRqdbtSAwWR71peW2ewflGfVXNzKR6dNqTXYZ4aU6 /eS6gzEKUqWdrT1OLZAIeX6vF9HKASL8IvK8IY1oc6DZ5jbyK0EEYqg5hmIqi4+KuHxe UJGQ== X-Gm-Message-State: AOAM533S90ziHkmU1GubygMXqzZbOdFRU8B2ST2qy0t4oCRR9d+64n79 bRM7h+4euQQlWZwjGX5SH4U/7w== X-Google-Smtp-Source: ABdhPJwZ+XcVDmhYbQnrVbYHU0N1B+Wj2NfG5DLkgZwDj+bvs2T5stE6pk6Sy9+BGhWryWNkn4sZcg== X-Received: by 2002:a1c:a184:: with SMTP id k126mr3676184wme.39.1601374225482; Tue, 29 Sep 2020 03:10:25 -0700 (PDT) Received: from localhost.localdomain (amontpellier-652-1-68-189.w109-210.abo.wanadoo.fr. [109.210.51.189]) by smtp.gmail.com with ESMTPSA id x19sm3380680wmj.48.2020.09.29.03.10.24 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 29 Sep 2020 03:10:24 -0700 (PDT) From: Bartosz Golaszewski To: Linus Walleij , Jonathan Corbet , Andy Shevchenko , Kent Gibson Cc: linux-gpio@vger.kernel.org, linux-doc@vger.kernel.org, linux-kernel@vger.kernel.org, Bartosz Golaszewski Subject: [PATCH v3 09/10] gpio: mockup: use the generic 'gpio-line-names' property Date: Tue, 29 Sep 2020 12:10:03 +0200 Message-Id: <20200929101004.20288-10-brgl@bgdev.pl> X-Mailer: git-send-email 2.26.1 In-Reply-To: <20200929101004.20288-1-brgl@bgdev.pl> References: <20200929101004.20288-1-brgl@bgdev.pl> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-gpio@vger.kernel.org From: Bartosz Golaszewski GPIO line names are currently created by the driver from the chip label. We'll want to support custom formats for line names (for instance: to name all lines the same) for user-space tests so create them in the module init function and pass them to the driver using the standard 'gpio-line-names' property. Signed-off-by: Bartosz Golaszewski Reviewed-by: Andy Shevchenko --- drivers/gpio/gpio-mockup.c | 70 +++++++++++++++++++++----------------- 1 file changed, 38 insertions(+), 32 deletions(-) diff --git a/drivers/gpio/gpio-mockup.c b/drivers/gpio/gpio-mockup.c index 1466f480aacd..2d865b530fe9 100644 --- a/drivers/gpio/gpio-mockup.c +++ b/drivers/gpio/gpio-mockup.c @@ -19,6 +19,7 @@ #include #include #include +#include #include #include "gpiolib.h" @@ -374,29 +375,6 @@ static void gpio_mockup_debugfs_setup(struct device *dev, } } -static int gpio_mockup_name_lines(struct device *dev, - struct gpio_mockup_chip *chip) -{ - struct gpio_chip *gc = &chip->gc; - char **names; - int i; - - names = devm_kcalloc(dev, gc->ngpio, sizeof(char *), GFP_KERNEL); - if (!names) - return -ENOMEM; - - for (i = 0; i < gc->ngpio; i++) { - names[i] = devm_kasprintf(dev, GFP_KERNEL, - "%s-%d", gc->label, i); - if (!names[i]) - return -ENOMEM; - } - - gc->names = (const char *const *)names; - - return 0; -} - static void gpio_mockup_dispose_mappings(void *data) { struct gpio_mockup_chip *chip = data; @@ -464,12 +442,6 @@ static int gpio_mockup_probe(struct platform_device *pdev) for (i = 0; i < gc->ngpio; i++) chip->lines[i].dir = GPIO_LINE_DIRECTION_IN; - if (device_property_read_bool(dev, "named-gpio-lines")) { - rv = gpio_mockup_name_lines(dev, chip); - if (rv) - return rv; - } - chip->irq_sim_domain = devm_irq_domain_create_sim(dev, NULL, gc->ngpio); if (IS_ERR(chip->irq_sim_domain)) @@ -510,6 +482,27 @@ static void gpio_mockup_unregister_pdevs(void) } } +static __init char **gpio_mockup_make_line_names(const char *label, + unsigned int num_lines) +{ + unsigned int i; + char **names; + + names = kcalloc(num_lines + 1, sizeof(char *), GFP_KERNEL); + if (!names) + return NULL; + + for (i = 0; i < num_lines; i++) { + names[i] = kasprintf(GFP_KERNEL, "%s-%u", label, i); + if (!names[i]) { + kfree_strarray(names, i); + return NULL; + } + } + + return names; +} + static int __init gpio_mockup_init(void) { struct property_entry properties[GPIO_MOCKUP_MAX_PROP]; @@ -517,6 +510,7 @@ static int __init gpio_mockup_init(void) struct platform_device_info pdevinfo; struct platform_device *pdev; char chip_label[32]; + char **line_names; u16 ngpio; if ((gpio_mockup_num_ranges < 2) || @@ -549,6 +543,7 @@ static int __init gpio_mockup_init(void) memset(properties, 0, sizeof(properties)); memset(&pdevinfo, 0, sizeof(pdevinfo)); prop = 0; + line_names = NULL; snprintf(chip_label, sizeof(chip_label), "gpio-mockup-%c", i + 'A'); @@ -564,15 +559,26 @@ static int __init gpio_mockup_init(void) : gpio_mockup_range_ngpio(i) - base; properties[prop++] = PROPERTY_ENTRY_U16("nr-gpios", ngpio); - if (gpio_mockup_named_lines) - properties[prop++] = PROPERTY_ENTRY_BOOL( - "named-gpio-lines"); + if (gpio_mockup_named_lines) { + line_names = gpio_mockup_make_line_names(chip_label, + ngpio); + if (!line_names) { + platform_driver_unregister(&gpio_mockup_driver); + gpio_mockup_unregister_pdevs(); + return -ENOMEM; + } + + properties[prop++] = PROPERTY_ENTRY_STRING_ARRAY_LEN( + "gpio-line-names", + line_names, ngpio); + } pdevinfo.name = "gpio-mockup"; pdevinfo.id = i; pdevinfo.properties = properties; pdev = platform_device_register_full(&pdevinfo); + kfree_strarray(line_names, ngpio); if (IS_ERR(pdev)) { pr_err("error registering device"); platform_driver_unregister(&gpio_mockup_driver); From patchwork Tue Sep 29 10:10:04 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bartosz Golaszewski X-Patchwork-Id: 285661 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-12.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID, HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_PATCH, MAILING_LIST_MULTI, SIGNED_OFF_BY,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 77919C4346E for ; Tue, 29 Sep 2020 10:10:37 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 2AC9020C09 for ; Tue, 29 Sep 2020 10:10:37 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=bgdev-pl.20150623.gappssmtp.com header.i=@bgdev-pl.20150623.gappssmtp.com header.b="Bqytaag0" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726064AbgI2KKg (ORCPT ); Tue, 29 Sep 2020 06:10:36 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:52770 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728129AbgI2KK3 (ORCPT ); Tue, 29 Sep 2020 06:10:29 -0400 Received: from mail-wm1-x343.google.com (mail-wm1-x343.google.com [IPv6:2a00:1450:4864:20::343]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 3FD70C0613D4 for ; Tue, 29 Sep 2020 03:10:28 -0700 (PDT) Received: by mail-wm1-x343.google.com with SMTP id x23so4026218wmi.3 for ; Tue, 29 Sep 2020 03:10:28 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bgdev-pl.20150623.gappssmtp.com; s=20150623; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=5IXYJy1aFbKAfJ2j0jd6nrzx4/J96MOWdHGgnxvVt6s=; b=Bqytaag0rKTC4QQ+qWveXzavNNaEqHxevK8DaMXu1cdj3IcaYIwILRVECn0LlsZlDc bnhyR/r3/XoHuludwRQr28qFAPFKWr0AZEF7QZz9+TtNfGvZqbgZrKdsegz+wQXj4wv5 xmkq4qQYA3gJ8FDNAK8gQx8auHkllj9drpMYNFboiODpmVJSJUIjJ5Jyyf8XxhWf3K/e CmjKXbMUB6mEdq72CITa+YZBDRsqM7ibnLRv80UkzpbbwNp+/puwaEJBuakwp9NlkrYY l0oTkharOXBwsHyFFJF+XhQW0a7JUSu2q9W8iRFs7Lf2jhDCzCkcmCMxvNqJYj7U31R4 E4eQ== 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:mime-version:content-transfer-encoding; bh=5IXYJy1aFbKAfJ2j0jd6nrzx4/J96MOWdHGgnxvVt6s=; b=CKyw1xttEzf1zcySFlgoqYkeKMHKnhGwtWweXHP0BmEaAaGZxo0xX/8awuWXF/BGlc UMoHcY/VpM8KfJsNasla6KhDSO1nfis8uTB3L/xpRP9oO9GIdynbBOe0DtYoTatEs3xL BEud5HdKRc9AVZI6Rqr1HhEUNVqe3unjX9Ft3MZr+yb7zip6RkT7s8qb9aoqCwdLt8LH hazz3KwdauhWxt8ncyRwqN0ZYikR7nAvsgBz51kXd9srRNn1LJBmvvdytM/08U8LzjlR uZqsTvdm/+SJVIVMYGc15IZqPtksC4UBnPk1D7XahDmCrlU5maj/fXdyluLRB7kIwL60 YFPA== X-Gm-Message-State: AOAM533dLzySovdH3sa+AfsJwrT7B2tfiLRtWae320B6qTtigCUCj888 UZvoYfYz9rbgkwu29qxm3JIUKA== X-Google-Smtp-Source: ABdhPJx/gvhzd/FKB6LjGn/+S/FIU5fpZIb48PI+CI+pS5wtR75htsMkj9kuqlUircqtHdieIIOSPQ== X-Received: by 2002:a7b:c111:: with SMTP id w17mr3533161wmi.109.1601374226929; Tue, 29 Sep 2020 03:10:26 -0700 (PDT) Received: from localhost.localdomain (amontpellier-652-1-68-189.w109-210.abo.wanadoo.fr. [109.210.51.189]) by smtp.gmail.com with ESMTPSA id x19sm3380680wmj.48.2020.09.29.03.10.25 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 29 Sep 2020 03:10:26 -0700 (PDT) From: Bartosz Golaszewski To: Linus Walleij , Jonathan Corbet , Andy Shevchenko , Kent Gibson Cc: linux-gpio@vger.kernel.org, linux-doc@vger.kernel.org, linux-kernel@vger.kernel.org, Bartosz Golaszewski Subject: [PATCH v3 10/10] gpio: mockup: refactor the module init function Date: Tue, 29 Sep 2020 12:10:04 +0200 Message-Id: <20200929101004.20288-11-brgl@bgdev.pl> X-Mailer: git-send-email 2.26.1 In-Reply-To: <20200929101004.20288-1-brgl@bgdev.pl> References: <20200929101004.20288-1-brgl@bgdev.pl> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-gpio@vger.kernel.org From: Bartosz Golaszewski Let's move the code preparing the device properties into a separate routine. This has the advantage of simplifying the error handling and makes the indentation less deep. Signed-off-by: Bartosz Golaszewski Reviewed-by: Andy Shevchenko --- drivers/gpio/gpio-mockup.c | 96 +++++++++++++++++++------------------- 1 file changed, 49 insertions(+), 47 deletions(-) diff --git a/drivers/gpio/gpio-mockup.c b/drivers/gpio/gpio-mockup.c index 2d865b530fe9..67ed4f238d43 100644 --- a/drivers/gpio/gpio-mockup.c +++ b/drivers/gpio/gpio-mockup.c @@ -503,16 +503,59 @@ static __init char **gpio_mockup_make_line_names(const char *label, return names; } -static int __init gpio_mockup_init(void) +static int __init gpio_mockup_register_chip(int idx) { struct property_entry properties[GPIO_MOCKUP_MAX_PROP]; - int i, prop, num_chips, err = 0, base; struct platform_device_info pdevinfo; struct platform_device *pdev; + char **line_names = NULL; char chip_label[32]; - char **line_names; + int prop = 0, base; u16 ngpio; + memset(properties, 0, sizeof(properties)); + memset(&pdevinfo, 0, sizeof(pdevinfo)); + + snprintf(chip_label, sizeof(chip_label), "gpio-mockup-%c", idx + 'A'); + properties[prop++] = PROPERTY_ENTRY_STRING("chip-label", chip_label); + + base = gpio_mockup_range_base(idx); + if (base >= 0) + properties[prop++] = PROPERTY_ENTRY_U32("gpio-base", base); + + ngpio = base < 0 ? gpio_mockup_range_ngpio(idx) + : gpio_mockup_range_ngpio(idx) - base; + properties[prop++] = PROPERTY_ENTRY_U16("nr-gpios", ngpio); + + if (gpio_mockup_named_lines) { + line_names = gpio_mockup_make_line_names(chip_label, ngpio); + if (!line_names) + return -ENOMEM; + + properties[prop++] = PROPERTY_ENTRY_STRING_ARRAY_LEN( + "gpio-line-names", line_names, ngpio); + } + + pdevinfo.name = "gpio-mockup"; + pdevinfo.id = idx; + pdevinfo.properties = properties; + + pdev = platform_device_register_full(&pdevinfo); + kfree_strarray(line_names, ngpio); + if (IS_ERR(pdev)) { + pr_err("error registering device"); + return PTR_ERR(pdev); + } + + gpio_mockup_pdevs[idx] = pdev; + + return 0; +} + +static int __init gpio_mockup_init(void) +{ + int i, num_chips, err; + if ((gpio_mockup_num_ranges < 2) || (gpio_mockup_num_ranges % 2) || (gpio_mockup_num_ranges > GPIO_MOCKUP_MAX_RANGES)) @@ -540,54 +583,13 @@ static int __init gpio_mockup_init(void) } for (i = 0; i < num_chips; i++) { - memset(properties, 0, sizeof(properties)); - memset(&pdevinfo, 0, sizeof(pdevinfo)); - prop = 0; - line_names = NULL; - - snprintf(chip_label, sizeof(chip_label), - "gpio-mockup-%c", i + 'A'); - properties[prop++] = PROPERTY_ENTRY_STRING("chip-label", - chip_label); - - base = gpio_mockup_range_base(i); - if (base >= 0) - properties[prop++] = PROPERTY_ENTRY_U32("gpio-base", - base); - - ngpio = base < 0 ? gpio_mockup_range_ngpio(i) - : gpio_mockup_range_ngpio(i) - base; - properties[prop++] = PROPERTY_ENTRY_U16("nr-gpios", ngpio); - - if (gpio_mockup_named_lines) { - line_names = gpio_mockup_make_line_names(chip_label, - ngpio); - if (!line_names) { - platform_driver_unregister(&gpio_mockup_driver); - gpio_mockup_unregister_pdevs(); - return -ENOMEM; - } - - properties[prop++] = PROPERTY_ENTRY_STRING_ARRAY_LEN( - "gpio-line-names", - line_names, ngpio); - } - - pdevinfo.name = "gpio-mockup"; - pdevinfo.id = i; - pdevinfo.properties = properties; - - pdev = platform_device_register_full(&pdevinfo); - kfree_strarray(line_names, ngpio); - if (IS_ERR(pdev)) { - pr_err("error registering device"); + err = gpio_mockup_register_chip(i); + if (err) { platform_driver_unregister(&gpio_mockup_driver); gpio_mockup_unregister_pdevs(); debugfs_remove_recursive(gpio_mockup_dbg_dir); - return PTR_ERR(pdev); + return err; } - - gpio_mockup_pdevs[i] = pdev; } return 0;