2010-10-22 05:51:56

by Blaise Gassend

[permalink] [raw]
Subject: [PATCH] compat: Fixes missing sem member in struct device for RT PREEMPT prior to 2.6.34

The RT PREEMPT patch eliminates the sem member in struct device
breaking device_lock, device_unlock and device_trylock in kernels
prior to 2.6.34. The attached patch replaces the use of sem by a use
of mutex.

Signed-off-by: Blaise Gassend <[email protected]>

diff --git a/include/linux/compat-2.6.34.h b/include/linux/compat-2.6.34.h
index 336c61b..5604c7e 100644
--- a/include/linux/compat-2.6.34.h
+++ b/include/linux/compat-2.6.34.h
@@ -142,17 +142,32 @@ do {

static inline void device_lock(struct device *dev)
{
+#if defined(CONFIG_NONE) || defined(CONFIG_PREEMPT_RT) || \
+ defined(CONFIG_PREEMPT_VOLUNTARY) || defined(CONFIG_PREEMPT_DESKTOP)
+ mutex_lock(&dev->parent->mutex);
+#else
down(&dev->sem);
+#endif
}

static inline int device_trylock(struct device *dev)
{
+#if defined(CONFIG_NONE) || defined(CONFIG_PREEMPT_RT) || \
+ defined(CONFIG_PREEMPT_VOLUNTARY) || defined(CONFIG_PREEMPT_DESKTOP)
+ return mutex_trylock(&dev->mutex);
+#else
return down_trylock(&dev->sem);
+#endif
}

static inline void device_unlock(struct device *dev)
{
+#if defined(CONFIG_NONE) || defined(CONFIG_PREEMPT_RT) || \
+ defined(CONFIG_PREEMPT_VOLUNTARY) || defined(CONFIG_PREEMPT_DESKTOP)
+ mutex_unlock(&dev->mutex);
+#else
up(&dev->sem);
+#endif
}

#if defined(CONFIG_PCMCIA) || defined(CONFIG_PCMCIA_MODULE)


2010-10-22 09:36:48

by Luis R. Rodriguez

[permalink] [raw]
Subject: Re: [PATCH] compat: Fixes missing sem member in struct device for RT PREEMPT prior to 2.6.34

On Thu, Oct 21, 2010 at 10:51 PM, Blaise Gassend
<[email protected]> wrote:
> The RT PREEMPT patch eliminates the sem member in struct device
> breaking device_lock, device_unlock and device_trylock in kernels
> prior to 2.6.34. The attached patch replaces the use of sem by a use
> of mutex.
>
> Signed-off-by: Blaise Gassend <[email protected]>

Alright, nice, thanks! Patch applied and I also propagated it to the
linux-2.6.36.y branch so that we can get this fix for the
compat-wireless-2.6.36 release as well. I should note your patch did
not apply as the offsets were way off but I did just read the patch
and merged it manually. What version of compat were you using?

Luis

2010-10-22 15:58:08

by Blaise Gassend

[permalink] [raw]
Subject: Re: [PATCH] compat: Fixes missing sem member in struct device for RT PREEMPT prior to 2.6.34

That was a diff against the master branch of
git://git.kernel.org/pub/scm/linux/kernel/git/mcgrof/compat.git that I
cloned last night. I produced the patch with git diff. What should I
have diffed against?

Blaise

On Fri, Oct 22, 2010 at 2:36 AM, Luis R. Rodriguez <[email protected]> wrote:
> On Thu, Oct 21, 2010 at 10:51 PM, Blaise Gassend
> <[email protected]> wrote:
>> The RT PREEMPT patch eliminates the sem member in struct device
>> breaking device_lock, device_unlock and device_trylock in kernels
>> prior to 2.6.34. The attached patch replaces the use of sem by a use
>> of mutex.
>>
>> Signed-off-by: Blaise Gassend <[email protected]>
>
> Alright, nice, thanks! Patch applied and I also propagated it to the
> linux-2.6.36.y branch so that we can get this fix for the
> compat-wireless-2.6.36 release as well. I should note your patch did
> not apply as the offsets were way off but I did just read the patch
> and merged it manually. What version of compat were you using?
>
> ?Luis
>

2010-10-22 16:04:39

by Luis R. Rodriguez

[permalink] [raw]
Subject: Re: [PATCH] compat: Fixes missing sem member in struct device for RT PREEMPT prior to 2.6.34

On Fri, Oct 22, 2010 at 8:58 AM, Blaise Gassend <[email protected]> wrote:
> That was a diff against the master branch of
> git://git.kernel.org/pub/scm/linux/kernel/git/mcgrof/compat.git that I
> cloned last night. I produced the patch with git diff. What should I
> have diffed against?

That's fine, for some reason it did not apply, but anyway I applied it
manually, thanks!!!

Luis