Skip to contentSkip to conversation

input: fix EVIOCGNAME regression

PATCH In review Daniel Mack 3 participants 6 messages Jul 13, 2009 – Jul 15, 2009

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

PATCH 1/1 input: fix EVIOCGNAME regression

Commit 3d5cb60e ("Input: simplify name handling for certain input handles") introduced a regression for the EVIOCGNAME ioctl.

Before this, patch, the platform device's name was given back to userspace which was good to identify devices. After this patch, the device was ("event%d", minor) which is not descriptive at all.

This fixes the behaviour by taking input_dev->name.

Cc Thadeu Lima de Souza Cascardo <[email protected]>
Cc Dmitry Torokhov <[email protected]>
---
 drivers/input/evdev.c |    6 +++---
 1 files changed, 3 insertions(+), 3 deletions(-)
drivers/input/evdev.c +3 -3
index 114efd8..c81e042 100644
@@ -608,8 +608,8 @@ static long evdev_do_ioctl(struct file *file, unsigned int cmd,
 						    p, compat_mode);
 
 			if (_IOC_NR(cmd) == _IOC_NR(EVIOCGNAME(0)))
-				return str_to_user(dev_name(&evdev->dev),
-						   _IOC_SIZE(cmd), p);
+				return str_to_user(evdev->handle.name,
+						    _IOC_SIZE(cmd), p);
 
 			if (_IOC_NR(cmd) == _IOC_NR(EVIOCGPHYS(0)))
 				return str_to_user(dev->phys, _IOC_SIZE(cmd), p);
@@ -818,7 +818,7 @@ static int evdev_connect(struct input_handler *handler, struct input_dev *dev,
 	evdev->minor = minor;
 
 	evdev->handle.dev = input_get_device(dev);
-	evdev->handle.name = dev_name(&evdev->dev);
+	evdev->handle.name = dev->name;
 	evdev->handle.handler = handler;
 	evdev->handle.private = evdev;
 
Signature · 1 line
1.6.3.1
maintainer
#1 lore raw

Hi Daniel,

Quoted 22 lines · Daniel Mack

Commit 3d5cb60e ("Input: simplify name handling for certain input handles") introduced a regression for the EVIOCGNAME ioctl.

Before this, patch, the platform device's name was given back to userspace which was good to identify devices. After this patch, the device was ("event%d", minor) which is not descriptive at all.

This fixes the behaviour by taking input_dev->name.

Cc Thadeu Lima de Souza Cascardo <[email protected]>
Cc Dmitry Torokhov <[email protected]>
---
 drivers/input/evdev.c |    6 +++---
 1 files changed, 3 insertions(+), 3 deletions(-)
drivers/input/evdev.c +0 -0
index 114efd8..c81e042 100644

drivers/input/evdev.c static long evdev_do_ioctl(struct file *file, unsigned int cmd, · line 612

Quoted 7 lines
drivers/input/evdev.c +2 -2
@@ -608,8 +608,8 @@ static long evdev_do_ioctl(struct file *file, unsigned int cmd,
 						    p, compat_mode);
 
 			if (_IOC_NR(cmd) == _IOC_NR(EVIOCGNAME(0)))
-				return str_to_user(dev_name(&evdev->dev),
-						   _IOC_SIZE(cmd), p);
+				return str_to_user(evdev->handle.name,
+						    _IOC_SIZE(cmd), p);

No, this actually should be just dev->name, handle names were always in the form of eventX or jsX. The change below is not needed either.

Btw, there is the similar issue in joydev.c as well.

Signature · 1 line
Dmitry
#2 lore raw
Quoted 25 lines · Dmitry Torokhov
Quoted 24 lines · Daniel Mack

Commit 3d5cb60e ("Input: simplify name handling for certain input handles") introduced a regression for the EVIOCGNAME ioctl.

Before this, patch, the platform device's name was given back to userspace which was good to identify devices. After this patch, the device was ("event%d", minor) which is not descriptive at all.

This fixes the behaviour by taking input_dev->name.

Cc Thadeu Lima de Souza Cascardo <[email protected]>
Cc Dmitry Torokhov <[email protected]>
---
 drivers/input/evdev.c |    6 +++---
 1 files changed, 3 insertions(+), 3 deletions(-)
drivers/input/evdev.c +0 -0
index 114efd8..c81e042 100644
@@ -608,8 +608,8 @@ static long evdev_do_ioctl(struct file *file, unsigned int cmd,
 						    p, compat_mode);
 
Quoted 9 lines

drivers/input/evdev.c static long evdev_do_ioctl(struct file *file, unsigned int cmd, · line 612

Quoted 5 lines
drivers/input/evdev.c +2 -2
 			if (_IOC_NR(cmd) == _IOC_NR(EVIOCGNAME(0)))
-				return str_to_user(dev_name(&evdev->dev),
-						   _IOC_SIZE(cmd), p);
+				return str_to_user(evdev->handle.name,
+						    _IOC_SIZE(cmd), p);

No, this actually should be just dev->name, handle names were always in the form of eventX or jsX. The change below is not needed either. Btw, there is the similar issue in joydev.c as well.

Ok, how about the one below?

Daniel

Quoted 1 line

From 0c754925117421778bd9adf1bd8f4e818fc65c74 Mon Sep 17 00:00:00 2001

From: Daniel Mack <[email protected]>
Date: Mon, 13 Jul 2009 18:33:53 +0200
Subject: [PATCH] input: fix EVIOCGNAME/JSIOCGNAME regression

Commit 3d5cb60e ("Input: simplify name handling for certain input handles") introduced a regression for the EVIOCGNAME/JSIOCGNAME ioctl.

Before this, patch, the platform device's name was given back to userspace which was good to identify devices. After this patch, the device is ("event%d", minor) which is not descriptive at all.

This fixes the behaviour by taking dev->name.

Cc Thadeu Lima de Souza Cascardo <[email protected]>
Cc Dmitry Torokhov <[email protected]>
---
 drivers/input/evdev.c  |    3 +--
 drivers/input/joydev.c |    7 +++----
 2 files changed, 4 insertions(+), 6 deletions(-)
drivers/input/evdev.c +1 -2
index 114efd8..1148140 100644
@@ -608,8 +608,7 @@ static long evdev_do_ioctl(struct file *file, unsigned int cmd,
 						    p, compat_mode);
 
 			if (_IOC_NR(cmd) == _IOC_NR(EVIOCGNAME(0)))
-				return str_to_user(dev_name(&evdev->dev),
-						   _IOC_SIZE(cmd), p);
+				return str_to_user(dev->name, _IOC_SIZE(cmd), p);
 
 			if (_IOC_NR(cmd) == _IOC_NR(EVIOCGPHYS(0)))
 				return str_to_user(dev->phys, _IOC_SIZE(cmd), p);
drivers/input/joydev.c +3 -4
index 0e12f89..16397aa 100644
@@ -536,14 +536,13 @@ static int joydev_ioctl_common(struct joydev *joydev,
 	default:
 		if ((cmd & ~IOCSIZE_MASK) == JSIOCGNAME(0)) {
 			int len;
-			const char *name = dev_name(&dev->dev);
 
-			if (!name)
+			if (!dev->name)
 				return 0;
-			len = strlen(name) + 1;
+			len = strlen(dev->name) + 1;
 			if (len > _IOC_SIZE(cmd))
 				len = _IOC_SIZE(cmd);
-			if (copy_to_user(argp, name, len))
+			if (copy_to_user(argp, dev->name, len))
 				return -EFAULT;
 			return len;
 		}
Signature · 1 line
1.6.3.1
Tested-by Reviewed-by
#3 lore raw
Quoted 36 lines · Daniel Mack
Quoted 25 lines · Dmitry Torokhov
Quoted 24 lines · Daniel Mack

Commit 3d5cb60e ("Input: simplify name handling for certain input handles") introduced a regression for the EVIOCGNAME ioctl.

Before this, patch, the platform device's name was given back to userspace which was good to identify devices. After this patch, the device was ("event%d", minor) which is not descriptive at all.

This fixes the behaviour by taking input_dev->name.

Cc Thadeu Lima de Souza Cascardo <[email protected]>
Cc Dmitry Torokhov <[email protected]>
---
 drivers/input/evdev.c |    6 +++---
 1 files changed, 3 insertions(+), 3 deletions(-)
drivers/input/evdev.c +0 -0
index 114efd8..c81e042 100644
@@ -608,8 +608,8 @@ static long evdev_do_ioctl(struct file *file, unsigned int cmd,
 						    p, compat_mode);
 
Quoted 9 lines

drivers/input/evdev.c static long evdev_do_ioctl(struct file *file, unsigned int cmd,

Quoted 5 lines
drivers/input/evdev.c +2 -2
 			if (_IOC_NR(cmd) == _IOC_NR(EVIOCGNAME(0)))
-				return str_to_user(dev_name(&evdev->dev),
-						   _IOC_SIZE(cmd), p);
+				return str_to_user(evdev->handle.name,
+						    _IOC_SIZE(cmd), p);

No, this actually should be just dev->name, handle names were always in the form of eventX or jsX. The change below is not needed either. Btw, there is the similar issue in joydev.c as well.

Quoted 3 lines

Ok, how about the one below?

Daniel

My bad. Those two reverts work for me.

I have also reviewed my own patch and understand what I did wrong and that I did mess with the input device name instead of keeping only to the event device naming. Regarding what I did intend to "fix" with the patch, it is all OK. So, if you want to, you may also consider my review. Although after this shame, you may not consider it worth enough. :-D

Quoted 65 lines

From 0c754925117421778bd9adf1bd8f4e818fc65c74 Mon Sep 17 00:00:00 2001
From: Daniel Mack <[email protected]>
Date: Mon, 13 Jul 2009 18:33:53 +0200
Subject: [PATCH] input: fix EVIOCGNAME/JSIOCGNAME regression

Commit 3d5cb60e ("Input: simplify name handling for certain input handles") introduced a regression for the EVIOCGNAME/JSIOCGNAME ioctl.

Before this, patch, the platform device's name was given back to userspace which was good to identify devices. After this patch, the device is ("event%d", minor) which is not descriptive at all.

This fixes the behaviour by taking dev->name.

Cc Thadeu Lima de Souza Cascardo <[email protected]>
Cc Dmitry Torokhov <[email protected]>
---
 drivers/input/evdev.c  |    3 +--
 drivers/input/joydev.c |    7 +++----
 2 files changed, 4 insertions(+), 6 deletions(-)
drivers/input/evdev.c +1 -2
index 114efd8..1148140 100644
@@ -608,8 +608,7 @@ static long evdev_do_ioctl(struct file *file, unsigned int cmd,
 						    p, compat_mode);
 
 			if (_IOC_NR(cmd) == _IOC_NR(EVIOCGNAME(0)))
-				return str_to_user(dev_name(&evdev->dev),
-						   _IOC_SIZE(cmd), p);
+				return str_to_user(dev->name, _IOC_SIZE(cmd), p);
 
 			if (_IOC_NR(cmd) == _IOC_NR(EVIOCGPHYS(0)))
 				return str_to_user(dev->phys, _IOC_SIZE(cmd), p);
drivers/input/joydev.c +3 -4
index 0e12f89..16397aa 100644
@@ -536,14 +536,13 @@ static int joydev_ioctl_common(struct joydev *joydev,
 	default:
 		if ((cmd & ~IOCSIZE_MASK) == JSIOCGNAME(0)) {
 			int len;
-			const char *name = dev_name(&dev->dev);
 
-			if (!name)
+			if (!dev->name)
 				return 0;
-			len = strlen(name) + 1;
+			len = strlen(dev->name) + 1;
 			if (len > _IOC_SIZE(cmd))
 				len = _IOC_SIZE(cmd);
-			if (copy_to_user(argp, name, len))
+			if (copy_to_user(argp, dev->name, len))
 				return -EFAULT;
 			return len;
 		}
Signature · 1 line
1.6.3.1
maintainer
#4 lore raw
In reply to Daniel Mack
Quoted 84 lines · Daniel Mack
Quoted 25 lines · Dmitry Torokhov
Quoted 24 lines · Daniel Mack

Commit 3d5cb60e ("Input: simplify name handling for certain input handles") introduced a regression for the EVIOCGNAME ioctl.

Before this, patch, the platform device's name was given back to userspace which was good to identify devices. After this patch, the device was ("event%d", minor) which is not descriptive at all.

This fixes the behaviour by taking input_dev->name.

Cc Thadeu Lima de Souza Cascardo <[email protected]>
Cc Dmitry Torokhov <[email protected]>
---
 drivers/input/evdev.c |    6 +++---
 1 files changed, 3 insertions(+), 3 deletions(-)
drivers/input/evdev.c +0 -0
index 114efd8..c81e042 100644
@@ -608,8 +608,8 @@ static long evdev_do_ioctl(struct file *file, unsigned int cmd,
 						    p, compat_mode);
 
Quoted 9 lines

drivers/input/evdev.c static long evdev_do_ioctl(struct file *file, unsigned int cmd,

Quoted 5 lines
drivers/input/evdev.c +2 -2
 			if (_IOC_NR(cmd) == _IOC_NR(EVIOCGNAME(0)))
-				return str_to_user(dev_name(&evdev->dev),
-						   _IOC_SIZE(cmd), p);
+				return str_to_user(evdev->handle.name,
+						    _IOC_SIZE(cmd), p);

No, this actually should be just dev->name, handle names were always in the form of eventX or jsX. The change below is not needed either. Btw, there is the similar issue in joydev.c as well.

Ok, how about the one below?

Daniel

From 0c754925117421778bd9adf1bd8f4e818fc65c74 Mon Sep 17 00:00:00 2001
From: Daniel Mack <[email protected]>
Date: Mon, 13 Jul 2009 18:33:53 +0200
Subject: [PATCH] input: fix EVIOCGNAME/JSIOCGNAME regression

Commit 3d5cb60e ("Input: simplify name handling for certain input handles") introduced a regression for the EVIOCGNAME/JSIOCGNAME ioctl.

Before this, patch, the platform device's name was given back to userspace which was good to identify devices. After this patch, the device is ("event%d", minor) which is not descriptive at all.

This fixes the behaviour by taking dev->name.

Cc Thadeu Lima de Souza Cascardo <[email protected]>
Cc Dmitry Torokhov <[email protected]>
---
 drivers/input/evdev.c  |    3 +--
 drivers/input/joydev.c |    7 +++----
 2 files changed, 4 insertions(+), 6 deletions(-)
drivers/input/evdev.c +1 -2
index 114efd8..1148140 100644
@@ -608,8 +608,7 @@ static long evdev_do_ioctl(struct file *file, unsigned int cmd,
 						    p, compat_mode);
 
 			if (_IOC_NR(cmd) == _IOC_NR(EVIOCGNAME(0)))
-				return str_to_user(dev_name(&evdev->dev),
-						   _IOC_SIZE(cmd), p);
+				return str_to_user(dev->name, _IOC_SIZE(cmd), p);
 
 			if (_IOC_NR(cmd) == _IOC_NR(EVIOCGPHYS(0)))
 				return str_to_user(dev->phys, _IOC_SIZE(cmd), p);
drivers/input/joydev.c +0 -0
index 0e12f89..16397aa 100644

drivers/input/joydev.c static int joydev_ioctl_common(struct joydev *joydev, · line 539

Quoted 4 lines
drivers/input/joydev.c +0 -1
@@ -536,14 +536,13 @@ static int joydev_ioctl_common(struct joydev *joydev,
 	default:
 		if ((cmd & ~IOCSIZE_MASK) == JSIOCGNAME(0)) {
 			int len;
-			const char *name = dev_name(&dev->dev);

I like my temps so I'll just change it to "const char *name = dev->name" here, otherwise applied to for-linus, thanks Daniel.

Signature · 1 line
Dmitry
maintainer
#5 lore raw
In reply to Daniel Mack
Quoted 84 lines · Daniel Mack
Quoted 25 lines · Dmitry Torokhov
Quoted 24 lines · Daniel Mack

Commit 3d5cb60e ("Input: simplify name handling for certain input handles") introduced a regression for the EVIOCGNAME ioctl.

Before this, patch, the platform device's name was given back to userspace which was good to identify devices. After this patch, the device was ("event%d", minor) which is not descriptive at all.

This fixes the behaviour by taking input_dev->name.

Cc Thadeu Lima de Souza Cascardo <[email protected]>
Cc Dmitry Torokhov <[email protected]>
---
 drivers/input/evdev.c |    6 +++---
 1 files changed, 3 insertions(+), 3 deletions(-)
drivers/input/evdev.c +0 -0
index 114efd8..c81e042 100644
@@ -608,8 +608,8 @@ static long evdev_do_ioctl(struct file *file, unsigned int cmd,
 						    p, compat_mode);
 
Quoted 9 lines

drivers/input/evdev.c static long evdev_do_ioctl(struct file *file, unsigned int cmd,

Quoted 5 lines
drivers/input/evdev.c +2 -2
 			if (_IOC_NR(cmd) == _IOC_NR(EVIOCGNAME(0)))
-				return str_to_user(dev_name(&evdev->dev),
-						   _IOC_SIZE(cmd), p);
+				return str_to_user(evdev->handle.name,
+						    _IOC_SIZE(cmd), p);

No, this actually should be just dev->name, handle names were always in the form of eventX or jsX. The change below is not needed either. Btw, there is the similar issue in joydev.c as well.

Ok, how about the one below?

Daniel

From 0c754925117421778bd9adf1bd8f4e818fc65c74 Mon Sep 17 00:00:00 2001
From: Daniel Mack <[email protected]>
Date: Mon, 13 Jul 2009 18:33:53 +0200
Subject: [PATCH] input: fix EVIOCGNAME/JSIOCGNAME regression

Commit 3d5cb60e ("Input: simplify name handling for certain input handles") introduced a regression for the EVIOCGNAME/JSIOCGNAME ioctl.

Before this, patch, the platform device's name was given back to userspace which was good to identify devices. After this patch, the device is ("event%d", minor) which is not descriptive at all.

This fixes the behaviour by taking dev->name.

Cc Thadeu Lima de Souza Cascardo <[email protected]>
Cc Dmitry Torokhov <[email protected]>
---
 drivers/input/evdev.c  |    3 +--
 drivers/input/joydev.c |    7 +++----
 2 files changed, 4 insertions(+), 6 deletions(-)
drivers/input/evdev.c +1 -2
index 114efd8..1148140 100644
@@ -608,8 +608,7 @@ static long evdev_do_ioctl(struct file *file, unsigned int cmd,
 						    p, compat_mode);
 
 			if (_IOC_NR(cmd) == _IOC_NR(EVIOCGNAME(0)))
-				return str_to_user(dev_name(&evdev->dev),
-						   _IOC_SIZE(cmd), p);
+				return str_to_user(dev->name, _IOC_SIZE(cmd), p);
 
 			if (_IOC_NR(cmd) == _IOC_NR(EVIOCGPHYS(0)))
 				return str_to_user(dev->phys, _IOC_SIZE(cmd), p);
drivers/input/joydev.c +0 -0
index 0e12f89..16397aa 100644

drivers/input/joydev.c static int joydev_ioctl_common(struct joydev *joydev, · line 539

Quoted 4 lines
drivers/input/joydev.c +0 -1
@@ -536,14 +536,13 @@ static int joydev_ioctl_common(struct joydev *joydev,
 	default:
 		if ((cmd & ~IOCSIZE_MASK) == JSIOCGNAME(0)) {
 			int len;
-			const char *name = dev_name(&dev->dev);

I like my temps so I'll just change it to "const char *name = dev->name" here, otherwise applied to for-linus, thanks Daniel.

Signature · 1 line
Dmitry