From patchwork Wed Dec 28 09:20:43 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andy Shevchenko X-Patchwork-Id: 37155 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:4e01:0:0:0:0:0 with SMTP id p1csp1797571wrt; Wed, 28 Dec 2022 01:22:00 -0800 (PST) X-Google-Smtp-Source: AMrXdXvcFHG+MguKYbOcHOFfdBNCuQ4jZk8Zef3RCd+yldaiqGKsu/8SPIYya8GfC874FCeyFl2b X-Received: by 2002:a17:902:b401:b0:188:6300:596a with SMTP id x1-20020a170902b40100b001886300596amr26107152plr.7.1672219320128; Wed, 28 Dec 2022 01:22:00 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1672219320; cv=none; d=google.com; s=arc-20160816; b=KAKuBDeFtGecr48J8imTW8tPTyErifNbV/UbVWGv38QdCuSIz3Q5VsIGK8vpB553OM ne+2IEpSpnt+20HdaOd6PMWv+zzQ9/ZZRHoKsZgSSZmA9hOy7AxuuYafUncBrUNRBo6A XYCPHszXpFDGJqUmnsGQBdRqcGqHMv9dgriSDucAbM2xuwfqhrd888sH094steuvBQUt H3yKP/EczNUv5Dh38gruntOGlmXJcjcG2mfyes7Dg5w7sxkgcEEASGFLoA/Q9paLWTy8 xsX3BiZDxc6H1P1QwDrrAqpGEQM+irsLc8PhTW7iyJgdzjW/yYiUnKIx1v9iM7poklaB x4lw== 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=IiFJjbsriPy0NUE8XOpr8rVgskTeL2sJ5U3yxXwazyo=; b=LsXjUKqSMziQVW2gz8avGucF+kJXV0HM6I+4eKUrRCDabyAEn0JUuMydRgi23uIJd5 8Mav0isrFvJVPGk1AsSb+VwWUfeA0T9m3+YL1YEZQH0PKD9CRvfF+SNAhjZQbqmht2x0 Uv6MU8PMRPS62Tfw5SYKV2i9I1qAkB7qxq+tqdMdUqqpJtG9cgPv2Xy3mTZ2Q+CKx8JV YQ4ziOfU0qThr0uwlh5hhwH6Dp3N8FHus8lPfhjGyFSDHj6HAp1mxKvGLdB9iuOt7Toc InqbyxOmrBxHTxFp8rmvY+7aoW378ufzbjkTzKcfvAyK5hvKn1n1aM3Pz6dr46R3kt54 O9kw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=bWc7r5zc; 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=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id h14-20020a170902f70e00b00188c7b09446si16093383plo.44.2022.12.28.01.21.48; Wed, 28 Dec 2022 01:22:00 -0800 (PST) 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; dkim=pass header.i=@intel.com header.s=Intel header.b=bWc7r5zc; 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=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232483AbiL1JUv (ORCPT + 99 others); Wed, 28 Dec 2022 04:20:51 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:34830 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232723AbiL1JUj (ORCPT ); Wed, 28 Dec 2022 04:20:39 -0500 Received: from mga01.intel.com (mga01.intel.com [192.55.52.88]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 5D234F15; Wed, 28 Dec 2022 01:20:38 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1672219238; x=1703755238; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=hNd/hArL9/6boN9uSffZJyCUY4OmKqVMlCay2nIEb8I=; b=bWc7r5zcnW8j5g8LSYJk6akI8ry7QzyDJcVUS6EfoW1TlbPGjUkOIS77 fwTriSAe4WdzAaIzXIWBVaagWEBh5QpWj6RIXOXy8Z2O/f1DnGoFXwP68 Wwvx3KMTFGMGjSYS4CIoSWjmkYZs2ZX9v/TixLelL/51163hRRPR9Te12 +emps6+O7wcKvlsYBMBzXp9Iy7UwEzyF5hcUwVl4T4Jhkb9sUK9A9tNVA gVOmD+uoMDQNwFCo+5ml1OrnZ6sY61lS890kRosy4ydSyJWiloiXUi4PA A75sEPfzzok7ZD8jAK8qTemXJkXRlBvhh+dJaro8NAQImbbRAO+IIA0Sx Q==; X-IronPort-AV: E=McAfee;i="6500,9779,10573"; a="348041442" X-IronPort-AV: E=Sophos;i="5.96,280,1665471600"; d="scan'208";a="348041442" Received: from fmsmga004.fm.intel.com ([10.253.24.48]) by fmsmga101.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 28 Dec 2022 01:20:30 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6500,9779,10573"; a="721737258" X-IronPort-AV: E=Sophos;i="5.96,280,1665471600"; d="scan'208";a="721737258" Received: from black.fi.intel.com ([10.237.72.28]) by fmsmga004.fm.intel.com with ESMTP; 28 Dec 2022 01:20:28 -0800 Received: by black.fi.intel.com (Postfix, from userid 1003) id E5663159; Wed, 28 Dec 2022 11:20:59 +0200 (EET) From: Andy Shevchenko To: Andy Shevchenko , Dmitry Torokhov , Bartosz Golaszewski , Linus Walleij , linux-gpio@vger.kernel.org, linux-acpi@vger.kernel.org, linux-kernel@vger.kernel.org Cc: Mika Westerberg , Bartosz Golaszewski Subject: [PATCH v4 1/3] gpiolib: Introduce gpio_device_get() and gpio_device_put() Date: Wed, 28 Dec 2022 11:20:43 +0200 Message-Id: <20221228092045.80425-2-andriy.shevchenko@linux.intel.com> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20221228092045.80425-1-andriy.shevchenko@linux.intel.com> References: <20221228092045.80425-1-andriy.shevchenko@linux.intel.com> MIME-Version: 1.0 X-Spam-Status: No, score=-7.0 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_EF,RCVD_IN_DNSWL_HI, RCVD_IN_MSPIKE_H3,RCVD_IN_MSPIKE_WL,SPF_HELO_NONE,SPF_NONE 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-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1753449045772292120?= X-GMAIL-MSGID: =?utf-8?q?1753449045772292120?= Introduce gpio_device_get() and gpio_device_put() helpers and convert existing users. Signed-off-by: Andy Shevchenko --- drivers/gpio/gpiolib-cdev.c | 21 +++++++++------------ drivers/gpio/gpiolib.c | 14 ++++++-------- drivers/gpio/gpiolib.h | 10 ++++++++++ 3 files changed, 25 insertions(+), 20 deletions(-) diff --git a/drivers/gpio/gpiolib-cdev.c b/drivers/gpio/gpiolib-cdev.c index e878e3f22b0e..0a33971c964c 100644 --- a/drivers/gpio/gpiolib-cdev.c +++ b/drivers/gpio/gpiolib-cdev.c @@ -321,7 +321,7 @@ static void linehandle_free(struct linehandle_state *lh) if (lh->descs[i]) gpiod_free(lh->descs[i]); kfree(lh->label); - put_device(&lh->gdev->dev); + gpio_device_put(lh->gdev); kfree(lh); } @@ -363,8 +363,7 @@ static int linehandle_create(struct gpio_device *gdev, void __user *ip) lh = kzalloc(sizeof(*lh), GFP_KERNEL); if (!lh) return -ENOMEM; - lh->gdev = gdev; - get_device(&gdev->dev); + lh->gdev = gpio_device_get(gdev); if (handlereq.consumer_label[0] != '\0') { /* label is only initialized if consumer_label is set */ @@ -1576,7 +1575,7 @@ static void linereq_free(struct linereq *lr) } kfifo_free(&lr->events); kfree(lr->label); - put_device(&lr->gdev->dev); + gpio_device_put(lr->gdev); kfree(lr); } @@ -1646,8 +1645,7 @@ static int linereq_create(struct gpio_device *gdev, void __user *ip) if (!lr) return -ENOMEM; - lr->gdev = gdev; - get_device(&gdev->dev); + lr->gdev = gpio_device_get(gdev); for (i = 0; i < ulr.num_lines; i++) { lr->lines[i].req = lr; @@ -1916,7 +1914,7 @@ static void lineevent_free(struct lineevent_state *le) if (le->desc) gpiod_free(le->desc); kfree(le->label); - put_device(&le->gdev->dev); + gpio_device_put(le->gdev); kfree(le); } @@ -2094,8 +2092,7 @@ static int lineevent_create(struct gpio_device *gdev, void __user *ip) le = kzalloc(sizeof(*le), GFP_KERNEL); if (!le) return -ENOMEM; - le->gdev = gdev; - get_device(&gdev->dev); + le->gdev = gpio_device_get(gdev); if (eventreq.consumer_label[0] != '\0') { /* label is only initialized if consumer_label is set */ @@ -2671,7 +2668,7 @@ static int gpio_chrdev_open(struct inode *inode, struct file *file) init_waitqueue_head(&cdev->wait); INIT_KFIFO(cdev->events); - cdev->gdev = gdev; + cdev->gdev = gpio_device_get(gdev); cdev->lineinfo_changed_nb.notifier_call = lineinfo_changed_notify; ret = blocking_notifier_chain_register(&gdev->notifier, @@ -2679,7 +2676,6 @@ static int gpio_chrdev_open(struct inode *inode, struct file *file) if (ret) goto out_free_bitmap; - get_device(&gdev->dev); file->private_data = cdev; ret = nonseekable_open(inode, file); @@ -2694,6 +2690,7 @@ static int gpio_chrdev_open(struct inode *inode, struct file *file) blocking_notifier_chain_unregister(&gdev->notifier, &cdev->lineinfo_changed_nb); out_free_bitmap: + gpio_device_put(gdev); bitmap_free(cdev->watched_lines); out_free_cdev: kfree(cdev); @@ -2716,7 +2713,7 @@ static int gpio_chrdev_release(struct inode *inode, struct file *file) bitmap_free(cdev->watched_lines); blocking_notifier_chain_unregister(&gdev->notifier, &cdev->lineinfo_changed_nb); - put_device(&gdev->dev); + gpio_device_put(gdev); kfree(cdev); return 0; diff --git a/drivers/gpio/gpiolib.c b/drivers/gpio/gpiolib.c index 5a66d9616d7c..fdb0dc464218 100644 --- a/drivers/gpio/gpiolib.c +++ b/drivers/gpio/gpiolib.c @@ -882,7 +882,7 @@ int gpiochip_add_data_with_key(struct gpio_chip *gc, void *data, gpiochip_free_valid_mask(gc); if (gdev->dev.release) { /* release() has been registered by gpiochip_setup_dev() */ - put_device(&gdev->dev); + gpio_device_put(gdev); goto err_print_message; } err_remove_from_list: @@ -972,7 +972,7 @@ void gpiochip_remove(struct gpio_chip *gc) */ gcdev_unregister(gdev); up_write(&gdev->sem); - put_device(&gdev->dev); + gpio_device_put(gdev); } EXPORT_SYMBOL_GPL(gpiochip_remove); @@ -2063,17 +2063,15 @@ static int validate_desc(const struct gpio_desc *desc, const char *func) int gpiod_request(struct gpio_desc *desc, const char *label) { int ret = -EPROBE_DEFER; - struct gpio_device *gdev; VALIDATE_DESC(desc); - gdev = desc->gdev; - if (try_module_get(gdev->owner)) { + if (try_module_get(desc->gdev->owner)) { ret = gpiod_request_commit(desc, label); if (ret) - module_put(gdev->owner); + module_put(desc->gdev->owner); else - get_device(&gdev->dev); + gpio_device_get(desc->gdev); } if (ret) @@ -2134,7 +2132,7 @@ void gpiod_free(struct gpio_desc *desc) { if (desc && desc->gdev && gpiod_free_commit(desc)) { module_put(desc->gdev->owner); - put_device(&desc->gdev->dev); + gpio_device_put(desc->gdev); } else { WARN_ON(extra_checks); } diff --git a/drivers/gpio/gpiolib.h b/drivers/gpio/gpiolib.h index b3c2db6eba80..cca81375f127 100644 --- a/drivers/gpio/gpiolib.h +++ b/drivers/gpio/gpiolib.h @@ -82,6 +82,16 @@ static inline struct gpio_device *to_gpio_device(struct device *dev) return container_of(dev, struct gpio_device, dev); } +static inline struct gpio_device *gpio_device_get(struct gpio_device *gdev) +{ + return to_gpio_device(get_device(&gdev->dev)); +} + +static inline void gpio_device_put(struct gpio_device *gdev) +{ + put_device(&gdev->dev); +} + /* gpio suffixes used for ACPI and device tree lookup */ static __maybe_unused const char * const gpio_suffixes[] = { "gpios", "gpio" }; From patchwork Wed Dec 28 09:20:44 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andy Shevchenko X-Patchwork-Id: 37154 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:4e01:0:0:0:0:0 with SMTP id p1csp1797472wrt; Wed, 28 Dec 2022 01:21:40 -0800 (PST) X-Google-Smtp-Source: AMrXdXtu/iY9W0EbY08/Q3zTyS7sml+Z4WTQFSmR4NEeLRgQF83vfAGNsY96TPIjyDMWYZRYmAW1 X-Received: by 2002:a17:90a:1b2d:b0:225:c9d4:9cd9 with SMTP id q42-20020a17090a1b2d00b00225c9d49cd9mr17710558pjq.32.1672219299745; Wed, 28 Dec 2022 01:21:39 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1672219299; cv=none; d=google.com; s=arc-20160816; b=fpvcr3eGUyUmllel15itBB+zjDQgYzLQeGzfgaizDGNQnq2FrfnO1ApFYvWUFuKvtr sk9D3OkZZDtIjU+MhgRNd8ZUWmlpldKN6e0Ll4aNSWDuD4TDZx2jmqaMnKqBBOLqxWCT 1/Hi/DzNm6XECM7kCtW6yMrV5GKeJPyjZQ54ldK33fIi9b+yZstuFb5fzhjYD5mptMMt oP558xZAOAE4dRzfABsSUEufsWB2GiayBfHTnRYWN9reAaSYfK96adBjltNAFt5u6P4g +doQRLv0/mjDFqPhg03xFSTx/4QH6HwPHw8PCNex35QJ0+cpzNdxR5pVyVJhbWlAiYkG uvLA== 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=JW+TKkf/JuHK5/KSb1tUXlQ1lBYptwBqI75RaFZegso=; b=BZcS+z2SJPNdCxLE4if4p+k4oowKjT2oMt6Yrs4De1ilXx+s61MJRbCYgWMpwClH9z fmKeOSNJtcIG5FLGLP+DvEo5gzfRAu+Su8zzsR1ryIZ1RUBGjFkJbEOdk74O8jx0z8x9 Fi5WcXpflvoNJMznmRvHTWgFM0PtgTrPESoqCVj/VZrDq8NPC+eLxQmFx1H7Ys5roo6z eVQW8PJmuYczVpa1SwHi8BihZ1c09hNSM8nsSTezw2yjRcG7R0K5dSMqvau9B6r8q3El CO5AmzBhRHFuLciJykXOrqTpmzgJx66FXI7//tke8Kbqa1s9msTfT1P+QzohK4oez4rf SZfA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=SVBmqPT1; 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=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id cl20-20020a17090af69400b0020ab20c54fesi19481969pjb.114.2022.12.28.01.21.28; Wed, 28 Dec 2022 01:21:39 -0800 (PST) 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; dkim=pass header.i=@intel.com header.s=Intel header.b=SVBmqPT1; 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=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232718AbiL1JUj (ORCPT + 99 others); Wed, 28 Dec 2022 04:20:39 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:34792 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232675AbiL1JUd (ORCPT ); Wed, 28 Dec 2022 04:20:33 -0500 Received: from mga17.intel.com (mga17.intel.com [192.55.52.151]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id E718363F3; Wed, 28 Dec 2022 01:20:32 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1672219232; x=1703755232; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=UMmpQONPDdapY9pS6wpbPLce5H+8MKwTLo52jhIYAws=; b=SVBmqPT1+qYMKiciGn3BF2995TeQslZN7W6/80ckXZ/W2I3b4EWVM+8F /IsAQkpOSXLC/a4Mg3VFjp9eOFA2alcFzvZZdZrNuIWP2qn5xxYYYT4HA hn2M6ipS+ddpqe/Eyb4mAG9A4pFhOF0V+9GNEZOOW+g0ObJMkhEmgZNXH GaKQPzSVKN3vRBe6cXf4pTNS/qirC4rMuN2TYSKdOZ3x61YR0jyxYL+TZ brgFVL6S0MVAPpA0RQrBq706xGAX7U/S3PD8Exg6fQaoX/bS4EtPhkq1g JFz5Ms7pnGocCFrV7io57fzxfk4YBEbL+Ox0pgUFistZnrJDfc5j49Rm6 w==; X-IronPort-AV: E=McAfee;i="6500,9779,10573"; a="301202849" X-IronPort-AV: E=Sophos;i="5.96,280,1665471600"; d="scan'208";a="301202849" Received: from orsmga003.jf.intel.com ([10.7.209.27]) by fmsmga107.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 28 Dec 2022 01:20:32 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6500,9779,10573"; a="603285106" X-IronPort-AV: E=Sophos;i="5.96,280,1665471600"; d="scan'208";a="603285106" Received: from black.fi.intel.com ([10.237.72.28]) by orsmga003.jf.intel.com with ESMTP; 28 Dec 2022 01:20:29 -0800 Received: by black.fi.intel.com (Postfix, from userid 1003) id 1D66619E; Wed, 28 Dec 2022 11:21:01 +0200 (EET) From: Andy Shevchenko To: Andy Shevchenko , Dmitry Torokhov , Bartosz Golaszewski , Linus Walleij , linux-gpio@vger.kernel.org, linux-acpi@vger.kernel.org, linux-kernel@vger.kernel.org Cc: Mika Westerberg , Bartosz Golaszewski , Thierry Reding Subject: [PATCH v4 2/3] gpiolib: Get rid of not used of_node member Date: Wed, 28 Dec 2022 11:20:44 +0200 Message-Id: <20221228092045.80425-3-andriy.shevchenko@linux.intel.com> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20221228092045.80425-1-andriy.shevchenko@linux.intel.com> References: <20221228092045.80425-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 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-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1753449024514756224?= X-GMAIL-MSGID: =?utf-8?q?1753449024514756224?= All new drivers should use fwnode and / or parent to provide the necessary information to the GPIO library. Cc: Thierry Reding Signed-off-by: Andy Shevchenko --- drivers/gpio/gpiolib-acpi.c | 10 ---------- drivers/gpio/gpiolib-acpi.h | 4 ---- drivers/gpio/gpiolib-of.c | 25 +++++-------------------- drivers/gpio/gpiolib-of.h | 5 ----- drivers/gpio/gpiolib.c | 11 +++-------- include/linux/gpio/driver.h | 7 ------- 6 files changed, 8 insertions(+), 54 deletions(-) diff --git a/drivers/gpio/gpiolib-acpi.c b/drivers/gpio/gpiolib-acpi.c index bed0380c5136..466622a8fb36 100644 --- a/drivers/gpio/gpiolib-acpi.c +++ b/drivers/gpio/gpiolib-acpi.c @@ -1387,16 +1387,6 @@ void acpi_gpiochip_remove(struct gpio_chip *chip) kfree(acpi_gpio); } -void acpi_gpio_dev_init(struct gpio_chip *gc, struct gpio_device *gdev) -{ - /* Set default fwnode to parent's one if present */ - if (gc->parent) - ACPI_COMPANION_SET(&gdev->dev, ACPI_COMPANION(gc->parent)); - - if (gc->fwnode) - device_set_node(&gdev->dev, gc->fwnode); -} - static int acpi_gpio_package_count(const union acpi_object *obj) { const union acpi_object *element = obj->package.elements; diff --git a/drivers/gpio/gpiolib-acpi.h b/drivers/gpio/gpiolib-acpi.h index 9475f99a9694..5fa315b3c912 100644 --- a/drivers/gpio/gpiolib-acpi.h +++ b/drivers/gpio/gpiolib-acpi.h @@ -26,8 +26,6 @@ struct gpio_device; void acpi_gpiochip_add(struct gpio_chip *chip); void acpi_gpiochip_remove(struct gpio_chip *chip); -void acpi_gpio_dev_init(struct gpio_chip *gc, struct gpio_device *gdev); - void acpi_gpiochip_request_interrupts(struct gpio_chip *chip); void acpi_gpiochip_free_interrupts(struct gpio_chip *chip); @@ -42,8 +40,6 @@ int acpi_gpio_count(struct device *dev, const char *con_id); static inline void acpi_gpiochip_add(struct gpio_chip *chip) { } static inline void acpi_gpiochip_remove(struct gpio_chip *chip) { } -static inline void acpi_gpio_dev_init(struct gpio_chip *gc, struct gpio_device *gdev) { } - static inline void acpi_gpiochip_request_interrupts(struct gpio_chip *chip) { } diff --git a/drivers/gpio/gpiolib-of.c b/drivers/gpio/gpiolib-of.c index 4fff7258ee41..a6f9788d6db0 100644 --- a/drivers/gpio/gpiolib-of.c +++ b/drivers/gpio/gpiolib-of.c @@ -668,7 +668,7 @@ static struct gpio_desc *of_parse_own_gpio(struct device_node *np, u32 tmp; int ret; - chip_np = chip->of_node; + chip_np = dev_of_node(&chip->gpiodev->dev); if (!chip_np) return ERR_PTR(-EINVAL); @@ -760,7 +760,7 @@ static int of_gpiochip_scan_gpios(struct gpio_chip *chip) struct device_node *np; int ret; - for_each_available_child_of_node(chip->of_node, np) { + for_each_available_child_of_node(dev_of_node(&chip->gpiodev->dev), np) { if (!of_property_read_bool(np, "gpio-hog")) continue; @@ -970,14 +970,15 @@ EXPORT_SYMBOL_GPL(of_mm_gpiochip_remove); #ifdef CONFIG_PINCTRL static int of_gpiochip_add_pin_range(struct gpio_chip *chip) { - struct device_node *np = chip->of_node; struct of_phandle_args pinspec; struct pinctrl_dev *pctldev; + struct device_node *np; int index = 0, ret; const char *name; static const char group_names_propname[] = "gpio-ranges-group-names"; struct property *group_names; + np = dev_of_node(&chip->gpiodev->dev); if (!np) return 0; @@ -1063,7 +1064,7 @@ int of_gpiochip_add(struct gpio_chip *chip) struct device_node *np; int ret; - np = to_of_node(dev_fwnode(&chip->gpiodev->dev)); + np = dev_of_node(&chip->gpiodev->dev); if (!np) return 0; @@ -1092,19 +1093,3 @@ void of_gpiochip_remove(struct gpio_chip *chip) { fwnode_handle_put(chip->fwnode); } - -void of_gpio_dev_init(struct gpio_chip *gc, struct gpio_device *gdev) -{ - /* Set default OF node to parent's one if present */ - if (gc->parent) - gdev->dev.of_node = gc->parent->of_node; - - if (gc->fwnode) - gc->of_node = to_of_node(gc->fwnode); - - /* If the gpiochip has an assigned OF node this takes precedence */ - if (gc->of_node) - gdev->dev.of_node = gc->of_node; - else - gc->of_node = gdev->dev.of_node; -} diff --git a/drivers/gpio/gpiolib-of.h b/drivers/gpio/gpiolib-of.h index a6c593e6766c..e5bb065d82ef 100644 --- a/drivers/gpio/gpiolib-of.h +++ b/drivers/gpio/gpiolib-of.h @@ -23,7 +23,6 @@ struct gpio_desc *of_find_gpio(struct device_node *np, int of_gpiochip_add(struct gpio_chip *gc); void of_gpiochip_remove(struct gpio_chip *gc); int of_gpio_get_count(struct device *dev, const char *con_id); -void of_gpio_dev_init(struct gpio_chip *gc, struct gpio_device *gdev); #else static inline struct gpio_desc *of_find_gpio(struct device_node *np, const char *con_id, @@ -38,10 +37,6 @@ static inline int of_gpio_get_count(struct device *dev, const char *con_id) { return 0; } -static inline void of_gpio_dev_init(struct gpio_chip *gc, - struct gpio_device *gdev) -{ -} #endif /* CONFIG_OF_GPIO */ extern struct notifier_block gpio_of_notifier; diff --git a/drivers/gpio/gpiolib.c b/drivers/gpio/gpiolib.c index fdb0dc464218..e72c539fbec5 100644 --- a/drivers/gpio/gpiolib.c +++ b/drivers/gpio/gpiolib.c @@ -659,10 +659,12 @@ int gpiochip_add_data_with_key(struct gpio_chip *gc, void *data, int base = 0; int ret = 0; + /* If the calling driver did not initialize firmware node, do it here */ if (gc->fwnode) fwnode = gc->fwnode; else if (gc->parent) fwnode = dev_fwnode(gc->parent); + gc->fwnode = fwnode; /* * First: allocate and populate the internal stat container, and @@ -676,14 +678,7 @@ int gpiochip_add_data_with_key(struct gpio_chip *gc, void *data, gdev->chip = gc; gc->gpiodev = gdev; - of_gpio_dev_init(gc, gdev); - acpi_gpio_dev_init(gc, gdev); - - /* - * Assign fwnode depending on the result of the previous calls, - * if none of them succeed, assign it to the parent's one. - */ - gc->fwnode = gdev->dev.fwnode = dev_fwnode(&gdev->dev) ?: fwnode; + device_set_node(&gdev->dev, gc->fwnode); gdev->id = ida_alloc(&gpio_ida, GFP_KERNEL); if (gdev->id < 0) { diff --git a/include/linux/gpio/driver.h b/include/linux/gpio/driver.h index 44783fc16125..2316cb7fa667 100644 --- a/include/linux/gpio/driver.h +++ b/include/linux/gpio/driver.h @@ -503,13 +503,6 @@ struct gpio_chip { * the device tree automatically may have an OF translation */ - /** - * @of_node: - * - * Pointer to a device tree node representing this GPIO controller. - */ - struct device_node *of_node; - /** * @of_gpio_n_cells: * From patchwork Wed Dec 28 09:20:45 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andy Shevchenko X-Patchwork-Id: 37153 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:4e01:0:0:0:0:0 with SMTP id p1csp1797318wrt; Wed, 28 Dec 2022 01:21:10 -0800 (PST) X-Google-Smtp-Source: AMrXdXuJmSOez11qtYNoPslzoCBCztxFzQ4Kq0hLa73Vg1gkxV5YEIdvG3SmwMhogljlVcT8saDH X-Received: by 2002:a17:902:d052:b0:192:5950:656c with SMTP id l18-20020a170902d05200b001925950656cmr18839196pll.37.1672219269921; Wed, 28 Dec 2022 01:21:09 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1672219269; cv=none; d=google.com; s=arc-20160816; b=pDViLYoc//+2VXEFnBQFK9Hm3oe2639W39jPLhWbQpk6UJuSv0RRHSMeL5y7VO3A8I E/bcfOInt6dz+nC8MYwbzoAWvR7kWEFmfZpxa0OFZ9pIzrypb2gUEZBomgG2Vu5tpRGz Lz8GSoz/glYQt1uTJ+NVyrykTUgNsZM7SxzwZfxcyVEbMOwaDDoCKmBglSCZcDnWG/q1 jeNikpxBCYfz69b5bZ0272mYUI4NrJe+k1yK5hGs1+iynwfIS0vQq3ZyK4Dys3/Hv8Eh RVcz20uU4lRIZ4XD98IUZ4mmrW4uo3d/TaJjWC+MfEarAARu4UX9dsssNW1gEy6L7Pj2 h1+Q== 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=YZ1cu7xyVjuOnHCdOv0gxjldUSiJKqYhE0ID8SYu3wk=; b=qvqJBGXYa+POjaKaIMVL86iA+FJyIYTKdRQZ9PnuwhbwkkH6ZWGO9xlR49VkvwPQca 2OWP6LYt8bjjuae2HbZtDLlnUUxg9hyBZ3Tab7+kco1pEvjm8amPeNo/vB8tnHoKuC/f osU7cp8jo9fuiCgx2gnqMvY8YwbIvSwWOeRu69KLeIDge8fD7apQlnGXxhMdWkMo4DkJ TPaRjfdmSurvA3Z1DtkvyCCzdaJAuGreA+Qq6VgQCi2MjzeTh3HR9Sku8BrjE1ridMca 9wD6flJdxBTTDCw6VVeixHBdpAcO0E60+C6Q83JuIxJOhUJN1lJpAPXhmNsKGKcqtdpR qIVw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=Hz0q7EuU; 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=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id 17-20020a170902e9d100b0018965245cbesi15721780plk.339.2022.12.28.01.20.57; Wed, 28 Dec 2022 01:21:09 -0800 (PST) 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; dkim=pass header.i=@intel.com header.s=Intel header.b=Hz0q7EuU; 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=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231533AbiL1JUo (ORCPT + 99 others); Wed, 28 Dec 2022 04:20:44 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:34800 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232676AbiL1JUe (ORCPT ); Wed, 28 Dec 2022 04:20:34 -0500 Received: from mga17.intel.com (mga17.intel.com [192.55.52.151]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id C3D91DF02; Wed, 28 Dec 2022 01:20:33 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1672219233; x=1703755233; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=GY6NY1HpIaYGhu1PBgNFe1uObbv63oyykWwXwJ1FhnY=; b=Hz0q7EuUnWgePoRMMiBY22ePeAiDf0Lz47X5Ke93N35tdgxsdKHUH05h SGmpBe4ZRrS8pxr+DFRBUFjLJ3M7pY9dGHnS5PESNcWkDqaPARkN1a4/W sBVSnr2imEVFd4jI1lBrici1rPgMT3k+2/IhDWttBQEOh9DLoBpF5OnO2 eTKFvdgtfuFF2AjBYg+4jkabKDFaP2yWXfn1BZWagjtiYfzdOFrxWGjCf olEBPoKVd23VEN+t86ycUncojwB6Qs17X1Ynwmn48IBLBl5uyVmUWtQeu Rp5MbE+1BSkADXXQ1mdTx+7H8kqNB4IFEvpdkBlc/B37DnhPBPO0S91y5 Q==; X-IronPort-AV: E=McAfee;i="6500,9779,10573"; a="301202856" X-IronPort-AV: E=Sophos;i="5.96,280,1665471600"; d="scan'208";a="301202856" Received: from orsmga003.jf.intel.com ([10.7.209.27]) by fmsmga107.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 28 Dec 2022 01:20:33 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6500,9779,10573"; a="603285114" X-IronPort-AV: E=Sophos;i="5.96,280,1665471600"; d="scan'208";a="603285114" Received: from black.fi.intel.com ([10.237.72.28]) by orsmga003.jf.intel.com with ESMTP; 28 Dec 2022 01:20:31 -0800 Received: by black.fi.intel.com (Postfix, from userid 1003) id 735381CA; Wed, 28 Dec 2022 11:21:02 +0200 (EET) From: Andy Shevchenko To: Andy Shevchenko , Dmitry Torokhov , Bartosz Golaszewski , Linus Walleij , linux-gpio@vger.kernel.org, linux-acpi@vger.kernel.org, linux-kernel@vger.kernel.org Cc: Mika Westerberg , Bartosz Golaszewski Subject: [PATCH v4 3/3] gpiolib: sort header inclusion alphabetically Date: Wed, 28 Dec 2022 11:20:45 +0200 Message-Id: <20221228092045.80425-4-andriy.shevchenko@linux.intel.com> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20221228092045.80425-1-andriy.shevchenko@linux.intel.com> References: <20221228092045.80425-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 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-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1753448992904919464?= X-GMAIL-MSGID: =?utf-8?q?1753448992904919464?= Sort header inclusion alphabetically. Signed-off-by: Andy Shevchenko --- drivers/gpio/gpiolib.c | 35 ++++++++++++++++++----------------- 1 file changed, 18 insertions(+), 17 deletions(-) diff --git a/drivers/gpio/gpiolib.c b/drivers/gpio/gpiolib.c index e72c539fbec5..ace11a89d24a 100644 --- a/drivers/gpio/gpiolib.c +++ b/drivers/gpio/gpiolib.c @@ -1,34 +1,35 @@ // SPDX-License-Identifier: GPL-2.0 +#include #include -#include -#include -#include -#include -#include -#include +#include +#include #include #include -#include -#include +#include +#include #include -#include -#include -#include #include #include +#include +#include +#include +#include +#include +#include #include -#include -#include -#include +#include +#include +#include + #include -#include "gpiolib.h" -#include "gpiolib-of.h" #include "gpiolib-acpi.h" -#include "gpiolib-swnode.h" #include "gpiolib-cdev.h" +#include "gpiolib-of.h" +#include "gpiolib-swnode.h" #include "gpiolib-sysfs.h" +#include "gpiolib.h" #define CREATE_TRACE_POINTS #include