Both ISDV4 and USB have their model class with a Detect() function. Use it, instead of having parts of the serial code in wcmConfig.c.
Signed-off-by: Peter Hutterer <[email protected]> --- src/wcmConfig.c | 28 +++++++--------------------- src/wcmISDV4.c | 12 +++++++++++- 2 files changed, 18 insertions(+), 22 deletions(-) diff --git a/src/wcmConfig.c b/src/wcmConfig.c index 3a459eb..3fef429 100644 --- a/src/wcmConfig.c +++ b/src/wcmConfig.c @@ -26,7 +26,6 @@ #include <sys/stat.h> #include <fcntl.h> #include <unistd.h> -#include <linux/serial.h> /***************************************************************************** * wcmAllocate -- @@ -382,32 +381,19 @@ wcmInitModel(LocalDevicePtr local) { WacomDevicePtr priv = (WacomDevicePtr)local->private; WacomCommonPtr common = priv->common; - struct serial_struct ser; - int rc; char id[BUFFER_SIZE]; float version; - rc = ioctl(local->fd, TIOCGSERIAL, &ser); - - /* we initialized wcmDeviceClasses to USB - * Bluetooth is also considered as USB */ - if (rc == 0) /* serial device */ - { - /* only ISDV4 are supported on X server 1.7 and later */ - common->wcmForceDevice = DEVICE_ISDV4; + /* Bluetooth is also considered as USB */ + if (gWacomISDV4Device.Detect(local)) common->wcmDevCls = &gWacomISDV4Device; - } + else if (gWacomUSBDevice.Detect(local)) + common->wcmDevCls = &gWacomUSBDevice; else { - /* Detect USB device class */ - if ((&gWacomUSBDevice)->Detect(local)) - common->wcmDevCls = &gWacomUSBDevice; - else - { - xf86Msg(X_ERROR, "%s: wcmInitModel found undetectable " - " %s \n", local->name, common->wcmDevice); - return FALSE; - } + xf86Msg(X_ERROR, "%s: wcmInitModel found undetectable " + " %s \n", local->name, common->wcmDevice); + return FALSE; } /* Initialize the tablet */ diff --git a/src/wcmISDV4.c b/src/wcmISDV4.c index 4b8f803..d341a22 100644 --- a/src/wcmISDV4.c +++ b/src/wcmISDV4.c @@ -146,7 +146,17 @@ static Bool isdv4Detect(LocalDevicePtr local) { WacomDevicePtr priv = (WacomDevicePtr) local->private; WacomCommonPtr common = priv->common; - return (common->wcmForceDevice == DEVICE_ISDV4) ? 1 : 0; + struct serial_struct ser; + int rc; + + rc = ioctl(local->fd, TIOCGSERIAL, &ser); + if (rc == -1) + return FALSE; + + /* only ISDV4 are supported on X server 1.7 and later */ + common->wcmForceDevice = DEVICE_ISDV4; + + return TRUE; } /***************************************************************************** -- 1.7.0.1 ------------------------------------------------------------------------------ ThinkGeek and WIRED's GeekDad team up for the Ultimate GeekDad Father's Day Giveaway. ONE MASSIVE PRIZE to the lucky parental unit. See the prize list and enter to win: http://p.sf.net/sfu/thinkgeek-promo _______________________________________________ Linuxwacom-devel mailing list [email protected] https://lists.sourceforge.net/lists/listinfo/linuxwacom-devel
