From patchwork Tue Jan 7 17:59:47 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tejun Heo X-Patchwork-Id: 3449391 X-Patchwork-Delegate: bhelgaas@google.com Return-Path: X-Original-To: patchwork-linux-pci@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork1.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.19.201]) by patchwork1.web.kernel.org (Postfix) with ESMTP id 2A7529F2E9 for ; Tue, 7 Jan 2014 18:00:57 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 9A11F20149 for ; Tue, 7 Jan 2014 18:00:52 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 7582F20136 for ; Tue, 7 Jan 2014 18:00:51 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753889AbaAGSA2 (ORCPT ); Tue, 7 Jan 2014 13:00:28 -0500 Received: from mail-qa0-f50.google.com ([209.85.216.50]:65314 "EHLO mail-qa0-f50.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753830AbaAGSAS (ORCPT ); Tue, 7 Jan 2014 13:00:18 -0500 Received: by mail-qa0-f50.google.com with SMTP id k4so833084qaq.37 for ; Tue, 07 Jan 2014 10:00:17 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=sender:from:to:cc:subject:date:message-id:in-reply-to:references; bh=PK3CvSoQT96pXuHWNU1hK4rAASioH29XYlrb6HPPr1A=; b=ifoZd8/IwEuTe1QvwQZbKGv3WTDGe3S8nYr3A7moJgU//87O/I//+iItOEU/YUD75J PMULAWwf7CZ6+hXFm1Ls6LFzlTX/6CwcbBqNuhNN7P6On9Kw/fhsLKAnJxYej453EE7i XPhatqN6Ic95dVT6ISVaeB64cqbAvKthJIdSsSqnNFGR8BYsrmiBYQboPfwTUHAJIn6Y Ji9/SiBPKrLgNQYMX/k6LY9F8SnJhw3OTpM6fkOn6gi5rxUCxjhXCaoebAG7FEsrNbI5 fKLcLuB+/1Thf4kq3VxCavG62ertQFAKkFzqzrhzv0sf6GCb5nP4NmEgtj4JxTzwOUzy S3XQ== X-Received: by 10.224.43.72 with SMTP id v8mr190237196qae.52.1389117617141; Tue, 07 Jan 2014 10:00:17 -0800 (PST) Received: from htj.dyndns.org.com (207-38-225-25.c3-0.43d-ubr1.qens-43d.ny.cable.rcn.com. [207.38.225.25]) by mx.google.com with ESMTPSA id r9sm101615001qey.19.2014.01.07.10.00.15 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 07 Jan 2014 10:00:16 -0800 (PST) From: Tejun Heo To: gregkh@linuxfoundation.org Cc: linux-kernel@vger.kernel.org, schwidefsky@de.ibm.com, heiko.carstens@de.ibm.com, stern@rowland.harvard.edu, JBottomley@parallels.com, bhelgaas@google.com, Tejun Heo , linux-pci@vger.kernel.org Subject: [PATCH 09/12] pci: use device_remove_file_self() instead of device_schedule_callback() Date: Tue, 7 Jan 2014 12:59:47 -0500 Message-Id: <1389117590-25705-10-git-send-email-tj@kernel.org> X-Mailer: git-send-email 1.8.4.2 In-Reply-To: <1389117590-25705-1-git-send-email-tj@kernel.org> References: <1389117590-25705-1-git-send-email-tj@kernel.org> Sender: linux-pci-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-pci@vger.kernel.org X-Spam-Status: No, score=-6.8 required=5.0 tests=BAYES_00,DKIM_SIGNED, RCVD_IN_DNSWL_HI,RP_MATCHES_RCVD,T_DKIM_INVALID,UNPARSEABLE_RELAY autolearn=unavailable version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP driver-core now supports synchrnous self-deletion of attributes and the asynchrnous removal mechanism is scheduled for removal. Use it instead of device_schedule_callback(). This makes "remove" behave synchronously. Signed-off-by: Tejun Heo Cc: Bjorn Helgaas Cc: linux-pci@vger.kernel.org --- drivers/pci/pci-sysfs.c | 24 ++++++------------------ 1 file changed, 6 insertions(+), 18 deletions(-) diff --git a/drivers/pci/pci-sysfs.c b/drivers/pci/pci-sysfs.c index c91e6c1..94d1cb8 100644 --- a/drivers/pci/pci-sysfs.c +++ b/drivers/pci/pci-sysfs.c @@ -352,32 +352,20 @@ static struct device_attribute dev_rescan_attr = __ATTR(rescan, (S_IWUSR|S_IWGRP), NULL, dev_rescan_store); -static void remove_callback(struct device *dev) -{ - struct pci_dev *pdev = to_pci_dev(dev); - - mutex_lock(&pci_remove_rescan_mutex); - pci_stop_and_remove_bus_device(pdev); - mutex_unlock(&pci_remove_rescan_mutex); -} - static ssize_t -remove_store(struct device *dev, struct device_attribute *dummy, +remove_store(struct device *dev, struct device_attribute *attr, const char *buf, size_t count) { - int ret = 0; unsigned long val; if (kstrtoul(buf, 0, &val) < 0) return -EINVAL; - /* An attribute cannot be unregistered by one of its own methods, - * so we have to use this roundabout approach. - */ - if (val) - ret = device_schedule_callback(dev, remove_callback); - if (ret) - count = ret; + if (val && device_remove_file_self(dev, attr)) { + mutex_lock(&pci_remove_rescan_mutex); + pci_stop_and_remove_bus_device(to_pci_dev(dev)); + mutex_unlock(&pci_remove_rescan_mutex); + } return count; } static struct device_attribute dev_remove_attr = __ATTR(remove,