Received: by 2002:a05:6359:c8b:b0:c7:702f:21d4 with SMTP id go11csp3277139rwb; Mon, 19 Sep 2022 18:40:59 -0700 (PDT) X-Google-Smtp-Source: AMsMyM4aAm5yNmx0M9fR3ZjxsSMY5NFPwC+HbeYNZi8BjMgln4A5Vo32MaK1kBIYVrRSSdtPf9mv X-Received: by 2002:a62:1bc8:0:b0:546:c62e:e84 with SMTP id b191-20020a621bc8000000b00546c62e0e84mr21541979pfb.45.1663638059070; Mon, 19 Sep 2022 18:40:59 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1663638059; cv=none; d=google.com; s=arc-20160816; b=Y5SuG2J6i4JdpDWhCmH89eUGVJBPC+LK9cQYFG9TzncY0wvEO0VeQIaJ3oxWflDo/h rHP3k5qhTNk4/8TSQxVBmU2tGRhluMf5l8jhw2mRV1w/mNFf40zHF5c/YwpD75XfSszE cWT3z6eTQdlH2UehRd8ecibIgPQy5UfpcuMX+ovCQMSHKgzO49nqJut7F3vmwciFaDhr e3YpYM56ZYjZEoch/F/y692j3SdmgRm+kyg54e0EsoMxgqgzSva9oNAVOHcWkxbj1h1b 5N3jVl7jiPdRfnEta80+gcsQhDrW2ndiBt22CyICwQQ9tazVqzpb0GCVIw7xBxv3B5dg +nig== 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; bh=19svAyGZhGyvvWRlCGkONMc7Z5Z9qn9eFuAKFpuqv28=; b=PON32u2A8pdrQk0yYUeLDwtR+aFn0M/qzGXnJ1jTl8ia8AbhZdiEf+oaJNmqSzczud QvknjCB7C/hTcjUqF+av6vIzgXXSGMdUxLXxj3rOng5a4gGrFi8baHc8Ms5V0sOKA+ER oI0uKx/ie1s18h85IJZ5nOMHcTwKsGa8/CqGoEsca2zXQmCkzo945a2aWW5RMYdMcMqp 6qkoUdI8OqEYAJ5YUQVtd7I6wxmphVZJ6r5BiOAdaMrnMMsFqGyXyrnFsiJzKeeHe3tI GHWu73/AHQCbV6c6omD6QDEjV6tIRdJ7cH9ZQVSm9tbR6QimPlrKPAAvg5fRuxrbYcEq 2lsQ== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=rock-chips.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id 4-20020a631344000000b00438e26dd702si137629pgt.468.2022.09.19.18.40.47; Mon, 19 Sep 2022 18:40:58 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=rock-chips.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229806AbiITBRz (ORCPT + 99 others); Mon, 19 Sep 2022 21:17:55 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:56370 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229684AbiITBRw (ORCPT ); Mon, 19 Sep 2022 21:17:52 -0400 Received: from mail-m11879.qiye.163.com (mail-m11879.qiye.163.com [115.236.118.79]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id AF95C422F1; Mon, 19 Sep 2022 18:17:51 -0700 (PDT) Received: from localhost.localdomain (unknown [58.22.7.114]) by mail-m11879.qiye.163.com (Hmail) with ESMTPA id 163F9680383; Tue, 20 Sep 2022 09:17:49 +0800 (CST) From: Jianqun Xu To: linus.walleij@linaro.org, brgl@bgdev.pl Cc: andriy.shevchenko@linux.intel.com, linux-gpio@vger.kernel.or, linux-kernel@vger.kernel.org, linux-gpio@vger.kernel.org, Jianqun Xu Subject: [PATCH RESEND] gpiolib: make gpiochip_find_by_name to be common function Date: Tue, 20 Sep 2022 09:17:47 +0800 Message-Id: <20220920011747.824280-1-jay.xu@rock-chips.com> X-Mailer: git-send-email 2.25.1 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-HM-Spam-Status: e1kfGhgUHx5ZQUpXWQgPGg8OCBgUHx5ZQUlOS1dZFg8aDwILHllBWSg2Ly tZV1koWUFJSktLSjdXWS1ZQUlXWQ8JGhUIEh9ZQVlCHkhIVklKS01DQxlMHk5MQlUTARMWGhIXJB QOD1lXWRgSC1lBWU5DVUlJVUxVSkpPWVdZFhoPEhUdFFlBWU9LSFVKSktITUpVSktLVUtZBg++ X-HM-Sender-Digest: e1kMHhlZQR0aFwgeV1kSHx4VD1lBWUc6Okk6Kzo5Lj0eTR4DDzE2NRgZ AQEaCShVSlVKTU1ITUhNTU1CTU5NVTMWGhIXVREaAlUDDjsJFBgQVhgTEgsIVRgUFkVZV1kSC1lB WU5DVUlJVUxVSkpPWVdZCAFZQUhITEs3Bg++ X-HM-Tid: 0a83587903442eb5kusn163f9680383 X-Spam-Status: No, score=-0.4 required=5.0 tests=BAYES_00,RCVD_IN_DNSWL_NONE, RCVD_IN_SORBS_WEB,SPF_HELO_NONE,SPF_PASS autolearn=no autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Move find_chip_by_name from gpiolib to the gpio/driver.h, also rename to gpiochip_find_by_name, make it to be a common function. Signed-off-by: Jianqun Xu --- drivers/gpio/gpiolib.c | 16 ++-------------- include/linux/gpio/driver.h | 12 ++++++++++++ 2 files changed, 14 insertions(+), 14 deletions(-) diff --git a/drivers/gpio/gpiolib.c b/drivers/gpio/gpiolib.c index cc9c0a12259e..c06334772c47 100644 --- a/drivers/gpio/gpiolib.c +++ b/drivers/gpio/gpiolib.c @@ -935,18 +935,6 @@ struct gpio_chip *gpiochip_find(void *data, } EXPORT_SYMBOL_GPL(gpiochip_find); -static int gpiochip_match_name(struct gpio_chip *gc, void *data) -{ - const char *name = data; - - return !strcmp(gc->label, name); -} - -static struct gpio_chip *find_chip_by_name(const char *name) -{ - return gpiochip_find((void *)name, gpiochip_match_name); -} - #ifdef CONFIG_GPIOLIB_IRQCHIP /* @@ -3660,7 +3648,7 @@ void gpiod_add_hogs(struct gpiod_hog *hogs) * The chip may have been registered earlier, so check if it * exists and, if so, try to hog the line now. */ - gc = find_chip_by_name(hog->chip_label); + gc = gpiochip_find_by_name(hog->chip_label); if (gc) gpiochip_machine_hog(gc, hog); } @@ -3745,7 +3733,7 @@ static struct gpio_desc *gpiod_find(struct device *dev, const char *con_id, return ERR_PTR(-EPROBE_DEFER); } - gc = find_chip_by_name(p->key); + gc = gpiochip_find_by_name(p->key); if (!gc) { /* diff --git a/include/linux/gpio/driver.h b/include/linux/gpio/driver.h index 6aeea1071b1b..4ed26a7d98ff 100644 --- a/include/linux/gpio/driver.h +++ b/include/linux/gpio/driver.h @@ -618,6 +618,18 @@ extern int devm_gpiochip_add_data_with_key(struct device *dev, struct gpio_chip extern struct gpio_chip *gpiochip_find(void *data, int (*match)(struct gpio_chip *gc, void *data)); +static int gpiochip_match_name(struct gpio_chip *gc, void *data) +{ + const char *name = data; + + return !strcmp(gc->label, name); +} + +static inline struct gpio_chip *gpiochip_find_by_name(const char *name) +{ + return gpiochip_find((void *)name, gpiochip_match_name); +} + bool gpiochip_line_is_irq(struct gpio_chip *gc, unsigned int offset); int gpiochip_reqres_irq(struct gpio_chip *gc, unsigned int offset); void gpiochip_relres_irq(struct gpio_chip *gc, unsigned int offset); -- 2.25.1