Skip to content

Commit

Permalink
Merge branch 'hwmon-for-linus' of git://git.kernel.org/pub/scm/linux/…
Browse files Browse the repository at this point in the history
…kernel/git/jdelvare/staging

Pull hwmon subsystem fixes from Jean Delvare.

* 'hwmon-for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/jdelvare/staging:
  hwmon: (fam15h_power) Tweak runavg_range on resume
  hwmon: (coretemp) Use get_online_cpus to avoid races involving CPU hotplug
  hwmon: (via-cputemp) Use get_online_cpus to avoid races involving CPU hotplug
  • Loading branch information
torvalds committed Sep 23, 2012
2 parents 0bf7a70 + 5f0ecb9 commit 0737c8d
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 2 deletions.
5 changes: 5 additions & 0 deletions drivers/hwmon/coretemp.c
Expand Up @@ -815,17 +815,20 @@ static int __init coretemp_init(void)
if (err)
goto exit;

get_online_cpus();
for_each_online_cpu(i)
get_core_online(i);

#ifndef CONFIG_HOTPLUG_CPU
if (list_empty(&pdev_list)) {
put_online_cpus();
err = -ENODEV;
goto exit_driver_unreg;
}
#endif

register_hotcpu_notifier(&coretemp_cpu_notifier);
put_online_cpus();
return 0;

#ifndef CONFIG_HOTPLUG_CPU
Expand All @@ -840,6 +843,7 @@ static void __exit coretemp_exit(void)
{
struct pdev_entry *p, *n;

get_online_cpus();
unregister_hotcpu_notifier(&coretemp_cpu_notifier);
mutex_lock(&pdev_list_mutex);
list_for_each_entry_safe(p, n, &pdev_list, list) {
Expand All @@ -848,6 +852,7 @@ static void __exit coretemp_exit(void)
kfree(p);
}
mutex_unlock(&pdev_list_mutex);
put_online_cpus();
platform_driver_unregister(&coretemp_driver);
}

Expand Down
15 changes: 13 additions & 2 deletions drivers/hwmon/fam15h_power.c
Expand Up @@ -129,12 +129,12 @@ static bool __devinit fam15h_power_is_internal_node0(struct pci_dev *f4)
* counter saturations resulting in bogus power readings.
* We correct this value ourselves to cope with older BIOSes.
*/
static DEFINE_PCI_DEVICE_TABLE(affected_device) = {
static const struct pci_device_id affected_device[] = {
{ PCI_VDEVICE(AMD, PCI_DEVICE_ID_AMD_15H_NB_F4) },
{ 0 }
};

static void __devinit tweak_runavg_range(struct pci_dev *pdev)
static void tweak_runavg_range(struct pci_dev *pdev)
{
u32 val;

Expand All @@ -158,6 +158,16 @@ static void __devinit tweak_runavg_range(struct pci_dev *pdev)
REG_TDP_RUNNING_AVERAGE, val);
}

#ifdef CONFIG_PM
static int fam15h_power_resume(struct pci_dev *pdev)
{
tweak_runavg_range(pdev);
return 0;
}
#else
#define fam15h_power_resume NULL
#endif

static void __devinit fam15h_power_init_data(struct pci_dev *f4,
struct fam15h_power_data *data)
{
Expand Down Expand Up @@ -256,6 +266,7 @@ static struct pci_driver fam15h_power_driver = {
.id_table = fam15h_power_id_table,
.probe = fam15h_power_probe,
.remove = __devexit_p(fam15h_power_remove),
.resume = fam15h_power_resume,
};

module_pci_driver(fam15h_power_driver);
5 changes: 5 additions & 0 deletions drivers/hwmon/via-cputemp.c
Expand Up @@ -328,6 +328,7 @@ static int __init via_cputemp_init(void)
if (err)
goto exit;

get_online_cpus();
for_each_online_cpu(i) {
struct cpuinfo_x86 *c = &cpu_data(i);

Expand All @@ -347,12 +348,14 @@ static int __init via_cputemp_init(void)

#ifndef CONFIG_HOTPLUG_CPU
if (list_empty(&pdev_list)) {
put_online_cpus();
err = -ENODEV;
goto exit_driver_unreg;
}
#endif

register_hotcpu_notifier(&via_cputemp_cpu_notifier);
put_online_cpus();
return 0;

#ifndef CONFIG_HOTPLUG_CPU
Expand All @@ -367,6 +370,7 @@ static void __exit via_cputemp_exit(void)
{
struct pdev_entry *p, *n;

get_online_cpus();
unregister_hotcpu_notifier(&via_cputemp_cpu_notifier);
mutex_lock(&pdev_list_mutex);
list_for_each_entry_safe(p, n, &pdev_list, list) {
Expand All @@ -375,6 +379,7 @@ static void __exit via_cputemp_exit(void)
kfree(p);
}
mutex_unlock(&pdev_list_mutex);
put_online_cpus();
platform_driver_unregister(&via_cputemp_driver);
}

Expand Down

0 comments on commit 0737c8d

Please sign in to comment.