From patchwork Tue Jul 25 20:58:00 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dmitry Torokhov X-Patchwork-Id: 793626 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=none (mailfrom) smtp.mailfrom=vger.kernel.org (client-ip=209.132.180.67; helo=vger.kernel.org; envelope-from=linux-gpio-owner@vger.kernel.org; receiver=) Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.b="b8RtrTPr"; dkim-atps=neutral Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by ozlabs.org (Postfix) with ESMTP id 3xH9fv1m1Hz9sMN for ; Wed, 26 Jul 2017 07:02:31 +1000 (AEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752664AbdGYU6G (ORCPT ); Tue, 25 Jul 2017 16:58:06 -0400 Received: from mail-pf0-f196.google.com ([209.85.192.196]:35483 "EHLO mail-pf0-f196.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752453AbdGYU6D (ORCPT ); Tue, 25 Jul 2017 16:58:03 -0400 Received: by mail-pf0-f196.google.com with SMTP id q85so13700108pfq.2; Tue, 25 Jul 2017 13:58:03 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=date:from:to:cc:subject:message-id:mime-version:content-disposition :user-agent; bh=OiEhFNl8Ebjz2GrWJDAdhS69gxNHHRJu4ReIS+88odA=; b=b8RtrTPr0PwsNPz7deev1t0D7bDyVHNWiAx/0zmsBUrTeO0w5/LL9m0Fe1vCkyZHUH itglMU/YhNsDP2aMt7mHUMrK35kWS/s1bP9enq+UJkydUc5wVa+WDzwDukgXVzMRmPBK 3dolbq3yJFTLU/ZKgGkmd9qSrmQ3eJlSrSj+FiyIc5XTGDP4GaUgd+6xHRACPmdNOMv+ OFFncbJDk5UmgDE8paelliVJToEZZkB1IwxnGSzCrZ9Gs/CB/nV6+4j3AQXUskikzn/t uNEaI+HbVkoffnxDIBV7uHWP26ReC8ftVjrqa+p4Zj4y9dGCG/JYiQ7iXvtmbrWV9mYF dbmg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:mime-version :content-disposition:user-agent; bh=OiEhFNl8Ebjz2GrWJDAdhS69gxNHHRJu4ReIS+88odA=; b=bD1Yoer8s5ZqAPNtvr6PDz4G/F0D5oV7vRmdidOHKGY7iGqgsuqkncv6GhoS6aX7yZ z18VVV1d416ztBmBOmpdnmsdT81j2I/tGA/l1k4NVOXoOLqxKM+aEeghbrcUis32sohi mJVYRLkLpmwQTwytJ+v3ANhfLS5JNI9tklSZnVmLxQLlrEnwpQQBHQpKQH7QOz/VWI9F L/yvv49v7U1gNeClfBH9LFNZt+9omeRB6oVufvXH6gOOqeHLNWR3qiMs+EGFieoPdFST FYVDmrAYHYT8690f3JDNoIRN+kVC/1cAtSVb/QX8U/ESDcfKw8MWe7mZ4ryNEmUkna8G W7zg== X-Gm-Message-State: AIVw113qMPduVIzGyRzqPMe6EZAypHffTrDCCA1oKKcNi7pLUV1o402s LHOggSgNUvdveQ== X-Received: by 10.101.76.76 with SMTP id l12mr13343109pgr.161.1501016283082; Tue, 25 Jul 2017 13:58:03 -0700 (PDT) Received: from dtor-ws ([2620:0:1000:1611:8879:a194:3c4c:cf3]) by smtp.gmail.com with ESMTPSA id b185sm9712167pfa.65.2017.07.25.13.58.02 (version=TLS1_2 cipher=AES128-SHA bits=128/128); Tue, 25 Jul 2017 13:58:02 -0700 (PDT) Date: Tue, 25 Jul 2017 13:58:00 -0700 From: Dmitry Torokhov To: Linus Walleij Cc: Lars-Peter Clausen , Mika Westerberg , Andy Shevchenko , linux-gpio@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH] gpio: add gpio_add_lookup_tables() to add several tables at once Message-ID: <20170725205800.GA25245@dtor-ws> MIME-Version: 1.0 Content-Disposition: inline User-Agent: Mutt/1.5.21 (2010-09-15) Sender: linux-gpio-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-gpio@vger.kernel.org When converting legacy board to use gpiod API() there migt be several lookup tables in board file, let's provide a way to register them all at once. Signed-off-by: Dmitry Torokhov Reviewed-by: Mika Westerberg --- drivers/gpio/gpiolib.c | 18 ++++++++++++++++++ include/linux/gpio/machine.h | 2 ++ 2 files changed, 20 insertions(+) diff --git a/drivers/gpio/gpiolib.c b/drivers/gpio/gpiolib.c index a42a1eea5714..f8f4f8b61db8 100644 --- a/drivers/gpio/gpiolib.c +++ b/drivers/gpio/gpiolib.c @@ -3010,6 +3010,24 @@ void gpiod_add_lookup_table(struct gpiod_lookup_table *table) mutex_unlock(&gpio_lookup_lock); } +/** + * gpiod_add_lookup_tables() - register GPIO device consumers + * @tables: list of table of consumers to register + * @n: number of tables in the list + */ +void gpiod_add_lookup_tables(struct gpiod_lookup_table **tables, + unsigned int n) +{ + unsigned int i; + + mutex_lock(&gpio_lookup_lock); + + for (i = 0; i < n; i++) + list_add_tail(&tables[i]->list, &gpio_lookup_list); + + mutex_unlock(&gpio_lookup_lock); +} + /** * gpiod_remove_lookup_table() - unregister GPIO device consumers * @table: table of consumers to unregister diff --git a/include/linux/gpio/machine.h b/include/linux/gpio/machine.h index f738d50cc17d..6f7ddce88fb8 100644 --- a/include/linux/gpio/machine.h +++ b/include/linux/gpio/machine.h @@ -58,6 +58,8 @@ struct gpiod_lookup_table { #ifdef CONFIG_GPIOLIB void gpiod_add_lookup_table(struct gpiod_lookup_table *table); +void gpiod_add_lookup_tables(struct gpiod_lookup_table **tables, + unsigned int n); void gpiod_remove_lookup_table(struct gpiod_lookup_table *table); #else static inline