Received: by 2002:a05:6359:c8b:b0:c7:702f:21d4 with SMTP id go11csp3268620rwb; Mon, 19 Sep 2022 18:29:06 -0700 (PDT) X-Google-Smtp-Source: AMsMyM5D2XgDfkno5kTW6RqHpOva+6ngyMF1d9CYZk9Cm8ZUplnSntzjteRBlb+j/nxBViy+cs25 X-Received: by 2002:a17:90a:c02:b0:1fb:b69d:140f with SMTP id 2-20020a17090a0c0200b001fbb69d140fmr1104271pjs.139.1663637346467; Mon, 19 Sep 2022 18:29:06 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1663637346; cv=none; d=google.com; s=arc-20160816; b=sa55IUdxMbya9ZsAsNEW6+Nwv80E28rHaoDLylZSbq7RhenClBdLKIN32+wkVONFPi dU83rbM8XdpgC/KpydnEnBdY0p+ZFo3nzCDrnJg7RrW39qZnrXUrwviBXU/OH7vVuRyx 1bU7djtdSi4+WvQc97CDSZ5Mx91Bw5JO9FMQPtp2ZYQKSdfXpEkjUtw7REO/8UI6fJNG 3B76UAJPzk3KIb2l2QzTtzjp5/7bNTY04uIg94plLwYiZ90Ix8Lj8g4KnmeRWU4KFgyc 9gt8MxSBGafkh+0VwMDJ17ZTDTrcCSbUSroOPMwzl7QjLva6Dr+Qy5vAQrGL4DF8Ve3z co8A== 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=r/uW69NQ9itf77rsBCnO/w/U8AXWjVudhVoSdDjGHuc=; b=MQ1Tit6gt7re4MwMU1BgLrlWP0BXWrlCg8iRonHw2HnGH2is4Fdl5ETVuyznjo52l1 5rfVcOr7A4i9iVwbg7eovLbdvYSSsl+YP2pQx1+PAfSESZ+qhehOLZyellev6nReI9dM 24DbJCXN79pY1/jZYz56PmTZ0rmXyhzoXNW9jUaFPyTHQvm6sWK6E3oV5xc6pP3KZQMC /dJeFI3BLJNzoKklAcdsCSZOoqpr0ZNoxqvgePDA+U3A1jf6opR553MKDIsU3TkLbIUs mhwBsa7Y6PEy3IbNIUWrBBQ5nUm9Q9Ph4OB7afxb3lVfp7EtWnYXasTa0W3U4uoZ5Mdk OS4g== 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 bc2-20020a170902930200b00176b8c373ddsi114292plb.257.2022.09.19.18.28.55; Mon, 19 Sep 2022 18:29:06 -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 S229473AbiITBJq (ORCPT + 99 others); Mon, 19 Sep 2022 21:09:46 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:43252 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229686AbiITBJn (ORCPT ); Mon, 19 Sep 2022 21:09:43 -0400 Received: from mail-m11873.qiye.163.com (mail-m11873.qiye.163.com [115.236.118.73]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 49C7E9FC4; Mon, 19 Sep 2022 18:09:36 -0700 (PDT) Received: from localhost.localdomain (unknown [58.22.7.114]) by mail-m11873.qiye.163.com (Hmail) with ESMTPA id 057BA900AD1; Tue, 20 Sep 2022 09:09:32 +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] gpiolib: make gpiochip_find_by_name to be common function Date: Tue, 20 Sep 2022 09:09:30 +0800 Message-Id: <20220920010930.822856-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 tZV1koWUFJSktLSjdXWS1ZQUlXWQ8JGhUIEh9ZQVkZTkxNVkoeGBkfTB5LH0kaTFUTARMWGhIXJB QOD1lXWRgSC1lBWU5DVUlJVUxVSkpPWVdZFhoPEhUdFFlBWU9LSFVKSktITUpVSktLVUtZBg++ X-HM-Sender-Digest: e1kMHhlZQR0aFwgeV1kSHx4VD1lBWUc6MS46OCo*DT0jTR5CNghNExIx UShPC01VSlVKTU1ITUhNSkxITUhPVTMWGhIXVREaAlUDDjsJFBgQVhgTEgsIVRgUFkVZV1kSC1lB WU5DVUlJVUxVSkpPWVdZCAFZQUlMTUM3Bg++ X-HM-Tid: 0a83587171812eafkusn057ba900ad1 X-Spam-Status: No, score=-0.4 required=5.0 tests=BAYES_00,RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H2,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 | 12 ------------ include/linux/gpio/driver.h | 12 ++++++++++++ 2 files changed, 12 insertions(+), 12 deletions(-) diff --git a/drivers/gpio/gpiolib.c b/drivers/gpio/gpiolib.c index cc9c0a12259e..60259e76d361 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 /* 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