aboutsummaryrefslogtreecommitdiffstats
path: root/include/linux/nubus.h
diff options
context:
space:
mode:
authorFinn Thain <fthain@telegraphics.com.au>2018-01-13 17:37:14 -0500
committerGeert Uytterhoeven <geert@linux-m68k.org>2018-01-16 16:47:29 +0100
commit7f86c765a6a2bb837c45f11526176125ff50e21f (patch)
tree6279c4d31d2bd999852544da73e446e0c28f901d /include/linux/nubus.h
parentnubus: Add expansion_type values for various Mac models (diff)
downloadlinux-dev-7f86c765a6a2bb837c45f11526176125ff50e21f.tar.xz
linux-dev-7f86c765a6a2bb837c45f11526176125ff50e21f.zip
nubus: Add support for the driver model
This patch brings basic support for the Linux Driver Model to the NuBus subsystem. For flexibility, the matching of boards with drivers is left up to the drivers. This is also the approach taken by NetBSD. A board may have many functions, and drivers may have to consider many functional resources and board resources in order to match a device. This implementation does not bind drivers to resources (nor does it bind many drivers to the same board). Apple's NuBus declaration ROM design is flexible enough to allow that, but I don't see a need to support it as we don't use the "slot zero" resources (in the main logic board ROM). Eliminate the global nubus_boards linked list by rewriting the procfs board iterator around bus_for_each_dev(). Hence the nubus device refcount can be used to determine the lifespan of board objects. Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org> Reviewed-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org> Tested-by: Stan Johnson <userm57@yahoo.com> Signed-off-by: Finn Thain <fthain@telegraphics.com.au> Signed-off-by: Geert Uytterhoeven <geert@linux-m68k.org>
Diffstat (limited to 'include/linux/nubus.h')
-rw-r--r--include/linux/nubus.h33
1 files changed, 30 insertions, 3 deletions
diff --git a/include/linux/nubus.h b/include/linux/nubus.h
index 2cbc7a199bca..6e8200215321 100644
--- a/include/linux/nubus.h
+++ b/include/linux/nubus.h
@@ -10,6 +10,7 @@
#ifndef LINUX_NUBUS_H
#define LINUX_NUBUS_H
+#include <linux/device.h>
#include <asm/nubus.h>
#include <uapi/linux/nubus.h>
@@ -32,7 +33,7 @@ struct nubus_dirent {
};
struct nubus_board {
- struct nubus_board *next;
+ struct device dev;
/* Only 9-E actually exist, though 0-8 are also theoretically
possible, and 0 is a special case which represents the
@@ -81,8 +82,14 @@ struct nubus_rsrc {
/* This is all NuBus functional resources (used to find devices later on) */
extern struct list_head nubus_func_rsrcs;
-/* This is all NuBus cards */
-extern struct nubus_board *nubus_boards;
+
+struct nubus_driver {
+ struct device_driver driver;
+ int (*probe)(struct nubus_board *board);
+ int (*remove)(struct nubus_board *board);
+};
+
+extern struct bus_type nubus_bus_type;
/* Generic NuBus interface functions, modelled after the PCI interface */
#ifdef CONFIG_PROC_FS
@@ -119,6 +126,9 @@ struct nubus_rsrc *nubus_next_rsrc_or_null(struct nubus_rsrc *from);
#define for_each_func_rsrc(f) \
for (f = nubus_first_rsrc_or_null(); f; f = nubus_next_rsrc_or_null(f))
+#define for_each_board_func_rsrc(b, f) \
+ for_each_func_rsrc(f) if (f->board != b) {} else
+
/* These are somewhat more NuBus-specific. They all return 0 for
success and -1 for failure, as you'd expect. */
@@ -152,6 +162,23 @@ void nubus_seq_write_rsrc_mem(struct seq_file *m,
unsigned int len);
unsigned char *nubus_dirptr(const struct nubus_dirent *nd);
+/* Declarations relating to driver model objects */
+int nubus_bus_register(void);
+int nubus_device_register(struct nubus_board *board);
+int nubus_driver_register(struct nubus_driver *ndrv);
+void nubus_driver_unregister(struct nubus_driver *ndrv);
+int nubus_proc_show(struct seq_file *m, void *data);
+
+static inline void nubus_set_drvdata(struct nubus_board *board, void *data)
+{
+ dev_set_drvdata(&board->dev, data);
+}
+
+static inline void *nubus_get_drvdata(struct nubus_board *board)
+{
+ return dev_get_drvdata(&board->dev);
+}
+
/* Returns a pointer to the "standard" slot space. */
static inline void *nubus_slot_addr(int slot)
{