From patchwork Mon Feb 3 19:03:02 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tejun Heo X-Patchwork-Id: 3570581 X-Patchwork-Delegate: bhelgaas@google.com Return-Path: X-Original-To: patchwork-linux-pci@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork2.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.19.201]) by patchwork2.web.kernel.org (Postfix) with ESMTP id 70DBCC02DC for ; Mon, 3 Feb 2014 19:04:18 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id AFB98201B9 for ; Mon, 3 Feb 2014 19:04:17 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id D68A720179 for ; Mon, 3 Feb 2014 19:04:16 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752608AbaBCTD2 (ORCPT ); Mon, 3 Feb 2014 14:03:28 -0500 Received: from mail-qa0-f49.google.com ([209.85.216.49]:36116 "EHLO mail-qa0-f49.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753409AbaBCTD0 (ORCPT ); Mon, 3 Feb 2014 14:03:26 -0500 Received: by mail-qa0-f49.google.com with SMTP id w8so10550720qac.36 for ; Mon, 03 Feb 2014 11:03:25 -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=a9NjVuFSnIpm/sKRSuS/b74W5OHqgYZ00SNLZPYudUE=; b=VB/Nzd6h5uen4WJqPtF8bWKN0IIiGqeuPc7AW6eKfyhCmaqV998iyGKjB0BswqEw4R 0C9lGp/F3qnNxLvgjQjAuPyLYilaoyp+1Srs1+vIlWlLG8Udjihk8kCYp2t/pnvhBGtG wSIKDraPawD4AeCYZY7O33yprdmf6pkoGN/pZzGZmEjIq8ODqajNh8KiBRLny822zoog Vhq/O6XUnNdQlRXzaWRZPYS2reHpjUXjic0ffnlm7NvDaUHWRN5WQmK/ffun8G1RpFVL iaLtemUDyFg3/RfoXK5r8NsU9Sj8i0UXP+jyNRD6f06i+lDDVYcVi1NY02DgZ4zWDLVW SPZw== X-Received: by 10.140.98.135 with SMTP id o7mr54297040qge.102.1391454205344; Mon, 03 Feb 2014 11:03:25 -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 g10sm59052242qaf.9.2014.02.03.11.03.23 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 03 Feb 2014 11:03:24 -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: Mon, 3 Feb 2014 14:03:02 -0500 Message-Id: <1391454185-32143-10-git-send-email-tj@kernel.org> X-Mailer: git-send-email 1.8.5.3 In-Reply-To: <1391454185-32143-1-git-send-email-tj@kernel.org> References: <1391454185-32143-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=-7.3 required=5.0 tests=BAYES_00,DKIM_SIGNED, RCVD_IN_DNSWL_HI,RP_MATCHES_RCVD,T_DKIM_INVALID,UNPARSEABLE_RELAY autolearn=ham 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 | 17 +++-------------- 1 file changed, 3 insertions(+), 14 deletions(-) diff --git a/drivers/pci/pci-sysfs.c b/drivers/pci/pci-sysfs.c index 276ef9c..4e0acef 100644 --- a/drivers/pci/pci-sysfs.c +++ b/drivers/pci/pci-sysfs.c @@ -351,28 +351,17 @@ static struct device_attribute dev_rescan_attr = __ATTR(rescan, (S_IWUSR|S_IWGRP), NULL, dev_rescan_store); -static void remove_callback(struct device *dev) -{ - pci_stop_and_remove_bus_device_locked(to_pci_dev(dev)); -} - 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)) + pci_stop_and_remove_bus_device_locked(to_pci_dev(dev)); return count; } static struct device_attribute dev_remove_attr = __ATTR(remove,