From patchwork Tue Jan 28 23:21:48 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tejun Heo X-Patchwork-Id: 3548491 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 B847C9F382 for ; Tue, 28 Jan 2014 23:23:21 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 4AFE020176 for ; Tue, 28 Jan 2014 23:23:20 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 6D44620171 for ; Tue, 28 Jan 2014 23:23:19 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754026AbaA1XWJ (ORCPT ); Tue, 28 Jan 2014 18:22:09 -0500 Received: from mail-qc0-f170.google.com ([209.85.216.170]:44291 "EHLO mail-qc0-f170.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1755888AbaA1XWH (ORCPT ); Tue, 28 Jan 2014 18:22:07 -0500 Received: by mail-qc0-f170.google.com with SMTP id e9so1708305qcy.29 for ; Tue, 28 Jan 2014 15:22:06 -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=CNo1wEiYPdu+xJMepznqtRsAnwZgxK1jOA3VCZoxvBhQEQAolKkpAb5dW57nWA/EOS KNkjexTxGPTu+BFNxEqc97ukBfrWUd/v8bonIDFOIuG7bF9Do4+bbnE9dLnrHk/XZ7Q+ Uc6Nwl4Qvn8NJgjwWp3EykxBSZatgbTUpbfvvO+J7rHC3AtLg7vXarUZmgkS2qzUwRn6 0f7t/pHnYn2rL4EoEvjfmZrjak5MuFpEJB+EpFFL3qEz7pBzPr13e4qbxq47Rcgh7IyA vNVJEJfX9eyFUn668a630aRUheWlI5jGYeFoD2JaaRHmdDcrICVujoJvcZxmhIGflRY1 +NCg== X-Received: by 10.224.52.3 with SMTP id f3mr7072543qag.26.1390951326869; Tue, 28 Jan 2014 15:22:06 -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 72sm415174qgv.19.2014.01.28.15.22.05 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 28 Jan 2014 15:22:06 -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 08/11] pci: use device_remove_file_self() instead of device_schedule_callback() Date: Tue, 28 Jan 2014 18:21:48 -0500 Message-Id: <1390951311-15325-9-git-send-email-tj@kernel.org> X-Mailer: git-send-email 1.8.5.3 In-Reply-To: <1390951311-15325-1-git-send-email-tj@kernel.org> References: <1390951311-15325-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=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 | 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,