From patchwork Wed Oct 11 20:26:35 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andy Shevchenko X-Patchwork-Id: 151544 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:612c:2908:b0:403:3b70:6f57 with SMTP id ib8csp795099vqb; Wed, 11 Oct 2023 13:27:01 -0700 (PDT) X-Google-Smtp-Source: AGHT+IGdT6TQ+TgSWzaW1YFeZFzWvqTZyO6lFl8A10V2f1ipx/PoOmjnufrMssLsyGk2AAcUxp0Z X-Received: by 2002:a92:db4f:0:b0:350:f353:4017 with SMTP id w15-20020a92db4f000000b00350f3534017mr20624604ilq.0.1697056021209; Wed, 11 Oct 2023 13:27:01 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1697056021; cv=none; d=google.com; s=arc-20160816; b=aiV6IcaFCUCtsP1eVTlMExWBradJnt+2lXHLebxt+dHiYAeklI6Ck+vBCbH0dZ498F Fucxpt3LGawn3BD0oWQXOVXdn12UD5BVxMn7OJtEzzHGRcGXcSjSfgibYzNZrztIjC1d 95m5/0AFo+0rshn5WY2GPlg0m1vzxiDE46I3ctMcTwoFuYh0mMDcqTyGf0q/wI1GHIEN N5PG0lcKMaNisdRG0236nmn7lF+6Ne6RNhCNPYul7U3TR2nTMvQdi6F3HpFHKM9t7s6p p8xqCmNQezc/bdC7W0N++2+FECyM8t+D43NcFe4ujp/Hql99coUkAWCY4wDsVKpXW18s 5pAw== 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 :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=Cvw4NaV3i3IRRXXk2LeoD0QbBDG/0Zxh7dNXZwTsBC8=; fh=RAF7KyPAfJnoj7VNMZqcV/N9L3IgTT6Eds+WXuPmNQA=; b=WHAGOXNYKP5APzcctOJGSyXdYIMbTgAhkqYLTWi/CgNRsnmxB1k4VDW3w08tW/7tDS 0rdlny+W8h1GBi6LsbYuRLKJI5N0smgAT1onxr5zjbIoz5NJJ+VkJLfEKRbat0mvgsyX YfcxrlViJJBUsm6avisMJMOvy+EsmC86LYw7CoOAZGELSC8PIImHDq9/poZiyQ2l8Ab3 F84SvDzJIwm1SMctk1fViw4ZFWMdkZ5/qCwhPeh8wB1bNBoXEGfNMsC95HcU6Q30zlY8 JBDfwvIsAHlzI7BmeESrxongdw9oeAKKx54CJZtd9kUIYSGOm1AUFfek0/ZXEyvzIOin LfxA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=Qe1ut4p6; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:7 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: from snail.vger.email (snail.vger.email. [2620:137:e000::3:7]) by mx.google.com with ESMTPS id x32-20020a634a20000000b00578a26aee75si553026pga.295.2023.10.11.13.27.00 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 11 Oct 2023 13:27:01 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:7 as permitted sender) client-ip=2620:137:e000::3:7; Authentication-Results: mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=Qe1ut4p6; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:7 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by snail.vger.email (Postfix) with ESMTP id 940F08025B63; Wed, 11 Oct 2023 13:27:00 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at snail.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1376434AbjJKU04 (ORCPT + 18 others); Wed, 11 Oct 2023 16:26:56 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:54972 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1376386AbjJKU0u (ORCPT ); Wed, 11 Oct 2023 16:26:50 -0400 Received: from mgamail.intel.com (mgamail.intel.com [192.55.52.43]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 6F18293; Wed, 11 Oct 2023 13:26:49 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1697056009; x=1728592009; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=bRyQlSHpeOLdYLvwN2SQBQmioztVBGvZYUmThNk322Y=; b=Qe1ut4p615zXxS5m9Y2RkWTU9HIeiLG6pQBt4cKi8/hAunDHyCr6XkF+ aWHlflxAOG48R4FhFVjPnRqIC+nxVvwfMudJm4BFo02wZXomg8btxNQxB vdKofhx1tK1pDkoabkA/XkuRi0x4tntCl6EvZacijLVGasnJvW/1T8pcp i4pW85tauzMHCvVyOaXAcl14ZfA3FzYJnGU8n/dBHNGoU6FjhEugcEf3H TMnZcPq5mV4fZvhr+WClvE2XaJx33aKcZZwbX0cowAbpOMGkMFsPCSsj4 +V4Z7kH/2TVpdlCCpa5YXBWNmtKVrqP4tjdtCVt97ykKluhTAhxLxWU24 Q==; X-IronPort-AV: E=McAfee;i="6600,9927,10860"; a="471015140" X-IronPort-AV: E=Sophos;i="6.03,217,1694761200"; d="scan'208";a="471015140" Received: from orsmga008.jf.intel.com ([10.7.209.65]) by fmsmga105.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 11 Oct 2023 13:26:48 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,10860"; a="783393504" X-IronPort-AV: E=Sophos;i="6.03,217,1694761200"; d="scan'208";a="783393504" Received: from black.fi.intel.com ([10.237.72.28]) by orsmga008.jf.intel.com with ESMTP; 11 Oct 2023 13:26:43 -0700 Received: by black.fi.intel.com (Postfix, from userid 1003) id 0BA25345; Wed, 11 Oct 2023 23:26:41 +0300 (EEST) From: Andy Shevchenko To: Bartosz Golaszewski , Andy Shevchenko , Linus Walleij , Dipen Patel , linux-gpio@vger.kernel.org, linux-kernel@vger.kernel.org, timestamp@lists.linux.dev, linux-tegra@vger.kernel.org Cc: Bartosz Golaszewski , Andy Shevchenko , Thierry Reding , Jonathan Hunter Subject: [PATCH v2 1/4] gpiolib: provide gpio_device_find_by_fwnode() Date: Wed, 11 Oct 2023 23:26:35 +0300 Message-Id: <20231011202638.372382-2-andriy.shevchenko@linux.intel.com> X-Mailer: git-send-email 2.40.0.1.gaa8946217a0b In-Reply-To: <20231011202638.372382-1-andriy.shevchenko@linux.intel.com> References: <20231011202638.372382-1-andriy.shevchenko@linux.intel.com> MIME-Version: 1.0 X-Spam-Status: No, score=-4.3 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_EF,RCVD_IN_DNSWL_MED,SPF_HELO_NONE, SPF_NONE,URIBL_BLOCKED autolearn=ham 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 X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (snail.vger.email [0.0.0.0]); Wed, 11 Oct 2023 13:27:00 -0700 (PDT) X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1779492214446488545 X-GMAIL-MSGID: 1779492214446488545 One of the ways of looking up GPIO devices is using their fwnode. Provide a helper for that to avoid every user implementing their own matching function. Reviewed-by: Dipen Patel Tested-by: Dipen Patel Reviewed-by: Linus Walleij Link: https://lore.kernel.org/r/20231010151709.4104747-2-andriy.shevchenko@linux.intel.com Signed-off-by: Andy Shevchenko --- drivers/gpio/gpiolib.c | 20 ++++++++++++++++++++ include/linux/gpio/driver.h | 1 + 2 files changed, 21 insertions(+) diff --git a/drivers/gpio/gpiolib.c b/drivers/gpio/gpiolib.c index 7b4d12b714a3..31c06a32cb8a 100644 --- a/drivers/gpio/gpiolib.c +++ b/drivers/gpio/gpiolib.c @@ -1142,6 +1142,26 @@ struct gpio_device *gpio_device_find_by_label(const char *label) } EXPORT_SYMBOL_GPL(gpio_device_find_by_label); +static int gpio_chip_match_by_fwnode(struct gpio_chip *gc, void *fwnode) +{ + return device_match_fwnode(&gc->gpiodev->dev, fwnode); +} + +/** + * gpio_device_find_by_fwnode() - wrapper around gpio_device_find() finding + * the GPIO device by its fwnode + * @fwnode: Firmware node to lookup + * + * Returns: + * Reference to the GPIO device or NULL. Reference must be released with + * gpio_device_put(). + */ +struct gpio_device *gpio_device_find_by_fwnode(const struct fwnode_handle *fwnode) +{ + return gpio_device_find((void *)fwnode, gpio_chip_match_by_fwnode); +} +EXPORT_SYMBOL_GPL(gpio_device_find_by_fwnode); + /** * gpio_device_get() - Increase the reference count of this GPIO device * @gdev: GPIO device to increase the refcount for diff --git a/include/linux/gpio/driver.h b/include/linux/gpio/driver.h index f8ad7f40100c..ae4162d3f1d3 100644 --- a/include/linux/gpio/driver.h +++ b/include/linux/gpio/driver.h @@ -611,6 +611,7 @@ struct gpio_chip *gpiochip_find(void *data, struct gpio_device *gpio_device_find(void *data, int (*match)(struct gpio_chip *gc, void *data)); struct gpio_device *gpio_device_find_by_label(const char *label); +struct gpio_device *gpio_device_find_by_fwnode(const struct fwnode_handle *fwnode); struct gpio_device *gpio_device_get(struct gpio_device *gdev); void gpio_device_put(struct gpio_device *gdev); From patchwork Wed Oct 11 20:26:36 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andy Shevchenko X-Patchwork-Id: 151547 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:612c:2908:b0:403:3b70:6f57 with SMTP id ib8csp795226vqb; Wed, 11 Oct 2023 13:27:14 -0700 (PDT) X-Google-Smtp-Source: AGHT+IEyM2irxKX+Qn1/8u5e3BT0FCsoD5L6fznL2uDiua1p9LYOI1wFuhO8fikN9MEJ7rzUs6cK X-Received: by 2002:a05:6a00:39a8:b0:692:ad93:e852 with SMTP id fi40-20020a056a0039a800b00692ad93e852mr24078088pfb.2.1697056034577; Wed, 11 Oct 2023 13:27:14 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1697056034; cv=none; d=google.com; s=arc-20160816; b=nAQz49QGklann9FmYCUg8DoduywEfI1ZQvV9471GzLMLuRp8Zua96g05JrSYUdSCEN zyDRMZXG52eGa0VowycP5ODpnAw8gvB5iPoaL2HIXqZvHnGqenZNADAsROy8qaguhlEp CCeycSwLiYV6s7OPrphiClDxH5t1ouEBGoMnS1HqDuQWVfKRgODI3c74IoK6MufvZwog uEFQpHqbdjue1okeSRr7ty4AynmCb8zKEDLcikC1cSkfd2vDUq4RZ76FYMoCO1/vdwaz +pPEwPB9XogzJig7AWeGHwSX+C0woHusR85v/ca8I011n0MkIwo2uq9IKEmdLPBPYeJY C9/w== 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 :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=N0PTTyrqNiexS0FYAFP3RcZ20WwP9sI7sY4iOO3a6GA=; fh=RAF7KyPAfJnoj7VNMZqcV/N9L3IgTT6Eds+WXuPmNQA=; b=yz6gnmGL9QHstXwn33Q7f5HCcCUCUldA69ytudRlVGB9rGMWDj94b+KdVMGJ9ZPtve geMsEETudok+vkYaa+NwZQqgKoTnxG9iZbpsErZb2hGG7uHFhJxp9UD2OAugc0kifRWF Hm9mgMufgQw9IIUny1QpduzAt/gqcBfYns+xoehF8I2gosaeDDU5k1l2CibJAOuNN3+P a/W1QRx6xfVU/lsR8trVudrfxG4Kq5lfWR6M+S7Xgrq9BMGCb+3Ofl8Cf1HyiON+7xGX c2UU9MU98UwiDCXV9HX/NIIDz46wtG7pMo3fwVh1YBuKOzuU8ns5kdYs0tA5i61SeRRL mUnA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=Md6+37kZ; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.31 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: from morse.vger.email (morse.vger.email. [23.128.96.31]) by mx.google.com with ESMTPS id y21-20020a056a00191500b00690258a9766si13554776pfi.373.2023.10.11.13.27.14 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 11 Oct 2023 13:27:14 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.31 as permitted sender) client-ip=23.128.96.31; Authentication-Results: mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=Md6+37kZ; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.31 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by morse.vger.email (Postfix) with ESMTP id 9B0C38049F02; Wed, 11 Oct 2023 13:27:10 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at morse.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1376461AbjJKU1A (ORCPT + 18 others); Wed, 11 Oct 2023 16:27:00 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:54958 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1376378AbjJKU0u (ORCPT ); Wed, 11 Oct 2023 16:26:50 -0400 Received: from mgamail.intel.com (mgamail.intel.com [192.55.52.43]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id E785290; Wed, 11 Oct 2023 13:26:48 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1697056008; x=1728592008; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=8PEWN3Jey64dbzw0CESM+jaomdEbjI2kq05LEDXsXnw=; b=Md6+37kZL+YEc+wDJjrsD3yGI95vhyUeK7gvtOq+RCdup+NDZq93J9u/ jWHikFi0XyK6HzCkVrlJd2M9LDADmslTGKe9fW8hqkkfhyF7bU5hT3qwu Uyeg0l1M8Brl9pNHQ4mGjmxEuOZomom07EDRuI+8/ArI0PQbT7KuXbFHG Iu613O1M+IoPIyxWuil4PCEzp24hbwbTkedGkRtDZLatbFKWFyMM6N0CR drzrOMq4ooizmpQrasBL77OafXFnTpKW6o73RteuOhTgTL1LNbBDwHXnJ t55maB1BqPlZ2/69OOlB9yf+9RqDSQiRRcR5PDV6SKaI7WLUoSVmTXnDn w==; X-IronPort-AV: E=McAfee;i="6600,9927,10860"; a="471015131" X-IronPort-AV: E=Sophos;i="6.03,217,1694761200"; d="scan'208";a="471015131" Received: from orsmga008.jf.intel.com ([10.7.209.65]) by fmsmga105.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 11 Oct 2023 13:26:46 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,10860"; a="783393502" X-IronPort-AV: E=Sophos;i="6.03,217,1694761200"; d="scan'208";a="783393502" Received: from black.fi.intel.com ([10.237.72.28]) by orsmga008.jf.intel.com with ESMTP; 11 Oct 2023 13:26:43 -0700 Received: by black.fi.intel.com (Postfix, from userid 1003) id 1C4B96CB; Wed, 11 Oct 2023 23:26:42 +0300 (EEST) From: Andy Shevchenko To: Bartosz Golaszewski , Andy Shevchenko , Linus Walleij , Dipen Patel , linux-gpio@vger.kernel.org, linux-kernel@vger.kernel.org, timestamp@lists.linux.dev, linux-tegra@vger.kernel.org Cc: Bartosz Golaszewski , Andy Shevchenko , Thierry Reding , Jonathan Hunter Subject: [PATCH v2 2/4] hte: tegra194: don't access struct gpio_chip Date: Wed, 11 Oct 2023 23:26:36 +0300 Message-Id: <20231011202638.372382-3-andriy.shevchenko@linux.intel.com> X-Mailer: git-send-email 2.40.0.1.gaa8946217a0b In-Reply-To: <20231011202638.372382-1-andriy.shevchenko@linux.intel.com> References: <20231011202638.372382-1-andriy.shevchenko@linux.intel.com> MIME-Version: 1.0 X-Spam-Status: No, score=2.8 required=5.0 tests=DKIMWL_WL_HIGH,DKIM_SIGNED, DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI, RCVD_IN_SBL_CSS,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 morse.vger.email Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (morse.vger.email [0.0.0.0]); Wed, 11 Oct 2023 13:27:10 -0700 (PDT) X-Spam-Level: ** X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1779492228259704686 X-GMAIL-MSGID: 1779492228259704686 From: Bartosz Golaszewski Using struct gpio_chip is not safe as it will disappear if the underlying driver is unbound for any reason. Switch to using reference counted struct gpio_device and its dedicated accessors. Signed-off-by: Bartosz Golaszewski Tested-by: Dipen Patel Reviewed-by: Linus Walleij [andy: used gpio_device_find_by_fwnode()] Reviewed-by: Dipen Patel Link: https://lore.kernel.org/r/20231010151709.4104747-3-andriy.shevchenko@linux.intel.com Signed-off-by: Andy Shevchenko --- drivers/hte/hte-tegra194.c | 33 +++++++++++++++++++-------------- 1 file changed, 19 insertions(+), 14 deletions(-) diff --git a/drivers/hte/hte-tegra194.c b/drivers/hte/hte-tegra194.c index 9fd3c00ff695..f6c2dbcd0aca 100644 --- a/drivers/hte/hte-tegra194.c +++ b/drivers/hte/hte-tegra194.c @@ -132,7 +132,7 @@ struct tegra_hte_soc { const struct tegra_hte_data *prov_data; struct tegra_hte_line_data *line_data; struct hte_chip *chip; - struct gpio_chip *c; + struct gpio_device *gdev; void __iomem *regs; }; @@ -421,7 +421,7 @@ static int tegra_hte_line_xlate(struct hte_chip *gc, * HTE/GTE namespace. */ if (gs->prov_data->type == HTE_TEGRA_TYPE_GPIO && !args) { - line_id = desc->attr.line_id - gs->c->base; + line_id = desc->attr.line_id - gpio_device_get_base(gs->gdev); map = gs->prov_data->map; map_sz = gs->prov_data->map_sz; } else if (gs->prov_data->type == HTE_TEGRA_TYPE_GPIO && args) { @@ -643,12 +643,15 @@ static irqreturn_t tegra_hte_isr(int irq, void *dev_id) static bool tegra_hte_match_from_linedata(const struct hte_chip *chip, const struct hte_ts_desc *hdesc) { + struct gpio_device *gdev __free(gpio_device_put) = NULL; struct tegra_hte_soc *hte_dev = chip->data; if (!hte_dev || (hte_dev->prov_data->type != HTE_TEGRA_TYPE_GPIO)) return false; - return hte_dev->c == gpiod_to_chip(hdesc->attr.line_data); + gdev = gpiod_to_device(hdesc->attr.line_data); + + return hte_dev->gdev == gdev; } static const struct of_device_id tegra_hte_of_match[] = { @@ -676,14 +679,11 @@ static void tegra_gte_disable(void *data) tegra_hte_writel(gs, HTE_TECTRL, 0); } -static int tegra_get_gpiochip_from_name(struct gpio_chip *chip, void *data) +static void tegra_hte_put_gpio_device(void *data) { - return !strcmp(chip->label, data); -} + struct gpio_device *gdev = data; -static int tegra_gpiochip_match(struct gpio_chip *chip, void *data) -{ - return chip->fwnode == of_node_to_fwnode(data); + gpio_device_put(gdev); } static int tegra_hte_probe(struct platform_device *pdev) @@ -763,8 +763,8 @@ static int tegra_hte_probe(struct platform_device *pdev) if (of_device_is_compatible(dev->of_node, "nvidia,tegra194-gte-aon")) { - hte_dev->c = gpiochip_find("tegra194-gpio-aon", - tegra_get_gpiochip_from_name); + hte_dev->gdev = + gpio_device_find_by_label("tegra194-gpio-aon"); } else { gpio_ctrl = of_parse_phandle(dev->of_node, "nvidia,gpio-controller", @@ -775,14 +775,19 @@ static int tegra_hte_probe(struct platform_device *pdev) return -ENODEV; } - hte_dev->c = gpiochip_find(gpio_ctrl, - tegra_gpiochip_match); + hte_dev->gdev = + gpio_device_find_by_fwnode(of_fwnode_handle(gpio_ctrl)); of_node_put(gpio_ctrl); } - if (!hte_dev->c) + if (!hte_dev->gdev) return dev_err_probe(dev, -EPROBE_DEFER, "wait for gpio controller\n"); + + ret = devm_add_action_or_reset(dev, tegra_hte_put_gpio_device, + hte_dev->gdev); + if (ret) + return ret; } hte_dev->chip = gc; From patchwork Wed Oct 11 20:26:37 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andy Shevchenko X-Patchwork-Id: 151545 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:612c:2908:b0:403:3b70:6f57 with SMTP id ib8csp795141vqb; Wed, 11 Oct 2023 13:27:05 -0700 (PDT) X-Google-Smtp-Source: AGHT+IHqbuefUn92hygKqwmVqL0wpapyUk5lr6U4iobv0lkCSJllWZw8QqzGL8SowSPlpwPM0Tsj X-Received: by 2002:a17:90b:4f4d:b0:27d:9b6:ec1b with SMTP id pj13-20020a17090b4f4d00b0027d09b6ec1bmr2294694pjb.4.1697056025442; Wed, 11 Oct 2023 13:27:05 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1697056025; cv=none; d=google.com; s=arc-20160816; b=qULcgEZ2AT0UAZ9ksCaDizvmolJJ+Pd0tptNZPdXGXEFSknV8G5cbwHDDiKH3FX95W qT3co4MjD/UOkbV5+NVHY/d3voyD+R6pVoqkNwhLAAIy7C8k1jL31AQ2urdB4B2glTHK mJepiSw7gxnW7r4w7A1Hk8NjyEl3MpfKUYKVPsTfkPWhrRj2gdvAuqb2TJl91K+uSNoU Ptt259noFuuA/MawPkPikOzmQKzxuPtieas1iFOVaRzNowetze90006ErzpKDZo5z9Ki OSoHy5UeYvoV63GDlK+sg4Bo/giWtH/AIO4UqHA+yy6Pi1VM3ucRq/XzRHoAO0Fess93 RebA== 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 :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=f23EjPvQjxdKJdZD6jFI1wUlR852YRhURxPUBJGAbcY=; fh=RAF7KyPAfJnoj7VNMZqcV/N9L3IgTT6Eds+WXuPmNQA=; b=Om5q+bR8fb5K82bJ38La1r1mogA7zl9mmoXvJXbmGzJYGFulKL443BuQQNlfW+fTnc 9/6Yd0m0HcTvjETOb4a/ST+EZyc5d6StGfOAel6pM2RpqJpo2X3xkOt4qV+ibg4GBFLI viLuk0QmpNuv4pzlPMow/60fb4qZUYPiv1xETW72VoG0nos4T1dGch8zW7yHVLs7WmXQ VmwFdbMp5dRts19uoMYTf0xT0HndLi/Whpcw7dgZo9D6MeintwFNuWeor5dgD3QU2UKH zjQFNVVzQ+q4Z0NSC/gz0YGoyrf3GnRZsCpkSOi9sGcRllZb0U14X47+2/zA9neHcKcL IF2g== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=PbGQqUkC; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.33 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: from lipwig.vger.email (lipwig.vger.email. [23.128.96.33]) by mx.google.com with ESMTPS id mu10-20020a17090b388a00b0027b436159b0si684989pjb.165.2023.10.11.13.27.05 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 11 Oct 2023 13:27:05 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.33 as permitted sender) client-ip=23.128.96.33; Authentication-Results: mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=PbGQqUkC; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.33 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by lipwig.vger.email (Postfix) with ESMTP id D5F058184524; Wed, 11 Oct 2023 13:26:59 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at lipwig.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1376362AbjJKU0t (ORCPT + 18 others); Wed, 11 Oct 2023 16:26:49 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:54930 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233360AbjJKU0s (ORCPT ); Wed, 11 Oct 2023 16:26:48 -0400 Received: from mgamail.intel.com (mgamail.intel.com [192.55.52.43]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 2533290; Wed, 11 Oct 2023 13:26:47 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1697056007; x=1728592007; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=ZRhu6GBogXEtacyQpk9MfPzZjieYt+h/X2GsbW/ugqU=; b=PbGQqUkCHfWl/z39Hmo2Pe/omc4YEB2mtpxEjtTP8w66A2mqWcIEG1H4 VPujcZH1QHdTrRcImoQXkhKo0NwITKDjhAmv+X0TIYDVj79i5dcEAHsTF KQYXvGP+IZ61Y+u82ZMtVJeHEG6w4eoEZuEAPNNDpcndvo/Pp5aAY8a0G D6AIeBQJnUOBnQrRPA1IUQn3dzCdXsUWWtbZGPhKtAR3rGQkFwNJhniVm LzRf9sRj2FrLL2CuH1XR0+aqXYf0e5H3f0lw287mearjip1T2+gMtdW0d sY3RIpJekKDOC2/Cx1OQNabSKbyEiq0zptK4Q1hE7+cIhRqru8s0ZyB0U Q==; X-IronPort-AV: E=McAfee;i="6600,9927,10860"; a="471015120" X-IronPort-AV: E=Sophos;i="6.03,217,1694761200"; d="scan'208";a="471015120" Received: from orsmga008.jf.intel.com ([10.7.209.65]) by fmsmga105.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 11 Oct 2023 13:26:46 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,10860"; a="783393503" X-IronPort-AV: E=Sophos;i="6.03,217,1694761200"; d="scan'208";a="783393503" Received: from black.fi.intel.com ([10.237.72.28]) by orsmga008.jf.intel.com with ESMTP; 11 Oct 2023 13:26:43 -0700 Received: by black.fi.intel.com (Postfix, from userid 1003) id 2C8766DA; Wed, 11 Oct 2023 23:26:42 +0300 (EEST) From: Andy Shevchenko To: Bartosz Golaszewski , Andy Shevchenko , Linus Walleij , Dipen Patel , linux-gpio@vger.kernel.org, linux-kernel@vger.kernel.org, timestamp@lists.linux.dev, linux-tegra@vger.kernel.org Cc: Bartosz Golaszewski , Andy Shevchenko , Thierry Reding , Jonathan Hunter Subject: [PATCH v2 3/4] hte: tegra194: Remove redundant dev_err() Date: Wed, 11 Oct 2023 23:26:37 +0300 Message-Id: <20231011202638.372382-4-andriy.shevchenko@linux.intel.com> X-Mailer: git-send-email 2.40.0.1.gaa8946217a0b In-Reply-To: <20231011202638.372382-1-andriy.shevchenko@linux.intel.com> References: <20231011202638.372382-1-andriy.shevchenko@linux.intel.com> MIME-Version: 1.0 X-Spam-Status: No, score=2.8 required=5.0 tests=DKIMWL_WL_HIGH,DKIM_SIGNED, DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI, RCVD_IN_SBL_CSS,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 lipwig.vger.email Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (lipwig.vger.email [0.0.0.0]); Wed, 11 Oct 2023 13:26:59 -0700 (PDT) X-Spam-Level: ** X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1779492218706801510 X-GMAIL-MSGID: 1779492218706801510 There is no need to call the dev_err() function directly to print a custom message when handling an error from platform_get_irq() function as it is going to display an appropriate error message in case of a failure. Reviewed-by: Dipen Patel Tested-by: Dipen Patel Reviewed-by: Linus Walleij Link: https://lore.kernel.org/r/20231010151709.4104747-4-andriy.shevchenko@linux.intel.com Signed-off-by: Andy Shevchenko --- drivers/hte/hte-tegra194.c | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/drivers/hte/hte-tegra194.c b/drivers/hte/hte-tegra194.c index f6c2dbcd0aca..cf6058193403 100644 --- a/drivers/hte/hte-tegra194.c +++ b/drivers/hte/hte-tegra194.c @@ -731,10 +731,8 @@ static int tegra_hte_probe(struct platform_device *pdev) return -ENOMEM; ret = platform_get_irq(pdev, 0); - if (ret < 0) { - dev_err_probe(dev, ret, "failed to get irq\n"); + if (ret < 0) return ret; - } hte_dev->hte_irq = ret; ret = devm_request_irq(dev, hte_dev->hte_irq, tegra_hte_isr, 0, dev_name(dev), hte_dev); From patchwork Wed Oct 11 20:26:38 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andy Shevchenko X-Patchwork-Id: 151546 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:612c:2908:b0:403:3b70:6f57 with SMTP id ib8csp795158vqb; Wed, 11 Oct 2023 13:27:08 -0700 (PDT) X-Google-Smtp-Source: AGHT+IHXMaOizGIo6elTtm7nCNMxQWBUTF3adOHNtHvql+I6KVJer4ys/Z+z7iHigHXaVKXqaQzF X-Received: by 2002:a17:903:22cc:b0:1b8:2ba0:c9a8 with SMTP id y12-20020a17090322cc00b001b82ba0c9a8mr24444720plg.2.1697056028288; Wed, 11 Oct 2023 13:27:08 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1697056028; cv=none; d=google.com; s=arc-20160816; b=Ek2LYFxRJ74c1/xlXh/2g5n3t0eV2tSPn/Kg6cPCOvSh5JepxbUuKbVLk1bs9eSIN6 OllSYF62idhs9WYKLa2+7697S5PiUg7evJgf//T45CbkfglaN8g2g/PAVY3NNyQZRyfn lJRWvh/8R7DRGDCUuOa85QkocKnw8V0LTeN150hB2w0lMBNwbtGlGul3P1bVaHOwOwER 3ULt5eYFriaezP1D1xeBn1GvnQ91tuVcpCOylGO/K9tZ2bEQBDkti31GcJYOaveNzDmA 2ENecX6JHc064cU4Rd0c4al9Ehd9OLJPHF8DT0Q8WX/CMSadenZkAktyVKN1zgZ31CCk QhYA== 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 :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=IHzNXPYAw9vTTq4b5q/gHf2D0jFK1r+/IPVTQnwjiFk=; fh=RAF7KyPAfJnoj7VNMZqcV/N9L3IgTT6Eds+WXuPmNQA=; b=LxP80+4zIazqmfkB4HiEl0ZcADUdrA5e8cRPeS6nuC7/Bv+fX4eNj7pxo87eqs7iL4 YpHS8asJrgZ5z2TmwySXrkf+vAaBKhfDbkgee0quqEeVnbI3o3D8Na1N3mBu2bCf1Y+5 nKcUVgKkxYtSHeJpHKz3rbCXEbTI2KH/VPWBe+VeuKIGvwyCiwX4ILZmQSfCG+wtncz/ l76hp9Q5DSeDKF/+MDyFUK5FzQdw5hJ5mwOWP+BRNmchApHQR+cXE0HhTRYAnrP9xBzp smRtkuBSoG8xvJmNIieE0ibho4lzkVrlSfo7N4YoJAaGD8htaj8qsvzyXOviUpskTx/s 7y5w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b="QkSij/IF"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.38 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: from fry.vger.email (fry.vger.email. [23.128.96.38]) by mx.google.com with ESMTPS id x12-20020a1709028ecc00b001bb2093efb6si479841plo.45.2023.10.11.13.27.08 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 11 Oct 2023 13:27:08 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.38 as permitted sender) client-ip=23.128.96.38; Authentication-Results: mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b="QkSij/IF"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.38 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by fry.vger.email (Postfix) with ESMTP id 1E70380B81C0; Wed, 11 Oct 2023 13:27:03 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at fry.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1376413AbjJKU0v (ORCPT + 18 others); Wed, 11 Oct 2023 16:26:51 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:54942 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1376374AbjJKU0u (ORCPT ); Wed, 11 Oct 2023 16:26:50 -0400 Received: from mgamail.intel.com (mgamail.intel.com [198.175.65.9]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 274FD91; Wed, 11 Oct 2023 13:26:47 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1697056007; x=1728592007; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=w7GO/YmuQf/fATRgis2loCwaDUE9BWEr6AP7smZXouQ=; b=QkSij/IFfw5XSTitxh/Sv3qHEFL6EM+pCfhY6VvaGoXZ5afhc7Xegnbx ISzfZAjJLUSIirAndEa6ZMS5ShpJT6aOkkjT62xi2ON8N3JM3r88DfGHH iGECrvNnn0RgPUY4L459WftXiaFkbiXNr2m3+BgBhetohYKdcs+wxuDQQ prI5ueKYWdgg2S++ocZQ43U5Veg2UccNZfUOG4FdzW9p6p895av2aj21g jrF5r7NwT2pmOcOY7YI1q12O18w29t/AEigVc58TnPiQ3rjH4QKICNRaa KRRmWPudqtj25JpBi/xfjb37qJg+HWHtVmNtdO3eTcCM1mWHjqaZhro7k g==; X-IronPort-AV: E=McAfee;i="6600,9927,10860"; a="3349165" X-IronPort-AV: E=Sophos;i="6.03,217,1694761200"; d="scan'208";a="3349165" Received: from fmsmga004.fm.intel.com ([10.253.24.48]) by orvoesa101.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 11 Oct 2023 13:26:46 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,10860"; a="824311018" X-IronPort-AV: E=Sophos;i="6.03,217,1694761200"; d="scan'208";a="824311018" Received: from black.fi.intel.com ([10.237.72.28]) by fmsmga004.fm.intel.com with ESMTP; 11 Oct 2023 13:26:43 -0700 Received: by black.fi.intel.com (Postfix, from userid 1003) id 37B4E71B; Wed, 11 Oct 2023 23:26:42 +0300 (EEST) From: Andy Shevchenko To: Bartosz Golaszewski , Andy Shevchenko , Linus Walleij , Dipen Patel , linux-gpio@vger.kernel.org, linux-kernel@vger.kernel.org, timestamp@lists.linux.dev, linux-tegra@vger.kernel.org Cc: Bartosz Golaszewski , Andy Shevchenko , Thierry Reding , Jonathan Hunter Subject: [PATCH v2 4/4] hte: tegra194: Switch to LATE_SIMPLE_DEV_PM_OPS() Date: Wed, 11 Oct 2023 23:26:38 +0300 Message-Id: <20231011202638.372382-5-andriy.shevchenko@linux.intel.com> X-Mailer: git-send-email 2.40.0.1.gaa8946217a0b In-Reply-To: <20231011202638.372382-1-andriy.shevchenko@linux.intel.com> References: <20231011202638.372382-1-andriy.shevchenko@linux.intel.com> MIME-Version: 1.0 X-Spam-Status: No, score=2.8 required=5.0 tests=DKIMWL_WL_HIGH,DKIM_SIGNED, DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI, RCVD_IN_SBL_CSS,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED autolearn=no autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on fry.vger.email Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (fry.vger.email [0.0.0.0]); Wed, 11 Oct 2023 13:27:03 -0700 (PDT) X-Spam-Level: ** X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1779492222246314469 X-GMAIL-MSGID: 1779492222246314469 SET_LATE_SYSTEM_SLEEP_PM_OPS is deprecated, replace it with LATE_SYSTEM_SLEEP_PM_OPS() and use pm_sleep_ptr() for setting the driver's pm routines. We can now remove the __maybe_unused qualifier in the suspend and resume functions. Tested-by: Dipen Patel Reviewed-by: Dipen Patel Reviewed-by: Linus Walleij Link: https://lore.kernel.org/r/20231010151709.4104747-5-andriy.shevchenko@linux.intel.com Signed-off-by: Andy Shevchenko --- drivers/hte/hte-tegra194.c | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/drivers/hte/hte-tegra194.c b/drivers/hte/hte-tegra194.c index cf6058193403..76e1b774c55e 100644 --- a/drivers/hte/hte-tegra194.c +++ b/drivers/hte/hte-tegra194.c @@ -815,7 +815,7 @@ static int tegra_hte_probe(struct platform_device *pdev) return 0; } -static int __maybe_unused tegra_hte_resume_early(struct device *dev) +static int tegra_hte_resume_early(struct device *dev) { u32 i; struct tegra_hte_soc *gs = dev_get_drvdata(dev); @@ -836,7 +836,7 @@ static int __maybe_unused tegra_hte_resume_early(struct device *dev) return 0; } -static int __maybe_unused tegra_hte_suspend_late(struct device *dev) +static int tegra_hte_suspend_late(struct device *dev) { u32 i; struct tegra_hte_soc *gs = dev_get_drvdata(dev); @@ -856,15 +856,14 @@ static int __maybe_unused tegra_hte_suspend_late(struct device *dev) } static const struct dev_pm_ops tegra_hte_pm = { - SET_LATE_SYSTEM_SLEEP_PM_OPS(tegra_hte_suspend_late, - tegra_hte_resume_early) + LATE_SYSTEM_SLEEP_PM_OPS(tegra_hte_suspend_late, tegra_hte_resume_early) }; static struct platform_driver tegra_hte_driver = { .probe = tegra_hte_probe, .driver = { .name = "tegra_hte", - .pm = &tegra_hte_pm, + .pm = pm_sleep_ptr(&tegra_hte_pm), .of_match_table = tegra_hte_of_match, }, };