From patchwork Fri May 31 14:15:33 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Heikki Krogerus X-Patchwork-Id: 10970325 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id C417E18A6 for ; Fri, 31 May 2019 14:17:06 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id ABA2F28B02 for ; Fri, 31 May 2019 14:17:06 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id A004428D30; Fri, 31 May 2019 14:17:06 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-7.9 required=2.0 tests=BAYES_00,MAILING_LIST_MULTI, RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 4D1DC28B02 for ; Fri, 31 May 2019 14:17:06 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726832AbfEaOPz (ORCPT ); Fri, 31 May 2019 10:15:55 -0400 Received: from mga05.intel.com ([192.55.52.43]:8345 "EHLO mga05.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726828AbfEaOPz (ORCPT ); Fri, 31 May 2019 10:15:55 -0400 X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from fmsmga001.fm.intel.com ([10.253.24.23]) by fmsmga105.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 31 May 2019 07:15:54 -0700 X-ExtLoop1: 1 Received: from black.fi.intel.com (HELO black.fi.intel.com.) ([10.237.72.28]) by fmsmga001.fm.intel.com with ESMTP; 31 May 2019 07:15:53 -0700 From: Heikki Krogerus To: "Rafael J. Wysocki" Cc: Hans de Goede , Greg Kroah-Hartman , Andy Shevchenko , linux-acpi@vger.kernel.org, linux-kernel@vger.kernel.org, platform-driver-x86@vger.kernel.org Subject: [PATCH v5 02/16] software node: Simplify software_node_release() function Date: Fri, 31 May 2019 17:15:33 +0300 Message-Id: <20190531141547.22728-3-heikki.krogerus@linux.intel.com> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20190531141547.22728-1-heikki.krogerus@linux.intel.com> References: <20190531141547.22728-1-heikki.krogerus@linux.intel.com> MIME-Version: 1.0 Sender: platform-driver-x86-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: platform-driver-x86@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP It's possible to release the node ID immediately when fwnode_remove_software_node() is called, no need to wait for software_node_release() with that. Signed-off-by: Heikki Krogerus Tested-by: Hans de Goede --- drivers/base/swnode.c | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/drivers/base/swnode.c b/drivers/base/swnode.c index 30077454eb68..7b321bf8424c 100644 --- a/drivers/base/swnode.c +++ b/drivers/base/swnode.c @@ -557,13 +557,6 @@ static void software_node_release(struct kobject *kobj) { struct software_node *swnode = kobj_to_swnode(kobj); - if (swnode->parent) { - ida_simple_remove(&swnode->parent->child_ids, swnode->id); - list_del(&swnode->entry); - } else { - ida_simple_remove(&swnode_root_ids, swnode->id); - } - ida_destroy(&swnode->child_ids); property_entries_free(swnode->properties); kfree(swnode); @@ -610,9 +603,6 @@ fwnode_create_software_node(const struct property_entry *properties, INIT_LIST_HEAD(&swnode->children); swnode->parent = p; - if (p) - list_add_tail(&swnode->entry, &p->children); - ret = kobject_init_and_add(&swnode->kobj, &software_node_type, p ? &p->kobj : NULL, "node%d", swnode->id); if (ret) { @@ -626,6 +616,9 @@ fwnode_create_software_node(const struct property_entry *properties, return ERR_PTR(ret); } + if (p) + list_add_tail(&swnode->entry, &p->children); + kobject_uevent(&swnode->kobj, KOBJ_ADD); return &swnode->fwnode; } @@ -638,6 +631,13 @@ void fwnode_remove_software_node(struct fwnode_handle *fwnode) if (!swnode) return; + if (swnode->parent) { + ida_simple_remove(&swnode->parent->child_ids, swnode->id); + list_del(&swnode->entry); + } else { + ida_simple_remove(&swnode_root_ids, swnode->id); + } + kobject_put(&swnode->kobj); } EXPORT_SYMBOL_GPL(fwnode_remove_software_node);