Revision: 51 http://svn.sourceforge.net/mactel-linux/?rev=51&view=rev Author: nboichat Date: 2006-10-16 21:49:40 -0700 (Mon, 16 Oct 2006)
Log Message: ----------- Update applesmc to support Macmini. 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-10-15 15:47:08 UTC (rev 50) +++ trunk/kernel/mactel-patches-2.6.18/applesmc.patch 2006-10-17 04:49:40 UTC (rev 51) @@ -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,12 +39,13 @@ 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-15 15:19:30.000000000 +0800 -@@ -0,0 +1,809 @@ +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-10-17 12:47:23.000000000 +0800 +@@ -0,0 +1,844 @@ +/* -+ * drivers/hwmon/applesmc.c - driver for Apple's SMC (various sensors) ++ * drivers/hwmon/applesmc.c - driver for Apple's SMC (various sensors, ++ * fan control) + * + * Copyright (C) 2006 Nicolas Boichat <[EMAIL PROTECTED]> + * @@ -127,7 +128,12 @@ +static struct timer_list applesmc_timer; +static struct input_dev *applesmc_idev; + -+/* Indicate whether this computer has light sensors and keyboard backlight. */ ++/* Indicate whether this computer has an accelerometer. */ ++static unsigned int applesmc_accelerometer = 0; ++ ++/* ++ * Indicate whether this computer has light sensors and keyboard backlight. ++ */ +static unsigned int applesmc_light = 0; + +static DECLARE_MUTEX(applesmc_sem); @@ -577,30 +583,10 @@ +}; + +static DEVICE_ATTR(position, 0444, applesmc_position_show, NULL); -+static DEVICE_ATTR(light, 0444, applesmc_light_show, NULL); +static DEVICE_ATTR(calibrate, 0644, applesmc_calibrate_show,applesmc_calibrate_store); + -+static struct attribute *applesmc_light_attributes[] = { -+ &dev_attr_position.attr, -+ &dev_attr_light.attr, -+ &dev_attr_calibrate.attr, -+ NULL, -+}; ++static DEVICE_ATTR(light, 0444, applesmc_light_show, NULL); + -+static struct attribute_group applesmc_light_attribute_group = { -+ .attrs = applesmc_light_attributes, -+}; -+ -+static struct attribute *applesmc_attributes[] = { -+ &dev_attr_position.attr, -+ &dev_attr_calibrate.attr, -+ NULL, -+}; -+ -+static struct attribute_group applesmc_attribute_group = { -+ .attrs = applesmc_attributes, -+}; -+ +#define sysfs_fan_speeds_offset(offset) \ +static ssize_t show_fan_actual_speed_##offset (struct device *dev, \ + struct device_attribute *attr, char *buf) \ @@ -679,41 +665,117 @@ + +/* Module stuff */ + -+/* applesmc_light_dmi_match - found a match. return one, short-circuiting the hunt. */ -+static int applesmc_light_dmi_match(struct dmi_system_id *id) ++/* ++ * applesmc_accelerometer_light_dmi_match - found a match. return one, ++ * short-circuiting the hunt. ++ */ ++static int applesmc_accelerometer_light_dmi_match(struct dmi_system_id *id) +{ ++ applesmc_accelerometer = 1; + applesmc_light = 1; -+ printk(KERN_INFO "applesmc: %s detected (model with light" -+ " sensors and backlight).\n", id->ident); ++ printk(KERN_INFO "applesmc: %s detected (model with accelerometer," ++ " light sensors and backlight).\n", id->ident); + return 1; +} + ++/* ++ * 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); ++ 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 light" -+ " sensors and backlight).\n", id->ident); ++ printk(KERN_INFO "applesmc: %s detected (model without accelerometer," ++ " light sensors and backlight).\n", id->ident); + return 1; +} + -+#define APPLESMC_DMI_MATCH(model) { \ ++#define APPLESMC_ACCELEROMETER_LIGHT_DMI_MATCH(model) { \ + .ident = "Apple " model, \ -+ .callback = applesmc_dmi_match, \ ++ .callback = applesmc_accelerometer_light_dmi_match, \ + .matches = { \ + DMI_MATCH(DMI_BOARD_VENDOR, "Apple"), \ + DMI_MATCH(DMI_PRODUCT_NAME, model) \ + } \ +} + -+#define APPLESMC_LIGHT_DMI_MATCH(model) { \ ++#define APPLESMC_ACCELEROMETER_DMI_MATCH(model) { \ + .ident = "Apple " model, \ -+ .callback = applesmc_light_dmi_match, \ ++ .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; ++ ++ ret = sysfs_create_file(&pdev->dev.kobj, &dev_attr_position.attr); ++ if (ret) ++ goto out; ++ ++ ret = sysfs_create_file(&pdev->dev.kobj, &dev_attr_calibrate.attr); ++ if (ret) ++ goto out; ++ ++ applesmc_idev = input_allocate_device(); ++ if (!applesmc_idev) { ++ ret = -ENOMEM; ++ goto out; ++ } ++ ++ /* initial calibrate for the input device */ ++ applesmc_calibrate(); ++ ++ /* initialize the input class */ ++ applesmc_idev->name = "applesmc"; ++ applesmc_idev->cdev.dev = &pdev->dev; ++ applesmc_idev->evbit[0] = BIT(EV_ABS); ++ input_set_abs_params(applesmc_idev, ABS_X, ++ -256, 256, APPLESMC_INPUT_FUZZ, APPLESMC_INPUT_FLAT); ++ input_set_abs_params(applesmc_idev, ABS_Y, ++ -256, 256, APPLESMC_INPUT_FUZZ, APPLESMC_INPUT_FLAT); ++ ++ input_register_device(applesmc_idev); ++ ++ /* start up our timer for the input device */ ++ init_timer(&applesmc_timer); ++ applesmc_timer.function = applesmc_mousedev_poll; ++ applesmc_timer.expires = jiffies + APPLESMC_POLL_PERIOD; ++ add_timer(&applesmc_timer); ++ ++ return 0; ++ ++out: ++ printk(KERN_WARNING "applesmc: driver init failed (ret=%d)!\n", ret); ++ return ret; ++} ++ ++/* Release all ressources used by the accelerometer */ ++static void applesmc_release_accelerometer(void) { ++ del_timer_sync(&applesmc_timer); ++ input_unregister_device(applesmc_idev); ++} ++ +static int __init applesmc_init(void) +{ + int ret; @@ -721,8 +783,9 @@ + /* Note that DMI_MATCH(...,"MacBook") will match "MacBookPro1,1". + * So we need to put MacBookPro before MacBook... */ + struct dmi_system_id applesmc_whitelist[] = { -+ APPLESMC_LIGHT_DMI_MATCH("MacBookPro"), -+ APPLESMC_DMI_MATCH("MacBook"), ++ APPLESMC_ACCELEROMETER_LIGHT_DMI_MATCH("MacBookPro"), ++ APPLESMC_ACCELEROMETER_DMI_MATCH("MacBook"), ++ APPLESMC_DMI_MATCH("Macmini"), + { .ident = NULL } + }; + @@ -748,15 +811,6 @@ + goto out_driver; + } + -+ if (applesmc_light) -+ ret = sysfs_create_group(&pdev->dev.kobj, -+ &applesmc_light_attribute_group); -+ else -+ ret = sysfs_create_group(&pdev->dev.kobj, -+ &applesmc_attribute_group); -+ if (ret) -+ goto out_device; -+ + /* create fan files */ + ret = applesmc_get_fan_count(); + if (ret < 0) { @@ -779,45 +833,30 @@ + } + } + -+ applesmc_idev = input_allocate_device(); -+ if (!applesmc_idev) { -+ ret = -ENOMEM; -+ goto out_group; ++ if (applesmc_accelerometer) { ++ ret = applesmc_create_accelerometer(); ++ if (ret) ++ goto out_device; + } + -+ /* initial calibrate for the input device */ -+ applesmc_calibrate(); ++ if (applesmc_light) { ++ /* Add light sensor file */ ++ ret = sysfs_create_file(&pdev->dev.kobj, &dev_attr_light.attr); ++ if (ret) ++ goto out_accelerometer; + -+ /* initialize the input class */ -+ applesmc_idev->name = "applesmc"; -+ applesmc_idev->cdev.dev = &pdev->dev; -+ applesmc_idev->evbit[0] = BIT(EV_ABS); -+ input_set_abs_params(applesmc_idev, ABS_X, -+ -256, 256, APPLESMC_INPUT_FUZZ, APPLESMC_INPUT_FLAT); -+ input_set_abs_params(applesmc_idev, ABS_Y, -+ -256, 256, APPLESMC_INPUT_FUZZ, APPLESMC_INPUT_FLAT); ++ /* register as a led device */ ++ ret = led_classdev_register(&pdev->dev, &applesmc_backlight); ++ if (ret < 0) ++ goto out_accelerometer; ++ } + -+ input_register_device(applesmc_idev); -+ -+ /* start up our timer for the input device */ -+ init_timer(&applesmc_timer); -+ applesmc_timer.function = applesmc_mousedev_poll; -+ applesmc_timer.expires = jiffies + APPLESMC_POLL_PERIOD; -+ add_timer(&applesmc_timer); -+ -+ /* register as a led device */ -+ ret = led_classdev_register(&pdev->dev, &applesmc_backlight); -+ if (ret < 0) -+ goto out_input_device; -+ + printk(KERN_INFO "applesmc: driver successfully loaded.\n"); + return 0; + -+out_input_device: -+ del_timer_sync(&applesmc_timer); -+ input_unregister_device(applesmc_idev); -+out_group: -+ sysfs_remove_group(&pdev->dev.kobj, &applesmc_attribute_group); ++out_accelerometer: ++ if (applesmc_accelerometer) ++ applesmc_release_accelerometer(); +out_device: + platform_device_unregister(pdev); +out_driver: @@ -831,14 +870,10 @@ + +static void __exit applesmc_exit(void) +{ -+ led_classdev_unregister(&applesmc_backlight); -+ del_timer_sync(&applesmc_timer); -+ input_unregister_device(applesmc_idev); + if (applesmc_light) -+ sysfs_remove_group(&pdev->dev.kobj, -+ &applesmc_light_attribute_group); -+ else -+ sysfs_remove_group(&pdev->dev.kobj, &applesmc_attribute_group); ++ led_classdev_unregister(&applesmc_backlight); ++ if (applesmc_accelerometer) ++ applesmc_release_accelerometer(); + platform_device_unregister(pdev); + platform_driver_unregister(&applesmc_driver); + release_region(APPLESMC_DATA_PORT, APPLESMC_NR_PORTS); 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