Commit 30b2a7d6 authored by Greg Kroah-Hartman's avatar Greg Kroah-Hartman

[PATCH] Compaq PCI Hotplug: move /proc files to sysfs

parent 43919624
...@@ -403,31 +403,8 @@ struct resource_lists { ...@@ -403,31 +403,8 @@ struct resource_lists {
#define msg_button_ignore "PCI slot #%d - button press ignored. (action in progress...)\n" #define msg_button_ignore "PCI slot #%d - button press ignored. (action in progress...)\n"
/* Proc functions for the hotplug controller info */ /* sysfs functions for the hotplug controller info */
#ifdef CONFIG_PROC_FS extern void cpqhp_create_ctrl_files (struct controller *ctrl);
extern int cpqhp_proc_init_ctrl (void);
extern int cpqhp_proc_destroy_ctrl (void);
extern int cpqhp_proc_create_ctrl (struct controller *ctrl);
extern int cpqhp_proc_remove_ctrl (struct controller *ctrl);
#else
static inline int cpqhp_proc_init_ctrl (void)
{
return 0;
}
static inline int cpqhp_proc_destroy_ctrl (void)
{
return 0;
}
static inline int cpqhp_proc_create_ctrl (struct controller *ctrl)
{
return 0;
}
static inline int cpqhp_proc_remove_ctrl (struct controller *ctrl)
{
return 0;
}
#endif
/* controller functions */ /* controller functions */
extern void cpqhp_pushbutton_thread (unsigned long event_pointer); extern void cpqhp_pushbutton_thread (unsigned long event_pointer);
......
...@@ -1038,6 +1038,7 @@ static int cpqhpc_probe(struct pci_dev *pdev, const struct pci_device_id *ent) ...@@ -1038,6 +1038,7 @@ static int cpqhpc_probe(struct pci_dev *pdev, const struct pci_device_id *ent)
dbg (" pcix_support %s\n", ctrl->pcix_support == 0 ? "not supported" : "supported"); dbg (" pcix_support %s\n", ctrl->pcix_support == 0 ? "not supported" : "supported");
ctrl->pci_dev = pdev; ctrl->pci_dev = pdev;
pci_set_drvdata(pdev, ctrl);
/* make our own copy of the pci bus structure, as we like tweaking it a lot */ /* make our own copy of the pci bus structure, as we like tweaking it a lot */
ctrl->pci_bus = kmalloc (sizeof (*ctrl->pci_bus), GFP_KERNEL); ctrl->pci_bus = kmalloc (sizeof (*ctrl->pci_bus), GFP_KERNEL);
...@@ -1231,11 +1232,7 @@ static int cpqhpc_probe(struct pci_dev *pdev, const struct pci_device_id *ent) ...@@ -1231,11 +1232,7 @@ static int cpqhpc_probe(struct pci_dev *pdev, const struct pci_device_id *ent)
// Done with exclusive hardware access // Done with exclusive hardware access
up(&ctrl->crit_sect); up(&ctrl->crit_sect);
rc = cpqhp_proc_create_ctrl (ctrl); cpqhp_create_ctrl_files (ctrl);
if (rc) {
err("cpqhp_proc_create_ctrl failed\n");
goto err_free_irq;
}
return 0; return 0;
...@@ -1309,10 +1306,6 @@ static int one_time_init(void) ...@@ -1309,10 +1306,6 @@ static int one_time_init(void)
goto error; goto error;
} }
retval = cpqhp_proc_init_ctrl();
if (retval)
goto error;
initialized = 1; initialized = 1;
return retval; return retval;
...@@ -1343,8 +1336,6 @@ static void unload_cpqphpd(void) ...@@ -1343,8 +1336,6 @@ static void unload_cpqphpd(void)
ctrl = cpqhp_ctrl_list; ctrl = cpqhp_ctrl_list;
while (ctrl) { while (ctrl) {
cpqhp_proc_remove_ctrl (ctrl);
if (ctrl->hpc_reg) { if (ctrl->hpc_reg) {
u16 misc; u16 misc;
rc = read_slot_enable (ctrl); rc = read_slot_enable (ctrl);
...@@ -1431,8 +1422,6 @@ static void unload_cpqphpd(void) ...@@ -1431,8 +1422,6 @@ static void unload_cpqphpd(void)
} }
} }
remove_proc_entry("hpc", 0);
// Stop the notification mechanism // Stop the notification mechanism
cpqhp_event_stop_thread(); cpqhp_event_stop_thread();
...@@ -1490,9 +1479,6 @@ static int __init cpqhpc_init(void) ...@@ -1490,9 +1479,6 @@ static int __init cpqhpc_init(void)
static void __exit cpqhpc_cleanup(void) static void __exit cpqhpc_cleanup(void)
{ {
dbg("cleaning up proc entries\n");
cpqhp_proc_destroy_ctrl();
dbg("unload_cpqphpd()\n"); dbg("unload_cpqphpd()\n");
unload_cpqphpd(); unload_cpqphpd();
......
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
* Compaq Hot Plug Controller Driver * Compaq Hot Plug Controller Driver
* *
* Copyright (c) 1995,2001 Compaq Computer Corporation * Copyright (c) 1995,2001 Compaq Computer Corporation
* Copyright (c) 2001 Greg Kroah-Hartman (greg@kroah.com) * Copyright (c) 2001,2003 Greg Kroah-Hartman (greg@kroah.com)
* Copyright (c) 2001 IBM Corp. * Copyright (c) 2001 IBM Corp.
* *
* All rights reserved. * All rights reserved.
...@@ -36,27 +36,20 @@ ...@@ -36,27 +36,20 @@
#include "cpqphp.h" #include "cpqphp.h"
/* A few routines that create sysfs entries for the hot plug controller */
static struct proc_dir_entry *ctrl_proc_root; static int show_ctrl (struct device *dev, char *buf)
/* A few routines that create proc entries for the hot plug controller */
static int read_ctrl (char *buf, char **start, off_t offset, int len, int *eof, void *data)
{ {
struct controller *ctrl = (struct controller *)data; struct pci_dev *pci_dev;
struct controller *ctrl;
char * out = buf; char * out = buf;
int index; int index;
struct pci_resource *res; struct pci_resource *res;
if (offset > 0) return 0; /* no partial requests */ pci_dev = container_of (dev, struct pci_dev, dev);
len = 0; ctrl = pci_get_drvdata(pci_dev);
*eof = 1;
out += sprintf(out, "hot plug ctrl Info Page\n"); out += sprintf(buf, "Free resources: memory\n");
out += sprintf(out, "bus = %d, device = %d, function = %d\n",
ctrl->bus, PCI_SLOT(ctrl->pci_dev->devfn),
PCI_FUNC(ctrl->pci_dev->devfn));
out += sprintf(out, "Free resources: memory\n");
index = 11; index = 11;
res = ctrl->mem_head; res = ctrl->mem_head;
while (res && index--) { while (res && index--) {
...@@ -85,29 +78,22 @@ static int read_ctrl (char *buf, char **start, off_t offset, int len, int *eof, ...@@ -85,29 +78,22 @@ static int read_ctrl (char *buf, char **start, off_t offset, int len, int *eof,
res = res->next; res = res->next;
} }
*start = buf; return out - buf;
len = out-buf;
return len;
} }
static DEVICE_ATTR (ctrl, S_IRUGO, show_ctrl, NULL);
static int read_dev (char *buf, char **start, off_t offset, int len, int *eof, void *data) static int show_dev (struct device *dev, char *buf)
{ {
struct controller *ctrl = (struct controller *)data; struct pci_dev *pci_dev;
struct controller *ctrl;
char * out = buf; char * out = buf;
int index; int index;
struct pci_resource *res; struct pci_resource *res;
struct pci_func *new_slot; struct pci_func *new_slot;
struct slot *slot; struct slot *slot;
if (offset > 0) return 0; /* no partial requests */ pci_dev = container_of (dev, struct pci_dev, dev);
len = 0; ctrl = pci_get_drvdata(pci_dev);
*eof = 1;
out += sprintf(out, "hot plug ctrl Info Page\n");
out += sprintf(out, "bus = %d, device = %d, function = %d\n",
ctrl->bus, PCI_SLOT(ctrl->pci_dev->devfn),
PCI_FUNC(ctrl->pci_dev->devfn));
slot=ctrl->slot; slot=ctrl->slot;
...@@ -146,52 +132,12 @@ static int read_dev (char *buf, char **start, off_t offset, int len, int *eof, v ...@@ -146,52 +132,12 @@ static int read_dev (char *buf, char **start, off_t offset, int len, int *eof, v
slot=slot->next; slot=slot->next;
} }
*start = buf; return out - buf;
len = out-buf;
return len;
} }
static DEVICE_ATTR (dev, S_IRUGO, show_dev, NULL);
int cpqhp_proc_create_ctrl (struct controller *ctrl) void cpqhp_create_ctrl_files (struct controller *ctrl)
{ {
strcpy(ctrl->proc_name, "hpca"); device_create_file (&ctrl->pci_dev->dev, &dev_attr_ctrl);
ctrl->proc_name[3] = 'a' + ctrl->bus; device_create_file (&ctrl->pci_dev->dev, &dev_attr_dev);
ctrl->proc_entry = create_proc_entry(ctrl->proc_name, S_IFREG | S_IRUGO, ctrl_proc_root);
ctrl->proc_entry->data = ctrl;
ctrl->proc_entry->read_proc = &read_ctrl;
strcpy(ctrl->proc_name2, "slot_a");
ctrl->proc_name2[5] = 'a' + ctrl->bus;
ctrl->proc_entry2 = create_proc_entry(ctrl->proc_name2, S_IFREG | S_IRUGO, ctrl_proc_root);
ctrl->proc_entry2->data = ctrl;
ctrl->proc_entry2->read_proc = &read_dev;
return 0;
} }
int cpqhp_proc_remove_ctrl (struct controller *ctrl)
{
if (ctrl->proc_entry)
remove_proc_entry(ctrl->proc_name, ctrl_proc_root);
if (ctrl->proc_entry2)
remove_proc_entry(ctrl->proc_name2, ctrl_proc_root);
return 0;
}
int cpqhp_proc_init_ctrl (void)
{
ctrl_proc_root = proc_mkdir("hpc", proc_root_driver);
if (!ctrl_proc_root)
return -ENOMEM;
ctrl_proc_root->owner = THIS_MODULE;
return 0;
}
int cpqhp_proc_destroy_ctrl (void)
{
remove_proc_entry("hpc", proc_root_driver);
return 0;
}
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment