[kernel/f15/user/kyle/f14-2.6.37] Linux 2.6.37.2

Kyle McMartin kyle at fedoraproject.org
Fri Mar 4 15:44:46 UTC 2011


commit 01c454921a13ed1f47811d43c0949ee58236d641
Author: Kyle McMartin <kyle at redhat.com>
Date:   Fri Mar 4 10:34:57 2011 -0500

    Linux 2.6.37.2

 applesmc_update.patch                              |  655 ++++++++------------
 ...-eDP-encoder-correctly-when-setting-modes.patch |   33 -
 kernel.spec                                        |   17 +-
 linux-2.6-ehci-check-port-status.patch             |    2 +-
 linux-next-macbook-air-input.patch                 |   64 --
 ...-cpu-counter-threshold-when-memory-is-low.patch |  389 ------------
 sources                                            |    1 +
 tpm-fix-stall-on-boot.patch                        |   24 -
 8 files changed, 251 insertions(+), 934 deletions(-)
---
diff --git a/applesmc_update.patch b/applesmc_update.patch
index d421468..f4adad3 100644
--- a/applesmc_update.patch
+++ b/applesmc_update.patch
@@ -1,7 +1,8 @@
 Update the applesmc driver. Should work on all hardware. Upstream in .38?
 
+
 diff --git a/drivers/hwmon/applesmc.c b/drivers/hwmon/applesmc.c
-index b6598aa..0d7e9ae 100644
+index 87a5fd51..4c07436 100644
 --- a/drivers/hwmon/applesmc.c
 +++ b/drivers/hwmon/applesmc.c
 @@ -4,6 +4,7 @@
@@ -12,39 +13,21 @@ index b6598aa..0d7e9ae 100644
   *
   * Based on hdaps.c driver:
   * Copyright (C) 2005 Robert Love <rml at novell.com>
-@@ -26,10 +27,12 @@
+@@ -26,10 +27,13 @@
   * 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA
   */
  
 +#define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
 +
  #include <linux/delay.h>
--#include <linux/platform_device.h>
+ #include <linux/platform_device.h>
  #include <linux/input-polldev.h>
  #include <linux/kernel.h>
 +#include <linux/slab.h>
  #include <linux/module.h>
  #include <linux/timer.h>
  #include <linux/dmi.h>
-@@ -39,16 +42,23 @@
- #include <linux/leds.h>
- #include <linux/hwmon.h>
- #include <linux/workqueue.h>
-+#include <linux/slab.h>
-+#include <linux/pnp.h>
-+#include <linux/irq.h>
-+#include <linux/interrupt.h>
- 
- /* data port used by Apple SMC */
--#define APPLESMC_DATA_PORT	0x300
-+#define APPLESMC_DATA_PORT	0x0
- /* command/status port used by Apple SMC */
--#define APPLESMC_CMD_PORT	0x304
-+#define APPLESMC_CMD_PORT	0x4
-+/* interrupt status port */
-+#define APPLESMC_ISR_PORT	0x1f
- 
- #define APPLESMC_NR_PORTS	32 /* 0x300-0x31f */
+@@ -49,6 +53,7 @@
  
  #define APPLESMC_MAX_DATA_LENGTH 32
  
@@ -52,12 +35,8 @@ index b6598aa..0d7e9ae 100644
  #define APPLESMC_MIN_WAIT	0x0040
  #define APPLESMC_MAX_WAIT	0x8000
  
-@@ -71,106 +81,19 @@
- #define MOTION_SENSOR_Z_KEY	"MO_Z" /* r-o sp78 (2 bytes) */
- #define MOTION_SENSOR_KEY	"MOCN" /* r/w ui16 */
+@@ -73,108 +78,15 @@
  
-+#define NOTIFICATION_KEY	"NTOK"
-+
  #define FANS_COUNT		"FNum" /* r-o ui8 */
  #define FANS_MANUAL		"FS! " /* r-w ui16 */
 -#define FAN_ACTUAL_SPEED	"F0Ac" /* r-o fpe2 (2 bytes) */
@@ -149,6 +128,10 @@ index b6598aa..0d7e9ae 100644
 -/* Set 22: MacBook Pro 7,1 */
 -	{ "TB0T", "TB1T", "TB2T", "TC0D", "TC0P", "TN0D", "TN0P", "TN0S",
 -	  "TN1D", "TN1F", "TN1G", "TN1S", "Th1H", "Ts0P", "Ts0S", NULL },
+-/* Set 23: MacBook Air 3,1 */
+-	{ "TB0T", "TB1T", "TB2T", "TC0D", "TC0E", "TC0P", "TC1E", "TCZ3",
+-	  "TCZ4", "TCZ5", "TG0E", "TG1E", "TG2E", "TGZ3", "TGZ4", "TGZ5",
+-	  "TH0F", "TH0O", "TM0P" },
 -};
 +#define FAN_ID_FMT		"F%dID" /* r-o char[16] */
  
@@ -168,7 +151,7 @@ index b6598aa..0d7e9ae 100644
  };
  
  #define INIT_TIMEOUT_MSECS	5000	/* wait up to 5s for device init ... */
-@@ -184,18 +107,58 @@ static const char* fan_speed_keys[] = {
+@@ -188,14 +100,48 @@ static const char* fan_speed_keys[] = {
  #define SENSOR_Y 1
  #define SENSOR_Z 2
  
@@ -183,15 +166,6 @@ index b6598aa..0d7e9ae 100644
 +#define to_index(attr) (to_sensor_dev_attr(attr)->index & 0xffff)
 +#define to_option(attr) (to_sensor_dev_attr(attr)->index >> 16)
 +
-+struct applesmc_pnp_device {
-+	int iobase;
-+	int iolen;
-+	int irq;
-+};
-+
-+struct pnp_dev *pdev;
-+struct applesmc_pnp_device *pnp_device;
-+
 +/* Dynamic device node attributes */
 +struct applesmc_dev_attr {
 +	struct sensor_device_attribute sda;	/* hwmon attributes */
@@ -205,8 +179,8 @@ index b6598aa..0d7e9ae 100644
 +	void *store;				/* store function */
 +	int option;				/* function argument */
 +	struct applesmc_dev_attr *nodes;	/* dynamic node array */
- };
- 
++};
++
 +/* AppleSMC entry - cached register information */
 +struct applesmc_entry {
 +	char key[5];		/* four-letter key code */
@@ -229,14 +203,12 @@ index b6598aa..0d7e9ae 100644
 +	bool has_key_backlight;		/* has keyboard backlight */
 +	bool init_complete;		/* true when fully initialized */
 +	struct applesmc_entry *cache;	/* cached key entries */
-+} smcreg;
-+
++} smcreg = {
++	.mutex = __MUTEX_INITIALIZER(smcreg.mutex),
+ };
+ 
  static const int debug;
--static struct platform_device *pdev;
- static s16 rest_x;
- static s16 rest_y;
- static u8 backlight_state[2];
-@@ -203,20 +166,6 @@ static u8 backlight_state[2];
+@@ -207,20 +153,6 @@ static u8 backlight_state[2];
  static struct device *hwmon_dev;
  static struct input_polled_dev *applesmc_idev;
  
@@ -257,24 +229,7 @@ index b6598aa..0d7e9ae 100644
  /*
   * Last index written to key_at_index sysfs file, and value to use for all other
   * key_at_index_* sysfs files.
-@@ -225,6 +174,16 @@ static unsigned int key_at_index;
- 
- static struct workqueue_struct *applesmc_led_wq;
- 
-+static u8 applesmc_read_reg(u8 reg)
-+{
-+	return inb(pnp_device->iobase + reg);
-+}
-+
-+static void applesmc_write_reg(u8 val, u8 reg)
-+{
-+	outb(val, pnp_device->iobase + reg);
-+}
-+
- /*
-  * __wait_status - Wait up to 32ms for the status port to get a certain value
-  * (masked with 0x0f), returning zero if the value is obtained.  Callers must
-@@ -238,18 +197,12 @@ static int __wait_status(u8 val)
+@@ -242,18 +174,10 @@ static int __wait_status(u8 val)
  
  	for (us = APPLESMC_MIN_WAIT; us < APPLESMC_MAX_WAIT; us <<= 1) {
  		udelay(us);
@@ -283,10 +238,9 @@ index b6598aa..0d7e9ae 100644
 -				printk(KERN_DEBUG
 -					"Waited %d us for status %x\n",
 -					2 * us - APPLESMC_MIN_WAIT, val);
-+		if ((applesmc_read_reg(APPLESMC_CMD_PORT)
-+		     & APPLESMC_STATUS_MASK) == val) {
++		if ((inb(APPLESMC_CMD_PORT) & APPLESMC_STATUS_MASK) == val)
  			return 0;
- 		}
+-		}
  	}
  
 -	printk(KERN_WARNING "applesmc: wait status failed: %x != %x\n",
@@ -295,16 +249,8 @@ index b6598aa..0d7e9ae 100644
  	return -EIO;
  }
  
-@@ -262,162 +215,246 @@ static int send_command(u8 cmd)
- {
- 	int us;
- 	for (us = APPLESMC_MIN_WAIT; us < APPLESMC_MAX_WAIT; us <<= 1) {
--		outb(cmd, APPLESMC_CMD_PORT);
-+		applesmc_write_reg(cmd, APPLESMC_CMD_PORT);
- 		udelay(us);
--		if ((inb(APPLESMC_CMD_PORT) & APPLESMC_STATUS_MASK) == 0x0c)
-+		if ((applesmc_read_reg(APPLESMC_CMD_PORT)
-+		     & APPLESMC_STATUS_MASK) == 0x0c)
+@@ -271,159 +195,242 @@ static int send_command(u8 cmd)
+ 		if ((inb(APPLESMC_CMD_PORT) & APPLESMC_STATUS_MASK) == 0x0c)
  			return 0;
  	}
 -	printk(KERN_WARNING "applesmc: command failed: %x -> %x\n",
@@ -332,8 +278,7 @@ index b6598aa..0d7e9ae 100644
 -		return -EIO;
 -
  	for (i = 0; i < 4; i++) {
--		outb(key[i], APPLESMC_DATA_PORT);
-+		applesmc_write_reg(key[i], APPLESMC_DATA_PORT);
+ 		outb(key[i], APPLESMC_DATA_PORT);
  		if (__wait_status(0x04))
  			return -EIO;
  	}
@@ -341,10 +286,7 @@ index b6598aa..0d7e9ae 100644
 -		printk(KERN_DEBUG "<%s", key);
 +	return 0;
 +}
- 
--	outb(len, APPLESMC_DATA_PORT);
--	if (debug)
--		printk(KERN_DEBUG ">%x", len);
++
 +static int read_smc(u8 cmd, const char *key, u8 *buffer, u8 len)
 +{
 +	int i;
@@ -353,19 +295,20 @@ index b6598aa..0d7e9ae 100644
 +		pr_warn("%s: read arg fail\n", key);
 +		return -EIO;
 +	}
-+
-+	applesmc_write_reg(len, APPLESMC_DATA_PORT);
+ 
+ 	outb(len, APPLESMC_DATA_PORT);
+-	if (debug)
+-		printk(KERN_DEBUG ">%x", len);
  
  	for (i = 0; i < len; i++) {
 -		if (__wait_status(0x05))
 +		if (__wait_status(0x05)) {
 +			pr_warn("%s: read data fail\n", key);
  			return -EIO;
--		buffer[i] = inb(APPLESMC_DATA_PORT);
++		}
+ 		buffer[i] = inb(APPLESMC_DATA_PORT);
 -		if (debug)
 -			printk(KERN_DEBUG "<%x", buffer[i]);
-+		}
-+		buffer[i] = applesmc_read_reg(APPLESMC_DATA_PORT);
  	}
 -	if (debug)
 -		printk(KERN_DEBUG "\n");
@@ -400,17 +343,15 @@ index b6598aa..0d7e9ae 100644
 -			return -EIO;
  	}
  
--	outb(len, APPLESMC_DATA_PORT);
-+	applesmc_write_reg(len, APPLESMC_DATA_PORT);
+ 	outb(len, APPLESMC_DATA_PORT);
  
  	for (i = 0; i < len; i++) {
 -		if (__wait_status(0x04))
 +		if (__wait_status(0x04)) {
 +			pr_warn("%s: write data fail\n", key);
  			return -EIO;
--		outb(buffer[i], APPLESMC_DATA_PORT);
 +		}
-+		applesmc_write_reg(buffer[i], APPLESMC_DATA_PORT);
+ 		outb(buffer[i], APPLESMC_DATA_PORT);
  	}
  
  	return 0;
@@ -605,7 +546,7 @@ index b6598aa..0d7e9ae 100644
 +	entry = applesmc_get_entry_by_key(key);
 +	if (IS_ERR(entry))
 +		return PTR_ERR(entry);
-+
+ 
 +	return applesmc_read_entry(entry, buffer, len);
 +}
 +
@@ -623,7 +564,7 @@ index b6598aa..0d7e9ae 100644
 +static int applesmc_has_key(const char *key, bool *value)
 +{
 +	const struct applesmc_entry *entry;
- 
++
 +	entry = applesmc_get_entry_by_key(key);
 +	if (IS_ERR(entry) && PTR_ERR(entry) != -EINVAL)
 +		return PTR_ERR(entry);
@@ -637,50 +578,25 @@ index b6598aa..0d7e9ae 100644
 - * hold applesmc_lock.
 + * applesmc_read_motion_sensor - Read motion sensor (X, Y or Z).
   */
- static int applesmc_read_motion_sensor(int index, s16* value)
- {
-@@ -444,100 +481,130 @@ static int applesmc_read_motion_sensor(int index, s16* value)
- }
- 
- /*
-- * applesmc_device_init - initialize the accelerometer.  Returns zero on success
-- * and negative error code on failure.  Can sleep.
-+ * applesmc_device_init - initialize the accelerometer.  Can sleep.
-  */
--static int applesmc_device_init(void)
-+static void applesmc_device_init(void)
+-static int applesmc_read_motion_sensor(int index, s16* value)
++static int applesmc_read_motion_sensor(int index, s16 *value)
  {
--	int total, ret = -ENXIO;
-+	int total;
+ 	u8 buffer[2];
+ 	int ret;
+@@ -455,50 +462,124 @@ static void applesmc_device_init(void)
+ 	int total;
  	u8 buffer[2];
  
 -	if (!applesmc_accelerometer)
--		return 0;
--
--	mutex_lock(&applesmc_lock);
 +	if (!smcreg.has_accelerometer)
-+		return;
+ 		return;
  
+-	mutex_lock(&applesmc_lock);
+-
  	for (total = INIT_TIMEOUT_MSECS; total > 0; total -= INIT_WAIT_MSECS) {
--		if (debug)
--			printk(KERN_DEBUG "applesmc try %d\n", total);
  		if (!applesmc_read_key(MOTION_SENSOR_KEY, buffer, 2) &&
--				(buffer[0] != 0x00 || buffer[1] != 0x00)) {
--			if (total == INIT_TIMEOUT_MSECS) {
--				printk(KERN_DEBUG "applesmc: device has"
--						" already been initialized"
--						" (0x%02x, 0x%02x).\n",
--						buffer[0], buffer[1]);
--			} else {
--				printk(KERN_DEBUG "applesmc: device"
--						" successfully initialized"
--						" (0x%02x, 0x%02x).\n",
--						buffer[0], buffer[1]);
--			}
--			ret = 0;
+ 				(buffer[0] != 0x00 || buffer[1] != 0x00))
 -			goto out;
--		}
-+				(buffer[0] != 0x00 || buffer[1] != 0x00))
 +			return;
  		buffer[0] = 0xe0;
  		buffer[1] = 0x00;
@@ -692,7 +608,6 @@ index b6598aa..0d7e9ae 100644
 -
 -out:
 -	mutex_unlock(&applesmc_lock);
--	return ret;
 +	pr_warn("failed to init the device\n");
  }
  
@@ -713,31 +628,23 @@ index b6598aa..0d7e9ae 100644
 -	mutex_lock(&applesmc_lock);
 +	if (s->init_complete)
 +		return 0;
- 
--	ret = applesmc_read_key(FANS_COUNT, buffer, 1);
-+	mutex_init(&s->mutex);
- 
--	mutex_unlock(&applesmc_lock);
++
 +	ret = read_register_count(&s->key_count);
- 	if (ret)
- 		return ret;
--	else
--		return buffer[0];
--}
++	if (ret)
++		return ret;
  
--/* Device model stuff */
--static int applesmc_probe(struct platform_device *dev)
--{
--	int ret;
+-	ret = applesmc_read_key(FANS_COUNT, buffer, 1);
 +	if (!s->cache)
 +		s->cache = kcalloc(s->key_count, sizeof(*s->cache), GFP_KERNEL);
 +	if (!s->cache)
 +		return -ENOMEM;
  
--	ret = applesmc_device_init();
+-	mutex_unlock(&applesmc_lock);
 +	ret = applesmc_read_key(FANS_COUNT, tmp, 1);
  	if (ret)
  		return ret;
+-	else
+-		return buffer[0];
 +	s->fan_count = tmp[0];
 +
 +	ret = applesmc_get_lower_bound(&s->temp_begin, "T");
@@ -769,11 +676,10 @@ index b6598aa..0d7e9ae 100644
 +	       s->has_accelerometer,
 +	       s->num_light_sensors,
 +	       s->has_key_backlight);
- 
--	printk(KERN_INFO "applesmc: device successfully initialized.\n");
- 	return 0;
- }
- 
++
++	return 0;
++}
++
 +/*
 + * applesmc_init_smcreg - Initialize register cache.
 + *
@@ -786,21 +692,40 @@ index b6598aa..0d7e9ae 100644
 +
 +	for (ms = 0; ms < INIT_TIMEOUT_MSECS; ms += INIT_WAIT_MSECS) {
 +		ret = applesmc_init_smcreg_try();
-+		if (!ret)
++		if (!ret) {
++			if (ms)
++				pr_info("init_smcreg() took %d ms\n", ms);
 +			return 0;
-+		pr_warn("slow init, retrying\n");
++		}
 +		msleep(INIT_WAIT_MSECS);
 +	}
 +
++	kfree(smcreg.cache);
++	smcreg.cache = NULL;
++
 +	return ret;
 +}
 +
 +static void applesmc_destroy_smcreg(void)
 +{
 +	kfree(smcreg.cache);
-+	memset(&smcreg, 0, sizeof(smcreg));
-+}
++	smcreg.cache = NULL;
++	smcreg.init_complete = false;
+ }
+ 
+ /* Device model stuff */
+ static int applesmc_probe(struct platform_device *dev)
+ {
++	int ret;
++
++	ret = applesmc_init_smcreg();
++	if (ret)
++		return ret;
 +
+ 	applesmc_device_init();
+ 
+ 	return 0;
+@@ -507,10 +588,8 @@ static int applesmc_probe(struct platform_device *dev)
  /* Synchronize device with memorized backlight state */
  static int applesmc_pm_resume(struct device *dev)
  {
@@ -812,33 +737,7 @@ index b6598aa..0d7e9ae 100644
  	return 0;
  }
  
- /* Reinitialize device on resume from hibernation */
- static int applesmc_pm_restore(struct device *dev)
- {
--	int ret = applesmc_device_init();
--	if (ret)
--		return ret;
-+	applesmc_device_init();
- 	return applesmc_pm_resume(dev);
- }
- 
-@@ -546,15 +613,6 @@ static const struct dev_pm_ops applesmc_pm_ops = {
- 	.restore = applesmc_pm_restore,
- };
- 
--static struct platform_driver applesmc_driver = {
--	.probe = applesmc_probe,
--	.driver	= {
--		.name = "applesmc",
--		.owner = THIS_MODULE,
--		.pm = &applesmc_pm_ops,
--	},
--};
--
- /*
-  * applesmc_calibrate - Set our "resting" values.  Callers must
-  * hold applesmc_lock.
-@@ -571,20 +629,15 @@ static void applesmc_idev_poll(struct input_polled_dev *dev)
+@@ -551,20 +630,15 @@ static void applesmc_idev_poll(struct input_polled_dev *dev)
  	struct input_dev *idev = dev->input;
  	s16 x, y;
  
@@ -861,7 +760,7 @@ index b6598aa..0d7e9ae 100644
  }
  
  /* Sysfs Files */
-@@ -601,8 +654,6 @@ static ssize_t applesmc_position_show(struct device *dev,
+@@ -581,8 +655,6 @@ static ssize_t applesmc_position_show(struct device *dev,
  	int ret;
  	s16 x, y, z;
  
@@ -870,7 +769,7 @@ index b6598aa..0d7e9ae 100644
  	ret = applesmc_read_motion_sensor(SENSOR_X, &x);
  	if (ret)
  		goto out;
-@@ -614,7 +665,6 @@ static ssize_t applesmc_position_show(struct device *dev,
+@@ -594,7 +666,6 @@ static ssize_t applesmc_position_show(struct device *dev,
  		goto out;
  
  out:
@@ -878,7 +777,7 @@ index b6598aa..0d7e9ae 100644
  	if (ret)
  		return ret;
  	else
-@@ -624,20 +674,20 @@ out:
+@@ -604,20 +675,20 @@ out:
  static ssize_t applesmc_light_show(struct device *dev,
  				struct device_attribute *attr, char *sysfsbuf)
  {
@@ -908,7 +807,7 @@ index b6598aa..0d7e9ae 100644
  	}
  
  	ret = applesmc_read_key(LIGHT_SENSOR_LEFT_KEY, buffer, data_length);
-@@ -653,7 +703,6 @@ static ssize_t applesmc_light_show(struct device *dev,
+@@ -633,7 +704,6 @@ static ssize_t applesmc_light_show(struct device *dev,
  	right = buffer[2];
  
  out:
@@ -916,7 +815,7 @@ index b6598aa..0d7e9ae 100644
  	if (ret)
  		return ret;
  	else
-@@ -664,36 +713,48 @@ out:
+@@ -644,36 +714,44 @@ out:
  static ssize_t applesmc_show_sensor_label(struct device *dev,
  			struct device_attribute *devattr, char *sysfsbuf)
  {
@@ -946,9 +845,9 @@ index b6598aa..0d7e9ae 100644
 -	struct sensor_device_attribute *attr = to_sensor_dev_attr(devattr);
 -	const char* key =
 -		temperature_sensors_sets[applesmc_temperature_set][attr->index];
- 
--	mutex_lock(&applesmc_lock);
 -
+-	mutex_lock(&applesmc_lock);
+ 
 -	ret = applesmc_read_key(key, buffer, 2);
 -	temp = buffer[0]*1000;
 -	temp += (buffer[1] >> 6) * 250;
@@ -967,10 +866,6 @@ index b6598aa..0d7e9ae 100644
 -		return snprintf(sysfsbuf, PAGE_SIZE, "%u\n", temp);
 +
 +	if (entry->len == 2) {
-+		if (buffer[0] >= 0x80) {
-+			/* The two byte format is signed - ignore negative */
-+			return -EINVAL;
-+		}
 +		temp = buffer[0] * 1000;
 +		temp += (buffer[1] >> 6) * 250;
 +	} else {
@@ -981,19 +876,19 @@ index b6598aa..0d7e9ae 100644
  }
  
  static ssize_t applesmc_show_fan_speed(struct device *dev,
-@@ -703,21 +764,12 @@ static ssize_t applesmc_show_fan_speed(struct device *dev,
+@@ -683,21 +761,12 @@ static ssize_t applesmc_show_fan_speed(struct device *dev,
  	unsigned int speed = 0;
  	char newkey[5];
  	u8 buffer[2];
 -	struct sensor_device_attribute_2 *sensor_attr =
 -						to_sensor_dev_attr_2(attr);
- 
+-
 -	newkey[0] = fan_speed_keys[sensor_attr->nr][0];
 -	newkey[1] = '0' + sensor_attr->index;
 -	newkey[2] = fan_speed_keys[sensor_attr->nr][2];
 -	newkey[3] = fan_speed_keys[sensor_attr->nr][3];
 -	newkey[4] = 0;
--
+ 
 -	mutex_lock(&applesmc_lock);
 +	sprintf(newkey, fan_speed_fmt[to_option(attr)], to_index(attr));
  
@@ -1004,24 +899,30 @@ index b6598aa..0d7e9ae 100644
  	if (ret)
  		return ret;
  	else
-@@ -732,27 +784,18 @@ static ssize_t applesmc_store_fan_speed(struct device *dev,
- 	u32 speed;
+@@ -709,30 +778,19 @@ static ssize_t applesmc_store_fan_speed(struct device *dev,
+ 					const char *sysfsbuf, size_t count)
+ {
+ 	int ret;
+-	u32 speed;
++	unsigned long speed;
  	char newkey[5];
  	u8 buffer[2];
 -	struct sensor_device_attribute_2 *sensor_attr =
 -						to_sensor_dev_attr_2(attr);
- 
- 	speed = simple_strtoul(sysfsbuf, NULL, 10);
- 
- 	if (speed > 0x4000) /* Bigger than a 14-bit value */
- 		return -EINVAL;
+-
+-	speed = simple_strtoul(sysfsbuf, NULL, 10);
+-
+-	if (speed > 0x4000) /* Bigger than a 14-bit value */
+-		return -EINVAL;
  
 -	newkey[0] = fan_speed_keys[sensor_attr->nr][0];
 -	newkey[1] = '0' + sensor_attr->index;
 -	newkey[2] = fan_speed_keys[sensor_attr->nr][2];
 -	newkey[3] = fan_speed_keys[sensor_attr->nr][3];
 -	newkey[4] = 0;
--
++	if (strict_strtoul(sysfsbuf, 10, &speed) < 0 || speed >= 0x4000)
++		return -EINVAL;		/* Bigger than a 14-bit value */
+ 
 -	mutex_lock(&applesmc_lock);
 +	sprintf(newkey, fan_speed_fmt[to_option(attr)], to_index(attr));
  
@@ -1033,7 +934,7 @@ index b6598aa..0d7e9ae 100644
  	if (ret)
  		return ret;
  	else
-@@ -760,19 +803,15 @@ static ssize_t applesmc_store_fan_speed(struct device *dev,
+@@ -740,19 +798,15 @@ static ssize_t applesmc_store_fan_speed(struct device *dev,
  }
  
  static ssize_t applesmc_show_fan_manual(struct device *dev,
@@ -1055,7 +956,7 @@ index b6598aa..0d7e9ae 100644
  	if (ret)
  		return ret;
  	else
-@@ -780,28 +819,25 @@ static ssize_t applesmc_show_fan_manual(struct device *dev,
+@@ -760,18 +814,16 @@ static ssize_t applesmc_show_fan_manual(struct device *dev,
  }
  
  static ssize_t applesmc_store_fan_manual(struct device *dev,
@@ -1065,17 +966,20 @@ index b6598aa..0d7e9ae 100644
  {
  	int ret;
  	u8 buffer[2];
- 	u32 input;
+-	u32 input;
++	unsigned long input;
  	u16 val;
 -	struct sensor_device_attribute *attr = to_sensor_dev_attr(devattr);
- 
- 	input = simple_strtoul(sysfsbuf, NULL, 10);
+-
+-	input = simple_strtoul(sysfsbuf, NULL, 10);
  
 -	mutex_lock(&applesmc_lock);
--
++	if (strict_strtoul(sysfsbuf, 10, &input) < 0)
++		return -EINVAL;
+ 
  	ret = applesmc_read_key(FANS_MANUAL, buffer, 2);
  	val = (buffer[0] << 8 | buffer[1]);
- 	if (ret)
+@@ -779,9 +831,9 @@ static ssize_t applesmc_store_fan_manual(struct device *dev,
  		goto out;
  
  	if (input)
@@ -1087,7 +991,7 @@ index b6598aa..0d7e9ae 100644
  
  	buffer[0] = (val >> 8) & 0xFF;
  	buffer[1] = val & 0xFF;
-@@ -809,7 +845,6 @@ static ssize_t applesmc_store_fan_manual(struct device *dev,
+@@ -789,7 +841,6 @@ static ssize_t applesmc_store_fan_manual(struct device *dev,
  	ret = applesmc_write_key(FANS_MANUAL, buffer, 2);
  
  out:
@@ -1095,19 +999,19 @@ index b6598aa..0d7e9ae 100644
  	if (ret)
  		return ret;
  	else
-@@ -822,21 +857,12 @@ static ssize_t applesmc_show_fan_position(struct device *dev,
+@@ -802,21 +853,12 @@ static ssize_t applesmc_show_fan_position(struct device *dev,
  	int ret;
  	char newkey[5];
  	u8 buffer[17];
 -	struct sensor_device_attribute_2 *sensor_attr =
 -						to_sensor_dev_attr_2(attr);
- 
+-
 -	newkey[0] = FAN_POSITION[0];
 -	newkey[1] = '0' + sensor_attr->index;
 -	newkey[2] = FAN_POSITION[2];
 -	newkey[3] = FAN_POSITION[3];
 -	newkey[4] = 0;
--
+ 
 -	mutex_lock(&applesmc_lock);
 +	sprintf(newkey, FAN_ID_FMT, to_index(attr));
  
@@ -1118,7 +1022,7 @@ index b6598aa..0d7e9ae 100644
  	if (ret)
  		return ret;
  	else
-@@ -852,18 +878,14 @@ static ssize_t applesmc_calibrate_show(struct device *dev,
+@@ -832,18 +874,14 @@ static ssize_t applesmc_calibrate_show(struct device *dev,
  static ssize_t applesmc_calibrate_store(struct device *dev,
  	struct device_attribute *attr, const char *sysfsbuf, size_t count)
  {
@@ -1137,7 +1041,7 @@ index b6598aa..0d7e9ae 100644
  }
  static DECLARE_WORK(backlight_work, &applesmc_backlight_set);
  
-@@ -886,13 +908,10 @@ static ssize_t applesmc_key_count_show(struct device *dev,
+@@ -866,13 +904,10 @@ static ssize_t applesmc_key_count_show(struct device *dev,
  	u8 buffer[4];
  	u32 count;
  
@@ -1151,7 +1055,7 @@ index b6598aa..0d7e9ae 100644
  	if (ret)
  		return ret;
  	else
-@@ -902,113 +921,53 @@ static ssize_t applesmc_key_count_show(struct device *dev,
+@@ -882,113 +917,53 @@ static ssize_t applesmc_key_count_show(struct device *dev,
  static ssize_t applesmc_key_at_index_read_show(struct device *dev,
  				struct device_attribute *attr, char *sysfsbuf)
  {
@@ -1207,16 +1111,16 @@ index b6598aa..0d7e9ae 100644
 -	int ret;
 -
 -	mutex_lock(&applesmc_lock);
+-
+-	ret = applesmc_get_key_at_index(key_at_index, key);
 +	const struct applesmc_entry *entry;
  
--	ret = applesmc_get_key_at_index(key_at_index, key);
+-	if (ret || !key[0]) {
+-		mutex_unlock(&applesmc_lock);
 +	entry = applesmc_get_entry_by_index(key_at_index);
 +	if (IS_ERR(entry))
 +		return PTR_ERR(entry);
  
--	if (ret || !key[0]) {
--		mutex_unlock(&applesmc_lock);
--
 -		return -EINVAL;
 -	}
 -
@@ -1237,13 +1141,9 @@ index b6598aa..0d7e9ae 100644
 -	char key[5];
 -	char info[6];
 -	int ret;
-+	const struct applesmc_entry *entry;
- 
+-
 -	mutex_lock(&applesmc_lock);
-+	entry = applesmc_get_entry_by_index(key_at_index);
-+	if (IS_ERR(entry))
-+		return PTR_ERR(entry);
- 
+-
 -	ret = applesmc_get_key_at_index(key_at_index, key);
 -
 -	if (ret || !key[0]) {
@@ -1253,9 +1153,13 @@ index b6598aa..0d7e9ae 100644
 -	}
 -
 -	ret = applesmc_get_key_type(key, info);
--
++	const struct applesmc_entry *entry;
+ 
 -	mutex_unlock(&applesmc_lock);
--
++	entry = applesmc_get_entry_by_index(key_at_index);
++	if (IS_ERR(entry))
++		return PTR_ERR(entry);
+ 
 -	if (!ret)
 -		return snprintf(sysfsbuf, PAGE_SIZE, "%s\n", info+1);
 -	else
@@ -1268,17 +1172,17 @@ index b6598aa..0d7e9ae 100644
  {
 -	char key[5];
 -	int ret;
--
--	mutex_lock(&applesmc_lock);
--
--	ret = applesmc_get_key_at_index(key_at_index, key);
 +	const struct applesmc_entry *entry;
  
--	mutex_unlock(&applesmc_lock);
+-	mutex_lock(&applesmc_lock);
 +	entry = applesmc_get_entry_by_index(key_at_index);
 +	if (IS_ERR(entry))
 +		return PTR_ERR(entry);
  
+-	ret = applesmc_get_key_at_index(key_at_index, key);
+-
+-	mutex_unlock(&applesmc_lock);
+-
 -	if (!ret && key[0])
 -		return snprintf(sysfsbuf, PAGE_SIZE, "%s\n", key);
 -	else
@@ -1287,20 +1191,25 @@ index b6598aa..0d7e9ae 100644
  }
  
  static ssize_t applesmc_key_at_index_show(struct device *dev,
-@@ -1020,12 +979,8 @@ static ssize_t applesmc_key_at_index_show(struct device *dev,
+@@ -1000,12 +975,13 @@ static ssize_t applesmc_key_at_index_show(struct device *dev,
  static ssize_t applesmc_key_at_index_store(struct device *dev,
  	struct device_attribute *attr, const char *sysfsbuf, size_t count)
  {
 -	mutex_lock(&applesmc_lock);
 -
- 	key_at_index = simple_strtoul(sysfsbuf, NULL, 10);
+-	key_at_index = simple_strtoul(sysfsbuf, NULL, 10);
++	unsigned long newkey;
  
 -	mutex_unlock(&applesmc_lock);
--
++	if (strict_strtoul(sysfsbuf, 10, &newkey) < 0
++	    || newkey >= smcreg.key_count)
++		return -EINVAL;
+ 
++	key_at_index = newkey;
  	return count;
  }
  
-@@ -1035,387 +990,101 @@ static struct led_classdev applesmc_backlight = {
+@@ -1015,387 +991,102 @@ static struct led_classdev applesmc_backlight = {
  	.brightness_set		= applesmc_brightness_set,
  };
  
@@ -1751,6 +1660,7 @@ index b6598aa..0d7e9ae 100644
 +			node->sda.dev_attr.show = grp->show;
 +			node->sda.dev_attr.store = grp->store;
 +			attr = &node->sda.dev_attr.attr;
++			sysfs_attr_init(attr);
 +			attr->name = node->name;
 +			attr->mode = S_IRUGO | (grp->store ? S_IWUSR : 0);
 +			ret = sysfs_create_file(&pdev->dev.kobj, attr);
@@ -1768,7 +1678,7 @@ index b6598aa..0d7e9ae 100644
  }
  
  /* Create accelerometer ressources */
-@@ -1424,8 +1093,10 @@ static int applesmc_create_accelerometer(void)
+@@ -1404,8 +1095,10 @@ static int applesmc_create_accelerometer(void)
  	struct input_dev *idev;
  	int ret;
  
@@ -1781,7 +1691,7 @@ index b6598aa..0d7e9ae 100644
  	if (ret)
  		goto out;
  
-@@ -1462,282 +1133,132 @@ out_idev:
+@@ -1442,190 +1135,96 @@ out_idev:
  	input_free_polled_device(applesmc_idev);
  
  out_sysfs:
@@ -1852,6 +1762,8 @@ index b6598aa..0d7e9ae 100644
 -	{ .accelerometer = 1, .light = 1, .temperature_set = 21 },
 -/* MacBook Pro 7,1: accelerometer, backlight and temperature set 22 */
 -	{ .accelerometer = 1, .light = 1, .temperature_set = 22 },
+-/* MacBook Air 3,1: accelerometer, backlight and temperature set 23 */
+-	{ .accelerometer = 0, .light = 0, .temperature_set = 23 },
 -};
 +static int applesmc_create_light_sensor(void)
 +{
@@ -1859,17 +1771,51 @@ index b6598aa..0d7e9ae 100644
 +		return 0;
 +	return applesmc_create_nodes(light_sensor_group, 1);
 +}
++
++static void applesmc_release_light_sensor(void)
++{
++	if (!smcreg.num_light_sensors)
++		return;
++	applesmc_destroy_nodes(light_sensor_group);
++}
++
++static int applesmc_create_key_backlight(void)
++{
++	if (!smcreg.has_key_backlight)
++		return 0;
++	applesmc_led_wq = create_singlethread_workqueue("applesmc-led");
++	if (!applesmc_led_wq)
++		return -ENOMEM;
++	return led_classdev_register(&pdev->dev, &applesmc_backlight);
++}
++
++static void applesmc_release_key_backlight(void)
++{
++	if (!smcreg.has_key_backlight)
++		return;
++	led_classdev_unregister(&applesmc_backlight);
++	destroy_workqueue(applesmc_led_wq);
++}
++
++static int applesmc_dmi_match(const struct dmi_system_id *id)
++{
++	return 1;
++}
  
--/* Note that DMI_MATCH(...,"MacBook") will match "MacBookPro1,1".
-- * So we need to put "Apple MacBook Pro" before "Apple MacBook". */
--static __initdata struct dmi_system_id applesmc_whitelist[] = {
+ /* Note that DMI_MATCH(...,"MacBook") will match "MacBookPro1,1".
+  * So we need to put "Apple MacBook Pro" before "Apple MacBook". */
+ static __initdata struct dmi_system_id applesmc_whitelist[] = {
+-	{ applesmc_dmi_match, "Apple MacBook Air 3", {
+-	  DMI_MATCH(DMI_BOARD_VENDOR, "Apple"),
+-	  DMI_MATCH(DMI_PRODUCT_NAME, "MacBookAir3") },
+-		&applesmc_dmi_data[23]},
 -	{ applesmc_dmi_match, "Apple MacBook Air 2", {
 -	  DMI_MATCH(DMI_BOARD_VENDOR, "Apple"),
 -	  DMI_MATCH(DMI_PRODUCT_NAME, "MacBookAir2") },
 -		&applesmc_dmi_data[15]},
--	{ applesmc_dmi_match, "Apple MacBook Air", {
--	  DMI_MATCH(DMI_BOARD_VENDOR, "Apple"),
--	  DMI_MATCH(DMI_PRODUCT_NAME, "MacBookAir") },
+ 	{ applesmc_dmi_match, "Apple MacBook Air", {
+ 	  DMI_MATCH(DMI_BOARD_VENDOR, "Apple"),
+ 	  DMI_MATCH(DMI_PRODUCT_NAME, "MacBookAir") },
 -		&applesmc_dmi_data[7]},
 -	{ applesmc_dmi_match, "Apple MacBook Pro 7", {
 -	  DMI_MATCH(DMI_BOARD_VENDOR, "Apple"),
@@ -1903,7 +1849,8 @@ index b6598aa..0d7e9ae 100644
 -	  DMI_MATCH(DMI_BOARD_VENDOR, "Apple Computer, Inc."),
 -	  DMI_MATCH(DMI_PRODUCT_NAME, "MacBookPro2,2") },
 -		&applesmc_dmi_data[18]},
--	{ applesmc_dmi_match, "Apple MacBook Pro", {
++	},
+ 	{ applesmc_dmi_match, "Apple MacBook Pro", {
 -	  DMI_MATCH(DMI_BOARD_VENDOR,"Apple"),
 -	  DMI_MATCH(DMI_PRODUCT_NAME,"MacBookPro") },
 -		&applesmc_dmi_data[0]},
@@ -1920,14 +1867,19 @@ index b6598aa..0d7e9ae 100644
 -	  DMI_MATCH(DMI_PRODUCT_NAME, "MacBook4") },
 -		&applesmc_dmi_data[6]},
 -	{ applesmc_dmi_match, "Apple MacBook 5", {
--	  DMI_MATCH(DMI_BOARD_VENDOR, "Apple"),
+ 	  DMI_MATCH(DMI_BOARD_VENDOR, "Apple"),
 -	  DMI_MATCH(DMI_PRODUCT_NAME, "MacBook5") },
 -		&applesmc_dmi_data[11]},
--	{ applesmc_dmi_match, "Apple MacBook", {
++	  DMI_MATCH(DMI_PRODUCT_NAME, "MacBookPro") },
++	},
+ 	{ applesmc_dmi_match, "Apple MacBook", {
 -	  DMI_MATCH(DMI_BOARD_VENDOR,"Apple"),
 -	  DMI_MATCH(DMI_PRODUCT_NAME,"MacBook") },
 -		&applesmc_dmi_data[2]},
--	{ applesmc_dmi_match, "Apple Macmini", {
++	  DMI_MATCH(DMI_BOARD_VENDOR, "Apple"),
++	  DMI_MATCH(DMI_PRODUCT_NAME, "MacBook") },
++	},
+ 	{ applesmc_dmi_match, "Apple Macmini", {
 -	  DMI_MATCH(DMI_BOARD_VENDOR,"Apple"),
 -	  DMI_MATCH(DMI_PRODUCT_NAME,"Macmini") },
 -		&applesmc_dmi_data[3]},
@@ -1936,12 +1888,14 @@ index b6598aa..0d7e9ae 100644
 -	  DMI_MATCH(DMI_PRODUCT_NAME,"MacPro2") },
 -		&applesmc_dmi_data[4]},
 -	{ applesmc_dmi_match, "Apple MacPro3", {
--	  DMI_MATCH(DMI_BOARD_VENDOR, "Apple"),
+ 	  DMI_MATCH(DMI_BOARD_VENDOR, "Apple"),
 -	  DMI_MATCH(DMI_PRODUCT_NAME, "MacPro3") },
 -		&applesmc_dmi_data[16]},
--	{ applesmc_dmi_match, "Apple MacPro", {
--	  DMI_MATCH(DMI_BOARD_VENDOR, "Apple"),
--	  DMI_MATCH(DMI_PRODUCT_NAME, "MacPro") },
++	  DMI_MATCH(DMI_PRODUCT_NAME, "Macmini") },
++	},
+ 	{ applesmc_dmi_match, "Apple MacPro", {
+ 	  DMI_MATCH(DMI_BOARD_VENDOR, "Apple"),
+ 	  DMI_MATCH(DMI_PRODUCT_NAME, "MacPro") },
 -		&applesmc_dmi_data[4]},
 -	{ applesmc_dmi_match, "Apple iMac 9,1", {
 -	  DMI_MATCH(DMI_BOARD_VENDOR, "Apple Inc."),
@@ -1959,109 +1913,43 @@ index b6598aa..0d7e9ae 100644
 -	  DMI_MATCH(DMI_BOARD_VENDOR, "Apple"),
 -	  DMI_MATCH(DMI_PRODUCT_NAME, "iMac5") },
 -		&applesmc_dmi_data[10]},
--	{ applesmc_dmi_match, "Apple iMac", {
++	},
+ 	{ applesmc_dmi_match, "Apple iMac", {
 -	  DMI_MATCH(DMI_BOARD_VENDOR,"Apple"),
 -	  DMI_MATCH(DMI_PRODUCT_NAME,"iMac") },
 -		&applesmc_dmi_data[5]},
--	{ .ident = NULL }
--};
-+static void applesmc_release_light_sensor(void)
-+{
-+	if (!smcreg.num_light_sensors)
-+		return;
-+	applesmc_destroy_nodes(light_sensor_group);
-+}
++	  DMI_MATCH(DMI_BOARD_VENDOR, "Apple"),
++	  DMI_MATCH(DMI_PRODUCT_NAME, "iMac") },
++	},
+ 	{ .ident = NULL }
+ };
  
--static int __init applesmc_init(void)
-+static int applesmc_create_key_backlight(void)
-+{
-+	if (!smcreg.has_key_backlight)
-+		return 0;
-+	applesmc_led_wq = create_singlethread_workqueue("applesmc-led");
-+	if (!applesmc_led_wq)
-+		return -ENOMEM;
-+	return led_classdev_register(&pdev->dev, &applesmc_backlight);
-+}
-+
-+static void applesmc_release_key_backlight(void)
-+{
-+	if (!smcreg.has_key_backlight)
-+		return;
-+	led_classdev_unregister(&applesmc_backlight);
-+	destroy_workqueue(applesmc_led_wq);
-+}
-+
-+static void applesmc_set_interrupt(u8 enable)
-+{
-+	applesmc_write_key(NOTIFICATION_KEY, &enable, 1);
-+}
-+
-+static irqreturn_t applesmc_interrupt(int irq, void *dev)
-+{
-+	printk("SMC Interrupt\n");
-+	return IRQ_HANDLED;
-+}
-+
-+static int __devinit applesmc_pnp_probe(struct pnp_dev *dev,
-+					const struct pnp_device_id *dev_id)
+ static int __init applesmc_init(void)
  {
  	int ret;
 -	int count;
 -	int i;
-+	struct resource *res;
-+	struct applesmc_pnp_device *applesmc_pnp_device;
  
--	if (!dmi_check_system(applesmc_whitelist)) {
+ 	if (!dmi_check_system(applesmc_whitelist)) {
 -		printk(KERN_WARNING "applesmc: supported laptop not found!\n");
--		ret = -ENODEV;
-+	pdev = dev;
-+
-+	applesmc_pnp_device = kzalloc(sizeof(struct applesmc_pnp_device),
-+				      GFP_KERNEL);
-+
-+	if (!applesmc_pnp_device) {
-+		ret = -ENOMEM;
++		pr_warn("supported laptop not found!\n");
+ 		ret = -ENODEV;
  		goto out;
  	}
- 
--	if (!request_region(APPLESMC_DATA_PORT, APPLESMC_NR_PORTS,
--								"applesmc")) {
-+	pnp_device = applesmc_pnp_device;
-+
-+	pnp_set_drvdata(dev, applesmc_pnp_device);
-+
-+	res = pnp_get_resource(dev, IORESOURCE_IO, 0);
-+
-+	if (!res) {
- 		ret = -ENXIO;
- 		goto out;
- 	}
- 
--	ret = platform_driver_register(&applesmc_driver);
--	if (ret)
--		goto out_region;
-+	applesmc_pnp_device->iobase = res->start;
-+	applesmc_pnp_device->iolen = res->end - res->start + 1;
- 
--	pdev = platform_device_register_simple("applesmc", APPLESMC_DATA_PORT,
--					       NULL, 0);
--	if (IS_ERR(pdev)) {
--		ret = PTR_ERR(pdev);
--		goto out_driver;
-+	if (!request_region(pnp_device->iobase, pnp_device->iolen, "applesmc")) {
-+		ret = -ENXIO;
-+		goto out;
+@@ -1647,83 +1246,34 @@ static int __init applesmc_init(void)
+ 		goto out_driver;
  	}
  
 -	ret = sysfs_create_file(&pdev->dev.kobj, &dev_attr_name.attr);
 +	/* create register cache */
 +	ret = applesmc_init_smcreg();
  	if (ret)
--		goto out_device;
--
+ 		goto out_device;
+ 
 -	/* Create key enumeration sysfs files */
 -	ret = sysfs_create_group(&pdev->dev.kobj, &key_enumeration_group);
--	if (ret)
++	ret = applesmc_create_nodes(info_group, 1);
+ 	if (ret)
 -		goto out_name;
 -
 -	/* create fan files */
@@ -2070,7 +1958,7 @@ index b6598aa..0d7e9ae 100644
 -		printk(KERN_ERR "applesmc: Cannot get the number of fans.\n");
 -	else
 -		printk(KERN_INFO "applesmc: %d fans found.\n", count);
-+		goto out_region;
++		goto out_smcreg;
  
 -	if (count > 4) {
 -		count = 4;
@@ -2078,8 +1966,7 @@ index b6598aa..0d7e9ae 100644
 -		       " but at most 4 fans are supported"
 -		       " by the driver.\n");
 -	}
-+	applesmc_device_init();
- 
+-
 -	while (fans_handled < count) {
 -		ret = sysfs_create_group(&pdev->dev.kobj,
 -					 &fan_attribute_groups[fans_handled]);
@@ -2087,10 +1974,7 @@ index b6598aa..0d7e9ae 100644
 -			goto out_fans;
 -		fans_handled++;
 -	}
-+	ret = applesmc_create_nodes(info_group, 1);
-+	if (ret)
-+		goto out_smcreg;
- 
+-
 -	for (i = 0;
 -	     temperature_sensors_sets[applesmc_temperature_set][i] != NULL;
 -	     i++) {
@@ -2155,23 +2039,12 @@ index b6598aa..0d7e9ae 100644
  
  	hwmon_dev = hwmon_device_register(&pdev->dev);
  	if (IS_ERR(hwmon_dev)) {
-@@ -1745,65 +1266,85 @@ static int __init applesmc_init(void)
+@@ -1731,32 +1281,22 @@ static int __init applesmc_init(void)
  		goto out_light_ledclass;
  	}
  
 -	printk(KERN_INFO "applesmc: driver successfully loaded.\n");
-+	res = pnp_get_resource(dev, IORESOURCE_IRQ, 0);
-+
-+	if (res) {
-+		applesmc_pnp_device->irq = res->start;
-+		ret = request_irq(res->start, applesmc_interrupt, IRQF_SHARED,
-+				  "applesmc", dev);
-+		if (ret)
-+			applesmc_pnp_device->irq = 0;
-+		else
-+			applesmc_set_interrupt(1);
-+	}
- 
+-
  	return 0;
  
  out_light_ledclass:
@@ -2200,38 +2073,31 @@ index b6598aa..0d7e9ae 100644
 -	sysfs_remove_group(&pdev->dev.kobj, &key_enumeration_group);
 -out_name:
 -	sysfs_remove_file(&pdev->dev.kobj, &dev_attr_name.attr);
--out_device:
--	platform_device_unregister(pdev);
--out_driver:
--	platform_driver_unregister(&applesmc_driver);
 +	applesmc_destroy_nodes(fan_group);
 +out_info:
 +	applesmc_destroy_nodes(info_group);
 +out_smcreg:
 +	applesmc_destroy_smcreg();
+ out_device:
+ 	platform_device_unregister(pdev);
+ out_driver:
+@@ -1764,32 +1304,23 @@ out_driver:
  out_region:
--	release_region(APPLESMC_DATA_PORT, APPLESMC_NR_PORTS);
-+	release_region(pnp_device->iobase, pnp_device->iolen);
+ 	release_region(APPLESMC_DATA_PORT, APPLESMC_NR_PORTS);
  out:
 -	printk(KERN_WARNING "applesmc: driver init failed (ret=%d)!\n", ret);
 +	pr_warn("driver init failed (ret=%d)!\n", ret);
  	return ret;
  }
  
--static void __exit applesmc_exit(void)
-+static void __devexit applesmc_pnp_remove(struct pnp_dev *dev)
+ static void __exit applesmc_exit(void)
  {
--	hwmon_device_unregister(hwmon_dev);
+ 	hwmon_device_unregister(hwmon_dev);
 -	if (applesmc_light) {
 -		led_classdev_unregister(&applesmc_backlight);
 -		destroy_workqueue(applesmc_led_wq);
 -		sysfs_remove_file(&pdev->dev.kobj, &dev_attr_light.attr);
-+	struct applesmc_pnp_device *applesmc_pnp_device = pnp_get_drvdata(dev);
-+
-+	if (applesmc_pnp_device->irq) {
-+		applesmc_set_interrupt(0);
-+		free_irq(applesmc_pnp_device->irq, dev);
- 	}
+-	}
 -	if (applesmc_accelerometer)
 -		applesmc_release_accelerometer();
 -	sysfs_remove_group(&pdev->dev.kobj, &label_attributes_group);
@@ -2241,13 +2107,6 @@ index b6598aa..0d7e9ae 100644
 -				   &fan_attribute_groups[--fans_handled]);
 -	sysfs_remove_group(&pdev->dev.kobj, &key_enumeration_group);
 -	sysfs_remove_file(&pdev->dev.kobj, &dev_attr_name.attr);
--	platform_device_unregister(pdev);
--	platform_driver_unregister(&applesmc_driver);
--	release_region(APPLESMC_DATA_PORT, APPLESMC_NR_PORTS);
--
--	printk(KERN_INFO "applesmc: driver unloaded.\n");
-+
-+	hwmon_device_unregister(hwmon_dev);
 +	applesmc_release_key_backlight();
 +	applesmc_release_light_sensor();
 +	applesmc_release_accelerometer();
@@ -2255,39 +2114,11 @@ index b6598aa..0d7e9ae 100644
 +	applesmc_destroy_nodes(fan_group);
 +	applesmc_destroy_nodes(info_group);
 +	applesmc_destroy_smcreg();
-+	release_region(pnp_device->iobase, pnp_device->iolen);
-+	kfree(applesmc_pnp_device);
-+}
-+
-+static const struct pnp_device_id applesmc_dev_table[] = {
-+	{"APP0001", 0},
-+	{"", 0},
-+};
-+
-+static struct pnp_driver applesmc_pnp_driver = {
-+	.name           = "Apple SMC",
-+	.probe          = applesmc_pnp_probe,
-+	.remove         = applesmc_pnp_remove,
-+	.id_table       = applesmc_dev_table,
-+	.driver = {
-+		.pm	= &applesmc_pm_ops,
-+	},
-+};
-+
-+static int __init applesmc_init(void)
-+{
-+	return pnp_register_driver(&applesmc_pnp_driver);
-+}
-+
-+static void __exit applesmc_exit(void)
-+{
-+	pnp_unregister_driver(&applesmc_pnp_driver);
+ 	platform_device_unregister(pdev);
+ 	platform_driver_unregister(&applesmc_driver);
+ 	release_region(APPLESMC_DATA_PORT, APPLESMC_NR_PORTS);
+-
+-	printk(KERN_INFO "applesmc: driver unloaded.\n");
  }
  
  module_init(applesmc_init);
-@@ -1812,4 +1353,4 @@ module_exit(applesmc_exit);
- MODULE_AUTHOR("Nicolas Boichat");
- MODULE_DESCRIPTION("Apple SMC");
- MODULE_LICENSE("GPL v2");
--MODULE_DEVICE_TABLE(dmi, applesmc_whitelist);
-+MODULE_DEVICE_TABLE(pnp, applesmc_dev_table);
diff --git a/kernel.spec b/kernel.spec
index 6e26555..de34f3f 100644
--- a/kernel.spec
+++ b/kernel.spec
@@ -51,7 +51,7 @@ Summary: The Linux kernel
 # For non-released -rc kernels, this will be prepended with "0.", so
 # for example a 3 here will become 0.3
 #
-%global baserelease 2
+%global baserelease 1
 %global fedora_build %{baserelease}
 
 # base_sublevel is the kernel version we're starting with and patching
@@ -63,7 +63,7 @@ Summary: The Linux kernel
 %if 0%{?released_kernel}
 
 # Do we have a -stable update to apply?
-%define stable_update 0
+%define stable_update 2
 # Is it a -stable RC?
 %define stable_rc 0
 # Set rpm version accordingly
@@ -679,7 +679,6 @@ Patch1824: drm-intel-next.patch
 # make sure the lvds comes back on lid open
 Patch1825: drm-intel-make-lvds-work.patch
 Patch1826: drm-intel-edp-fixes.patch
-Patch1827: drm_i915-check-eDP-encoder-correctly-when-setting-modes.patch
 
 Patch1900: linux-2.6-intel-iommu-igfx.patch
 
@@ -719,8 +718,6 @@ Patch12017: prevent-runtime-conntrack-changes.patch
 
 Patch12018: neuter_intel_microcode_load.patch
 
-Patch12030: tpm-fix-stall-on-boot.patch
-
 Patch12100: applesmc_update.patch
 Patch12101: apple_backlight.patch
 Patch12102: efifb_update.patch
@@ -738,7 +735,6 @@ Patch12303: dmar-disable-when-ricoh-multifunction.patch
 
 Patch12401: debug-tty-print-dev-name.patch
 
-Patch12410: mm-page-allocator-adjust-the-per-cpu-counter-threshold-when-memory-is-low.patch
 Patch12411: mm-vmstat-use-a-single-setter-function-and-callback-for-adjusting-percpu-thresholds.patch
 
 Patch12421: fs-call-security_d_instantiate-in-d_obtain_alias.patch
@@ -1305,7 +1301,6 @@ ApplyPatch drm-intel-big-hammer.patch
 ApplyPatch drm-intel-make-lvds-work.patch
 ApplyPatch linux-2.6-intel-iommu-igfx.patch
 ApplyPatch drm-intel-edp-fixes.patch
-ApplyPatch drm_i915-check-eDP-encoder-correctly-when-setting-modes.patch
 
 # linux1394 git patches
 #ApplyPatch linux-2.6-firewire-git-update.patch
@@ -1339,9 +1334,6 @@ ApplyPatch add-appleir-usb-driver.patch
 
 ApplyPatch neuter_intel_microcode_load.patch
 
-# try to fix stalls during boot (#530393)
-ApplyPatch tpm-fix-stall-on-boot.patch
-
 # various fixes for Apple and EFI
 ApplyPatch applesmc_update.patch
 ApplyPatch apple_backlight.patch
@@ -1363,7 +1355,6 @@ ApplyPatch dmar-disable-when-ricoh-multifunction.patch
 ApplyPatch debug-tty-print-dev-name.patch
 
 # backport some fixes for kswapd from mmotm, rhbz#649694
-ApplyPatch mm-page-allocator-adjust-the-per-cpu-counter-threshold-when-memory-is-low.patch
 ApplyPatch mm-vmstat-use-a-single-setter-function-and-callback-for-adjusting-percpu-thresholds.patch
 
 # rhbz#662344,600690
@@ -1984,6 +1975,10 @@ fi
 #                 ||----w |
 #                 ||     ||
 %changelog
+* Fri Mar 04 2011 Kyle McMartin <kmcmartin at redhat.com> 2.6.37.2-1
+- Linux 2.6.37.2 for Fedora 14 and 13
+- Drop/fixup conflicting and merged patches.
+
 * Wed Jan 19 2011 Roland McGrath <roland at redhat.com>
 - utrace update
 
diff --git a/linux-2.6-ehci-check-port-status.patch b/linux-2.6-ehci-check-port-status.patch
index 6182c77..6584941 100644
--- a/linux-2.6-ehci-check-port-status.patch
+++ b/linux-2.6-ehci-check-port-status.patch
@@ -50,5 +50,5 @@ index 796ea0c..d9c0748 100644
 -	if (!suspending && (ehci_readl(ehci, &ehci->regs->status) & STS_PCD))
 +	if (!suspending && ehci_port_change(ehci))
  		usb_hcd_resume_root_hub(ehci_to_hcd(ehci));
- }
+ 
  
diff --git a/linux-next-macbook-air-input.patch b/linux-next-macbook-air-input.patch
index 16d4d6d..25fab86 100644
--- a/linux-next-macbook-air-input.patch
+++ b/linux-next-macbook-air-input.patch
@@ -119,67 +119,3 @@ index 68114db..104b9f9 100644
  #define USB_DEVICE_ID_APPLE_ALU_WIRELESS_2009_ISO   0x023a
  #define USB_DEVICE_ID_APPLE_ALU_WIRELESS_2009_JIS   0x023b
 
-diff --git a/drivers/input/mouse/bcm5974.c b/drivers/input/mouse/bcm5974.c
-index b952317..ee82851 100644
---- a/drivers/input/mouse/bcm5974.c
-+++ b/drivers/input/mouse/bcm5974.c
-@@ -55,6 +55,14 @@
- #define USB_DEVICE_ID_APPLE_WELLSPRING3_ANSI	0x0236
- #define USB_DEVICE_ID_APPLE_WELLSPRING3_ISO	0x0237
- #define USB_DEVICE_ID_APPLE_WELLSPRING3_JIS	0x0238
-+/* MacbookAir3,2 (unibody), aka wellspring5 */
-+#define USB_DEVICE_ID_APPLE_WELLSPRING4_ANSI	0x023f
-+#define USB_DEVICE_ID_APPLE_WELLSPRING4_ISO	0x0240
-+#define USB_DEVICE_ID_APPLE_WELLSPRING4_JIS	0x0241
-+/* MacbookAir3,1 (unibody), aka wellspring4 */
-+#define USB_DEVICE_ID_APPLE_WELLSPRING4A_ANSI	0x0242
-+#define USB_DEVICE_ID_APPLE_WELLSPRING4A_ISO	0x0243
-+#define USB_DEVICE_ID_APPLE_WELLSPRING4A_JIS	0x0244
- 
- #define BCM5974_DEVICE(prod) {					\
- 	.match_flags = (USB_DEVICE_ID_MATCH_DEVICE |		\
-@@ -80,6 +88,14 @@ static const struct usb_device_id bcm5974_table[] = {
- 	BCM5974_DEVICE(USB_DEVICE_ID_APPLE_WELLSPRING3_ANSI),
- 	BCM5974_DEVICE(USB_DEVICE_ID_APPLE_WELLSPRING3_ISO),
- 	BCM5974_DEVICE(USB_DEVICE_ID_APPLE_WELLSPRING3_JIS),
-+	/* MacbookAir3,2 */
-+	BCM5974_DEVICE(USB_DEVICE_ID_APPLE_WELLSPRING4_ANSI),
-+	BCM5974_DEVICE(USB_DEVICE_ID_APPLE_WELLSPRING4_ISO),
-+	BCM5974_DEVICE(USB_DEVICE_ID_APPLE_WELLSPRING4_JIS),
-+	/* MacbookAir3,1 */
-+	BCM5974_DEVICE(USB_DEVICE_ID_APPLE_WELLSPRING4A_ANSI),
-+	BCM5974_DEVICE(USB_DEVICE_ID_APPLE_WELLSPRING4A_ISO),
-+	BCM5974_DEVICE(USB_DEVICE_ID_APPLE_WELLSPRING4A_JIS),
- 	/* Terminating entry */
- 	{}
- };
-@@ -234,6 +250,30 @@ static const struct bcm5974_config bcm5974_config_table[] = {
- 		{ DIM_X, DIM_X / SN_COORD, -4460, 5166 },
- 		{ DIM_Y, DIM_Y / SN_COORD, -75, 6700 }
- 	},
-+	{
-+		USB_DEVICE_ID_APPLE_WELLSPRING4_ANSI,
-+		USB_DEVICE_ID_APPLE_WELLSPRING4_ISO,
-+		USB_DEVICE_ID_APPLE_WELLSPRING4_JIS,
-+		HAS_INTEGRATED_BUTTON,
-+		0x84, sizeof(struct bt_data),
-+		0x81, TYPE2, FINGER_TYPE2, FINGER_TYPE2 + SIZEOF_ALL_FINGERS,
-+		{ DIM_PRESSURE, DIM_PRESSURE / SN_PRESSURE, 0, 300 },
-+		{ DIM_WIDTH, DIM_WIDTH / SN_WIDTH, 0, 2048 },
-+		{ DIM_X, DIM_X / SN_COORD, -4620, 5140 },
-+		{ DIM_Y, DIM_Y / SN_COORD, -150, 6600 }
-+	},
-+	{
-+		USB_DEVICE_ID_APPLE_WELLSPRING4A_ANSI,
-+		USB_DEVICE_ID_APPLE_WELLSPRING4A_ISO,
-+		USB_DEVICE_ID_APPLE_WELLSPRING4A_JIS,
-+		HAS_INTEGRATED_BUTTON,
-+		0x84, sizeof(struct bt_data),
-+		0x81, TYPE2, FINGER_TYPE2, FINGER_TYPE2 + SIZEOF_ALL_FINGERS,
-+		{ DIM_PRESSURE, DIM_PRESSURE / SN_PRESSURE, 0, 300 },
-+		{ DIM_WIDTH, DIM_WIDTH / SN_WIDTH, 0, 2048 },
-+		{ DIM_X, DIM_X / SN_COORD, -4616, 5112 },
-+		{ DIM_Y, DIM_Y / SN_COORD, -142, 5234 }
-+	},
- 	{}
- };
diff --git a/sources b/sources
index 864fa70..f2870ab 100644
--- a/sources
+++ b/sources
@@ -1 +1,2 @@
 c8ee37b4fdccdb651e0603d35350b434  linux-2.6.37.tar.bz2
+bb5798f2a2a5af13219d1a250c4dad11  patch-2.6.37.2.bz2


More information about the scm-commits mailing list