From patchwork Mon Mar 30 08:59:54 2009 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Taku Izumi X-Patchwork-Id: 15104 Received: from vger.kernel.org (vger.kernel.org [209.132.176.167]) by demeter.kernel.org (8.14.2/8.14.2) with ESMTP id n2U90GVO011569 for ; Mon, 30 Mar 2009 09:00:16 GMT Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754087AbZC3JAG (ORCPT ); Mon, 30 Mar 2009 05:00:06 -0400 Received: (majordomo@vger.kernel.org) by vger.kernel.org id S1754449AbZC3JAG (ORCPT ); Mon, 30 Mar 2009 05:00:06 -0400 Received: from fgwmail5.fujitsu.co.jp ([192.51.44.35]:40392 "EHLO fgwmail5.fujitsu.co.jp" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754087AbZC3JAE (ORCPT ); Mon, 30 Mar 2009 05:00:04 -0400 Received: from m2.gw.fujitsu.co.jp ([10.0.50.72]) by fgwmail5.fujitsu.co.jp (Fujitsu Gateway) with ESMTP id n2U900SP004789 for (envelope-from izumi.taku@jp.fujitsu.com); Mon, 30 Mar 2009 18:00:00 +0900 Received: from smail (m2 [127.0.0.1]) by outgoing.m2.gw.fujitsu.co.jp (Postfix) with ESMTP id 5051C45DE61 for ; Mon, 30 Mar 2009 18:00:00 +0900 (JST) Received: from s2.gw.fujitsu.co.jp (s2.gw.fujitsu.co.jp [10.0.50.92]) by m2.gw.fujitsu.co.jp (Postfix) with ESMTP id EB1FB45DE55 for ; Mon, 30 Mar 2009 17:59:59 +0900 (JST) Received: from s2.gw.fujitsu.co.jp (localhost.localdomain [127.0.0.1]) by s2.gw.fujitsu.co.jp (Postfix) with ESMTP id 8E4841DB803F for ; Mon, 30 Mar 2009 17:59:59 +0900 (JST) Received: from m108.s.css.fujitsu.com (m108.s.css.fujitsu.com [10.249.87.108]) by s2.gw.fujitsu.co.jp (Postfix) with ESMTP id 46204E18001 for ; Mon, 30 Mar 2009 17:59:59 +0900 (JST) Received: from m108.css.fujitsu.com (m108 [127.0.0.1]) by m108.s.css.fujitsu.com (Postfix) with ESMTP id 159C642805A; Mon, 30 Mar 2009 17:59:59 +0900 (JST) Received: from [127.0.0.1] (unknown [10.124.100.133]) by m108.s.css.fujitsu.com (Postfix) with ESMTP id 70D77428059; Mon, 30 Mar 2009 17:59:58 +0900 (JST) Message-ID: <49D08A0A.2070102@jp.fujitsu.com> Date: Mon, 30 Mar 2009 17:59:54 +0900 From: Taku Izumi User-Agent: Thunderbird 1.5.0.8 (Windows/20061025) MIME-Version: 1.0 To: Kenji Kaneshige , linux-pci@vger.kernel.org CC: jbarnes@virtuousgeek.org, greg@kroah.com Subject: Re: pci_hotplug: create the symlink to the hotplug driver at the hotplug slot directory References: <49CC80C1.2090101@jp.fujitsu.com> <49CCF4F2.9040704@jp.fujitsu.com> In-Reply-To: <49CCF4F2.9040704@jp.fujitsu.com> Sender: linux-pci-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-pci@vger.kernel.org This patch creates the symlink to the hotplug driver at the hotplug slot directory (/sys/bus/pci/slots/). As a result, we can know easily what driver manages the hotplug slot. - change the symlink name from driver name to "driver" according to Kenji-san's comment. Signed-off-by: Taku Izumi --- drivers/pci/hotplug/pci_hotplug_core.c | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) -- 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 Index: linux-next.29rc6/drivers/pci/hotplug/pci_hotplug_core.c =================================================================== --- linux-next.29rc6.orig/drivers/pci/hotplug/pci_hotplug_core.c +++ linux-next.29rc6/drivers/pci/hotplug/pci_hotplug_core.c @@ -420,9 +420,20 @@ static int has_test_file(struct pci_slot return -ENOENT; } +static int has_owner_file(struct pci_slot *pci_slot) +{ + struct hotplug_slot *slot = pci_slot->hotplug; + if ((!slot) || (!slot->ops)) + return -ENODEV; + if (slot->ops->owner) + return 0; + return -ENOENT; +} + static int fs_add_slot(struct pci_slot *slot) { int retval = 0; + struct hotplug_slot *hotplug = slot->hotplug; if (has_power_file(slot) == 0) { retval = sysfs_create_file(&slot->kobj, &hotplug_slot_attr_power.attr); @@ -472,8 +483,20 @@ static int fs_add_slot(struct pci_slot * goto exit_test; } + if (has_owner_file(slot) == 0) { + retval = sysfs_create_link(&slot->kobj, + &hotplug->ops->owner->mkobj.kobj, + "driver"); + if (retval) + goto exit_owner; + } + goto exit; +exit_owner: + if (has_test_file(slot) == 0) + sysfs_remove_file(&slot->kobj, &hotplug_slot_attr_test.attr); + exit_test: if (has_cur_bus_speed_file(slot) == 0) sysfs_remove_file(&slot->kobj, &hotplug_slot_attr_cur_bus_speed.attr); @@ -524,6 +547,9 @@ static void fs_remove_slot(struct pci_sl if (has_test_file(slot) == 0) sysfs_remove_file(&slot->kobj, &hotplug_slot_attr_test.attr); + + if (has_owner_file(slot) == 0) + sysfs_remove_link(&slot->kobj, "driver"); } static struct hotplug_slot *get_slot_from_name (const char *name)