[parisc-linux-cvs] Correct init for ps2 devices

Thomas Marteau marteaut@esiee.fr
Thu, 20 Dec 2001 15:31:55 +0100


This is a multi-part message in MIME format.
--------------070800090308030406020203
Content-Type: text/plain; charset=us-ascii; format=flowed
Content-Transfer-Encoding: 7bit

I put the section where we claim the memory and the IRQ after the 
hardware detection.
As a result, you won't see any more keyboard, psaux in your 
/proc/interrupts if you have mouse support but no mouse connected to 
your box. This is the main difference with before. I also noticed a 
better stability with the plug and replug test.

Thomas.
ESIEE Team

--------------070800090308030406020203
Content-Type: text/plain;
 name="hardware.c.diff"
Content-Transfer-Encoding: 7bit
Content-Disposition: inline;
 filename="hardware.c.diff"

--- hardware.c	Thu Dec 20 15:25:32 2001
+++ hardware.c.new	Thu Dec 20 15:25:11 2001
@@ -245,7 +245,7 @@
 	{HPHW_NPROC,0x616,0x4,0x81,"Piranha 120"},
 	{HPHW_NPROC,0x617,0x4,0x81,"Jason 50"},
 	{HPHW_NPROC,0x618,0x4,0x81,"Jason 100"},
-	{HPHW_NPROC,0x619,0x4,0x81,"Mirage 80 "},
+	{HPHW_NPROC,0x619,0x4,0x81,"Mirage 80"},
 	{HPHW_NPROC,0x61A,0x4,0x81,"SAIC L-80"},
 	{HPHW_NPROC,0x61B,0x4,0x81,"Rocky1 L-60"},
 	{HPHW_NPROC,0x61C,0x4,0x81,"Anole T (743/T)"},

--------------070800090308030406020203
Content-Type: text/plain;
 name="hp_psaux.c.diff"
Content-Transfer-Encoding: 7bit
Content-Disposition: inline;
 filename="hp_psaux.c.diff"

===================================================================
RCS file: /var/cvs/linux/drivers/char/hp_psaux.c,v
retrieving revision 1.17
retrieving revision 1.18
diff -c -r1.17 -r1.18
*** linux/drivers/char/hp_psaux.c	2001/12/19 23:26:07	1.17
--- linux/drivers/char/hp_psaux.c	2001/12/20 12:08:19	1.18
***************
*** 6,15 ****
   *	Copyright 1999, 2000 Philipp Rumpf <prumpf@tux.org>
*
   *	2000/10/26	Debacker Xavier (debackex@esiee.fr)
   *			Marteau Thomas (marteaut@esiee.fr)
-  * 			Djoudi Malek (djoudim@esiee.fr)
   *	fixed leds control
!  *	implemented the psaux and controlled the mouse scancode based on pc_keyb.c
   */
  
  #include <linux/config.h>
--- 6,17 ----
   *	Copyright 1999, 2000 Philipp Rumpf <prumpf@tux.org>
*
   *	2000/10/26	Debacker Xavier (debackex@esiee.fr)
+  *	implemented the psaux and controlled the mouse scancode based on pc_keyb.c
   *			Marteau Thomas (marteaut@esiee.fr)
   *	fixed leds control
!  *
!  *	2001/12/17	Marteau Thomas (marteaut@esiee.fr)
!  *	get nice initialisation procedure
   */
  
  #include <linux/config.h>
***************
*** 73,79 ****
  
  static spinlock_t	kbd_controller_lock = SPIN_LOCK_UNLOCKED;
  static unsigned long lasikbd_hpa;
- static unsigned long lasips2_hpa;
  
  static volatile int cmd_status;
  
--- 75,80 ----
***************
*** 105,111 ****
  
  	while (read_status(hpa) & LASI_STAT_TBNE) {
  		if (!--wait) {
- 			printk(KERN_WARNING "Lasi PS/2 transmit buffer timeout\n");
  			return 0;
  		}
  		mdelay(1);
--- 106,111 ----
***************
*** 123,129 ****
  
  	while (!(read_status(hpa) & LASI_STAT_RBNE)) {
  		if (!--wait) {
- 			printk(KERN_WARNING "Lasi PS/2 receive buffer timeout\n");
  			return 0;
  		}
  		mdelay(1);
--- 123,128 ----
***************
*** 487,495 ****
  
  static void lasikbd_interrupt(int irq, void *dev, struct pt_regs *regs)
  {
- 	lasips2_hpa = (unsigned long) dev; /* save "hpa" for lasikbd_leds() */
  	kbd_pt_regs = regs;
! 	handle_lasikbd_event(lasips2_hpa);
  }
  
  extern int pckbd_translate(unsigned char, unsigned char *, char);
--- 486,493 ----
  
  static void lasikbd_interrupt(int irq, void *dev, struct pt_regs *regs)
  {
  	kbd_pt_regs = regs;
! 	handle_lasikbd_event((unsigned long) dev);
  }
  
  extern int pckbd_translate(unsigned char, unsigned char *, char);
***************
*** 497,505 ****
  extern int pckbd_getkeycode(unsigned int);
  
  static struct kbd_ops gsc_ps2_kbd_ops = {
! 	setkeycode:	pckbd_setkeycode,
! 	getkeycode:	pckbd_getkeycode,
! 	translate:	pckbd_translate,
  	leds:		lasikbd_leds,
  #ifdef CONFIG_MAGIC_SYSRQ
  	sysrq_key:	0x54,
--- 495,503 ----
  extern int pckbd_getkeycode(unsigned int);
  
  static struct kbd_ops gsc_ps2_kbd_ops = {
! 	setkeycode:     pckbd_setkeycode,
!         getkeycode:     pckbd_getkeycode,
!         translate:	pckbd_translate,
  	leds:		lasikbd_leds,
  #ifdef CONFIG_MAGIC_SYSRQ
  	sysrq_key:	0x54,
***************
*** 520,526 ****
  	switch (id) {
  	case 0:
  		name = "keyboard";
! 		lasikbd_hpa = hpa;
  		break;
  	case 1:
  		name = "psaux";
--- 518,524 ----
  	switch (id) {
  	case 0:
  		name = "keyboard";
! 		lasikbd_hpa = hpa;	/* save "hpa" for lasikbd_leds() */
  		break;
  	case 1:
  		name = "psaux";
***************
*** 534,553 ****
  	/* reset the PS/2 port */
  	lasi_ps2_reset(hpa);
  
- 	/* allocate the irq and memory region for that device */
- 	if (!dev->irq)
- 		return -ENODEV;
- 		    
- 	if (request_irq(dev->irq, lasikbd_interrupt, 0, name, (void *)hpa))
- 		return -ENODEV;
- 	
- 	if (!request_mem_region(hpa, LASI_STATUS + 4, name))
- 		return -ENODEV;
- 
  	switch (id) {
  	case 0:	
  	        device_found = init_keyb(hpa);
! 		register_kbd_ops(&gsc_ps2_kbd_ops);
  		break;
  	case 1:
  #ifdef CONFIG_PSMOUSE
--- 532,541 ----
  	/* reset the PS/2 port */
  	lasi_ps2_reset(hpa);
  
  	switch (id) {
  	case 0:	
  	        device_found = init_keyb(hpa);
! 		if (device_found) register_kbd_ops(&gsc_ps2_kbd_ops);
  		break;
  	case 1:
  #ifdef CONFIG_PSMOUSE
***************
*** 571,576 ****
--- 559,577 ----
  		return 0;	
  #endif
  	} /* of case */
+ 	
+ 	if (device_found) {
+ 	/* Here we claim only if we have a device attached */   
+ 		/* allocate the irq and memory region for that device */
+ 		if (!dev->irq)
+ 	 	return -ENODEV;
+ 	   
+ 	  	if (request_irq(dev->irq, lasikbd_interrupt, 0, name, (void *)hpa))
+ 	  	return -ENODEV;
+ 	   
+ 	  	if (!request_mem_region(hpa, LASI_STATUS + 4, name))
+ 	  	return -ENODEV;
+ 	}
  	
  	printk(KERN_INFO "PS/2 %s port at 0x%08lx (irq %d) found, "
  			 "%sdevice attached.\n",


--------------070800090308030406020203--