Skip to contentSkip to conversation

uio: make uio_info's name and version const

PATCH Applied Stephen Rothwell 3 participants 4 messages Dec 12, 2008 – Dec 19, 2008

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 uio: make uio_info's name and version const

These are only ever assigned constant strings and never modified.

This was noticed because Wolfram Sang needed to cast the result of of_get_property() in order to assign it to the name field of a struct uio_info.

---
 Documentation/DocBook/uio-howto.tmpl |    4 ++--
 include/linux/uio_driver.h           |    4 ++--
 2 files changed, 4 insertions(+), 4 deletions(-)

Tested by compiling all the uio drivers available on x86. The others (all in arch sh) only ever assign constant string literals to these fields.

[Resent with properly quoted recipient addresses]

Documentation/DocBook/uio-howto.tmpl +2 -2
index df87d1b..21ba47e 100644
@@ -339,12 +339,12 @@ offset = N * getpagesize();
 
 <itemizedlist>
 <listitem><para>
-<varname>char *name</varname>: Required. The name of your driver as
+<varname>const char *name</varname>: Required. The name of your driver as
 it will appear in sysfs. I recommend using the name of your module for this.
 </para></listitem>
 
 <listitem><para>
-<varname>char *version</varname>: Required. This string appears in
+<varname>const char *version</varname>: Required. This string appears in
 <filename>/sys/class/uio/uioX/version</filename>.
 </para></listitem>
 
include/linux/uio_driver.h +2 -2
index cdf338d..b5f23b1 100644
@@ -57,8 +57,8 @@ struct uio_device;
  */
 struct uio_info {
 	struct uio_device	*uio_dev;
-	char			*name;
-	char			*version;
+	const char		*name;
+	const char		*version;
 	struct uio_mem		mem[MAX_UIO_MAPS];
 	long			irq;
 	unsigned long		irq_flags;
Signature · 6 lines
1.6.0.5

-- 
Cheers,
Stephen Rothwell                    [email protected]
http://www.canb.auug.org.au/~sfr/
#1 lore raw
Quoted 1 line · Stephen Rothwell

These are only ever assigned constant strings and never modified.

Hi Stephen,
that's correct, thanks for pointing this out.

@Greg: Stephen's patch will only apply with some fuzz since you've accepted my portio patches in your queue. Below there's a version that should apply cleanly.

Quoted 6 lines

This was noticed because Wolfram Sang needed to cast the result of of_get_property() in order to assign it to the name field of a struct uio_info.

Quoted 47 lines
---
 Documentation/DocBook/uio-howto.tmpl |    4 ++--
 include/linux/uio_driver.h           |    4 ++--
 2 files changed, 4 insertions(+), 4 deletions(-)

Tested by compiling all the uio drivers available on x86. The others (all in arch sh) only ever assign constant string literals to these fields.

[Resent with properly quoted recipient addresses]

Documentation/DocBook/uio-howto.tmpl +2 -2
index df87d1b..21ba47e 100644
@@ -339,12 +339,12 @@ offset = N * getpagesize();
 
 <itemizedlist>
 <listitem><para>
-<varname>char *name</varname>: Required. The name of your driver as
+<varname>const char *name</varname>: Required. The name of your driver as
 it will appear in sysfs. I recommend using the name of your module for this.
 </para></listitem>
 
 <listitem><para>
-<varname>char *version</varname>: Required. This string appears in
+<varname>const char *version</varname>: Required. This string appears in
 <filename>/sys/class/uio/uioX/version</filename>.
 </para></listitem>
 
include/linux/uio_driver.h +2 -2
index cdf338d..b5f23b1 100644
@@ -57,8 +57,8 @@ struct uio_device;
  */
 struct uio_info {
 	struct uio_device	*uio_dev;
-	char			*name;
-	char			*version;
+	const char		*name;
+	const char		*version;
 	struct uio_mem		mem[MAX_UIO_MAPS];
 	long			irq;
 	unsigned long		irq_flags;
Signature · 1 line
1.6.0.5

--------->8-----begin rebased version------------------------------------

These are only ever assigned constant strings and never modified.

This was noticed because Wolfram Sang needed to cast the result of of_get_property() in order to assign it to the name field of a struct uio_info.

---
 Documentation/DocBook/uio-howto.tmpl |    4 ++--
 include/linux/uio_driver.h           |    4 ++--
 2 files changed, 4 insertions(+), 4 deletions(-)

Tested by compiling all the uio drivers available on x86. The others (all in arch sh) only ever assign constant string literals to these fields.

Documentation/DocBook/uio-howto.tmpl +2 -2
Index: linux-2.6.28-rc/Documentation/DocBook/uio-howto.tmpl
===================================================================
@@ -393,12 +393,12 @@
 
 <itemizedlist>
 <listitem><para>
-<varname>char *name</varname>: Required. The name of your driver as
+<varname>const char *name</varname>: Required. The name of your driver as
 it will appear in sysfs. I recommend using the name of your module for this.
 </para></listitem>
 
 <listitem><para>
-<varname>char *version</varname>: Required. This string appears in
+<varname>const char *version</varname>: Required. This string appears in
 <filename>/sys/class/uio/uioX/version</filename>.
 </para></listitem>
 
include/linux/uio_driver.h +2 -2
Index: linux-2.6.28-rc/include/linux/uio_driver.h
===================================================================
@@ -76,8 +76,8 @@
  */
 struct uio_info {
 	struct uio_device	*uio_dev;
-	char			*name;
-	char			*version;
+	const char		*name;
+	const char		*version;
 	struct uio_mem		mem[MAX_UIO_MAPS];
 	struct uio_port		port[MAX_UIO_PORT_REGIONS];
 	long			irq;
#2 lore raw

Hi Hans,

Quoted 4 lines · On Fri, 12 Dec 2008 11:44:21 +0100 "Hans J. Koch" <[email protected]> wrote:

@Greg: Stephen's patch will only apply with some fuzz since you've accepted my portio patches in your queue. Below there's a version that should apply cleanly.

Thanks for that.

Signature · 3 lines
Cheers,
Stephen Rothwell                    [email protected]
http://www.canb.auug.org.au/~sfr/
#3 lore raw

patch uio-make-uio_info-s-name-and-version-const.patch added to gregkh-2.6 tree

In reply to Hans J. Koch

This is a note to let you know that I've just added the patch titled

Subject: uio: make uio_info's name and version const

to my gregkh-2.6 tree. Its filename is

uio-make-uio_info-s-name-and-version-const.patch

This tree can be found at
http://www.kernel.org/pub/linux/kernel/people/gregkh/gregkh-2.6/patches/

Quoted 1 line

From [email protected] Thu Dec 18 15:52:51 2008

From: Stephen Rothwell <[email protected]>
Date: Fri, 12 Dec 2008 11:44:21 +0100
Subject: uio: make uio_info's name and version const
To: Stephen Rothwell <[email protected]>
Cc: "Hans J. Koch" <[email protected]>, Greg Kroah-Hartman <[email protected]>, LKML <[email protected]>, Wolfram Sang <[email protected]>
Message-ID: <20081212104420.GA3084@local>
Content-Disposition: inline

From: Stephen Rothwell <[email protected]>

These are only ever assigned constant strings and never modified.

This was noticed because Wolfram Sang needed to cast the result of of_get_property() in order to assign it to the name field of a struct uio_info.

---
 Documentation/DocBook/uio-howto.tmpl |    4 ++--
 include/linux/uio_driver.h           |    4 ++--
 2 files changed, 4 insertions(+), 4 deletions(-)
Documentation/DocBook/uio-howto.tmpl +2 -2
@@ -393,12 +393,12 @@ offset = N * getpagesize();
 
 <itemizedlist>
 <listitem><para>
-<varname>char *name</varname>: Required. The name of your driver as
+<varname>const char *name</varname>: Required. The name of your driver as
 it will appear in sysfs. I recommend using the name of your module for this.
 </para></listitem>
 
 <listitem><para>
-<varname>char *version</varname>: Required. This string appears in
+<varname>const char *version</varname>: Required. This string appears in
 <filename>/sys/class/uio/uioX/version</filename>.
 </para></listitem>
 
include/linux/uio_driver.h +2 -2
@@ -76,8 +76,8 @@ struct uio_device;
  */
 struct uio_info {
 	struct uio_device	*uio_dev;
-	char			*name;
-	char			*version;
+	const char		*name;
+	const char		*version;
 	struct uio_mem		mem[MAX_UIO_MAPS];
 	struct uio_port		port[MAX_UIO_PORT_REGIONS];
 	long			irq;

Patches currently in gregkh-2.6 which might be from [email protected] are

usb/usb-don-t-use-__module_param_call.patch driver-core/uio-make-uio_info-s-name-and-version-const.patch staging/staging-go7007-convert-driver-to-use-video_ioctl2.patch staging/staging-comedi-fix-build-if-config_proc_fs-is-not-set.patch staging/staging-meilhaus-fix-__symbol_get-problems.patch