All of lore.kernel.org
 help / color / mirror / Atom feed
* re: drivers/platform/x86/sony-laptop.c: fix scancodes
@ 2011-11-30 12:55 Dan Carpenter
  2011-11-30 13:22 ` John Hughes
                   ` (2 more replies)
  0 siblings, 3 replies; 4+ messages in thread
From: Dan Carpenter @ 2011-11-30 12:55 UTC (permalink / raw)
  To: John Hughes; +Cc: platform-driver-x86, Andrew Morton

Hi John,

Commit 04840b50f395 "drivers/platform/x86/sony-laptop.c: fix scancodes"
introduces a gcc warning:

drivers/platform/x86/sony-laptop.c:395:14: warning:
	‘scancode’ may be used uninitialized in this function [-Wuninitialized]

   345  static void sony_laptop_report_input_event(u8 event)
   346  {
   347          struct input_dev *jog_dev = sony_laptop_input.jog_dev;
   348          struct input_dev *key_dev = sony_laptop_input.key_dev;
   349          struct sony_laptop_keypress kp = { NULL };
   350          int scancode;
   351  

-- [snip] --

   373          /* key_dev events */
   374          case SONYPI_EVENT_JOGDIAL_PRESSED:
   375                  kp.key = BTN_MIDDLE;
   376                  kp.dev = jog_dev;
   377                  break;

scancode doesn't get initialized on this path, but kp.dev is set.

   378  
   379          default:
   380                  if (event >= ARRAY_SIZE(sony_laptop_input_index)) {
   381                          dprintk("sony_laptop_report_input_event, event not known: %d\n", event);
   382                          break;
   383                  }
   384                  scancode = sony_laptop_input_index[event];
   385                  if (scancode != -1) {
   386                          kp.key = sony_laptop_input_keycode_map[scancode];
   387                          if (kp.key != KEY_UNKNOWN)
   388                                  kp.dev = key_dev;
   389                  }
   390                  break;
   391          }
   392  
   393          if (kp.dev) {
   394                  /* we emit the scancode so we can always remap the key */
   395                  input_event(kp.dev, EV_MSC, MSC_SCAN, scancode);

We use scancode here.

regards,
dan carpenter

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: drivers/platform/x86/sony-laptop.c: fix scancodes
  2011-11-30 12:55 drivers/platform/x86/sony-laptop.c: fix scancodes Dan Carpenter
@ 2011-11-30 13:22 ` John Hughes
  2011-11-30 21:50 ` John Hughes
  2011-12-03 11:47 ` [PATCH] Fix scancodes emitted by sony-laptop driver (Version 2 with warnings fixed) John Hughes
  2 siblings, 0 replies; 4+ messages in thread
From: John Hughes @ 2011-11-30 13:22 UTC (permalink / raw)
  To: Dan Carpenter; +Cc: platform-driver-x86, Andrew Morton

On 30/11/11 13:55, Dan Carpenter wrote:
> Hi John,
>
> Commit 04840b50f395 "drivers/platform/x86/sony-laptop.c: fix scancodes"
> introduces a gcc warning:
>
> drivers/platform/x86/sony-laptop.c:395:14: warning:
> 	‘scancode’ may be used uninitialized in this function [-Wuninitialized]

Ok, that's a dumb bug on my part.

I'll make a better patch this evening.

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: drivers/platform/x86/sony-laptop.c: fix scancodes
  2011-11-30 12:55 drivers/platform/x86/sony-laptop.c: fix scancodes Dan Carpenter
  2011-11-30 13:22 ` John Hughes
@ 2011-11-30 21:50 ` John Hughes
  2011-12-03 11:47 ` [PATCH] Fix scancodes emitted by sony-laptop driver (Version 2 with warnings fixed) John Hughes
  2 siblings, 0 replies; 4+ messages in thread
From: John Hughes @ 2011-11-30 21:50 UTC (permalink / raw)
  To: Dan Carpenter
  Cc: John Hughes, platform-driver-x86, Andrew Morton, Mattia Dongili

On 11/30/2011 01:55 PM, Dan Carpenter wrote:
> Hi John,
>
> Commit 04840b50f395 "drivers/platform/x86/sony-laptop.c: fix scancodes"
> introduces a gcc warning:
>
> drivers/platform/x86/sony-laptop.c:395:14: warning:
> 	‘scancode’ may be used uninitialized in this function [-Wuninitialized]
>    

Ok, my code was broken, but so was the original - the jogdial device 
isn't supposed to send scancodes for it's events:

         jog_dev->name = "Sony Vaio Jogdial";
         jog_dev->id.bustype = BUS_ISA;
         jog_dev->id.vendor = PCI_VENDOR_ID_SONY;
         key_dev->dev.parent =&acpi_device->dev;

         input_set_capability(jog_dev, EV_KEY, BTN_MIDDLE);
         input_set_capability(jog_dev, EV_REL, REL_WHEEL);

Note,  no EV_MSC, MSC_SCAN here.

Whoops, anoher bug!  Look there, it's setting key_dev->dev.parent 
instead of jog_dev.dev_parent!

I'll post a new patch when I've finished testing it.

^ permalink raw reply	[flat|nested] 4+ messages in thread

* [PATCH] Fix scancodes emitted by sony-laptop driver (Version 2 with warnings fixed)
  2011-11-30 12:55 drivers/platform/x86/sony-laptop.c: fix scancodes Dan Carpenter
  2011-11-30 13:22 ` John Hughes
  2011-11-30 21:50 ` John Hughes
@ 2011-12-03 11:47 ` John Hughes
  2 siblings, 0 replies; 4+ messages in thread
From: John Hughes @ 2011-12-03 11:47 UTC (permalink / raw)
  To: Dan Carpenter, Mattia Dongili
  Cc: John Hughes, platform-driver-x86, Andrew Morton, linux-kernel

[-- Attachment #1: Type: text/plain, Size: 486 bytes --]

On 30/11/11 13:55, Dan Carpenter wrote:
> Hi John,
>
> Commit 04840b50f395 "drivers/platform/x86/sony-laptop.c: fix scancodes"
> introduces a gcc warning:
>
> drivers/platform/x86/sony-laptop.c:395:14: warning:
> 	‘scancode’ may be used uninitialized in this function [-Wuninitialized]
>    

Ok, I've fixed my stupid mistake and also the two bugs in the jogdial 
driver (It wasn't setting it's parent and it was emitting scancode 
events even though it's not a keyboard device).



[-- Attachment #2: sony-scancode.patch --]
[-- Type: text/x-patch, Size: 3161 bytes --]

The scancodes returned by the sony-laptop driver for function keys did not
match the scancodes used to remap keys.  Also, since the scancode was sent
to the input subsystem after the mapped keysym the /lib/udev/keymap
utility was confused about which scancode to report for which keysym.

This patch fixes the driver so the correct scancode is shown for each
key.  It also adds to the documentation a description of where to find
the scancodes.

Signed-off-by: John Hughes <john@calva.com>

diff --git a/Documentation/laptops/sony-laptop.txt b/Documentation/laptops/sony-laptop.txt
index 2bd4e82..0d5ac7f 100644
--- a/Documentation/laptops/sony-laptop.txt
+++ b/Documentation/laptops/sony-laptop.txt
@@ -17,6 +17,11 @@ subsystem. See the logs of acpid or /proc/acpi/event and
 devices are created by the driver. Additionally, loading the driver with the
 debug option will report all events in the kernel log.
 
+The "scancodes" passed to the input system (that can be remapped with udev)
+are indexes to the table "sony_laptop_input_keycode_map" in the sony-laptop.c
+module.  For example the "FN/E" key combination (EJECTCD on some models)
+generates the scancode 20 (0x14).
+
 Backlight control:
 ------------------
 If your laptop model supports it, you will find sysfs files in the
diff --git a/drivers/platform/x86/sony-laptop.c b/drivers/platform/x86/sony-laptop.c
index c006dee..4babb79 100644
--- a/drivers/platform/x86/sony-laptop.c
+++ b/drivers/platform/x86/sony-laptop.c
@@ -347,6 +347,7 @@ static void sony_laptop_report_input_event(u8 event)
 	struct input_dev *jog_dev = sony_laptop_input.jog_dev;
 	struct input_dev *key_dev = sony_laptop_input.key_dev;
 	struct sony_laptop_keypress kp = { NULL };
+	int scancode = -1;
 
 	if (event == SONYPI_EVENT_FNKEY_RELEASED ||
 			event == SONYPI_EVENT_ANYBUTTON_RELEASED) {
@@ -380,8 +381,8 @@ static void sony_laptop_report_input_event(u8 event)
 			dprintk("sony_laptop_report_input_event, event not known: %d\n", event);
 			break;
 		}
-		if (sony_laptop_input_index[event] != -1) {
-			kp.key = sony_laptop_input_keycode_map[sony_laptop_input_index[event]];
+		if ((scancode = sony_laptop_input_index[event]) != -1) {
+			kp.key = sony_laptop_input_keycode_map[scancode];
 			if (kp.key != KEY_UNKNOWN)
 				kp.dev = key_dev;
 		}
@@ -389,9 +390,11 @@ static void sony_laptop_report_input_event(u8 event)
 	}
 
 	if (kp.dev) {
+		/* if we have a scancode we emit it so we can always
+                   remap the key */
+		if (scancode != -1)
+			input_event(kp.dev, EV_MSC, MSC_SCAN, scancode);
 		input_report_key(kp.dev, kp.key, 1);
-		/* we emit the scancode so we can always remap the key */
-		input_event(kp.dev, EV_MSC, MSC_SCAN, event);
 		input_sync(kp.dev);
 
 		/* schedule key release */
@@ -466,7 +469,7 @@ static int sony_laptop_setup_input(struct acpi_device *acpi_device)
 	jog_dev->name = "Sony Vaio Jogdial";
 	jog_dev->id.bustype = BUS_ISA;
 	jog_dev->id.vendor = PCI_VENDOR_ID_SONY;
-	key_dev->dev.parent = &acpi_device->dev;
+	jog_dev->dev.parent = &acpi_device->dev;
 
 	input_set_capability(jog_dev, EV_KEY, BTN_MIDDLE);
 	input_set_capability(jog_dev, EV_REL, REL_WHEEL);

^ permalink raw reply related	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2011-12-03 11:47 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2011-11-30 12:55 drivers/platform/x86/sony-laptop.c: fix scancodes Dan Carpenter
2011-11-30 13:22 ` John Hughes
2011-11-30 21:50 ` John Hughes
2011-12-03 11:47 ` [PATCH] Fix scancodes emitted by sony-laptop driver (Version 2 with warnings fixed) John Hughes

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.