Revision: 56
          http://svn.sourceforge.net/mactel-linux/?rev=56&view=rev
Author:   nboichat
Date:     2006-11-04 06:43:49 -0800 (Sat, 04 Nov 2006)

Log Message:
-----------
Update temperature sensors for MacMini. (and several DMI matching cleanups)

Modified Paths:
--------------
    trunk/kernel/mactel-patches-2.6.18/applesmc.patch

Modified: trunk/kernel/mactel-patches-2.6.18/applesmc.patch
===================================================================
--- trunk/kernel/mactel-patches-2.6.18/applesmc.patch   2006-11-02 10:47:25 UTC 
(rev 55)
+++ trunk/kernel/mactel-patches-2.6.18/applesmc.patch   2006-11-04 14:43:49 UTC 
(rev 56)
@@ -1,6 +1,6 @@
-diff -pruN linux-2.6.18/drivers/hwmon.vanilla/Kconfig 
linux-2.6.18/drivers/hwmon/Kconfig
---- linux-2.6.18/drivers/hwmon.vanilla/Kconfig 2006-10-14 13:07:48.000000000 
+0800
-+++ linux-2.6.18/drivers/hwmon/Kconfig 2006-10-14 13:08:22.000000000 +0800
+diff -pruN linux/drivers/hwmon.vanilla/Kconfig linux/drivers/hwmon/Kconfig
+--- linux/drivers/hwmon.vanilla/Kconfig        2006-10-14 13:07:48.000000000 
+0800
++++ linux/drivers/hwmon/Kconfig        2006-10-14 13:08:22.000000000 +0800
 @@ -507,6 +507,26 @@ config SENSORS_HDAPS
          Say Y here if you have an applicable laptop and want to experience
          the awesome power of hdaps.
@@ -28,9 +28,9 @@
  config HWMON_DEBUG_CHIP
        bool "Hardware Monitoring Chip debugging messages"
        depends on HWMON
-diff -pruN linux-2.6.18/drivers/hwmon.vanilla/Makefile 
linux-2.6.18/drivers/hwmon/Makefile
---- linux-2.6.18/drivers/hwmon.vanilla/Makefile        2006-10-14 
13:07:48.000000000 +0800
-+++ linux-2.6.18/drivers/hwmon/Makefile        2006-10-14 13:08:22.000000000 
+0800
+diff -pruN linux/drivers/hwmon.vanilla/Makefile linux/drivers/hwmon/Makefile
+--- linux/drivers/hwmon.vanilla/Makefile       2006-10-14 13:07:48.000000000 
+0800
++++ linux/drivers/hwmon/Makefile       2006-10-14 13:08:22.000000000 +0800
 @@ -18,6 +18,7 @@ obj-$(CONFIG_SENSORS_ADM1025)        += adm1025
  obj-$(CONFIG_SENSORS_ADM1026) += adm1026.o
  obj-$(CONFIG_SENSORS_ADM1031) += adm1031.o
@@ -39,10 +39,10 @@
  obj-$(CONFIG_SENSORS_ATXP1)   += atxp1.o
  obj-$(CONFIG_SENSORS_DS1621)  += ds1621.o
  obj-$(CONFIG_SENSORS_F71805F) += f71805f.o
-diff -pruN linux-2.6.18/drivers/hwmon.vanilla/applesmc.c 
linux-2.6.18/drivers/hwmon/applesmc.c
---- linux-2.6.18/drivers/hwmon.vanilla/applesmc.c      1970-01-01 
07:30:00.000000000 +0730
-+++ linux-2.6.18/drivers/hwmon/applesmc.c      2006-10-19 18:19:50.000000000 
+0800
-@@ -0,0 +1,898 @@
+diff -pruN linux/drivers/hwmon.vanilla/applesmc.c 
linux/drivers/hwmon/applesmc.c
+--- linux/drivers/hwmon.vanilla/applesmc.c     1970-01-01 07:30:00.000000000 
+0730
++++ linux/drivers/hwmon/applesmc.c     2006-11-04 22:36:08.000000000 +0800
+@@ -0,0 +1,908 @@
 +/*
 + * drivers/hwmon/applesmc.c - driver for Apple's SMC (various sensors,
 + * fan control)
@@ -110,8 +110,11 @@
 +#define FAN_SAFE_SPEED          "F0Sf" //r-o length 2
 +#define FAN_TARGET_SPEED        "F0Tg" //r-w length 2
 +
-+static const char* temperature_sensors[] =
-+      { "TB0T", "TC0D", "TC0P", "Th0H", "Ts0P", "Th1H", "Ts1P" };
++static const char* temperature_sensors_sets[][8] =
++{
++      { "TB0T", "TC0D", "TC0P", "Th0H", "Ts0P", "Th1H", "Ts1P", NULL },
++      { "TC0D", "TC0P", NULL }
++};
 +
 +#define INIT_TIMEOUT_MSECS    5000    /* wait up to 5s for device init ... */
 +#define INIT_WAIT_MSECS               50      /* ... in 50ms increments */
@@ -124,6 +127,16 @@
 +#define SENSOR_Y 1
 +#define SENSOR_Z 2
 +
++/* Structure to be passed to DMI_MATCH function */
++struct dmi_match_data {
++/* Indicate whether this computer has an accelerometer. */
++      int accelerometer;
++/* Indicate whether this computer has light sensors and keyboard backlight. */
++      int light;
++/* Indicate which temperature sensors set to use. */
++      int temperature_set;
++};
++
 +static int debug = 0;
 +static struct platform_device *pdev;
 +static s16 rest_x;
@@ -134,11 +147,12 @@
 +/* Indicate whether this computer has an accelerometer. */
 +static unsigned int applesmc_accelerometer = 0;
 +
-+/* 
-+ * Indicate whether this computer has light sensors and keyboard backlight.
-+ */
++/* Indicate whether this computer has light sensors and keyboard backlight. */
 +static unsigned int applesmc_light = 0;
 +
++/* Indicate which temperature sensors set to use. */
++static unsigned int applesmc_temperature_set = 0;
++
 +static DECLARE_MUTEX(applesmc_sem);
 +
 +/*
@@ -270,6 +284,8 @@
 +      int total, ret = -ENXIO;
 +      u8 buffer[2];
 +
++      if (!applesmc_accelerometer) return 0;
++
 +      down(&applesmc_sem);
 +
 +      for (total = INIT_TIMEOUT_MSECS; total > 0; total -= INIT_WAIT_MSECS) {
@@ -691,7 +707,7 @@
 +static ssize_t show_temperature_##offset (struct device *dev, \
 +                              struct device_attribute *attr, char *buf) \
 +{ \
-+      return applesmc_show_temperature(dev, buf, 
temperature_sensors[offset]);  \
++      return applesmc_show_temperature(dev, buf, 
temperature_sensors_sets[applesmc_temperature_set][offset]);  \
 +} \
 +static DEVICE_ATTR(temperature_##offset, S_IRUGO, \
 +                                      show_temperature_##offset, NULL);
@@ -704,79 +720,36 @@
 +sysfs_temperature_offset(5);
 +sysfs_temperature_offset(6);
 +
-+#define device_create_files_temperature(client) \
++#define device_create_files_temperature(client, offset) \
 +{ \
-+      sysfs_create_file(client, &dev_attr_temperature_0.attr); \
-+      sysfs_create_file(client, &dev_attr_temperature_1.attr); \
-+      sysfs_create_file(client, &dev_attr_temperature_2.attr); \
-+      sysfs_create_file(client, &dev_attr_temperature_3.attr); \
-+      sysfs_create_file(client, &dev_attr_temperature_4.attr); \
-+      sysfs_create_file(client, &dev_attr_temperature_5.attr); \
-+      sysfs_create_file(client, &dev_attr_temperature_6.attr); \
++      sysfs_create_file(client, &dev_attr_temperature_##offset.attr); \
 +} while (0)
 +
 +/* Module stuff */
 +
 +/* 
-+ * applesmc_accelerometer_light_dmi_match - found a match.  return one,
-+ * short-circuiting the hunt.
++ * applesmc_dmi_match - found a match.  return one, short-circuiting 
++ * the hunt.
 + */
-+static int applesmc_accelerometer_light_dmi_match(struct dmi_system_id *id)
++static int applesmc_dmi_match(struct dmi_system_id *id)
 +{
-+      applesmc_accelerometer = 1;
-+      applesmc_light = 1;
-+      printk(KERN_INFO "applesmc: %s detected (model with accelerometer,"
-+                              " light sensors and backlight).\n", id->ident);
-+      return 1;
-+}
++      int i = 0;
++      struct dmi_match_data* dmi_data =
++                                      (struct dmi_match_data*)id->driver_data;
++      printk(KERN_INFO "applesmc: %s detected:\n", id->ident);
++      applesmc_accelerometer = dmi_data->accelerometer;
++      printk(KERN_INFO "applesmc:  - Model %s accelerometer\n",
++                              applesmc_accelerometer ? "with" : "without");
++      applesmc_light = dmi_data->light;
++      printk(KERN_INFO "applesmc:  - Model %s light sensors and backlight\n",
++                                      applesmc_light ? "with" : "without");
 +
-+/* 
-+ * applesmc_accelerometer_dmi_match - found a match.  return one,
-+ * short-circuiting the hunt.
-+ */
-+static int applesmc_accelerometer_dmi_match(struct dmi_system_id *id)
-+{
-+      applesmc_accelerometer = 1;
-+      printk(KERN_INFO "applesmc: %s detected (model with accelerometer, but"
-+                      "without light sensors and backlight).\n", id->ident);
++      applesmc_temperature_set =  dmi_data->temperature_set;
++      while (temperature_sensors_sets[applesmc_temperature_set][i] != NULL) 
i++;
++      printk(KERN_INFO "applesmc:  - Model with %d temperature sensors\n", i);
 +      return 1;
 +}
 +
-+/* applesmc_dmi_match - found a match.  return one, short-circuiting the 
hunt. */
-+static int applesmc_dmi_match(struct dmi_system_id *id)
-+{
-+      printk(KERN_INFO "applesmc: %s detected (model without accelerometer,"
-+                              " light sensors and backlight).\n", id->ident);
-+      return 1;
-+}
-+
-+#define APPLESMC_ACCELEROMETER_LIGHT_DMI_MATCH(model) {       \
-+      .ident = "Apple " model,                                \
-+      .callback = applesmc_accelerometer_light_dmi_match,     \
-+      .matches = {                                    \
-+              DMI_MATCH(DMI_BOARD_VENDOR, "Apple"),   \
-+              DMI_MATCH(DMI_PRODUCT_NAME, model)      \
-+      }                                               \
-+}
-+
-+#define APPLESMC_ACCELEROMETER_DMI_MATCH(model) {     \
-+      .ident = "Apple " model,                                \
-+      .callback = applesmc_accelerometer_dmi_match,           \
-+      .matches = {                                    \
-+              DMI_MATCH(DMI_BOARD_VENDOR, "Apple"),   \
-+              DMI_MATCH(DMI_PRODUCT_NAME, model)      \
-+      }                                               \
-+}
-+
-+#define APPLESMC_DMI_MATCH(model) {           \
-+      .ident = "Apple " model,                                \
-+      .callback = applesmc_dmi_match,                 \
-+      .matches = {                                    \
-+              DMI_MATCH(DMI_BOARD_VENDOR, "Apple"),   \
-+              DMI_MATCH(DMI_PRODUCT_NAME, model)      \
-+      }                                               \
-+}
-+
 +/* Create accelerometer ressources */
 +static int applesmc_create_accelerometer(void) {
 +      int ret;
@@ -832,12 +805,28 @@
 +{
 +      int ret;
 +
++      struct dmi_match_data applesmc_dmi_data[] = {
++        { .accelerometer = 1, .light = 1, .temperature_set = 0 },
++        { .accelerometer = 1, .light = 0, .temperature_set = 0 },
++        { .accelerometer = 0, .light = 0, .temperature_set = 1 }
++      };
++
 +      /* Note that DMI_MATCH(...,"MacBook") will match "MacBookPro1,1".
-+       * So we need to put MacBookPro before MacBook... */
++       * So we need to put APPLESMC_MACBOOKPRO_DMI_MATCH before 
++       * APPLESMC_MACBOOK_DMI_MATCH. */
 +      struct dmi_system_id applesmc_whitelist[] = {
-+              APPLESMC_ACCELEROMETER_LIGHT_DMI_MATCH("MacBookPro"),
-+              APPLESMC_ACCELEROMETER_DMI_MATCH("MacBook"),
-+              APPLESMC_DMI_MATCH("Macmini"),
++              { applesmc_dmi_match, "Apple MacBook Pro", {
++                DMI_MATCH(DMI_BOARD_VENDOR,"Apple"),
++                DMI_MATCH(DMI_PRODUCT_NAME,"MacBookPro") },
++                      (void*)&applesmc_dmi_data[0]},
++              { applesmc_dmi_match, "Apple MacBook", {
++                DMI_MATCH(DMI_BOARD_VENDOR,"Apple"),
++                DMI_MATCH(DMI_PRODUCT_NAME,"MacBook") },
++                      (void*)&applesmc_dmi_data[1]},
++              { applesmc_dmi_match, "Apple MacMini", {
++                DMI_MATCH(DMI_BOARD_VENDOR,"Apple"),
++                DMI_MATCH(DMI_PRODUCT_NAME,"MacMini") },
++                      (void*)&applesmc_dmi_data[2]},
 +              { .ident = NULL }
 +      };
 +
@@ -885,8 +874,29 @@
 +              }
 +      }
 +
-+      device_create_files_temperature(&pdev->dev.kobj);
++      ret = 0;
++      while (temperature_sensors_sets[applesmc_temperature_set][ret] != NULL) 
ret++;
 +
++      switch (ret) {
++      default:
++      case 7:
++              device_create_files_temperature(&pdev->dev.kobj, 6);
++      case 6:
++              device_create_files_temperature(&pdev->dev.kobj, 5);
++      case 5:
++              device_create_files_temperature(&pdev->dev.kobj, 4);
++      case 4:
++              device_create_files_temperature(&pdev->dev.kobj, 3);
++      case 3:
++              device_create_files_temperature(&pdev->dev.kobj, 2);
++      case 2:
++              device_create_files_temperature(&pdev->dev.kobj, 1);
++      case 1:
++              device_create_files_temperature(&pdev->dev.kobj, 0);
++      case 0:
++              ;
++      }
++
 +      if (applesmc_accelerometer) {
 +              ret = applesmc_create_accelerometer();
 +              if (ret)
@@ -941,4 +951,3 @@
 +MODULE_AUTHOR("Nicolas Boichat");
 +MODULE_DESCRIPTION("Apple SMC");
 +MODULE_LICENSE("GPL v2");
-


This was sent by the SourceForge.net collaborative development platform, the 
world's largest Open Source development site.

-------------------------------------------------------------------------
Using Tomcat but need to do more? Need to support web services, security?
Get stuff done quickly with pre-integrated technology to make your job easier
Download IBM WebSphere Application Server v.1.0.1 based on Apache Geronimo
http://sel.as-us.falkag.net/sel?cmd=lnk&kid=120709&bid=263057&dat=121642
_______________________________________________
Mactel-linux-devel mailing list
Mactel-linux-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/mactel-linux-devel

Reply via email to