Commit 17445dc8 authored by James Bottomley's avatar James Bottomley

add mca-driver handling

Tidies up the handling of MCA drivers
parent 30e8f697
# Makefile for the Linux MCA bus support
obj-y := mca-bus.o mca-device.o mca-legacy.o
obj-y := mca-bus.o mca-device.o mca-driver.o mca-legacy.o
obj-$(CONFIG_PROC_FS) += mca-proc.o
export-objs := mca-bus.o mca-legacy.o mca-proc.o
export-objs := mca-bus.o mca-legacy.o mca-proc.o mca-driver.o
include $(TOPDIR)/Rules.make
......@@ -30,8 +30,6 @@
#include <linux/module.h>
#include <linux/init.h>
#include <linux/slab.h>
#include <linux/list.h>
#include <asm/io.h>
/* Very few machines have more than one MCA bus. However, there are
* those that do (Voyager 35xx/5xxx), so we do it this way for future
......@@ -50,15 +48,16 @@ static int mca_bus_match (struct device *dev, struct device_driver *drv)
struct mca_device *mca_dev = to_mca_device (dev);
struct mca_driver *mca_drv = to_mca_driver (drv);
const short *mca_ids = mca_drv->id_table;
int i;
if (!mca_ids)
return 0;
while (*mca_ids) {
if (*mca_ids == mca_dev->pos_id)
for(i = 0; mca_ids[i]; i++) {
if (mca_ids[i] == mca_dev->pos_id) {
mca_dev->index = i;
return 1;
mca_ids++;
}
}
return 0;
......@@ -70,24 +69,6 @@ struct bus_type mca_bus_type = {
};
EXPORT_SYMBOL (mca_bus_type);
int mca_driver_register (struct mca_driver *mca_drv)
{
int r;
mca_drv->driver.bus = &mca_bus_type;
if ((r = driver_register (&mca_drv->driver)) < 0)
return r;
return 1;
}
void mca_driver_unregister (struct mca_driver *mca_drv)
{
bus_remove_driver (&mca_drv->driver);
driver_unregister (&mca_drv->driver);
}
static ssize_t mca_show_pos_id(struct device *dev, char *buf, size_t count,
loff_t off)
{
......@@ -135,7 +116,7 @@ static ssize_t mca_show_pos(struct device *dev, char *buf, size_t count,
static DEVICE_ATTR(id, S_IRUGO, mca_show_pos_id, NULL);
static DEVICE_ATTR(pos, S_IRUGO, mca_show_pos, NULL);
int __init mca_register_device (int bus, struct mca_device *mca_dev)
int __init mca_register_device(int bus, struct mca_device *mca_dev)
{
struct mca_bus *mca_bus = mca_root_busses[bus];
......@@ -184,6 +165,3 @@ int __init mca_system_init (void)
{
return bus_register(&mca_bus_type);
}
EXPORT_SYMBOL (mca_driver_register);
EXPORT_SYMBOL (mca_driver_unregister);
......@@ -52,6 +52,9 @@ struct mca_device {
int pos_id;
int slot;
/* index into id_table, set by the bus match routine */
int index;
/* is there a driver installed? 0 - No, 1 - Yes */
int driver_loaded;
/* POS registers */
......@@ -100,8 +103,6 @@ struct mca_driver {
#define to_mca_driver(mdriver) container_of(mdriver, struct mca_driver, driver)
/* Ongoing supported API functions */
extern int mca_driver_register(struct mca_driver *);
extern int mca_register_device(int bus, struct mca_device *);
extern struct mca_device *mca_find_device_by_slot(int slot);
extern int mca_system_init(void);
extern struct mca_bus *mca_attach_bus(int);
......@@ -121,10 +122,11 @@ extern enum MCA_AdapterStatus mca_device_status(struct mca_device *mca_dev);
extern struct bus_type mca_bus_type;
static inline void mca_register_driver(struct mca_driver *drv)
{
driver_register(&drv->driver);
}
extern int mca_register_driver(struct mca_driver *drv);
extern void mca_unregister_driver(struct mca_driver *drv);
/* WARNING: only called by the boot time device setup */
extern int mca_register_device(int bus, struct mca_device *mca_dev);
/* for now, include the legacy API */
#include <linux/mca-legacy.h>
......
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