[PATCH 4/7] xfree86: Convert xf86InputDriverList to xorg_list.
Michal Suchanek
hramrach at gmail.com
Tue Jul 17 07:41:56 PDT 2012
Signed-off-by: Michal Suchanek <hramrach at gmail.com>
---
hw/xfree86/common/xf86Globals.c | 2 --
hw/xfree86/common/xf86Helper.c | 41 ++++++++++++++++++++-------------------
hw/xfree86/common/xf86InPriv.h | 4 ----
hw/xfree86/common/xf86Xinput.h | 3 ++-
hw/xfree86/doc/ddxDesign.xml | 8 +++++---
5 files changed, 28 insertions(+), 30 deletions(-)
diff --git a/hw/xfree86/common/xf86Globals.c b/hw/xfree86/common/xf86Globals.c
index 7df7a80..2f5e802 100644
--- a/hw/xfree86/common/xf86Globals.c
+++ b/hw/xfree86/common/xf86Globals.c
@@ -156,8 +156,6 @@ Bool xf86DoConfigure = FALSE;
Bool xf86DoShowOptions = FALSE;
DriverPtr *xf86DriverList = NULL;
int xf86NumDrivers = 0;
-InputDriverPtr *xf86InputDriverList = NULL;
-int xf86NumInputDrivers = 0;
int xf86NumScreens = 0;
int xf86NumGPUScreens = 0;
diff --git a/hw/xfree86/common/xf86Helper.c b/hw/xfree86/common/xf86Helper.c
index 90484bb..187cf1f 100644
--- a/hw/xfree86/common/xf86Helper.c
+++ b/hw/xfree86/common/xf86Helper.c
@@ -62,6 +62,8 @@
#include <sys/resource.h>
#endif
+static struct xorg_list *xf86InputDriverList = NULL;
+
static int xf86ScrnInfoPrivateCount = 0;
/* Add a pointer to a new DriverRec to xf86DriverList */
@@ -109,41 +111,40 @@ xf86DeleteDriver(int drvIndex)
void
xf86AddInputDriver(InputDriverPtr driver, pointer module, int flags)
{
+ InputDriverPtr rec;
/* Don't add null entries */
if (!driver)
return;
- if (xf86InputDriverList == NULL)
- xf86NumInputDrivers = 0;
+ if (xf86InputDriverList == NULL) {
+ xf86InputDriverList = malloc(sizeof(struct xorg_list));
+ xorg_list_init(xf86InputDriverList);
+ }
- xf86NumInputDrivers++;
- xf86InputDriverList = xnfrealloc(xf86InputDriverList,
- xf86NumInputDrivers *
- sizeof(InputDriverPtr));
- xf86InputDriverList[xf86NumInputDrivers - 1] =
- xnfalloc(sizeof(InputDriverRec));
- *xf86InputDriverList[xf86NumInputDrivers - 1] = *driver;
- xf86InputDriverList[xf86NumInputDrivers - 1]->module = module;
+ rec = calloc(sizeof(InputDriverRec),1);
+ *rec = *driver;
+ rec->module = module;
+ xorg_list_add(&rec->entry, xf86InputDriverList);
}
void
-xf86DeleteInputDriver(int drvIndex)
+xf86DeleteInputDriver(InputDriverPtr driver)
{
- if (xf86InputDriverList[drvIndex] && xf86InputDriverList[drvIndex]->module)
- UnloadModule(xf86InputDriverList[drvIndex]->module);
- free(xf86InputDriverList[drvIndex]);
- xf86InputDriverList[drvIndex] = NULL;
+ UnloadModule(driver->module);
+ xorg_list_del(&driver->entry);
+ free(driver);
}
InputDriverPtr
xf86LookupInputDriver(const char *name)
{
- int i;
+ InputDriverPtr iterator;
+ if (!xf86InputDriverList)
+ return NULL;
- for (i = 0; i < xf86NumInputDrivers; i++) {
- if (xf86InputDriverList[i] && xf86InputDriverList[i]->driverName &&
- xf86NameCmp(name, xf86InputDriverList[i]->driverName) == 0)
- return xf86InputDriverList[i];
+ xorg_list_for_each_entry(iterator, xf86InputDriverList, entry) {
+ if(xf86NameCmp(iterator->driverName, name) == 0)
+ return iterator;
}
return NULL;
}
diff --git a/hw/xfree86/common/xf86InPriv.h b/hw/xfree86/common/xf86InPriv.h
index 5826ac3..6f4d8c1 100644
--- a/hw/xfree86/common/xf86InPriv.h
+++ b/hw/xfree86/common/xf86InPriv.h
@@ -33,10 +33,6 @@
#ifndef _xf86InPriv_h
#define _xf86InPriv_h
-/* xf86Globals.c */
-extern InputDriverPtr *xf86InputDriverList;
-extern int xf86NumInputDrivers;
-
/* xf86Helper.c */
InputDriverPtr xf86LookupInputDriver(const char *name);
diff --git a/hw/xfree86/common/xf86Xinput.h b/hw/xfree86/common/xf86Xinput.h
index 35c38a5..8d3ce75 100644
--- a/hw/xfree86/common/xf86Xinput.h
+++ b/hw/xfree86/common/xf86Xinput.h
@@ -76,6 +76,7 @@ typedef struct _InputDriverRec {
struct _InputInfoRec * pInfo, int flags);
pointer module;
const char **default_options;
+ struct xorg_list entry;
} InputDriverRec, *InputDriverPtr;
/* This is to input devices what the ScrnInfoRec is to screens. */
@@ -180,7 +181,7 @@ InputInfoPtr xf86AllocateInput(void);
/* xf86Helper.c */
extern _X_EXPORT void xf86AddInputDriver(InputDriverPtr driver, pointer module,
int flags);
-extern _X_EXPORT void xf86DeleteInputDriver(int drvIndex);
+extern _X_EXPORT void xf86DeleteInputDriver(InputDriverPtr driver);
extern _X_EXPORT InputDriverPtr xf86LookupInputDriver(const char *name);
extern _X_EXPORT InputInfoPtr xf86LookupInput(const char *name);
extern _X_EXPORT void xf86DeleteInput(InputInfoPtr pInp, int flags);
diff --git a/hw/xfree86/doc/ddxDesign.xml b/hw/xfree86/doc/ddxDesign.xml
index 4c2ca47..e23ae61 100644
--- a/hw/xfree86/doc/ddxDesign.xml
+++ b/hw/xfree86/doc/ddxDesign.xml
@@ -719,9 +719,11 @@ Here is what <function>InitOutput()</function> does:
essential details and driver entry points required during the early
phase of <function>InitInput()</function>.
<function>xf86AddInputDriver()</function> adds it to the global
- <varname>xf86InputDriverList[]</varname> array. For a static server,
- the <varname>xf86InputDriverList[]</varname> array is initialised at
- build time.
+ <varname>xf86InputDriverList</varname>. Use
+ <function>xf86LookupInputDriver()</function> to look up a driver in the
+ list. It used to be a pointer array but since static servers are no
+ longer supported a more dynamic structure is used.
+
</para>
<para>
--
1.7.10.4
More information about the xorg-devel
mailing list