Commit 8813d1c00ca923c1683da625ff85959be1db9a49
Committed by
Linus Torvalds
1 parent
809aa5048f
Exists in
master
and in
39 other branches
mca: add integrated device bus matching
The MCA bus has a few "integrated" functions, which are effectively virtual slots on the bus. The problem is that these special functions don't have dedicated pos IDs, so we have to manufacture ids for them outside the pos space ... and these ids can't be matched by the standard matching function, so add a special registration that requests a list of pos ids or a particular integrated function. Signed-off-by: James Bottomley <James.Bottomley@SteelEye.com> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Showing 3 changed files with 31 additions and 10 deletions Side-by-side Diff
drivers/mca/mca-bus.c
... | ... | @@ -48,18 +48,24 @@ |
48 | 48 | struct mca_device *mca_dev = to_mca_device (dev); |
49 | 49 | struct mca_driver *mca_drv = to_mca_driver (drv); |
50 | 50 | const unsigned short *mca_ids = mca_drv->id_table; |
51 | - int i; | |
51 | + int i = 0; | |
52 | 52 | |
53 | - if (!mca_ids) | |
54 | - return 0; | |
55 | - | |
56 | - for(i = 0; mca_ids[i]; i++) { | |
57 | - if (mca_ids[i] == mca_dev->pos_id) { | |
58 | - mca_dev->index = i; | |
59 | - return 1; | |
53 | + if (mca_ids) { | |
54 | + for(i = 0; mca_ids[i]; i++) { | |
55 | + if (mca_ids[i] == mca_dev->pos_id) { | |
56 | + mca_dev->index = i; | |
57 | + return 1; | |
58 | + } | |
60 | 59 | } |
61 | 60 | } |
62 | - | |
61 | + /* If the integrated id is present, treat it as though it were an | |
62 | + * additional id in the id_table (it can't be because by definition, | |
63 | + * integrated id's overflow a short */ | |
64 | + if (mca_drv->integrated_id && mca_dev->pos_id == | |
65 | + mca_drv->integrated_id) { | |
66 | + mca_dev->index = i; | |
67 | + return 1; | |
68 | + } | |
63 | 69 | return 0; |
64 | 70 | } |
65 | 71 |
drivers/mca/mca-driver.c
... | ... | @@ -36,11 +36,24 @@ |
36 | 36 | mca_drv->driver.bus = &mca_bus_type; |
37 | 37 | if ((r = driver_register(&mca_drv->driver)) < 0) |
38 | 38 | return r; |
39 | + mca_drv->integrated_id = 0; | |
39 | 40 | } |
40 | 41 | |
41 | 42 | return 0; |
42 | 43 | } |
43 | 44 | EXPORT_SYMBOL(mca_register_driver); |
45 | + | |
46 | +int mca_register_driver_integrated(struct mca_driver *mca_driver, | |
47 | + int integrated_id) | |
48 | +{ | |
49 | + int r = mca_register_driver(mca_driver); | |
50 | + | |
51 | + if (!r) | |
52 | + mca_driver->integrated_id = integrated_id; | |
53 | + | |
54 | + return r; | |
55 | +} | |
56 | +EXPORT_SYMBOL(mca_register_driver_integrated); | |
44 | 57 | |
45 | 58 | void mca_unregister_driver(struct mca_driver *mca_drv) |
46 | 59 | { |
include/linux/mca.h
... | ... | @@ -94,6 +94,7 @@ |
94 | 94 | struct mca_driver { |
95 | 95 | const short *id_table; |
96 | 96 | void *driver_data; |
97 | + int integrated_id; | |
97 | 98 | struct device_driver driver; |
98 | 99 | }; |
99 | 100 | #define to_mca_driver(mdriver) container_of(mdriver, struct mca_driver, driver) |
... | ... | @@ -125,6 +126,7 @@ |
125 | 126 | extern struct bus_type mca_bus_type; |
126 | 127 | |
127 | 128 | extern int mca_register_driver(struct mca_driver *drv); |
129 | +extern int mca_register_driver_integrated(struct mca_driver *, int); | |
128 | 130 | extern void mca_unregister_driver(struct mca_driver *drv); |
129 | 131 | |
130 | 132 | /* WARNING: only called by the boot time device setup */ |