[GIT PATCH] driver core fixes against 2.6.24-git

Previous thread: [BUG] 2.6.24 refuses to boot - NMI watchdog problem? by Chris Rankin on Saturday, February 2, 2008 - 7:36 pm. (9 messages)

Next thread: [GIT PATCH] PCI fixes for 2.6.24-git by Greg KH on Saturday, February 2, 2008 - 7:44 pm. (1 message)
To: Linus Torvalds <torvalds@...>, Andrew Morton <akpm@...>
Cc: <linux-kernel@...>, Paul Mundt <lethal@...>, Frank Seidel <fseidel@...>, Dave Young <hidave.darkstar@...>, Tsugikazu Shibata <tshibata@...>, Jan Engelhardt <jengelh@...>, Rafael J. Wysocki <rjw@...>, Stephen Rothwell <sfr@...>, Cornelia Huck <cornelia.huck@...>
Date: Saturday, February 2, 2008 - 7:43 pm

Here's 10 patches against your current git tree that fix some more build
issues (with CONFIG_SYSFS=n), update some documentation, and refresh the
nozomi driver with some fixes.

Please pull from:
master.kernel.org:/pub/scm/linux/kernel/git/gregkh/driver-2.6.git/

Patches will be sent as a follow-on to this message to lkml for people
to see.

thanks,

greg k-h

------------

Documentation/driver-model/platform.txt | 6 +-
Documentation/ja_JP/stable_kernel_rules.txt | 79 ++++++++++++
drivers/base/core.c | 40 ++----
drivers/base/driver.c | 9 +-
drivers/base/power/main.c | 1 +
drivers/base/power/power.h | 1 -
drivers/char/nozomi.c | 172 +++++++++-----------------
include/linux/device.h | 6 +
kernel/Makefile | 3 +-
lib/kobject.c | 2 +-
10 files changed, 167 insertions(+), 152 deletions(-)
create mode 100644 Documentation/ja_JP/stable_kernel_rules.txt

---------------

Cornelia Huck (1):
Driver core: Remove unneeded get_{device,driver}() calls.

Dave Young (2):
kobject: kerneldoc comment fix
driver core: convert to use class_find_device api

Frank Seidel (2):
nozomi driver update
nozomi: finish constification

Jan Engelhardt (1):
nozomi: constify driver

Paul Mundt (1):
kobject: Always build in kernel/ksysfs.o.

Rafael J. Wysocki (1):
PM: Export device_pm_schedule_removal

Stephen Rothwell (1):
Driver core: Update some prototypes in platform.txt

Tsugikazu Shibata (1):
Add ja_JP translation of stable_kernel_rules.txt

--

To: <linux-kernel@...>
Cc: Cornelia Huck <cornelia.huck@...>, Dave Young <hidave.darkstar@...>, Greg Kroah-Hartman <gregkh@...>
Date: Saturday, February 2, 2008 - 7:56 pm

From: Cornelia Huck <cornelia.huck@de.ibm.com>

Driver core: Remove unneeded get_{device,driver}() calls.

Code trying to add/remove attributes must hold a reference to
the device resp. driver anyway, so let's remove those reference
count games.

Signed-off-by: Cornelia Huck <cornelia.huck@de.ibm.com>
Cc: Dave Young <hidave.darkstar@gmail.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
---
drivers/base/core.c | 8 ++------
drivers/base/driver.c | 9 +++------
2 files changed, 5 insertions(+), 12 deletions(-)

diff --git a/drivers/base/core.c b/drivers/base/core.c
index a0cfda5..9c0070b 100644
--- a/drivers/base/core.c
+++ b/drivers/base/core.c
@@ -423,10 +423,8 @@ struct kset *devices_kset;
int device_create_file(struct device *dev, struct device_attribute *attr)
{
int error = 0;
- if (get_device(dev)) {
+ if (dev)
error = sysfs_create_file(&dev->kobj, &attr->attr);
- put_device(dev);
- }
return error;
}

@@ -437,10 +435,8 @@ int device_create_file(struct device *dev, struct device_attribute *attr)
*/
void device_remove_file(struct device *dev, struct device_attribute *attr)
{
- if (get_device(dev)) {
+ if (dev)
sysfs_remove_file(&dev->kobj, &attr->attr);
- put_device(dev);
- }
}

/**
diff --git a/drivers/base/driver.c b/drivers/base/driver.c
index a35f041..ba75184 100644
--- a/drivers/base/driver.c
+++ b/drivers/base/driver.c
@@ -97,10 +97,9 @@ int driver_create_file(struct device_driver *drv,
struct driver_attribute *attr)
{
int error;
- if (get_driver(drv)) {
+ if (drv)
error = sysfs_create_file(&drv->p->kobj, &attr->attr);
- put_driver(drv);
- } else
+ else
error = -EINVAL;
return error;
}
@@ -114,10 +113,8 @@ EXPORT_SYMBOL_GPL(driver_create_file);
void driver_remove_file(struct device_driver *drv,
struct driver_attribute *attr)
{
- if (get_driver(drv)) {
+ if (drv)
sysfs_remove_file(&drv->p->ko...

To: <linux-kernel@...>
Cc: Stephen Rothwell <sfr@...>, Greg Kroah-Hartman <gregkh@...>
Date: Saturday, February 2, 2008 - 7:56 pm

From: Stephen Rothwell <sfr@canb.auug.org.au>

Just make these match the actual code.

Signed-off-by: Stephen Rothwell <sfr@canb.auug.org.au>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
---
Documentation/driver-model/platform.txt | 6 +++---
1 files changed, 3 insertions(+), 3 deletions(-)

diff --git a/Documentation/driver-model/platform.txt b/Documentation/driver-model/platform.txt
index 2a97320..83009fd 100644
--- a/Documentation/driver-model/platform.txt
+++ b/Documentation/driver-model/platform.txt
@@ -122,15 +122,15 @@ None the less, there are some APIs to support such legacy drivers. Avoid
using these calls except with such hotplug-deficient drivers.

struct platform_device *platform_device_alloc(
- char *name, unsigned id);
+ const char *name, int id);

You can use platform_device_alloc() to dynamically allocate a device, which
you will then initialize with resources and platform_device_register().
A better solution is usually:

struct platform_device *platform_device_register_simple(
- char *name, unsigned id,
- struct resource *res, unsigned nres);
+ const char *name, int id,
+ struct resource *res, unsigned int nres);

You can use platform_device_register_simple() as a one-step call to allocate
and register a device.
--
1.5.3.8

--

To: <linux-kernel@...>
Cc: Dave Young <hidave.darkstar@...>, Greg Kroah-Hartman <gregkh@...>
Date: Saturday, February 2, 2008 - 7:56 pm

From: Dave Young <hidave.darkstar@gmail.com>

Convert to use class_find_device api in drivers/base/core.c

Signed-off-by: Dave Young <hidave.darkstar@gmail.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
---
drivers/base/core.c | 32 +++++++++++---------------------
1 files changed, 11 insertions(+), 21 deletions(-)

diff --git a/drivers/base/core.c b/drivers/base/core.c
index b172787..a0cfda5 100644
--- a/drivers/base/core.c
+++ b/drivers/base/core.c
@@ -1144,25 +1144,11 @@ error:
}
EXPORT_SYMBOL_GPL(device_create);

-/**
- * find_device - finds a device that was created with device_create()
- * @class: pointer to the struct class that this device was registered with
- * @devt: the dev_t of the device that was previously registered
- */
-static struct device *find_device(struct class *class, dev_t devt)
+static int __match_devt(struct device *dev, void *data)
{
- struct device *dev = NULL;
- struct device *dev_tmp;
+ dev_t *devt = data;

- down(&class->sem);
- list_for_each_entry(dev_tmp, &class->devices, node) {
- if (dev_tmp->devt == devt) {
- dev = dev_tmp;
- break;
- }
- }
- up(&class->sem);
- return dev;
+ return dev->devt == *devt;
}

/**
@@ -1177,9 +1163,11 @@ void device_destroy(struct class *class, dev_t devt)
{
struct device *dev;

- dev = find_device(class, devt);
- if (dev)
+ dev = class_find_device(class, &devt, __match_devt);
+ if (dev) {
+ put_device(dev);
device_unregister(dev);
+ }
}
EXPORT_SYMBOL_GPL(device_destroy);

@@ -1203,9 +1191,11 @@ void destroy_suspended_device(struct class *class, dev_t devt)
{
struct device *dev;

- dev = find_device(class, devt);
- if (dev)
+ dev = class_find_device(class, &devt, __match_devt);
+ if (dev) {
device_pm_schedule_removal(dev);
+ put_device(dev);
+ }
}
EXPORT_SYMBOL_GPL(destroy_suspended_device);
#endif /* CONFIG_PM_SLEEP */
--
1.5.3.8

--

To: <linux-kernel@...>
Cc: Rafael J. Wysocki <rjw@...>, Greg Kroah-Hartman <gregkh@...>
Date: Saturday, February 2, 2008 - 7:56 pm

From: Rafael J. Wysocki <rjw@sisk.pl>

Move the declaration of device_pm_schedule_removal() to device.h
and make it exported, as it will be used directly by some drivers
for unregistering device objects during suspend/resume cycles in a
safe way.

Signed-off-by: Rafael J. Wysocki <rjw@sisk.pl>
Acked-by: Pavel Machek <pavel@ucw.cz>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
---
drivers/base/power/main.c | 1 +
drivers/base/power/power.h | 1 -
include/linux/device.h | 6 ++++++
3 files changed, 7 insertions(+), 1 deletions(-)

diff --git a/drivers/base/power/main.c b/drivers/base/power/main.c
index 200ed5f..bdc03f7 100644
--- a/drivers/base/power/main.c
+++ b/drivers/base/power/main.c
@@ -129,6 +129,7 @@ void device_pm_schedule_removal(struct device *dev)
list_move_tail(&dev->power.entry, &dpm_destroy);
mutex_unlock(&dpm_list_mtx);
}
+EXPORT_SYMBOL_GPL(device_pm_schedule_removal);

/**
* pm_sleep_lock - mutual exclusion for registration and suspend
diff --git a/drivers/base/power/power.h b/drivers/base/power/power.h
index 6f0dfca..e32d3bd 100644
--- a/drivers/base/power/power.h
+++ b/drivers/base/power/power.h
@@ -13,7 +13,6 @@ static inline struct device *to_device(struct list_head *entry)

extern void device_pm_add(struct device *);
extern void device_pm_remove(struct device *);
-extern void device_pm_schedule_removal(struct device *);
extern int pm_sleep_lock(void);
extern void pm_sleep_unlock(void);

diff --git a/include/linux/device.h b/include/linux/device.h
index db375be..479c0b3 100644
--- a/include/linux/device.h
+++ b/include/linux/device.h
@@ -534,11 +534,17 @@ extern struct device *device_create(struct class *cls, struct device *parent,
extern void device_destroy(struct class *cls, dev_t devt);
#ifdef CONFIG_PM_SLEEP
extern void destroy_suspended_device(struct class *cls, dev_t devt);
+extern void device_pm_schedule_removal(struct device *);
#else /* !CONFIG_PM_SLEEP */
st...

To: <linux-kernel@...>
Cc: Frank Seidel <fseidel@...>, Greg Kroah-Hartman <gregkh@...>
Date: Saturday, February 2, 2008 - 7:56 pm

From: Frank Seidel <fseidel@suse.de>

Even some more constifications

Signed-off-by: Frank Seidel <fseidel@suse.de>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
---
drivers/char/nozomi.c | 14 +++++++-------
1 files changed, 7 insertions(+), 7 deletions(-)

diff --git a/drivers/char/nozomi.c b/drivers/char/nozomi.c
index 7979eb1..dfaab23 100644
--- a/drivers/char/nozomi.c
+++ b/drivers/char/nozomi.c
@@ -395,7 +395,7 @@ struct buffer {
} __attribute__ ((packed));

/* Global variables */
-static struct pci_device_id nozomi_pci_tbl[] __devinitdata = {
+static const struct pci_device_id nozomi_pci_tbl[] __devinitconst = {
{PCI_DEVICE(VENDOR1, DEVICE1)},
{},
};
@@ -778,13 +778,13 @@ static void disable_transmit_dl(enum port_type port, struct nozomi *dc)
* Return 1 - send buffer to card and ack.
* Return 0 - don't ack, don't send buffer to card.
*/
-static int send_data(enum port_type index, struct nozomi *dc)
+static int send_data(enum port_type index, const struct nozomi *dc)
{
u32 size = 0;
const struct port *port = &dc->port[index];
- u8 toggle = port->toggle_ul;
+ const u8 toggle = port->toggle_ul;
void __iomem *addr = port->ul_addr[toggle];
- u32 ul_size = port->ul_size[toggle];
+ const u32 ul_size = port->ul_size[toggle];
struct tty_struct *tty = port->tty;

/* Get data from tty and place in buf for now */
@@ -1732,7 +1732,7 @@ static int ntty_tiocmset(struct tty_struct *tty, struct file *file,
static int ntty_cflags_changed(struct port *port, unsigned long flags,
struct async_icount *cprev)
{
- struct async_icount cnow = port->tty_icount;
+ const struct async_icount cnow = port->tty_icount;
int ret;

ret = ((flags & TIOCM_RNG) && (cnow.rng != cprev->rng)) ||
@@ -1747,7 +1747,7 @@ static int ntty_cflags_changed(struct port *port, unsigned long flags,

static int ntty_ioctl_tiocgicount(struct port *port, void __user *argp)
{
- struct async_icount c...

To: <linux-kernel@...>
Cc: Jan Engelhardt <jengelh@...>, Frank Seidel <fseidel@...>, Greg Kroah-Hartman <gregkh@...>
Date: Saturday, February 2, 2008 - 7:55 pm

From: Jan Engelhardt <jengelh@computergmbh.de>

nozomi: constify structures and annotate vars

Signed-off-by: Jan Engelhardt <jengelh@computergmbh.de>
Signed-off-by: Frank Seidel <fseidel@suse.de>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
---
drivers/char/nozomi.c | 38 ++++++++++++++++++--------------------
1 files changed, 18 insertions(+), 20 deletions(-)

diff --git a/drivers/char/nozomi.c b/drivers/char/nozomi.c
index 86ded7e..7979eb1 100644
--- a/drivers/char/nozomi.c
+++ b/drivers/char/nozomi.c
@@ -395,7 +395,7 @@ struct buffer {
} __attribute__ ((packed));

/* Global variables */
-static struct pci_device_id nozomi_pci_tbl[] = {
+static struct pci_device_id nozomi_pci_tbl[] __devinitdata = {
{PCI_DEVICE(VENDOR1, DEVICE1)},
{},
};
@@ -471,12 +471,12 @@ out:
* -Optimize
* -Rewrite cleaner
*/
-static u32 write_mem32(void __iomem *mem_addr_start, u32 *buf,
+static u32 write_mem32(void __iomem *mem_addr_start, const u32 *buf,
u32 size_bytes)
{
u32 i = 0;
u32 *ptr = (__force u32 *) mem_addr_start;
- u16 *buf16;
+ const u16 *buf16;

if (unlikely(!ptr || !buf))
return 0;
@@ -484,7 +484,7 @@ static u32 write_mem32(void __iomem *mem_addr_start, u32 *buf,
/* shortcut for extremely often used cases */
switch (size_bytes) {
case 2: /* 2 bytes */
- buf16 = (u16 *) buf;
+ buf16 = (const u16 *)buf;
writew(__cpu_to_le16(*buf16), (void __iomem *)ptr);
return 2;
break;
@@ -501,7 +501,7 @@ static u32 write_mem32(void __iomem *mem_addr_start, u32 *buf,
while (i < size_bytes) {
if (size_bytes - i == 2) {
/* 2 bytes */
- buf16 = (u16 *) buf;
+ buf16 = (const u16 *)buf;
writew(__cpu_to_le16(*buf16), (void __iomem *)ptr);
i += 2;
} else {
@@ -723,8 +723,7 @@ static int nozomi_read_config_table(struct nozomi *dc)
/* Enable uplink interrupts */
static void enable_transmit_ul(enum port_type port, struct nozomi *dc)
{
- u16 mask[NOZOMI_MAX_PORTS] = \
- {MDM...

To: <linux-kernel@...>
Cc: Frank Seidel <fseidel@...>, Greg Kroah-Hartman <gregkh@...>
Date: Saturday, February 2, 2008 - 7:55 pm

From: Frank Seidel <fseidel@suse.de>

Minor cleanups and removal of in-file changelog:

- Correction of misspellings and wrong encoded Name
- changed 'unsigned' to 'unsigned int' for better readability
- use of generic devicefile access macro
- fixed/added explanatory comment to ntty_put_char

Signed-off-by: Frank Seidel <fseidel@suse.de>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
---
drivers/char/nozomi.c | 122 ++++++++++++++----------------------------------
1 files changed, 36 insertions(+), 86 deletions(-)

diff --git a/drivers/char/nozomi.c b/drivers/char/nozomi.c
index 6076e66..86ded7e 100644
--- a/drivers/char/nozomi.c
+++ b/drivers/char/nozomi.c
@@ -2,7 +2,7 @@
* nozomi.c -- HSDPA driver Broadband Wireless Data Card - Globe Trotter
*
* Written by: Ulf Jakobsson,
- * Jan

To: <linux-kernel@...>
Cc: Tsugikazu Shibata <tshibata@...>, Greg Kroah-Hartman <gregkh@...>
Date: Saturday, February 2, 2008 - 7:55 pm

From: Tsugikazu Shibata <tshibata@ab.jp.nec.com>

Contents are reviewed by Japanese translation community called "JF".
Thanks a lot!

Singed-off-by: Tsugikazu Shibata <tshibata@ab.jp.nec.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
---
Documentation/ja_JP/stable_kernel_rules.txt | 79 +++++++++++++++++++++++++++
1 files changed, 79 insertions(+), 0 deletions(-)
create mode 100644 Documentation/ja_JP/stable_kernel_rules.txt

diff --git a/Documentation/ja_JP/stable_kernel_rules.txt b/Documentation/ja_JP/stable_kernel_rules.txt
new file mode 100644
index 0000000..17d8751
--- /dev/null
+++ b/Documentation/ja_JP/stable_kernel_rules.txt
@@ -0,0 +1,79 @@
+NOTE:
+This is Japanese translated version of "Documentation/stable_kernel_rules.txt".
+This one is maintained by Tsugikazu Shibata <tshibata@ab.jp.nec.com>
+and JF Project team <www.linux.or.jp/JF>.
+If you find difference with original file or problem in translation,
+please contact maintainer of this file or JF project.
+
+Please also note that purpose of this file is easier to read for non
+English natives and do no intended to fork. So, if you have any
+comment or update of this file, please try to update Original(English)
+file at first.
+
+==================================
+

To: <linux-kernel@...>
Cc: Dave Young <hidave.darkstar@...>, Greg Kroah-Hartman <gregkh@...>
Date: Saturday, February 2, 2008 - 7:55 pm

From: Dave Young <hidave.darkstar@gmail.com>

Fix kerneldoc comment of kobject_create.

Signed-off-by: Dave Young <hidave.darkstar@gmail.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
---
lib/kobject.c | 2 +-
1 files changed, 1 insertions(+), 1 deletions(-)

diff --git a/lib/kobject.c b/lib/kobject.c
index 1d63ead..d784dae 100644
--- a/lib/kobject.c
+++ b/lib/kobject.c
@@ -637,7 +637,7 @@ struct kobject *kobject_create(void)
* @name: the name for the kset
* @parent: the parent kobject of this kobject, if any.
*
- * This function creates a kset structure dynamically and registers it
+ * This function creates a kobject structure dynamically and registers it
* with sysfs. When you are finished with this structure, call
* kobject_put() and the structure will be dynamically freed when
* it is no longer being used.
--
1.5.3.8

--

To: <linux-kernel@...>
Cc: Paul Mundt <lethal@...>, Greg Kroah-Hartman <gregkh@...>
Date: Saturday, February 2, 2008 - 7:55 pm

From: Paul Mundt <lethal@linux-sh.org>

kernel/ksysfs.c seems to be a random dumping group for misc globals
that the rest of the tree depend on. This has caused problems with
exports in the past when sysfs is disabled, which can already be
observed in commit-id 51107301b629640f9ab76fe23bf385e187b9ac29.

The latest one is the kernel_kobj usage, which presently results in:

fs/built-in.o: In function `debugfs_init':
inode.c:(.init.text+0xc34): undefined reference to `kernel_kobj'
make: *** [.tmp_vmlinux1] Error 1

kernel/ksysfs.c itself at this point only contains globals and some
basic sysfs initialization, the sysfs initialization code is optimized
out when we build with sysfs disabled. Given that, it's easier to just
build in unconditionally, rather than trying to find some other random
place to dump and initialize the globals.

Additionally, the current trend seems to be decoupling of kobjects from
sysfs, in which case it still makes sense to perform the kernel_kobj
initialization that happens here even if sysfs is disabled, as
lib/kobject.o is built-in unconditionally.

Signed-off-by: Paul Mundt <lethal@linux-sh.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
---
kernel/Makefile | 3 +--
1 files changed, 1 insertions(+), 2 deletions(-)

diff --git a/kernel/Makefile b/kernel/Makefile
index 8885627..db9af70 100644
--- a/kernel/Makefile
+++ b/kernel/Makefile
@@ -9,7 +9,7 @@ obj-y = sched.o fork.o exec_domain.o panic.o printk.o profile.o \
rcupdate.o extable.o params.o posix-timers.o \
kthread.o wait.o kfifo.o sys_ni.o posix-cpu-timers.o mutex.o \
hrtimer.o rwsem.o latency.o nsproxy.o srcu.o \
- utsname.o notifier.o
+ utsname.o notifier.o ksysfs.o

obj-$(CONFIG_SYSCTL) += sysctl_check.o
obj-$(CONFIG_STACKTRACE) += stacktrace.o
@@ -49,7 +49,6 @@ obj-$(CONFIG_AUDIT) += audit.o auditfilter.o
obj-$(CONFIG_AUDITSYSCALL) += auditsc.o
obj-$(CONFIG_AUDIT_TREE) += audit_tree.o
obj-$(CONFIG_KPROBES) += kprobes.o
...

Previous thread: [BUG] 2.6.24 refuses to boot - NMI watchdog problem? by Chris Rankin on Saturday, February 2, 2008 - 7:36 pm. (9 messages)

Next thread: [GIT PATCH] PCI fixes for 2.6.24-git by Greg KH on Saturday, February 2, 2008 - 7:44 pm. (1 message)