Received: by 2002:a05:6a10:9e8c:0:0:0:0 with SMTP id y12csp271073pxx; Thu, 29 Oct 2020 02:07:03 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyvwPDATX8vgr0VbpS3TbLNTNGH6Lrq+0URFUyRVLXTyiaTQifYGGaRpGh6HMwxsqdSwNxF X-Received: by 2002:aa7:c2d7:: with SMTP id m23mr542920edp.230.1603962423550; Thu, 29 Oct 2020 02:07:03 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1603962423; cv=none; d=google.com; s=arc-20160816; b=utFTH4a0fKKMtkMDtJ2duHWh4NlUizlgDent7yzsr7lS7WJF/6rXS5knX5OHEBy1A3 +n9bGAeXtAyrKeXwR6K8hFH4K2WQvk+2GYoXdeT+kPZL99pcqkxGFyhKwT0gSQr1dexA w+oXRy9+jWVjQWsZiKJ9C27mwMTGIWtbH2cQ2qq7pay8Iqp9qVtE7GAH8NfNojhRXBlF cqRtNTpli0NkouHrrfTT+DpHjCwNRsHovSksMSW0F7Zl0Ad7J9GRQ+SZWlj8AScIwwrz 0gIqF+r1jzmFprPdDpqAd/NoP8dXNM7yWCgJIN2fvBu2d6XUwYgqwioKlWHIT6zjefKZ 7JRA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :message-id:date:subject:cc:to:from:ironport-sdr:dkim-signature; bh=ZzrBKQ+s9dk85lZZfiJG0UtohbsCcBMHvXllHKW91mw=; b=iL2yoVAlWIUUnU8Mo4rWfueE34JlptfABnYQjnknluq3ODgEzTc6qYw/2jRyAiOefA aNzugFP6R7HDygFPUnHgTHFagIQBebK9g6OBdQOP3ZCCXvxYsUPkusAI7CcFjCYsLC+2 zLFmsKKyxTSGPhMShI9WfFstISBVDN0QpzyvkmIFNSBkq/oMEcjLyco9+blV5wBaFMme lmcDjn2RiYiU4CG1nAfi4McfgssHLEYVY/wb2RoOGhLpcXXSEH5/Sbe+yvA24x6/jaeR sYnUiqvTGvDfXV5aasFIT9IREj8B9Vp+zYOu/jFOFottF5kfOl/EFog62eDT7Afq5stq w5+Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass (test mode) header.i=@axis.com header.s=axis-central1 header.b=EV2mBWtK; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=axis.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id e7si1475280edu.247.2020.10.29.02.06.41; Thu, 29 Oct 2020 02:07:03 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass (test mode) header.i=@axis.com header.s=axis-central1 header.b=EV2mBWtK; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=axis.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729341AbgJ2IRk (ORCPT + 99 others); Thu, 29 Oct 2020 04:17:40 -0400 Received: from smtp2.axis.com ([195.60.68.18]:11815 "EHLO smtp2.axis.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726231AbgJ2IRb (ORCPT ); Thu, 29 Oct 2020 04:17:31 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=axis.com; l=3148; q=dns/txt; s=axis-central1; t=1603959450; x=1635495450; h=from:to:cc:subject:date:message-id:mime-version: content-transfer-encoding; bh=ZzrBKQ+s9dk85lZZfiJG0UtohbsCcBMHvXllHKW91mw=; b=EV2mBWtKGeNDKZjkkpjEiqyd9f/U6ahEiOZRwo2Hjzlz+CjVjO0iWMEE n42U0GYiAs4XguhUR3vwKfQ9y2wt/IWy7rvAnp/Eq7ZyiR7iDqTcVNF7n RbOn6xCl4TP18d8czdMe8xVfO7KyEIIvvjwxuGaj2b+vLX1S7oCwkoGol AeTQ4441GEpa5T4mhMSFdGb6RE1csZhVQo3Z66qe64EmEroSPvXTqVawi 4VMZJFbrBONkqMh2BiDxNnMIdScOEJWiedH2AqDs1d4RnBBYGmAx/o4Xk /rzm5o/JP4RijyHg5NuAmJSAYH4wQYxaNwa1xZbR1qeMHjtxQb3Txi9HX Q==; IronPort-SDR: k/BMqfxgNlRV9WmHIiQcDyvvKgrh4iESeehFl82DmRXwOq7zRPLaqqlPIyLd0/yyf8kF9SfJwr 6IIeHaj9TbqJ+/BPrxCaZaFh7hO7KELxmpPg+ZDk0cYMu/42AVQlPH/57OmGds2oMFd341mw+o koWF31u9kNUwVZbyJ10T7HkZ3q6GDPlPX6k6nLD/1CZb4fCTuuz9OMQbDiIdCbOyZ1lqQhwKER isZBQykQYJnD2jzeJs0WoOkvzlsWkCDkHOU2ARrb7kqsQeMxrel9xep4UL1zEA94RkVqIeA7vV BXw= X-IronPort-AV: E=Sophos;i="5.77,429,1596492000"; d="scan'208";a="14031930" From: Vincent Whitchurch To: Bamvor Jian Zhang , Linus Walleij , Bartosz Golaszewski CC: , , , Vincent Whitchurch , , Subject: [PATCH v4] gpio: mockup: Allow probing from device tree Date: Thu, 29 Oct 2020 09:17:20 +0100 Message-ID: <20201029081721.9593-1-vincent.whitchurch@axis.com> X-Mailer: git-send-email 2.28.0 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Content-Type: text/plain Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Allow the mockup driver to be probed via the device tree without any module parameters, allowing it to be used to configure and test higher level drivers like the leds-gpio driver and corresponding userspace before actual hardware is available. Signed-off-by: Vincent Whitchurch --- Notes: v4: - Remove of_match_ptr() to fix unused variable warning with W=1 - Include linux/mod_devicetable.h instead of linux/of.h v3: - Keep includes sorted alphabetically - Drop CONFIG_OF ifdefs v2: - Remove most of the added code, since the latest driver doesn't need it. - Drop DT binding document, since Rob Herring was OK with not documenting this: https://lore.kernel.org/linux-devicetree/5baa1ae6.1c69fb81.847f2.3ab1@mx.google.com/ Range-diff against v3: 1: 1e9b8f36676d ! 1: 4e8fdcfe1a47 gpio: mockup: Allow probing from device tree @@ Commit message ## Notes ## + v4: + - Remove of_match_ptr() to fix unused variable warning with W=1 + - Include linux/mod_devicetable.h instead of linux/of.h + v3: - Keep includes sorted alphabetically - Drop CONFIG_OF ifdefs @@ Notes ## drivers/gpio/gpio-mockup.c ## @@ + #include #include #include ++#include #include -+#include #include #include - #include @@ drivers/gpio/gpio-mockup.c: static int gpio_mockup_probe(struct platform_device *pdev) return 0; } @@ drivers/gpio/gpio-mockup.c: static int gpio_mockup_probe(struct platform_device static struct platform_driver gpio_mockup_driver = { .driver = { .name = "gpio-mockup", -+ .of_match_table = of_match_ptr(gpio_mockup_of_match), ++ .of_match_table = gpio_mockup_of_match, }, .probe = gpio_mockup_probe, }; drivers/gpio/gpio-mockup.c | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/drivers/gpio/gpio-mockup.c b/drivers/gpio/gpio-mockup.c index 67ed4f238d43..28b757d34046 100644 --- a/drivers/gpio/gpio-mockup.c +++ b/drivers/gpio/gpio-mockup.c @@ -15,6 +15,7 @@ #include #include #include +#include #include #include #include @@ -460,9 +461,16 @@ static int gpio_mockup_probe(struct platform_device *pdev) return 0; } +static const struct of_device_id gpio_mockup_of_match[] = { + { .compatible = "gpio-mockup", }, + {}, +}; +MODULE_DEVICE_TABLE(of, gpio_mockup_of_match); + static struct platform_driver gpio_mockup_driver = { .driver = { .name = "gpio-mockup", + .of_match_table = gpio_mockup_of_match, }, .probe = gpio_mockup_probe, }; @@ -556,8 +564,7 @@ static int __init gpio_mockup_init(void) { int i, num_chips, err; - if ((gpio_mockup_num_ranges < 2) || - (gpio_mockup_num_ranges % 2) || + if ((gpio_mockup_num_ranges % 2) || (gpio_mockup_num_ranges > GPIO_MOCKUP_MAX_RANGES)) return -EINVAL; -- 2.28.0