diff mbox

Hard module dependencies

Message ID 4ACB6C89.4030407@canonical.com
State Rejected
Headers show

Commit Message

Tim Gardner Oct. 6, 2009, 4:12 p.m. UTC
Andy - How about something like this? I need to test some boundary
conditions (like what happens if the target is not a module, etc), and
flesh out the commit log, perhaps add some comments to the function.

Comments

Andy Whitcroft Oct. 8, 2009, 10:42 a.m. UTC | #1
On Tue, Oct 06, 2009 at 10:12:57AM -0600, Tim Gardner wrote:
> Andy - How about something like this? I need to test some boundary
> conditions (like what happens if the target is not a module, etc), and
> flesh out the commit log, perhaps add some comments to the function.
> -- 
> Tim Gardner tim.gardner@canonical.com

> From 31223d1147dc4d96a70688b5987e9cb63b579f62 Mon Sep 17 00:00:00 2001
> From: Tim Gardner <tim.gardner@canonical.com>
> Date: Tue, 6 Oct 2009 08:52:38 -0600
> Subject: [PATCH 1/2] UBUNTU: [Upstream] Added module_depends()
> 
> Signed-off-by: Tim Gardner <tim.gardner@canonical.com>
> ---
>  include/linux/module.h |   19 +++++++++++++++++++
>  1 files changed, 19 insertions(+), 0 deletions(-)
> 
> diff --git a/include/linux/module.h b/include/linux/module.h
> index 098bdb7..8827da5 100644
> --- a/include/linux/module.h
> +++ b/include/linux/module.h
> @@ -703,6 +703,25 @@ static inline void module_remove_modinfo_attrs(struct module *mod)
>  
>  #define __MODULE_STRING(x) __stringify(x)
>  
> +static inline void module_depends(const char *mod_name)
> +{
> +	struct module *mod;
> +
> +	if (mutex_lock_interruptible(&module_mutex) != 0) {
> +		printk(KERN_ERR "%s Could not get module_mutex\n",__func__);
> +		return;
> +	}
> +	mod = find_module(mod_name);
> +	if (!mod) {
> +		mutex_unlock(&module_mutex);
> +		printk(KERN_ERR "%s Could not find module %s\n",__func__,mod_name);
> +		return;
> +	}
> +	if (use_module(THIS_MODULE,mod) <= 0) {
> +		printk(KERN_ERR "%s Could not load module %s\n",__func__,mod_name);
> +	}
> +	mutex_unlock(&module_mutex);
> +}
>  
>  #ifdef CONFIG_GENERIC_BUG
>  int  module_bug_finalize(const Elf_Ehdr *, const Elf_Shdr *,

Looking pretty sensible, how did this fair in testing?

-apw
Tim Gardner Oct. 8, 2009, 1:50 p.m. UTC | #2
Andy Whitcroft wrote:
> On Tue, Oct 06, 2009 at 10:12:57AM -0600, Tim Gardner wrote:
>> Andy - How about something like this? I need to test some boundary
>> conditions (like what happens if the target is not a module, etc), and
>> flesh out the commit log, perhaps add some comments to the function.
>> -- 
>> Tim Gardner tim.gardner@canonical.com
> 
>> From 31223d1147dc4d96a70688b5987e9cb63b579f62 Mon Sep 17 00:00:00 2001
>> From: Tim Gardner <tim.gardner@canonical.com>
>> Date: Tue, 6 Oct 2009 08:52:38 -0600
>> Subject: [PATCH 1/2] UBUNTU: [Upstream] Added module_depends()
>>
>> Signed-off-by: Tim Gardner <tim.gardner@canonical.com>
>> ---
>>  include/linux/module.h |   19 +++++++++++++++++++
>>  1 files changed, 19 insertions(+), 0 deletions(-)
>>
>> diff --git a/include/linux/module.h b/include/linux/module.h
>> index 098bdb7..8827da5 100644
>> --- a/include/linux/module.h
>> +++ b/include/linux/module.h
>> @@ -703,6 +703,25 @@ static inline void module_remove_modinfo_attrs(struct module *mod)
>>  
>>  #define __MODULE_STRING(x) __stringify(x)
>>  
>> +static inline void module_depends(const char *mod_name)
>> +{
>> +	struct module *mod;
>> +
>> +	if (mutex_lock_interruptible(&module_mutex) != 0) {
>> +		printk(KERN_ERR "%s Could not get module_mutex\n",__func__);
>> +		return;
>> +	}
>> +	mod = find_module(mod_name);
>> +	if (!mod) {
>> +		mutex_unlock(&module_mutex);
>> +		printk(KERN_ERR "%s Could not find module %s\n",__func__,mod_name);
>> +		return;
>> +	}
>> +	if (use_module(THIS_MODULE,mod) <= 0) {
>> +		printk(KERN_ERR "%s Could not load module %s\n",__func__,mod_name);
>> +	}
>> +	mutex_unlock(&module_mutex);
>> +}
>>  
>>  #ifdef CONFIG_GENERIC_BUG
>>  int  module_bug_finalize(const Elf_Ehdr *, const Elf_Shdr *,
> 
> Looking pretty sensible, how did this fair in testing?
> 
> -apw

I ended up going with a much simpler hack, but still had to touch 2
module source files to get the job done. I think there is a more elegant
way using request_module(). I missed it the first time 'cause I was
looking in modules.h instead of kmod.h for support functions.

http://kernel.ubuntu.com/git?p=ubuntu/ubuntu-karmic.git;a=commit;h=456d96a8165788cfd1e593fb7540f4a58fe2f46b

We're definitely going to do something different for Lucid.

rtg
diff mbox

Patch

From 1fde7bd238eb7150fdf372192651d8e384768f06 Mon Sep 17 00:00:00 2001
From: Tim Gardner <tim.gardner@canonical.com>
Date: Tue, 6 Oct 2009 08:57:53 -0600
Subject: [PATCH 2/2] UBUNTU: [Upstream] i915: Depends on intel-agp

Signed-off-by: Tim Gardner <tim.gardner@canonical.com>
---
 drivers/gpu/drm/i915/i915_drv.c |    1 +
 1 files changed, 1 insertions(+), 0 deletions(-)

diff --git a/drivers/gpu/drm/i915/i915_drv.c b/drivers/gpu/drm/i915/i915_drv.c
index c078d99..14f079c 100644
--- a/drivers/gpu/drm/i915/i915_drv.c
+++ b/drivers/gpu/drm/i915/i915_drv.c
@@ -227,6 +227,7 @@  static struct drm_driver driver = {
 
 static int __init i915_init(void)
 {
+	module_depends("intel_agp");
 	driver.num_ioctls = i915_max_ioctl;
 
 	/*
-- 
1.6.2.4