Advertisement
Guest User

thinkpad_acpi patch for Lenovo P50

a guest
Apr 6th, 2016
233
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Diff 3.02 KB | None | 0 0
  1. diff --git a/drivers/platform/x86/thinkpad_acpi.c b/drivers/platform/x86/thinkpad_acpi.c
  2. index e305ab5..4f65a22 100644
  3. --- a/drivers/platform/x86/thinkpad_acpi.c
  4. +++ b/drivers/platform/x86/thinkpad_acpi.c
  5. @@ -324,6 +324,8 @@ static struct {
  6.     u32 has_adaptive_kbd:1;
  7.  } tp_features;
  8.  
  9. +static u8 active_fan;
  10. +
  11.  static struct {
  12.     u16 hotkey_mask_ff:1;
  13.     u16 volume_ctrl_forbidden:1;
  14. @@ -7907,6 +7909,14 @@ static bool fan_select_fan2(void)
  15.     return true;
  16.  }
  17.  
  18. +static void fan_select_fan(void)
  19. +{
  20. +  if(active_fan == 1)
  21. +    fan_select_fan1();
  22. +  else
  23. +    fan_select_fan2();
  24. +}
  25. +
  26.  /*
  27.   * Call with fan_mutex held
  28.   */
  29. @@ -8059,6 +8069,7 @@ static int fan_set_level(int level)
  30.         else if (level & TP_EC_FAN_AUTO)
  31.             level |= 4; /* safety min speed 4 */
  32.  
  33. +                fan_select_fan();
  34.         if (!acpi_ec_write(fan_status_offset, level))
  35.             return -EIO;
  36.         else
  37. @@ -8403,6 +8414,54 @@ static ssize_t fan_pwm1_store(struct device *dev,
  38.  
  39.  static DEVICE_ATTR(pwm1, S_IWUSR | S_IRUGO, fan_pwm1_show, fan_pwm1_store);
  40.  
  41. +static ssize_t fan_pwm2_enable_show(struct device *dev,
  42. +                   struct device_attribute *attr,
  43. +                   char *buf)
  44. +{
  45. +  ssize_t result;
  46. +  active_fan = 2;
  47. +  result = fan_pwm1_enable_show(dev,attr,buf);
  48. +  active_fan = 1;
  49. +  return result;
  50. +}
  51. +
  52. +static ssize_t fan_pwm2_enable_store(struct device *dev,
  53. +                    struct device_attribute *attr,
  54. +                    const char *buf, size_t count)
  55. +{
  56. +  ssize_t result;
  57. +  active_fan = 2;
  58. +  result = fan_pwm1_enable_store(dev,attr,buf,count);
  59. +  active_fan = 1;
  60. +  return result;
  61. +}
  62. +
  63. +static ssize_t fan_pwm2_show(struct device *dev,
  64. +                struct device_attribute *attr,
  65. +                char *buf)
  66. +{
  67. +  ssize_t result;
  68. +  active_fan = 2;
  69. +  result = fan_pwm1_show(dev,attr,buf);
  70. +  active_fan = 1;
  71. +  return result;
  72. +}
  73. +
  74. +static ssize_t fan_pwm2_store(struct device *dev,
  75. +                 struct device_attribute *attr,
  76. +                 const char *buf, size_t count)
  77. +{
  78. +  ssize_t result;
  79. +  active_fan = 2;
  80. +  result = fan_pwm1_store(dev,attr,buf,count);
  81. +  active_fan = 1;
  82. +  return result;
  83. +}
  84. +
  85. +static DEVICE_ATTR(pwm2_enable, S_IWUSR | S_IRUGO,
  86. +          fan_pwm2_enable_show, fan_pwm2_enable_store);
  87. +static DEVICE_ATTR(pwm2, S_IWUSR | S_IRUGO, fan_pwm2_show, fan_pwm2_store);
  88. +
  89.  /* sysfs fan fan1_input ------------------------------------------------ */
  90.  static ssize_t fan_fan1_input_show(struct device *dev,
  91.                struct device_attribute *attr,
  92. @@ -8470,6 +8529,7 @@ static DRIVER_ATTR(fan_watchdog, S_IWUSR | S_IRUGO,
  93.  static struct attribute *fan_attributes[] = {
  94.     &dev_attr_pwm1_enable.attr, &dev_attr_pwm1.attr,
  95.     &dev_attr_fan1_input.attr,
  96. +   &dev_attr_pwm2_enable.attr, &dev_attr_pwm2.attr,
  97.     NULL, /* for fan2_input */
  98.     NULL
  99.  };
  100. @@ -8518,7 +8578,7 @@ static int __init fan_init(struct ibm_init_struct *iibm)
  101.     fan_control_commands = 0;
  102.     fan_watchdog_maxinterval = 0;
  103.     tp_features.fan_ctrl_status_undef = 0;
  104. -   tp_features.second_fan = 0;
  105. +   tp_features.second_fan = 1;
  106.     fan_control_desired_level = 7;
  107.  
  108.     if (tpacpi_is_ibm()) {
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement