Commit 29e7ee37 authored by Linus Torvalds's avatar Linus Torvalds
Browse files

Merge master.kernel.org:/pub/scm/linux/kernel/git/gregkh/driver-2.6

* master.kernel.org:/pub/scm/linux/kernel/git/gregkh/driver-2.6:
  sysfs: cosmetic clean up on node creation failure paths
  sysfs: kill an extra put in sysfs_create_link() failure path
  Driver core: check return code of sysfs_create_link()
  HOWTO: Add the knwon_regression URI to the documentation
  dev_vdbg() documentation
  dev_vdbg(), available with -DVERBOSE_DEBUG
  sysfs: make sysfs_init_inode() static
  sysfs: fix sysfs root inode nlink accounting
  Documentation fix devres.txt: lib/iomap.c -> lib/devres.c
  sysfs: avoid kmem_cache_free(NULL)
  PM: remove deprecated dpm_runtime_* routines
  PM: Remove deprecated sysfs files
  Driver core: accept all valid action-strings in uevent-trigger
  debugfs: remove rmdir() non-empty complaint
parents fc15bc81 967e35dc
Loading
Loading
Loading
Loading
+18 −2
Original line number Diff line number Diff line
@@ -633,12 +633,27 @@ covers RTL which is used frequently with assembly language in the kernel.

Kernel developers like to be seen as literate. Do mind the spelling
of kernel messages to make a good impression. Do not use crippled
words like "dont" and use "do not" or "don't" instead.
words like "dont"; use "do not" or "don't" instead.  Make the messages
concise, clear, and unambiguous.

Kernel messages do not have to be terminated with a period.

Printing numbers in parentheses (%d) adds no value and should be avoided.

There are a number of driver model diagnostic macros in <linux/device.h>
which you should use to make sure messages are matched to the right device
and driver, and are tagged with the right level:  dev_err(), dev_warn(),
dev_info(), and so forth.  For messages that aren't associated with a
particular device, <linux/kernel.h> defines pr_debug() and pr_info().

Coming up with good debugging messages can be quite a challenge; and once
you have them, they can be a huge help for remote troubleshooting.  Such
messages should be compiled out when the DEBUG symbol is not defined (that
is, by default they are not included).  When you use dev_dbg() or pr_debug(),
that's automatic.  Many subsystems have Kconfig options to turn on -DDEBUG.
A related convention uses VERBOSE_DEBUG to add dev_vdbg() messages to the
ones already enabled by DEBUG.


		Chapter 14: Allocating memory

@@ -790,4 +805,5 @@ Kernel CodingStyle, by greg@kroah.com at OLS 2002:
http://www.kroah.com/linux/talks/ols_2002_kernel_codingstyle_talk/html/

--
Last updated on 2006-December-06.
Last updated on 2007-July-13.
+3 −0
Original line number Diff line number Diff line
@@ -249,6 +249,9 @@ process is as follows:
    release a new -rc kernel every week.
  - Process continues until the kernel is considered "ready", the
    process should last around 6 weeks.
  - A list of known regressions present in each -rc release is
    tracked at the following URI:
    http://kernelnewbies.org/known_regressions

It is worth mentioning what Andrew Morton wrote on the linux-kernel
mailing list about kernel releases:
+1 −1
Original line number Diff line number Diff line
@@ -207,7 +207,7 @@ responsibility. This is usually non-issue because bus ops and
resource allocations already do the job.

For an example of single-instance devres type, read pcim_iomap_table()
in lib/iomap.c.
in lib/devres.c.

All devres interface functions can be called without context if the
right gfp mask is given.
+1 −3
Original line number Diff line number Diff line
@@ -26,9 +26,7 @@ Who: Hans Verkuil <hverkuil@xs4all.nl> and

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

What:	/sys/devices/.../power/state
	dev->power.power_state
	dpm_runtime_{suspend,resume)()
What:	dev->power.power_state
When:	July 2007
Why:	Broken design for runtime control over driver power states, confusing
	driver-internal runtime power management with:  mechanisms to support
+125 −43
Original line number Diff line number Diff line
@@ -24,6 +24,8 @@
#include "base.h"
#include "power/power.h"

extern const char *kobject_actions[];

int (*platform_notify)(struct device * dev) = NULL;
int (*platform_notify_remove)(struct device * dev) = NULL;

@@ -303,10 +305,25 @@ out:
static ssize_t store_uevent(struct device *dev, struct device_attribute *attr,
			    const char *buf, size_t count)
{
	if (memcmp(buf, "add", 3) != 0)
	size_t len = count;
	enum kobject_action action;

	if (len && buf[len-1] == '\n')
		len--;

	for (action = 0; action < KOBJ_MAX; action++) {
		if (strncmp(kobject_actions[action], buf, len) != 0)
			continue;
		if (kobject_actions[action][len] != '\0')
			continue;
		kobject_uevent(&dev->kobj, action);
		goto out;
	}

	dev_err(dev, "uevent: unsupported action-string; this will "
			"be ignored in a future kernel version");
		     "be ignored in a future kernel version\n");
	kobject_uevent(&dev->kobj, KOBJ_ADD);
out:
	return count;
}

@@ -643,6 +660,82 @@ static int setup_parent(struct device *dev, struct device *parent)
	return 0;
}

static int device_add_class_symlinks(struct device *dev)
{
	int error;

	if (!dev->class)
		return 0;
	error = sysfs_create_link(&dev->kobj, &dev->class->subsys.kobj,
				  "subsystem");
	if (error)
		goto out;
	/*
	 * If this is not a "fake" compatible device, then create the
	 * symlink from the class to the device.
	 */
	if (dev->kobj.parent != &dev->class->subsys.kobj) {
		error = sysfs_create_link(&dev->class->subsys.kobj, &dev->kobj,
					  dev->bus_id);
		if (error)
			goto out_subsys;
	}
	/* only bus-device parents get a "device"-link */
	if (dev->parent && dev->parent->bus) {
		error = sysfs_create_link(&dev->kobj, &dev->parent->kobj,
					  "device");
		if (error)
			goto out_busid;
#ifdef CONFIG_SYSFS_DEPRECATED
		{
			char * class_name = make_class_name(dev->class->name,
								&dev->kobj);
			if (class_name)
				error = sysfs_create_link(&dev->parent->kobj,
							&dev->kobj, class_name);
			kfree(class_name);
			if (error)
				goto out_device;
		}
#endif
	}
	return 0;

#ifdef CONFIG_SYSFS_DEPRECATED
out_device:
	if (dev->parent)
		sysfs_remove_link(&dev->kobj, "device");
#endif
out_busid:
	if (dev->kobj.parent != &dev->class->subsys.kobj)
		sysfs_remove_link(&dev->class->subsys.kobj, dev->bus_id);
out_subsys:
	sysfs_remove_link(&dev->kobj, "subsystem");
out:
	return error;
}

static void device_remove_class_symlinks(struct device *dev)
{
	if (!dev->class)
		return;
	if (dev->parent) {
#ifdef CONFIG_SYSFS_DEPRECATED
		char *class_name;

		class_name = make_class_name(dev->class->name, &dev->kobj);
		if (class_name) {
			sysfs_remove_link(&dev->parent->kobj, class_name);
			kfree(class_name);
		}
#endif
		sysfs_remove_link(&dev->kobj, "device");
	}
	if (dev->kobj.parent != &dev->class->subsys.kobj)
		sysfs_remove_link(&dev->class->subsys.kobj, dev->bus_id);
	sysfs_remove_link(&dev->kobj, "subsystem");
}

/**
 *	device_add - add device to device hierarchy.
 *	@dev:	device.
@@ -657,7 +750,6 @@ static int setup_parent(struct device *dev, struct device *parent)
int device_add(struct device *dev)
{
	struct device *parent = NULL;
	char *class_name = NULL;
	struct class_interface *class_intf;
	int error = -EINVAL;

@@ -697,27 +789,9 @@ int device_add(struct device *dev)
			goto ueventattrError;
	}

	if (dev->class) {
		sysfs_create_link(&dev->kobj, &dev->class->subsys.kobj,
				  "subsystem");
		/* If this is not a "fake" compatible device, then create the
		 * symlink from the class to the device. */
		if (dev->kobj.parent != &dev->class->subsys.kobj)
			sysfs_create_link(&dev->class->subsys.kobj,
					  &dev->kobj, dev->bus_id);
		if (parent) {
			sysfs_create_link(&dev->kobj, &dev->parent->kobj,
							"device");
#ifdef CONFIG_SYSFS_DEPRECATED
			class_name = make_class_name(dev->class->name,
							&dev->kobj);
			if (class_name)
				sysfs_create_link(&dev->parent->kobj,
						  &dev->kobj, class_name);
#endif
		}
	}

	error = device_add_class_symlinks(dev);
	if (error)
		goto SymlinkError;
	error = device_add_attrs(dev);
	if (error)
		goto AttrsError;
@@ -744,7 +818,6 @@ int device_add(struct device *dev)
		up(&dev->class->sem);
	}
 Done:
	kfree(class_name);
	put_device(dev);
	return error;
 BusError:
@@ -755,6 +828,8 @@ int device_add(struct device *dev)
					     BUS_NOTIFY_DEL_DEVICE, dev);
	device_remove_attrs(dev);
 AttrsError:
	device_remove_class_symlinks(dev);
 SymlinkError:
	if (MAJOR(dev->devt))
		device_remove_file(dev, &devt_attr);

@@ -1139,7 +1214,7 @@ int device_rename(struct device *dev, char *new_name)
{
	char *old_class_name = NULL;
	char *new_class_name = NULL;
	char *old_symlink_name = NULL;
	char *old_device_name = NULL;
	int error;

	dev = get_device(dev);
@@ -1153,42 +1228,49 @@ int device_rename(struct device *dev, char *new_name)
		old_class_name = make_class_name(dev->class->name, &dev->kobj);
#endif

	if (dev->class) {
		old_symlink_name = kmalloc(BUS_ID_SIZE, GFP_KERNEL);
		if (!old_symlink_name) {
	old_device_name = kmalloc(BUS_ID_SIZE, GFP_KERNEL);
	if (!old_device_name) {
		error = -ENOMEM;
			goto out_free_old_class;
		}
		strlcpy(old_symlink_name, dev->bus_id, BUS_ID_SIZE);
		goto out;
	}

	strlcpy(old_device_name, dev->bus_id, BUS_ID_SIZE);
	strlcpy(dev->bus_id, new_name, BUS_ID_SIZE);

	error = kobject_rename(&dev->kobj, new_name);
	if (error) {
		strlcpy(dev->bus_id, old_device_name, BUS_ID_SIZE);
		goto out;
	}

#ifdef CONFIG_SYSFS_DEPRECATED
	if (old_class_name) {
		new_class_name = make_class_name(dev->class->name, &dev->kobj);
		if (new_class_name) {
			sysfs_create_link(&dev->parent->kobj, &dev->kobj,
					  new_class_name);
			error = sysfs_create_link(&dev->parent->kobj,
						  &dev->kobj, new_class_name);
			if (error)
				goto out;
			sysfs_remove_link(&dev->parent->kobj, old_class_name);
		}
	}
#endif

	if (dev->class) {
		sysfs_remove_link(&dev->class->subsys.kobj,
				  old_symlink_name);
		sysfs_create_link(&dev->class->subsys.kobj, &dev->kobj,
		sysfs_remove_link(&dev->class->subsys.kobj, old_device_name);
		error = sysfs_create_link(&dev->class->subsys.kobj, &dev->kobj,
					  dev->bus_id);
		if (error) {
			/* Uh... how to unravel this if restoring can fail? */
			dev_err(dev, "%s: sysfs_create_symlink failed (%d)\n",
				__FUNCTION__, error);
		}
	}
out:
	put_device(dev);

	kfree(new_class_name);
	kfree(old_symlink_name);
 out_free_old_class:
	kfree(old_class_name);
	kfree(old_device_name);

	return error;
}
Loading