Skip to contentSkip to conversation

driver core fixes for 2.6.24-rc3

PATCH New Greg KH 1 participant 7 messages Nov 28, 2007

Subsystems (7)
lore
Share & tools
lore

Greg KH

author
#0 lore raw

PATCH 1/1 driver core fixes for 2.6.24-rc3

Here are some driver core bugfixes and documentation updates for 2.6.24-rc3. It fixes a regression with CONFIG_PM being set and not set that people have reported.

There's some other minor fixes, and an update for the UIO documentation.

All of these have been in the -mm tree for a while.

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/DocBook/Makefile       |    2 +-
 Documentation/DocBook/uio-howto.tmpl |   90 ++++++++++++----------------------
 drivers/base/core.c                  |    4 +-
 drivers/base/power/Makefile          |    3 +-
 drivers/base/power/main.c            |    8 +---
 drivers/base/power/power.h           |   28 ++++++++---
 drivers/char/Kconfig                 |    2 +-
 fs/sysfs/file.c                      |    6 ++-
 lib/kobject.c                        |    4 +-
 9 files changed, 68 insertions(+), 79 deletions(-)

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

Daniel Drake (1):
create /sys/.../power when CONFIG_PM is set

Hans J Koch (2):
UIO: fix up the UIO documentation
UIO: add UIO documentation target to DocBook Makefile

Johannes Berg (1):
kobject: two typo fixes

Kay Sievers (1):
allow LEGACY_PTYS to be set to 0

Miao Xie (1):
sysfs: fix off-by-one error in fill_read_buffer()

#1 lore raw

PATCH 1/6 allow LEGACY_PTYS to be set to 0

From: Kay Sievers <[email protected]>

The count of legacy pty devices can be set by a kernel commandline parameter. For the distro kernel, we would like to disable all pty's by default, but keep the opportunity to request devices on the kernel commandline.

---
 drivers/char/Kconfig |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)
drivers/char/Kconfig +1 -1
index bf18d75..a509b8d 100644
@@ -457,7 +457,7 @@ config LEGACY_PTYS
 config LEGACY_PTY_COUNT
 	int "Maximum number of legacy PTY in use"
 	depends on LEGACY_PTYS
-	range 1 256
+	range 0 256
 	default "256"
 	---help---
 	  The maximum number of legacy PTYs that can be used at any one time.
Signature · 1 line
1.5.3.4
#2 lore raw

PATCH 2/6 create /sys/.../power when CONFIG_PM is set

In reply to Greg KH

From: Daniel Drake <[email protected]>

The CONFIG_SUSPEND changes in 2.6.23 caused a regression under certain configuration conditions (SUSPEND=n, USB_AUTOSUSPEND=y) where all USB device attributes in sysfs (idVendor, idProduct, ...) silently disappeared, causing udev breakage and more.

The cause of this is that the /sys/.../power subdirectory is now only created when CONFIG_PM_SLEEP is set, however, it should be created whenever CONFIG_PM is set to handle the above situation. The following patch fixes the regression.

---
 drivers/base/core.c         |    4 +++-
 drivers/base/power/Makefile |    3 ++-
 drivers/base/power/main.c   |    8 +-------
 drivers/base/power/power.h  |   28 +++++++++++++++++++++-------
 4 files changed, 27 insertions(+), 16 deletions(-)
drivers/base/core.c +3 -1
index 3f4d6aa..2683eac 100644
@@ -770,9 +770,10 @@ int device_add(struct device *dev)
 	error = device_add_attrs(dev);
 	if (error)
 		goto AttrsError;
-	error = device_pm_add(dev);
+	error = dpm_sysfs_add(dev);
 	if (error)
 		goto PMError;
+	device_pm_add(dev);
 	error = bus_add_device(dev);
 	if (error)
 		goto BusError;
@@ -797,6 +798,7 @@ int device_add(struct device *dev)
 	return error;
  BusError:
 	device_pm_remove(dev);
+	dpm_sysfs_remove(dev);
  PMError:
 	if (dev->bus)
 		blocking_notifier_call_chain(&dev->bus->bus_notifier,
drivers/base/power/Makefile +2 -1
index a803733..44504e6 100644
@@ -1,5 +1,6 @@
 obj-y			:= shutdown.o
-obj-$(CONFIG_PM_SLEEP)	+= main.o sysfs.o
+obj-$(CONFIG_PM)	+= sysfs.o
+obj-$(CONFIG_PM_SLEEP)	+= main.o
 obj-$(CONFIG_PM_TRACE)	+= trace.o
 
 ifeq ($(CONFIG_DEBUG_DRIVER),y)
drivers/base/power/main.c +1 -7
index 0ab4ab2..691ffb6 100644
@@ -38,20 +38,14 @@ static DEFINE_MUTEX(dpm_list_mtx);
 int (*platform_enable_wakeup)(struct device *dev, int is_on);
 
 
-int device_pm_add(struct device *dev)
+void device_pm_add(struct device *dev)
 {
-	int error;
-
 	pr_debug("PM: Adding info for %s:%s\n",
 		 dev->bus ? dev->bus->name : "No Bus",
 		 kobject_name(&dev->kobj));
 	mutex_lock(&dpm_list_mtx);
 	list_add_tail(&dev->power.entry, &dpm_active);
-	error = dpm_sysfs_add(dev);
-	if (error)
-		list_del(&dev->power.entry);
 	mutex_unlock(&dpm_list_mtx);
-	return error;
 }
 
 void device_pm_remove(struct device *dev)
drivers/base/power/power.h +21 -7
index 5c4efd4..379da4e 100644
@@ -13,14 +13,29 @@ extern void device_shutdown(void);
 
 extern struct list_head dpm_active;	/* The active device list */
 
-static inline struct device * to_device(struct list_head * entry)
+static inline struct device *to_device(struct list_head *entry)
 {
 	return container_of(entry, struct device, power.entry);
 }
 
-extern int device_pm_add(struct device *);
+extern void device_pm_add(struct device *);
 extern void device_pm_remove(struct device *);
 
+#else /* CONFIG_PM_SLEEP */
+
+
+static inline void device_pm_add(struct device *dev)
+{
+}
+
+static inline void device_pm_remove(struct device *dev)
+{
+}
+
+#endif
+
+#ifdef CONFIG_PM
+
 /*
  * sysfs.c
  */
@@ -28,16 +43,15 @@ extern void device_pm_remove(struct device *);
 extern int dpm_sysfs_add(struct device *);
 extern void dpm_sysfs_remove(struct device *);
 
-#else /* CONFIG_PM_SLEEP */
-
+#else /* CONFIG_PM */
 
-static inline int device_pm_add(struct device * dev)
+static inline int dpm_sysfs_add(struct device *dev)
 {
 	return 0;
 }
-static inline void device_pm_remove(struct device * dev)
-{
 
+static inline void dpm_sysfs_remove(struct device *dev)
+{
 }
 
 #endif
Signature · 1 line
1.5.3.4
#3 lore raw

PATCH 3/6 UIO: fix up the UIO documentation

In reply to Greg KH

From: Hans J Koch <[email protected]>

Remove references to the old uio_dummy demo module from UIO documentation. Add a small paragraph to make it clearer that UIO is not a universal driver interface.

---
 Documentation/DocBook/uio-howto.tmpl |   90 ++++++++++++----------------------
 1 files changed, 32 insertions(+), 58 deletions(-)
Documentation/DocBook/uio-howto.tmpl +32 -58
index c119484..fdd7f4f 100644
@@ -30,6 +30,12 @@
 
 <revhistory>
 	<revision>
+	<revnumber>0.4</revnumber>
+	<date>2007-11-26</date>
+	<authorinitials>hjk</authorinitials>
+	<revremark>Removed section about uio_dummy.</revremark>
+	</revision>
+	<revision>
 	<revnumber>0.3</revnumber>
 	<date>2007-04-29</date>
 	<authorinitials>hjk</authorinitials>
@@ -94,6 +100,26 @@ interested in translating it, please email me
 	user space. This simplifies development and reduces the risk of
 	serious bugs within a kernel module.
 	</para>
+	<para>
+	Please note that UIO is not an universal driver interface. Devices
+	that are already handled well by other kernel subsystems (like
+	networking or serial or USB) are no candidates for an UIO driver.
+	Hardware that is ideally suited for an UIO driver fulfills all of
+	the following:
+	</para>
+<itemizedlist>
+<listitem>
+	<para>The device has memory that can be mapped. The device can be
+	controlled completely by writing to this memory.</para>
+</listitem>
+<listitem>
+	<para>The device usually generates interrupts.</para>
+</listitem>
+<listitem>
+	<para>The device does not fit into one of the standard kernel
+	subsystems.</para>
+</listitem>
+</itemizedlist>
 </sect1>
 
 <sect1 id="thanks">
@@ -174,8 +200,9 @@ interested in translating it, please email me
 	For cards that don't generate interrupts but need to be
 	polled, there is the possibility to set up a timer that
 	triggers the interrupt handler at configurable time intervals.
-	See <filename>drivers/uio/uio_dummy.c</filename> for an
-	example of this technique.
+	This interrupt simulation is done by calling
+	<function>uio_event_notify()</function>
+	from the timer's event handler.
 	</para>
 
 	<para>
@@ -263,63 +290,11 @@ offset = N * getpagesize();
 </sect1>
 </chapter>
 
-<chapter id="using-uio_dummy" xreflabel="Using uio_dummy">
-<?dbhtml filename="using-uio_dummy.html"?>
-<title>Using uio_dummy</title>
-	<para>
-	Well, there is no real use for uio_dummy. Its only purpose is
-	to test most parts of the UIO system (everything except
-	hardware interrupts), and to serve as an example for the
-	kernel module that you will have to write yourself.
-	</para>
-
-<sect1 id="what_uio_dummy_does">
-<title>What uio_dummy does</title>
-	<para>
-	The kernel module <filename>uio_dummy.ko</filename> creates a
-	device that uses a timer to generate periodic interrupts. The
-	interrupt handler does nothing but increment a counter. The
-	driver adds two custom attributes, <varname>count</varname>
-	and <varname>freq</varname>, that appear under
-	<filename>/sys/devices/platform/uio_dummy/</filename>.
-	</para>
-
-	<para>
-	The attribute <varname>count</varname> can be read and
-	written.  The associated file
-	<filename>/sys/devices/platform/uio_dummy/count</filename>
-	appears as a normal text file and contains the total number of
-	timer interrupts. If you look at it (e.g. using
-	<function>cat</function>), you'll notice it is slowly counting
-	up.
-	</para>
-
-	<para>
-	The attribute <varname>freq</varname> can be read and written.
-	The content of
-	<filename>/sys/devices/platform/uio_dummy/freq</filename>
-	represents the number of system timer ticks between two timer
-	interrupts. The default value of <varname>freq</varname> is
-	the value of the kernel variable <varname>HZ</varname>, which
-	gives you an interval of one second. Lower values will
-	increase the frequency. Try the following:
-	</para>
-<programlisting format="linespecific">
-cd /sys/devices/platform/uio_dummy/
-echo 100 > freq
-</programlisting>
-	<para>
-	Use <function>cat count</function> to see how the interrupt
-	frequency changes.
-	</para>
-</sect1>
-</chapter>
-
 <chapter id="custom_kernel_module" xreflabel="Writing your own kernel module">
 <?dbhtml filename="custom_kernel_module.html"?>
 <title>Writing your own kernel module</title>
 	<para>
-	Please have a look at <filename>uio_dummy.c</filename> as an
+	Please have a look at <filename>uio_cif.c</filename> as an
 	example. The following paragraphs explain the different
 	sections of this file.
 	</para>
@@ -354,9 +329,8 @@ See the description below for details.
 interrupt, it's your modules task to determine the irq number during
 initialization. If you don't have a hardware generated interrupt but
 want to trigger the interrupt handler in some other way, set
-<varname>irq</varname> to <varname>UIO_IRQ_CUSTOM</varname>. The
-uio_dummy module does this as it triggers the event mechanism in a timer
-routine. If you had no interrupt at all, you could set
+<varname>irq</varname> to <varname>UIO_IRQ_CUSTOM</varname>.
+If you had no interrupt at all, you could set
 <varname>irq</varname> to <varname>UIO_IRQ_NONE</varname>, though this
 rarely makes sense.
 </para></listitem>
Signature · 1 line
1.5.3.4
#4 lore raw

PATCH 4/6 UIO: add UIO documentation target to DocBook Makefile

In reply to Greg KH

From: Hans J Koch <[email protected]>

Add the DocBook documentation for the Userspace I/O framework to the Makefile.

---
 Documentation/DocBook/Makefile |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)
Documentation/DocBook/Makefile +1 -1
index 054a7ec..4953bc2 100644
@@ -11,7 +11,7 @@ DOCBOOKS := wanbook.xml z8530book.xml mcabook.xml videobook.xml \
 	    procfs-guide.xml writing_usb_driver.xml \
 	    kernel-api.xml filesystems.xml lsm.xml usb.xml \
 	    gadget.xml libata.xml mtdnand.xml librs.xml rapidio.xml \
-	    genericirq.xml s390-drivers.xml
+	    genericirq.xml s390-drivers.xml uio-howto.xml
 
 ###
 # The build process is as follows (targets):
Signature · 1 line
1.5.3.4
#5 lore raw

PATCH 5/6 kobject: two typo fixes

In reply to Greg KH

From: Johannes Berg <[email protected]>

This fixes two typos from commit
34358c26a2c96b2a068dc44e0ac602106a466bce.

---
 lib/kobject.c |    4 ++--
 1 files changed, 2 insertions(+), 2 deletions(-)
lib/kobject.c +2 -2
index a7e3bf4..b52e9f4 100644
@@ -313,8 +313,8 @@ int kobject_rename(struct kobject * kobj, const char *new_name)
 		struct kobject *temp_kobj;
 		temp_kobj = kset_find_obj(kobj->kset, new_name);
 		if (temp_kobj) {
-			printk(KERN_WARNING "kobject '%s' can not be renamed "
-			       "to '%s' as '%s' is already in existance.\n",
+			printk(KERN_WARNING "kobject '%s' cannot be renamed "
+			       "to '%s' as '%s' is already in existence.\n",
 			       kobject_name(kobj), new_name, new_name);
 			kobject_put(temp_kobj);
 			return -EINVAL;
Signature · 1 line
1.5.3.4
#6 lore raw

PATCH 6/6 sysfs: fix off-by-one error in fill_read_buffer()

In reply to Greg KH

From: Miao Xie <[email protected]>

I found that there is a off-by-one problem in the following code.

Version: 2.6.24-rc2
File: fs/sysfs/file.c:118-122
Function: fill_read_buffer
--------------------------------------------------------------------

	count = ops->show(kobj, attr_sd->s_attr.attr, buffer->page);

	sysfs_put_active_two(attr_sd);

	BUG_ON(count > (ssize_t)PAGE_SIZE);

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

Because according to the specification of the sysfs and the implement of the show methods, the show methods return the number of bytes which would be generated for the given input, excluding the trailing null.So if the return value of the show methods equals PAGE_SIZE - 1, the buffer is full in fact. And if the return value equals PAGE_SIZE, the resulting string was already truncated,or buffer overflow occurred.

This patch fixes an off-by-one error in fill_read_buffer.

---
 fs/sysfs/file.c |    6 +++++-
 1 files changed, 5 insertions(+), 1 deletions(-)
fs/sysfs/file.c +5 -1
index 27d1785..4045bdc 100644
@@ -119,7 +119,11 @@ static int fill_read_buffer(struct dentry * dentry, struct sysfs_buffer * buffer
 
 	sysfs_put_active_two(attr_sd);
 
-	BUG_ON(count > (ssize_t)PAGE_SIZE);
+	/*
+	 * The code works fine with PAGE_SIZE return but it's likely to
+	 * indicate truncated result or overflow in normal use cases.
+	 */
+	BUG_ON(count >= (ssize_t)PAGE_SIZE);
 	if (count >= 0) {
 		buffer->needs_read_fill = 0;
 		buffer->count = count;
Signature · 1 line
1.5.3.4