Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 2bfc3c6e authored by Bjorn Helgaas's avatar Bjorn Helgaas Committed by Dmitry Torokhov
Browse files

Input: i8042 - fix logic around pnp_register_driver()



Do not assume that pnp_register_driver() returns the number of
devices claimed.

Signed-off-by: default avatarBjorn Helgaas <bjorn.helgaas@hp.com>
Signed-off-by: default avatarDmitry Torokhov <dtor@mail.ru>
parent dd55563f
Loading
Loading
Loading
Loading
+16 −10
Original line number Original line Diff line number Diff line
@@ -192,7 +192,9 @@ static struct dmi_system_id __initdata i8042_dmi_nomux_table[] = {
#include <linux/pnp.h>
#include <linux/pnp.h>


static int i8042_pnp_kbd_registered;
static int i8042_pnp_kbd_registered;
static unsigned int i8042_pnp_kbd_devices;
static int i8042_pnp_aux_registered;
static int i8042_pnp_aux_registered;
static unsigned int i8042_pnp_aux_devices;


static int i8042_pnp_command_reg;
static int i8042_pnp_command_reg;
static int i8042_pnp_data_reg;
static int i8042_pnp_data_reg;
@@ -219,6 +221,7 @@ static int i8042_pnp_kbd_probe(struct pnp_dev *dev, const struct pnp_device_id *
		strncat(i8042_pnp_kbd_name, pnp_dev_name(dev), sizeof(i8042_pnp_kbd_name));
		strncat(i8042_pnp_kbd_name, pnp_dev_name(dev), sizeof(i8042_pnp_kbd_name));
	}
	}


	i8042_pnp_kbd_devices++;
	return 0;
	return 0;
}
}


@@ -239,6 +242,7 @@ static int i8042_pnp_aux_probe(struct pnp_dev *dev, const struct pnp_device_id *
		strncat(i8042_pnp_aux_name, pnp_dev_name(dev), sizeof(i8042_pnp_aux_name));
		strncat(i8042_pnp_aux_name, pnp_dev_name(dev), sizeof(i8042_pnp_aux_name));
	}
	}


	i8042_pnp_aux_devices++;
	return 0;
	return 0;
}
}


@@ -287,21 +291,23 @@ static void i8042_pnp_exit(void)


static int __init i8042_pnp_init(void)
static int __init i8042_pnp_init(void)
{
{
	int result_kbd = 0, result_aux = 0;
	char kbd_irq_str[4] = { 0 }, aux_irq_str[4] = { 0 };
	char kbd_irq_str[4] = { 0 }, aux_irq_str[4] = { 0 };
	int err;


	if (i8042_nopnp) {
	if (i8042_nopnp) {
		printk(KERN_INFO "i8042: PNP detection disabled\n");
		printk(KERN_INFO "i8042: PNP detection disabled\n");
		return 0;
		return 0;
	}
	}


	if ((result_kbd = pnp_register_driver(&i8042_pnp_kbd_driver)) >= 0)
	err = pnp_register_driver(&i8042_pnp_kbd_driver);
	if (!err)
		i8042_pnp_kbd_registered = 1;
		i8042_pnp_kbd_registered = 1;


	if ((result_aux = pnp_register_driver(&i8042_pnp_aux_driver)) >= 0)
	err = pnp_register_driver(&i8042_pnp_aux_driver);
	if (!err)
		i8042_pnp_aux_registered = 1;
		i8042_pnp_aux_registered = 1;


	if (result_kbd <= 0 && result_aux <= 0) {
	if (!i8042_pnp_kbd_devices && !i8042_pnp_aux_devices) {
		i8042_pnp_exit();
		i8042_pnp_exit();
#if defined(__ia64__)
#if defined(__ia64__)
		return -ENODEV;
		return -ENODEV;
@@ -311,24 +317,24 @@ static int __init i8042_pnp_init(void)
#endif
#endif
	}
	}


	if (result_kbd > 0)
	if (i8042_pnp_kbd_devices)
		snprintf(kbd_irq_str, sizeof(kbd_irq_str),
		snprintf(kbd_irq_str, sizeof(kbd_irq_str),
			"%d", i8042_pnp_kbd_irq);
			"%d", i8042_pnp_kbd_irq);
	if (result_aux > 0)
	if (i8042_pnp_aux_devices)
		snprintf(aux_irq_str, sizeof(aux_irq_str),
		snprintf(aux_irq_str, sizeof(aux_irq_str),
			"%d", i8042_pnp_aux_irq);
			"%d", i8042_pnp_aux_irq);


	printk(KERN_INFO "PNP: PS/2 Controller [%s%s%s] at %#x,%#x irq %s%s%s\n",
	printk(KERN_INFO "PNP: PS/2 Controller [%s%s%s] at %#x,%#x irq %s%s%s\n",
		i8042_pnp_kbd_name, (result_kbd > 0 && result_aux > 0) ? "," : "",
		i8042_pnp_kbd_name, (i8042_pnp_kbd_devices && i8042_pnp_aux_devices) ? "," : "",
		i8042_pnp_aux_name,
		i8042_pnp_aux_name,
		i8042_pnp_data_reg, i8042_pnp_command_reg,
		i8042_pnp_data_reg, i8042_pnp_command_reg,
		kbd_irq_str, (result_kbd > 0 && result_aux > 0) ? "," : "",
		kbd_irq_str, (i8042_pnp_kbd_devices && i8042_pnp_aux_devices) ? "," : "",
		aux_irq_str);
		aux_irq_str);


#if defined(__ia64__)
#if defined(__ia64__)
	if (result_kbd <= 0)
	if (!i8042_pnp_kbd_devices)
		i8042_nokbd = 1;
		i8042_nokbd = 1;
	if (result_aux <= 0)
	if (!i8042_pnp_aux_devices)
		i8042_noaux = 1;
		i8042_noaux = 1;
#endif
#endif