From a7506f139d60934c04dab33554fba07c371ca61b Mon Sep 17 00:00:00 2001 From: Peter Hutterer Date: Fri, 26 Nov 2021 11:06:19 +1000 Subject: Add a hook to update the device's name in the driver Signed-off-by: Peter Hutterer --- src/WacomInterface.h | 2 ++ src/wcmConfig.c | 6 ++---- src/xf86Wacom.c | 8 ++++++++ 3 files changed, 12 insertions(+), 4 deletions(-) (limited to 'src') diff --git a/src/WacomInterface.h b/src/WacomInterface.h index ef12e83..1794d1c 100644 --- a/src/WacomInterface.h +++ b/src/WacomInterface.h @@ -107,6 +107,8 @@ void wcmClose(WacomDevicePtr priv); int wcmGetFd(WacomDevicePtr priv); void wcmSetFd(WacomDevicePtr priv, int fd); +/* Update the driver implementation's name, if any */ +void wcmSetName(WacomDevicePtr priv, const char *name); static inline void wcmAxisSet(WacomAxisData *data, diff --git a/src/wcmConfig.c b/src/wcmConfig.c index b8a4858..3a89cb8 100644 --- a/src/wcmConfig.c +++ b/src/wcmConfig.c @@ -693,7 +693,6 @@ static inline WacomType getType(const char *type) * "wacom" */ int wcmPreInit(WacomDevicePtr priv) { - InputInfoPtr pInfo = priv->pInfo; WacomCommonPtr common = NULL; char *type = NULL, *device = NULL; char *oldname = NULL; @@ -750,10 +749,9 @@ int wcmPreInit(WacomDevicePtr priv) char *new_name; if (asprintf(&new_name, "%s %s", priv->name, type) == -1) new_name = strdup(priv->name); - free(pInfo->name); free(priv->name); - pInfo->name = new_name; - priv->name = strdup(new_name); + priv->name = new_name; + wcmSetName(priv, new_name); } /* check if the type is valid for those don't need hotplug */ diff --git a/src/xf86Wacom.c b/src/xf86Wacom.c index 296ed5c..d8ca5c4 100644 --- a/src/xf86Wacom.c +++ b/src/xf86Wacom.c @@ -587,6 +587,14 @@ void wcmSetFd(WacomDevicePtr priv, int fd) priv->pInfo->fd = fd; } +void wcmSetName(WacomDevicePtr priv, const char *name) +{ + InputInfoPtr pInfo = priv->pInfo; + + free(pInfo->name); + pInfo->name = strdup(name); +} + /***************************************************************************** * wcmOpen -- ****************************************************************************/ -- cgit v1.2.1