diff options
Diffstat (limited to 'drivers/hwmon/applesmc.c')
-rw-r--r-- | drivers/hwmon/applesmc.c | 81 |
1 files changed, 44 insertions, 37 deletions
diff --git a/drivers/hwmon/applesmc.c b/drivers/hwmon/applesmc.c index 7ea6a8f66056..f085c18d2905 100644 --- a/drivers/hwmon/applesmc.c +++ b/drivers/hwmon/applesmc.c | |||
@@ -142,6 +142,12 @@ static const char *temperature_sensors_sets[][41] = { | |||
142 | "TM1S", "TM2P", "TM2S", "TM3S", "TM8P", "TM8S", "TM9P", "TM9S", | 142 | "TM1S", "TM2P", "TM2S", "TM3S", "TM8P", "TM8S", "TM9P", "TM9S", |
143 | "TN0C", "TN0D", "TN0H", "TS0C", "Tp0C", "Tp1C", "Tv0S", "Tv1S", | 143 | "TN0C", "TN0D", "TN0H", "TS0C", "Tp0C", "Tp1C", "Tv0S", "Tv1S", |
144 | NULL }, | 144 | NULL }, |
145 | /* Set 17: iMac 9,1 */ | ||
146 | { "TA0P", "TC0D", "TC0H", "TC0P", "TG0D", "TG0H", "TH0P", "TL0P", | ||
147 | "TN0D", "TN0H", "TN0P", "TO0P", "Tm0P", "Tp0P", NULL }, | ||
148 | /* Set 18: MacBook Pro 2,2 */ | ||
149 | { "TB0T", "TC0D", "TC0P", "TG0H", "TG0P", "TG0T", "TM0P", "TTF0", | ||
150 | "Th0H", "Th1H", "Tm0P", "Ts0P", NULL }, | ||
145 | }; | 151 | }; |
146 | 152 | ||
147 | /* List of keys used to read/write fan speeds */ | 153 | /* List of keys used to read/write fan speeds */ |
@@ -189,6 +195,9 @@ static unsigned int applesmc_accelerometer; | |||
189 | /* Indicates whether this computer has light sensors and keyboard backlight. */ | 195 | /* Indicates whether this computer has light sensors and keyboard backlight. */ |
190 | static unsigned int applesmc_light; | 196 | static unsigned int applesmc_light; |
191 | 197 | ||
198 | /* The number of fans handled by the driver */ | ||
199 | static unsigned int fans_handled; | ||
200 | |||
192 | /* Indicates which temperature sensors set to use. */ | 201 | /* Indicates which temperature sensors set to use. */ |
193 | static unsigned int applesmc_temperature_set; | 202 | static unsigned int applesmc_temperature_set; |
194 | 203 | ||
@@ -518,7 +527,7 @@ static int applesmc_pm_restore(struct device *dev) | |||
518 | return applesmc_pm_resume(dev); | 527 | return applesmc_pm_resume(dev); |
519 | } | 528 | } |
520 | 529 | ||
521 | static struct dev_pm_ops applesmc_pm_ops = { | 530 | static const struct dev_pm_ops applesmc_pm_ops = { |
522 | .resume = applesmc_pm_resume, | 531 | .resume = applesmc_pm_resume, |
523 | .restore = applesmc_pm_restore, | 532 | .restore = applesmc_pm_restore, |
524 | }; | 533 | }; |
@@ -1350,6 +1359,10 @@ static __initdata struct dmi_match_data applesmc_dmi_data[] = { | |||
1350 | { .accelerometer = 1, .light = 1, .temperature_set = 15 }, | 1359 | { .accelerometer = 1, .light = 1, .temperature_set = 15 }, |
1351 | /* MacPro3,1: temperature set 16 */ | 1360 | /* MacPro3,1: temperature set 16 */ |
1352 | { .accelerometer = 0, .light = 0, .temperature_set = 16 }, | 1361 | { .accelerometer = 0, .light = 0, .temperature_set = 16 }, |
1362 | /* iMac 9,1: light sensor only, temperature set 17 */ | ||
1363 | { .accelerometer = 0, .light = 0, .temperature_set = 17 }, | ||
1364 | /* MacBook Pro 2,2: accelerometer, backlight and temperature set 18 */ | ||
1365 | { .accelerometer = 1, .light = 1, .temperature_set = 18 }, | ||
1353 | }; | 1366 | }; |
1354 | 1367 | ||
1355 | /* Note that DMI_MATCH(...,"MacBook") will match "MacBookPro1,1". | 1368 | /* Note that DMI_MATCH(...,"MacBook") will match "MacBookPro1,1". |
@@ -1375,6 +1388,10 @@ static __initdata struct dmi_system_id applesmc_whitelist[] = { | |||
1375 | DMI_MATCH(DMI_BOARD_VENDOR, "Apple"), | 1388 | DMI_MATCH(DMI_BOARD_VENDOR, "Apple"), |
1376 | DMI_MATCH(DMI_PRODUCT_NAME, "MacBookPro3") }, | 1389 | DMI_MATCH(DMI_PRODUCT_NAME, "MacBookPro3") }, |
1377 | &applesmc_dmi_data[9]}, | 1390 | &applesmc_dmi_data[9]}, |
1391 | { applesmc_dmi_match, "Apple MacBook Pro 2,2", { | ||
1392 | DMI_MATCH(DMI_BOARD_VENDOR, "Apple Computer, Inc."), | ||
1393 | DMI_MATCH(DMI_PRODUCT_NAME, "MacBookPro2,2") }, | ||
1394 | &applesmc_dmi_data[18]}, | ||
1378 | { applesmc_dmi_match, "Apple MacBook Pro", { | 1395 | { applesmc_dmi_match, "Apple MacBook Pro", { |
1379 | DMI_MATCH(DMI_BOARD_VENDOR,"Apple"), | 1396 | DMI_MATCH(DMI_BOARD_VENDOR,"Apple"), |
1380 | DMI_MATCH(DMI_PRODUCT_NAME,"MacBookPro") }, | 1397 | DMI_MATCH(DMI_PRODUCT_NAME,"MacBookPro") }, |
@@ -1415,6 +1432,10 @@ static __initdata struct dmi_system_id applesmc_whitelist[] = { | |||
1415 | DMI_MATCH(DMI_BOARD_VENDOR, "Apple"), | 1432 | DMI_MATCH(DMI_BOARD_VENDOR, "Apple"), |
1416 | DMI_MATCH(DMI_PRODUCT_NAME, "MacPro") }, | 1433 | DMI_MATCH(DMI_PRODUCT_NAME, "MacPro") }, |
1417 | &applesmc_dmi_data[4]}, | 1434 | &applesmc_dmi_data[4]}, |
1435 | { applesmc_dmi_match, "Apple iMac 9,1", { | ||
1436 | DMI_MATCH(DMI_BOARD_VENDOR, "Apple Inc."), | ||
1437 | DMI_MATCH(DMI_PRODUCT_NAME, "iMac9,1") }, | ||
1438 | &applesmc_dmi_data[17]}, | ||
1418 | { applesmc_dmi_match, "Apple iMac 8", { | 1439 | { applesmc_dmi_match, "Apple iMac 8", { |
1419 | DMI_MATCH(DMI_BOARD_VENDOR, "Apple"), | 1440 | DMI_MATCH(DMI_BOARD_VENDOR, "Apple"), |
1420 | DMI_MATCH(DMI_PRODUCT_NAME, "iMac8") }, | 1441 | DMI_MATCH(DMI_PRODUCT_NAME, "iMac8") }, |
@@ -1474,39 +1495,24 @@ static int __init applesmc_init(void) | |||
1474 | 1495 | ||
1475 | /* create fan files */ | 1496 | /* create fan files */ |
1476 | count = applesmc_get_fan_count(); | 1497 | count = applesmc_get_fan_count(); |
1477 | if (count < 0) { | 1498 | if (count < 0) |
1478 | printk(KERN_ERR "applesmc: Cannot get the number of fans.\n"); | 1499 | printk(KERN_ERR "applesmc: Cannot get the number of fans.\n"); |
1479 | } else { | 1500 | else |
1480 | printk(KERN_INFO "applesmc: %d fans found.\n", count); | 1501 | printk(KERN_INFO "applesmc: %d fans found.\n", count); |
1481 | 1502 | ||
1482 | switch (count) { | 1503 | if (count > 4) { |
1483 | default: | 1504 | count = 4; |
1484 | printk(KERN_WARNING "applesmc: More than 4 fans found," | 1505 | printk(KERN_WARNING "applesmc: More than 4 fans found," |
1485 | " but at most 4 fans are supported" | 1506 | " but at most 4 fans are supported" |
1486 | " by the driver.\n"); | 1507 | " by the driver.\n"); |
1487 | case 4: | 1508 | } |
1488 | ret = sysfs_create_group(&pdev->dev.kobj, | 1509 | |
1489 | &fan_attribute_groups[3]); | 1510 | while (fans_handled < count) { |
1490 | if (ret) | 1511 | ret = sysfs_create_group(&pdev->dev.kobj, |
1491 | goto out_key_enumeration; | 1512 | &fan_attribute_groups[fans_handled]); |
1492 | case 3: | 1513 | if (ret) |
1493 | ret = sysfs_create_group(&pdev->dev.kobj, | 1514 | goto out_fans; |
1494 | &fan_attribute_groups[2]); | 1515 | fans_handled++; |
1495 | if (ret) | ||
1496 | goto out_key_enumeration; | ||
1497 | case 2: | ||
1498 | ret = sysfs_create_group(&pdev->dev.kobj, | ||
1499 | &fan_attribute_groups[1]); | ||
1500 | if (ret) | ||
1501 | goto out_key_enumeration; | ||
1502 | case 1: | ||
1503 | ret = sysfs_create_group(&pdev->dev.kobj, | ||
1504 | &fan_attribute_groups[0]); | ||
1505 | if (ret) | ||
1506 | goto out_fan_1; | ||
1507 | case 0: | ||
1508 | ; | ||
1509 | } | ||
1510 | } | 1516 | } |
1511 | 1517 | ||
1512 | for (i = 0; | 1518 | for (i = 0; |
@@ -1575,10 +1581,10 @@ out_accelerometer: | |||
1575 | applesmc_release_accelerometer(); | 1581 | applesmc_release_accelerometer(); |
1576 | out_temperature: | 1582 | out_temperature: |
1577 | sysfs_remove_group(&pdev->dev.kobj, &temperature_attributes_group); | 1583 | sysfs_remove_group(&pdev->dev.kobj, &temperature_attributes_group); |
1578 | sysfs_remove_group(&pdev->dev.kobj, &fan_attribute_groups[0]); | 1584 | out_fans: |
1579 | out_fan_1: | 1585 | while (fans_handled) |
1580 | sysfs_remove_group(&pdev->dev.kobj, &fan_attribute_groups[1]); | 1586 | sysfs_remove_group(&pdev->dev.kobj, |
1581 | out_key_enumeration: | 1587 | &fan_attribute_groups[--fans_handled]); |
1582 | sysfs_remove_group(&pdev->dev.kobj, &key_enumeration_group); | 1588 | sysfs_remove_group(&pdev->dev.kobj, &key_enumeration_group); |
1583 | out_name: | 1589 | out_name: |
1584 | sysfs_remove_file(&pdev->dev.kobj, &dev_attr_name.attr); | 1590 | sysfs_remove_file(&pdev->dev.kobj, &dev_attr_name.attr); |
@@ -1604,8 +1610,9 @@ static void __exit applesmc_exit(void) | |||
1604 | if (applesmc_accelerometer) | 1610 | if (applesmc_accelerometer) |
1605 | applesmc_release_accelerometer(); | 1611 | applesmc_release_accelerometer(); |
1606 | sysfs_remove_group(&pdev->dev.kobj, &temperature_attributes_group); | 1612 | sysfs_remove_group(&pdev->dev.kobj, &temperature_attributes_group); |
1607 | sysfs_remove_group(&pdev->dev.kobj, &fan_attribute_groups[0]); | 1613 | while (fans_handled) |
1608 | sysfs_remove_group(&pdev->dev.kobj, &fan_attribute_groups[1]); | 1614 | sysfs_remove_group(&pdev->dev.kobj, |
1615 | &fan_attribute_groups[--fans_handled]); | ||
1609 | sysfs_remove_group(&pdev->dev.kobj, &key_enumeration_group); | 1616 | sysfs_remove_group(&pdev->dev.kobj, &key_enumeration_group); |
1610 | sysfs_remove_file(&pdev->dev.kobj, &dev_attr_name.attr); | 1617 | sysfs_remove_file(&pdev->dev.kobj, &dev_attr_name.attr); |
1611 | platform_device_unregister(pdev); | 1618 | platform_device_unregister(pdev); |