From patchwork Tue Oct 8 20:20:16 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bjorn Helgaas X-Patchwork-Id: 281618 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by ozlabs.org (Postfix) with ESMTP id 4C9C22C00AB for ; Wed, 9 Oct 2013 07:20:42 +1100 (EST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1755103Ab3JHUUk (ORCPT ); Tue, 8 Oct 2013 16:20:40 -0400 Received: from mail-gg0-f182.google.com ([209.85.161.182]:63473 "EHLO mail-gg0-f182.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754063Ab3JHUUU (ORCPT ); Tue, 8 Oct 2013 16:20:20 -0400 Received: by mail-gg0-f182.google.com with SMTP id h13so1551534ggd.41 for ; Tue, 08 Oct 2013 13:20:19 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20120113; h=subject:to:from:cc:date:message-id:in-reply-to:references :user-agent:mime-version:content-type:content-transfer-encoding; bh=GlKJ8Yyu6jExi0Uchi+aTpD4ypgsfHOdYR3wqlxNmzY=; b=Z5RJJft1uctNcijHjVK9Yxq3aLXCQ/HM2GwuXqLGZ58WVFkWk5mMssL1eLQihU3BrL mXg3w3N3zaG7GivuOJl7VNctJdac4Krjt59tASXnpENIXYe+TFwIwp0J8lK+a6bHTIZT fBl8v3yAzfvsUi9ixgfb9rQ0JzH2RwGiZxHmLJvZXh8gmeafrMwqLiJOZQqptQMjz57F ER0VB34qgbV7BqM20UU4Rint9CIHg6WEwaquBoxC9lwcjsMV1PuJiOqbT3ndZr/MOuUB UP6TT4AuZZzzPZih2xKJkMb9uccb01g/rs5GmHhXPeddIXkINsxCywMZjHcXjhpHVvLR 0dUw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:subject:to:from:cc:date:message-id:in-reply-to :references:user-agent:mime-version:content-type :content-transfer-encoding; bh=GlKJ8Yyu6jExi0Uchi+aTpD4ypgsfHOdYR3wqlxNmzY=; b=BKlrkR0UGpq71fYnJANb4AZ019HBkuV8kZqlMknkiJbk8NgX22GAdmz/5+VXbrlQyS C1tSbVenj+JxP2sQnADBtXCIzWQP5IaECtBEavWdiKf9psGIpDGX9GLO4bOk1WU7OYnf WKZjfdp5FFNwjOyCk+6tlRPpSRYaa5PogzA9KT3fTtztnqxBSsiS8jZtgmrQDQXMFceq 9CPlJgX5xM5z64pZhV9oF1bfdQzw71Z2/TJYbSHWb+cOnIPsqJU5O+HLRdGX3r+nhbKq NcmnFrSI42o862PwizJCeC/XGuVHJuLG/CaX69PFRuWTVlPyAQOrkPgOZ+WfrdBfK+8o WsEQ== X-Gm-Message-State: ALoCoQnoUX5CXncmfIvnEdRfX583hADoTCtFiiebP/vzn7eCDee5cRDImWketaXdcMot2TV7jBdgP9TeQ3BYflGV9mDLyBwyLVPM5fRTdkxmTtJEfaPhKS0nuM0f9R8689Oe57tecjimCOTokgB92FnBXkQub62XiTnKPt9evfEqk9JqQXFGUQQevYMbAgzfphHADxefOgqW8dnQ5TDaQaec6hMAJWoiZg== X-Received: by 10.236.207.73 with SMTP id m49mr3027857yho.5.1381263619173; Tue, 08 Oct 2013 13:20:19 -0700 (PDT) Received: from localhost ([192.168.198.25]) by mx.google.com with ESMTPSA id a21sm54886003yhc.23.1969.12.31.16.00.00 (version=TLSv1.2 cipher=RC4-SHA bits=128/128); Tue, 08 Oct 2013 13:20:18 -0700 (PDT) Subject: [PATCH 1/2] kobject: remove kset from sysfs immediately in kset_unregister() To: Greg Kroah-Hartman From: Bjorn Helgaas Cc: Veaceslav Falico , Russell King , Neil Horman , linux-pci@vger.kernel.org, linux-kernel@vger.kernel.org, Zdenek Kabelac Date: Tue, 08 Oct 2013 14:20:16 -0600 Message-ID: <20131008202016.19377.17182.stgit@bhelgaas-glaptop.roam.corp.google.com> In-Reply-To: <20131008201915.19377.34185.stgit@bhelgaas-glaptop.roam.corp.google.com> References: <20131008201915.19377.34185.stgit@bhelgaas-glaptop.roam.corp.google.com> User-Agent: StGit/0.16 MIME-Version: 1.0 Sender: linux-pci-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-pci@vger.kernel.org There's no explicit "unlink from sysfs" interface for ksets, so I think callers of kset_unregister() expect the kset to be removed from sysfs immediately, without waiting for the last reference to be released. This patch makes the sysfs removal happen immediately, so the caller may create a new kset with the same name as soon as kset_unregister() returns. Signed-off-by: Bjorn Helgaas --- Documentation/kobject.txt | 3 ++- lib/kobject.c | 1 + 2 files changed, 3 insertions(+), 1 deletion(-) -- To unsubscribe from this list: send the line "unsubscribe linux-pci" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html diff --git a/Documentation/kobject.txt b/Documentation/kobject.txt index c5182bb..8e8b501 100644 --- a/Documentation/kobject.txt +++ b/Documentation/kobject.txt @@ -342,7 +342,8 @@ kset use: When you are finished with the kset, call: void kset_unregister(struct kset *kset); -to destroy it. +to destroy it. This removes the kset from sysfs and, after the kset +reference count goes to zero, releases it. An example of using a kset can be seen in the samples/kobject/kset-example.c file in the kernel tree. diff --git a/lib/kobject.c b/lib/kobject.c index 9621751..9098992 100644 --- a/lib/kobject.c +++ b/lib/kobject.c @@ -753,6 +753,7 @@ void kset_unregister(struct kset *k) { if (!k) return; + kobject_del(&k->kobj); kobject_put(&k->kobj); }