diff options
author | Keith Packard <keithp@keithp.com> | 2014-07-15 17:31:58 -0700 |
---|---|---|
committer | Keith Packard <keithp@keithp.com> | 2014-07-17 17:10:48 -0700 |
commit | 60c05ce1ab5d9dc7c034b6b3723f43a42ea637d8 (patch) | |
tree | 0b688aa26d7d635a4d52086db766948b484a3740 /include | |
parent | 55f5bfb578e934319d1308cbb56c900c5ac7cfa7 (diff) |
config: Replace OdevAttributes linked list with struct
OdevAttributes are a fixed set of values with known types; instead of
storing them in a linked list and requiring accessor/settor functions,
replace the list header, struct OdevAttributes, with a struct that
directly contains the values. This provides for compile-time
typechecking of the values, eliminates a significant amount of code
and generally simplifies using this datatype.
Signed-off-by: Keith Packard <keithp@keithp.com>
Reviewed-by: Hans de Goede <hdegoede@redhat.com>
Diffstat (limited to 'include')
-rw-r--r-- | include/hotplug.h | 69 |
1 files changed, 23 insertions, 46 deletions
diff --git a/include/hotplug.h b/include/hotplug.h index 4c2fa970c..6fe76c806 100644 --- a/include/hotplug.h +++ b/include/hotplug.h @@ -32,64 +32,41 @@ extern _X_EXPORT void config_pre_init(void); extern _X_EXPORT void config_init(void); extern _X_EXPORT void config_fini(void); -enum { ODEV_ATTRIB_UNKNOWN = -1, ODEV_ATTRIB_STRING = 0, ODEV_ATTRIB_INT }; - -struct OdevAttribute { - struct xorg_list member; - int attrib_id; - union { - char *attrib_name; - int attrib_value; - }; - int attrib_type; -}; +/* Bump this each time you add something to the struct + * so that drivers can easily tell what is available + */ +#define ODEV_ATTRIBUTES_VERSION 1 struct OdevAttributes { - struct xorg_list list; -}; + /* path to kernel device node - Linux e.g. /dev/dri/card0 */ + char *path; -/* Note starting with xserver 1.16 this function never fails */ -struct OdevAttributes * -config_odev_allocate_attribute_list(void); + /* system device path - Linux e.g. /sys/devices/pci0000:00/0000:00:01.0/0000:01:00.0/drm/card1 */ + char *syspath; -void -config_odev_free_attribute_list(struct OdevAttributes *attribs); + /* DRI-style bus id */ + char *busid; -/* Note starting with xserver 1.16 this function never fails */ -Bool -config_odev_add_attribute(struct OdevAttributes *attribs, int attrib, - const char *attrib_name); + /* Server managed FD */ + int fd; -char * -config_odev_get_attribute(struct OdevAttributes *attribs, int attrib_id); + /* Major number of the device node pointed to by ODEV_ATTRIB_PATH */ + int major; -/* Note starting with xserver 1.16 this function never fails */ -Bool -config_odev_add_int_attribute(struct OdevAttributes *attribs, int attrib, - int attrib_value); + /* Minor number of the device node pointed to by ODEV_ATTRIB_PATH */ + int minor; + + /* kernel driver name */ + char *driver; +}; -int -config_odev_get_int_attribute(struct OdevAttributes *attribs, int attrib, - int def); +/* Note starting with xserver 1.16 this function never fails */ +struct OdevAttributes * +config_odev_allocate_attributes(void); void config_odev_free_attributes(struct OdevAttributes *attribs); -/* path to kernel device node - Linux e.g. /dev/dri/card0 */ -#define ODEV_ATTRIB_PATH 1 -/* system device path - Linux e.g. /sys/devices/pci0000:00/0000:00:01.0/0000:01:00.0/drm/card1 */ -#define ODEV_ATTRIB_SYSPATH 2 -/* DRI-style bus id */ -#define ODEV_ATTRIB_BUSID 3 -/* Server managed FD */ -#define ODEV_ATTRIB_FD 4 -/* Major number of the device node pointed to by ODEV_ATTRIB_PATH */ -#define ODEV_ATTRIB_MAJOR 5 -/* Minor number of the device node pointed to by ODEV_ATTRIB_PATH */ -#define ODEV_ATTRIB_MINOR 6 -/* kernel driver name */ -#define ODEV_ATTRIB_DRIVER 7 - typedef void (*config_odev_probe_proc_ptr)(struct OdevAttributes *attribs); void config_odev_probe(config_odev_probe_proc_ptr probe_callback); |