From 38dbdde48f135c6b8fd1524eacf79041c7b5899a Mon Sep 17 00:00:00 2001 From: Johannes Berg Date: Wed, 7 Aug 2013 11:40:09 +0200 Subject: [PATCH] backports: fix device_release_driver The new macro, introduced by commit 9f5876fa9cfb8cd6f450c200043ca7e31915f976 Author: Luis R. Rodriguez Date: Thu Jul 18 16:40:55 2013 -0700 backports: backport drvdata = NULL core driver fixes evaluates its argument multiple times, causing crashes as there are potential side-effects of the called code and/or the arguments. Fix this by converting it to static inlines. Also remove the driver_probe_device() macro that has the same issue, but tries to wrap a function that isn't even available outside the driver core code in any kernel. Signed-off-by: Johannes Berg Signed-off-by: Luis R. Rodriguez --- backport/backport-include/linux/device.h | 25 +++++++++--------------- 1 file changed, 9 insertions(+), 16 deletions(-) diff --git a/backport/backport-include/linux/device.h b/backport/backport-include/linux/device.h index ba55d0ec8bff..909a534c16fb 100644 --- a/backport/backport-include/linux/device.h +++ b/backport/backport-include/linux/device.h @@ -177,22 +177,15 @@ extern int dev_set_name(struct device *dev, const char *name, ...) #endif #if LINUX_VERSION_CODE <= KERNEL_VERSION(3,6,0) -#define driver_probe_device(__drv, __dev) \ -({ \ - int ret; \ - ret = (driver_probe_device)(__drv, __dev); \ - if (ret) \ - dev_set_drvdata(__dev, NULL); \ - return ret; \ -}) - -#define device_release_driver(__dev) \ -({ \ - (device_release_driver)(__dev); \ - device_lock(__dev); \ - dev_set_drvdata(__dev, NULL); \ - device_unlock(__dev); \ -}) +static inline void +backport_device_release_driver(struct device *dev) +{ + device_release_driver(dev); + device_lock(dev); + dev_set_drvdata(dev, NULL); + device_unlock(dev); +} +#define device_release_driver LINUX_BACKPORT(device_release_driver) #endif /* LINUX_VERSION_CODE <= KERNEL_VERSION(3,6,0) */ #endif /* __BACKPORT_DEVICE_H */ -- 2.30.2