xfree86: move xf86AllocateInput and xf86DeleteInput to xf86Xinput.c

Make xf86AllocateInput static in the process, this function is only called
from one location.

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
Reviewed-by: Adam Jackson <ajax@redhat.com>
Reviewed-by: Daniel Stone <daniel@fooishbar.org>
This commit is contained in:
Peter Hutterer 2010-07-22 12:00:07 +10:00
parent d2a5f41664
commit b55ac354af
3 changed files with 89 additions and 91 deletions

View File

@ -274,96 +274,6 @@ xf86AllocateScrnInfoPrivateIndex(void)
return idx;
}
/* Allocate a new InputInfoRec and append it to the tail of xf86InputDevs. */
InputInfoPtr
xf86AllocateInput(InputDriverPtr drv, IDevPtr idev)
{
InputInfoPtr new, *prev = NULL;
if (!(new = calloc(sizeof(InputInfoRec), 1)))
return NULL;
new->drv = drv;
drv->refCount++;
new->module = DuplicateModule(drv->module, NULL);
for (prev = &xf86InputDevs; *prev; prev = &(*prev)->next)
;
*prev = new;
new->next = NULL;
new->fd = -1;
new->name = idev->identifier;
new->type_name = "UNKNOWN";
new->device_control = NULL;
new->read_input = NULL;
new->history_size = 0;
new->control_proc = NULL;
new->close_proc = NULL;
new->switch_mode = NULL;
new->conversion_proc = NULL;
new->reverse_conversion_proc = NULL;
new->dev = NULL;
new->private_flags = 0;
new->always_core_feedback = NULL;
new->private = NULL;
new->conf_idev = idev;
xf86CollectInputOptions(new, (const char**)drv->default_options, NULL);
xf86ProcessCommonOptions(new, new->options);
return new;
}
/*
* Remove an entry from xf86InputDevs. Ideally it should free all allocated
* data. To do this properly may require a driver hook.
*/
void
xf86DeleteInput(InputInfoPtr pInp, int flags)
{
InputInfoPtr p;
/* First check if the inputdev is valid. */
if (pInp == NULL)
return;
#if 0
/* If a free function is defined, call it here. */
if (pInp->free)
pInp->free(pInp, 0);
#endif
if (pInp->module)
UnloadModule(pInp->module);
if (pInp->drv)
pInp->drv->refCount--;
/* This should *really* be handled in drv->UnInit(dev) call instead, but
* if the driver forgets about it make sure we free it or at least crash
* with flying colors */
free(pInp->private);
FreeInputAttributes(pInp->attrs);
/* Remove the entry from the list. */
if (pInp == xf86InputDevs)
xf86InputDevs = pInp->next;
else {
p = xf86InputDevs;
while (p && p->next != pInp)
p = p->next;
if (p)
p->next = pInp->next;
/* Else the entry wasn't in the xf86InputDevs list (ignore this). */
}
free(pInp);
}
Bool
xf86AddPixFormat(ScrnInfoPtr pScrn, int depth, int bpp, int pad)
{

View File

@ -705,6 +705,95 @@ IgnoreInputClass(const IDevPtr idev, const InputAttributes *attrs)
return ignore;
}
/* Allocate a new InputInfoRec and append it to the tail of xf86InputDevs. */
static InputInfoPtr
xf86AllocateInput(InputDriverPtr drv, IDevPtr idev)
{
InputInfoPtr new, *prev = NULL;
if (!(new = calloc(sizeof(InputInfoRec), 1)))
return NULL;
new->drv = drv;
drv->refCount++;
new->module = DuplicateModule(drv->module, NULL);
for (prev = &xf86InputDevs; *prev; prev = &(*prev)->next)
;
*prev = new;
new->next = NULL;
new->fd = -1;
new->name = idev->identifier;
new->type_name = "UNKNOWN";
new->device_control = NULL;
new->read_input = NULL;
new->history_size = 0;
new->control_proc = NULL;
new->close_proc = NULL;
new->switch_mode = NULL;
new->conversion_proc = NULL;
new->reverse_conversion_proc = NULL;
new->dev = NULL;
new->private_flags = 0;
new->always_core_feedback = NULL;
new->private = NULL;
new->conf_idev = idev;
xf86CollectInputOptions(new, (const char**)drv->default_options, NULL);
xf86ProcessCommonOptions(new, new->options);
return new;
}
/*
* Remove an entry from xf86InputDevs. Ideally it should free all allocated
* data. To do this properly may require a driver hook.
*/
void
xf86DeleteInput(InputInfoPtr pInp, int flags)
{
InputInfoPtr p;
/* First check if the inputdev is valid. */
if (pInp == NULL)
return;
#if 0
/* If a free function is defined, call it here. */
if (pInp->free)
pInp->free(pInp, 0);
#endif
if (pInp->module)
UnloadModule(pInp->module);
if (pInp->drv)
pInp->drv->refCount--;
/* This should *really* be handled in drv->UnInit(dev) call instead, but
* if the driver forgets about it make sure we free it or at least crash
* with flying colors */
free(pInp->private);
FreeInputAttributes(pInp->attrs);
/* Remove the entry from the list. */
if (pInp == xf86InputDevs)
xf86InputDevs = pInp->next;
else {
p = xf86InputDevs;
while (p && p->next != pInp)
p = p->next;
if (p)
p->next = pInp->next;
/* Else the entry wasn't in the xf86InputDevs list (ignore this). */
}
free(pInp);
}
/**
* Create a new input device, activate and enable it.
*

View File

@ -188,7 +188,6 @@ int xf86NewInputDevice(IDevPtr idev, DeviceIntPtr *pdev, BOOL is_auto);
/* xf86Helper.c */
extern _X_EXPORT void xf86AddInputDriver(InputDriverPtr driver, pointer module, int flags);
extern _X_EXPORT void xf86DeleteInputDriver(int drvIndex);
extern _X_INTERNAL InputInfoPtr xf86AllocateInput(InputDriverPtr drv, IDevPtr idev);
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);