mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Tejun Heo <tj@home-tj.org>
To: rusty@rustcorp.com.au, mochel@osdl.org, greg@kroah.com
Cc: linux-kernel@vger.kernel.org
Subject: [PATCH 2.6.10-rc1 13/15] driver-model: devparam applied
Date: Thu, 4 Nov 2004 15:53:58 +0900	[thread overview]
Message-ID: <20041104065358.GM24890@home-tj.org> (raw)
In-Reply-To: <20041104063532.GA24566@home-tj.org>

 dp_13_devparam_apply.patch

 This is the 13th patch of 15 patches for devparam.

 This patch hooks devparam into the driver-model.  Devparam is
complete now.


Signed-off-by: Tejun Heo <tj@home-tj.org>


Index: linux-export/drivers/base/bus.c
===================================================================
--- linux-export.orig/drivers/base/bus.c	2004-11-04 10:25:58.000000000 +0900
+++ linux-export/drivers/base/bus.c	2004-11-04 14:26:03.000000000 +0900
@@ -266,20 +266,30 @@ void device_bind_driver(struct device * 
  */
 int driver_probe_device(struct device_driver * drv, struct device * dev)
 {
+	int error;
+
 	if (drv->bus->match && !drv->bus->match(dev, drv))
 		return -ENODEV;
 
 	dev->driver = drv;
+
+	if ((error = devparam_set_params(dev)) != 0)
+		goto devparam_fail;
+
 	if (drv->probe) {
-		int error = drv->probe(dev);
-		if (error) {
-			dev->driver = NULL;
-			return error;
-		}
+		error = drv->probe(dev);
+		if (error)
+			goto probe_fail;
 	}
 
 	device_bind_driver(dev);
 	return 0;
+
+ probe_fail:
+	devparam_release_params(dev);
+ devparam_fail:
+	dev->driver = NULL;
+	return error;
 }
 
 
@@ -376,6 +386,7 @@ void device_release_driver(struct device
 		device_detach_shutdown(dev);
 		if (drv->remove)
 			drv->remove(dev);
+		devparam_release_params(dev);
 		dev->driver = NULL;
 	}
 }
Index: linux-export/drivers/base/driver.c
===================================================================
--- linux-export.orig/drivers/base/driver.c	2004-11-04 10:25:58.000000000 +0900
+++ linux-export/drivers/base/driver.c	2004-11-04 14:26:03.000000000 +0900
@@ -85,9 +85,14 @@ void put_driver(struct device_driver * d
  */
 int driver_register(struct device_driver * drv)
 {
+	int ret;
 	INIT_LIST_HEAD(&drv->devices);
 	init_MUTEX_LOCKED(&drv->unload_sem);
-	return bus_add_driver(drv);
+	if ((ret = devparam_driver_init(drv)) < 0)
+		return ret;
+	if ((ret = bus_add_driver(drv)) < 0)
+		devparam_driver_release(drv);
+	return ret;
 }
 
 
@@ -109,6 +114,7 @@ void driver_unregister(struct device_dri
 	bus_remove_driver(drv);
 	down(&drv->unload_sem);
 	up(&drv->unload_sem);
+	devparam_driver_release(drv);
 }
 
 /**
Index: linux-export/init/main.c
===================================================================
--- linux-export.orig/init/main.c	2004-11-04 14:25:59.000000000 +0900
+++ linux-export/init/main.c	2004-11-04 14:26:03.000000000 +0900
@@ -38,6 +38,7 @@
 #include <linux/profile.h>
 #include <linux/rcupdate.h>
 #include <linux/moduleparam.h>
+#include <linux/deviceparam.h>
 #include <linux/kallsyms.h>
 #include <linux/writeback.h>
 #include <linux/cpu.h>
@@ -286,29 +287,32 @@ __setup("quiet", quiet_kernel);
  */
 static int __init unknown_bootoption(char *param, char *val, void *arg)
 {
+	char *cp = NULL;
+
 	/* Change NUL term back to "=", to make "param" the whole string. */
 	if (val) {
 		/* param=val or param="val"? */
 		if (val == param+strlen(param)+1)
-			val[-1] = '=';
+			cp = val - 1;
 		else if (val == param+strlen(param)+2) {
-			val[-2] = '=';
+			cp = val - 2;
 			memmove(val-1, val, strlen(val)+1);
 			val--;
 		} else
 			BUG();
+		*cp = '=';
 	}
 
 	/* Handle obsolete-style parameters */
 	if (obsolete_checksetup(param))
 		return 0;
 
-	/*
-	 * Preemptive maintenance for "why didn't my mispelled command
-	 * line work?"
-	 */
+	/* It might be a device parameter, pass it to deviceparam facility. */
 	if (strchr(param, '.') && (!val || strchr(param, '.') < val)) {
-		printk(KERN_ERR "Unknown boot option `%s': ignoring\n", param);
+		/* Restore NUL term. */
+		if (cp)
+			*cp = '\0';
+		devparam_maybe_bootopt(param, val);
 		return 0;
 	}
 
@@ -652,6 +656,8 @@ static void __init do_basic_setup(void)
 	sock_init();
 
 	do_initcalls();
+
+	devparam_finish_bootopts();
 }
 
 static void do_pre_smp_initcalls(void)
Index: linux-export/kernel/module.c
===================================================================
--- linux-export.orig/kernel/module.c	2004-11-04 14:25:59.000000000 +0900
+++ linux-export/kernel/module.c	2004-11-04 14:26:03.000000000 +0900
@@ -29,6 +29,7 @@
 #include <linux/rcupdate.h>
 #include <linux/cpu.h>
 #include <linux/moduleparam.h>
+#include <linux/deviceparam.h>
 #include <linux/errno.h>
 #include <linux/err.h>
 #include <linux/vermagic.h>
@@ -1696,6 +1697,10 @@ static struct module *load_module(void _
 	if (err < 0)
 		goto cleanup;
 
+	/* Set up device args vector */
+	if (devparam_module_init(mod) < 0)
+		goto arch_cleanup;
+
 	mod->args = args;
 	if (obsparmindex) {
 		err = obsolete_params(mod->name, mod->args,
@@ -1716,7 +1721,7 @@ static struct module *load_module(void _
 				 sechdrs[setupindex].sh_addr,
 				 sechdrs[setupindex].sh_size
 				 / sizeof(struct kernel_param),
-				 NULL, NULL);
+				 devparam_unknown_modparam, mod);
 	}
 	err = mod_sysfs_setup(mod, 
 			      (struct kernel_param *)
@@ -1724,7 +1729,7 @@ static struct module *load_module(void _
 			      sechdrs[setupindex].sh_size
 			      / sizeof(struct kernel_param));
 	if (err < 0)
-		goto arch_cleanup;
+		goto devparam_done;
 	add_sect_attrs(mod, hdr->e_shnum, secstrings, sechdrs);
 
 	/* Get rid of temporary copy */
@@ -1733,6 +1738,8 @@ static struct module *load_module(void _
 	/* Done! */
 	return mod;
 
+ devparam_done:
+	devparam_module_done(mod);
  arch_cleanup:
 	module_arch_cleanup(mod);
  cleanup:
@@ -1804,6 +1811,10 @@ sys_init_module(void __user *umod,
 	/* Start the module */
 	if (mod->init != NULL)
 		ret = mod->init();
+
+	/* We're done with device params */
+	devparam_module_done(mod);
+
 	if (ret < 0) {
 		/* Init routine failed: abort.  Try to protect us from
                    buggy refcounters. */

  parent reply	other threads:[~2004-11-04  7:05 UTC|newest]

Thread overview: 16+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2004-11-04  6:35 [PATCH 2.6.10-rc1 0/15] driver-model: per-device parameter, round 3 Tejun Heo
2004-11-04  6:38 ` [PATCH 2.6.10-rc1 1/15] driver-model: param_array_set num field fix Tejun Heo
2004-11-04  6:39 ` [PATCH 2.6.10-rc1 2/15] driver-model: flag type helpers added to moduleparam Tejun Heo
2004-11-04  6:40 ` [PATCH 2.6.10-rc1 3/15] driver-model: Tejun Heo
2004-11-04  6:44 ` [PATCH 2.6.10-rc1 4/15] driver-model: const qualifier removed from @val of param_array() Tejun Heo
2004-11-04  6:45 ` [PATCH 2.6.10-rc1 5/15] driver-model: param_array_delims() implemented Tejun Heo
2004-11-04  6:47 ` [PATCH 2.6.10-rc1 6/15] driver-model: ':' added to default param_array delimiters Tejun Heo
2004-11-04  6:48 ` [PATCH 2.6.10-rc1 7/15] driver-model: next_arg() renamed to param_next_arg() and became global Tejun Heo
2004-11-04  6:49 ` [PATCH 2.6.10-rc1 8/15] driver-model: MODULE_PARAM_PREFIX is changed to empty string from nothing Tejun Heo
2004-11-04  6:50 ` [PATCH 2.6.10-rc1 9/15] driver-model: parse_args()'s @unknown function modified to take void *arg Tejun Heo
2004-11-04  6:51 ` [PATCH 2.6.10-rc1 10/15] driver-model: module_param_array() changed back to accept variable name directly for @num and module_param_arr() added Tejun Heo
2004-11-04  6:52 ` [PATCH 2.6.10-rc1 11/15] driver-model: module_param_array/arr() change applied Tejun Heo
2004-11-04  6:53 ` [PATCH 2.6.10-rc1 12/15] driver-model: devparam implemented Tejun Heo
2004-11-04  6:53 ` Tejun Heo [this message]
2004-11-04  6:54 ` [PATCH 2.6.10-rc1 14/15] driver-model: devparam documentation Tejun Heo
2004-11-04  6:54 ` [PATCH 2.6.10-rc1 15/15] driver-model: via-velocity converted to use devparam Tejun Heo

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20041104065358.GM24890@home-tj.org \
    --to=tj@home-tj.org \
    --cc=greg@kroah.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mochel@osdl.org \
    --cc=rusty@rustcorp.com.au \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®