Turn g_udev static

This commit is contained in:
twinaphex 2015-11-30 16:52:29 +01:00
parent 28602d84af
commit 62260cf892
4 changed files with 23 additions and 12 deletions

View File

@ -6,7 +6,7 @@
static bool udev_mon_inited;
static struct udev_monitor *g_udev_mon;
struct udev *g_udev;
static struct udev *g_udev;
bool udev_mon_new(void)
{
@ -61,3 +61,15 @@ struct udev_device *udev_mon_receive_device(void)
{
return udev_monitor_receive_device(g_udev_mon);
}
struct udev_enumerate *udev_mon_enumerate(void)
{
return udev_enumerate_new(g_udev);
}
/* Get the filename of the /sys entry for the device
* and create a udev_device object (dev) representing it. */
struct udev_device *udev_mon_device_new(const char *name)
{
return udev_device_new_from_syspath(g_udev, name);
}

View File

@ -21,8 +21,6 @@
#include <boolean.h>
extern struct udev *g_udev;
bool udev_mon_new(void);
void udev_mon_free(bool is_joypad);
@ -31,4 +29,8 @@ bool udev_mon_hotplug_available(void);
struct udev_device *udev_mon_receive_device(void);
struct udev_enumerate *udev_mon_enumerate(void);
struct udev_device *udev_mon_device_new(const char *name);
#endif

View File

@ -580,7 +580,7 @@ static bool open_devices(udev_input_t *udev, const char *type, device_handle_cb
{
struct udev_list_entry *devs = NULL;
struct udev_list_entry *item = NULL;
struct udev_enumerate *enumerate = udev_enumerate_new(g_udev);
struct udev_enumerate *enumerate = udev_mon_enumerate();
if (!enumerate)
return false;
@ -591,12 +591,9 @@ static bool open_devices(udev_input_t *udev, const char *type, device_handle_cb
for (item = devs; item; item = udev_list_entry_get_next(item))
{
const char *name = udev_list_entry_get_name(item);
/* Get the filename of the /sys entry for the device
* and create a udev_device object (dev) representing it. */
struct udev_device *dev = udev_device_new_from_syspath(g_udev, name);
const char *devnode = udev_device_get_devnode(dev);
const char *name = udev_list_entry_get_name(item);
struct udev_device *dev = udev_mon_device_new(name);
const char *devnode = udev_device_get_devnode(dev);
if (devnode)
{

View File

@ -518,7 +518,7 @@ static bool udev_joypad_init(void *data)
if (!udev_mon_new())
goto error;
enumerate = udev_enumerate_new(g_udev);
enumerate = udev_mon_enumerate();
if (!enumerate)
goto error;
@ -529,7 +529,7 @@ static bool udev_joypad_init(void *data)
for (item = devs; item; item = udev_list_entry_get_next(item))
{
const char *name = udev_list_entry_get_name(item);
struct udev_device *dev = udev_device_new_from_syspath(g_udev, name);
struct udev_device *dev = udev_mon_device_new(name);
const char *devnode = udev_device_get_devnode(dev);
if (devnode)