diff options
author | Jean Delvare <khali@linux-fr.org> | 2011-09-16 15:21:43 -0400 |
---|---|---|
committer | Guenter Roeck <guenter.roeck@ericsson.com> | 2011-09-21 20:25:18 -0400 |
commit | 6bf9e9b09c3abb5447bbbf16c2d0cbe721e44f3f (patch) | |
tree | e72c28e0063718c3505080ef136a68b49347d289 /drivers/hwmon | |
parent | d93dc5c4478c1fd5de85a3e8aece9aad7bbae044 (diff) |
hwmon: (coretemp) Drop duplicate function get_pkg_tjmax
Function get_pkg_tjmax is a simplified copy of get_tjmax. Drop it and
always use get_tjmax, result is the same and this avoids code
duplication.
Also make get_tjmax less verbose: don't warn about MSR read failure
when failure was expected, and don't report TjMax in the logs unless
debugging is enabled.
Signed-off-by: Jean Delvare <khali@linux-fr.org>
Cc: Fenghua Yu <fenghua.yu@intel.com>
Cc: Guenter Roeck <guenter.roeck@ericsson.com>
Cc: Durgadoss R <durgadoss.r@intel.com>
Acked-by: Fenghua Yu <fenghua.yu@intel.com>
Signed-off-by: Guenter Roeck <guenter.roeck@ericsson.com>
Diffstat (limited to 'drivers/hwmon')
-rw-r--r-- | drivers/hwmon/coretemp.c | 26 |
1 files changed, 4 insertions, 22 deletions
diff --git a/drivers/hwmon/coretemp.c b/drivers/hwmon/coretemp.c index 411257676133..256f70803eb3 100644 --- a/drivers/hwmon/coretemp.c +++ b/drivers/hwmon/coretemp.c | |||
@@ -374,7 +374,6 @@ static int adjust_tjmax(struct cpuinfo_x86 *c, u32 id, struct device *dev) | |||
374 | 374 | ||
375 | static int get_tjmax(struct cpuinfo_x86 *c, u32 id, struct device *dev) | 375 | static int get_tjmax(struct cpuinfo_x86 *c, u32 id, struct device *dev) |
376 | { | 376 | { |
377 | /* The 100C is default for both mobile and non mobile CPUs */ | ||
378 | int err; | 377 | int err; |
379 | u32 eax, edx; | 378 | u32 eax, edx; |
380 | u32 val; | 379 | u32 val; |
@@ -385,7 +384,8 @@ static int get_tjmax(struct cpuinfo_x86 *c, u32 id, struct device *dev) | |||
385 | */ | 384 | */ |
386 | err = rdmsr_safe_on_cpu(id, MSR_IA32_TEMPERATURE_TARGET, &eax, &edx); | 385 | err = rdmsr_safe_on_cpu(id, MSR_IA32_TEMPERATURE_TARGET, &eax, &edx); |
387 | if (err) { | 386 | if (err) { |
388 | dev_warn(dev, "Unable to read TjMax from CPU.\n"); | 387 | if (c->x86_model > 0xe && c->x86_model != 0x1c) |
388 | dev_warn(dev, "Unable to read TjMax from CPU %u\n", id); | ||
389 | } else { | 389 | } else { |
390 | val = (eax >> 16) & 0xff; | 390 | val = (eax >> 16) & 0xff; |
391 | /* | 391 | /* |
@@ -393,7 +393,7 @@ static int get_tjmax(struct cpuinfo_x86 *c, u32 id, struct device *dev) | |||
393 | * will be used | 393 | * will be used |
394 | */ | 394 | */ |
395 | if (val) { | 395 | if (val) { |
396 | dev_info(dev, "TjMax is %d C.\n", val); | 396 | dev_dbg(dev, "TjMax is %d degrees C\n", val); |
397 | return val * 1000; | 397 | return val * 1000; |
398 | } | 398 | } |
399 | } | 399 | } |
@@ -414,21 +414,6 @@ static void __devinit get_ucode_rev_on_cpu(void *edx) | |||
414 | rdmsr(MSR_IA32_UCODE_REV, eax, *(u32 *)edx); | 414 | rdmsr(MSR_IA32_UCODE_REV, eax, *(u32 *)edx); |
415 | } | 415 | } |
416 | 416 | ||
417 | static int get_pkg_tjmax(unsigned int cpu, struct device *dev) | ||
418 | { | ||
419 | int err; | ||
420 | u32 eax, edx, val; | ||
421 | |||
422 | err = rdmsr_safe_on_cpu(cpu, MSR_IA32_TEMPERATURE_TARGET, &eax, &edx); | ||
423 | if (!err) { | ||
424 | val = (eax >> 16) & 0xff; | ||
425 | if (val) | ||
426 | return val * 1000; | ||
427 | } | ||
428 | dev_warn(dev, "Unable to read Pkg-TjMax from CPU:%u\n", cpu); | ||
429 | return 100000; /* Default TjMax: 100 degree celsius */ | ||
430 | } | ||
431 | |||
432 | static int create_name_attr(struct platform_data *pdata, struct device *dev) | 417 | static int create_name_attr(struct platform_data *pdata, struct device *dev) |
433 | { | 418 | { |
434 | sysfs_attr_init(&pdata->name_attr.attr); | 419 | sysfs_attr_init(&pdata->name_attr.attr); |
@@ -588,10 +573,7 @@ static int create_core_data(struct platform_data *pdata, | |||
588 | goto exit_free; | 573 | goto exit_free; |
589 | 574 | ||
590 | /* We can access status register. Get Critical Temperature */ | 575 | /* We can access status register. Get Critical Temperature */ |
591 | if (pkg_flag) | 576 | tdata->tjmax = get_tjmax(c, cpu, &pdev->dev); |
592 | tdata->tjmax = get_pkg_tjmax(pdev->id, &pdev->dev); | ||
593 | else | ||
594 | tdata->tjmax = get_tjmax(c, cpu, &pdev->dev); | ||
595 | 577 | ||
596 | /* | 578 | /* |
597 | * Test if we can access the intrpt register. If so, increase the | 579 | * Test if we can access the intrpt register. If so, increase the |