From patchwork Wed Apr 10 15:24:55 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Heikki Krogerus X-Patchwork-Id: 10894259 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 6C7C613B5 for ; Wed, 10 Apr 2019 15:26:24 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 529F128A2E for ; Wed, 10 Apr 2019 15:26:24 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 44CE328C06; Wed, 10 Apr 2019 15:26:24 +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 180E328A2E for ; Wed, 10 Apr 2019 15:26:23 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1730651AbfDJPZR (ORCPT ); Wed, 10 Apr 2019 11:25:17 -0400 Received: from mga06.intel.com ([134.134.136.31]:15566 "EHLO mga06.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1730541AbfDJPZO (ORCPT ); Wed, 10 Apr 2019 11:25:14 -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 orsmga104.jf.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 10 Apr 2019 08:25:13 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.60,332,1549958400"; d="scan'208";a="163102922" Received: from black.fi.intel.com (HELO black.fi.intel.com.) ([10.237.72.28]) by fmsmga001.fm.intel.com with ESMTP; 10 Apr 2019 08:25:11 -0700 From: Heikki Krogerus To: "Rafael J. Wysocki" Cc: Greg Kroah-Hartman , Hans de Goede , Darren Hart , Andy Shevchenko , linux-acpi@vger.kernel.org, linux-kernel@vger.kernel.org, platform-driver-x86@vger.kernel.org Subject: [PATCH v2 02/12] software node: Simplify software_node_release() function Date: Wed, 10 Apr 2019 18:24:55 +0300 Message-Id: <20190410152505.87041-3-heikki.krogerus@linux.intel.com> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20190410152505.87041-1-heikki.krogerus@linux.intel.com> References: <20190410152505.87041-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. This change has no functional effect. Signed-off-by: Heikki Krogerus --- 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);