diff options
Diffstat (limited to 'drivers/hwmon/k8temp.c')
| -rw-r--r-- | drivers/hwmon/k8temp.c | 66 |
1 files changed, 22 insertions, 44 deletions
diff --git a/drivers/hwmon/k8temp.c b/drivers/hwmon/k8temp.c index 418496f1302..734d55d48cc 100644 --- a/drivers/hwmon/k8temp.c +++ b/drivers/hwmon/k8temp.c @@ -22,7 +22,6 @@ */ #include <linux/module.h> -#include <linux/delay.h> #include <linux/init.h> #include <linux/slab.h> #include <linux/jiffies.h> @@ -46,7 +45,7 @@ struct k8temp_data { unsigned long last_updated; /* in jiffies */ /* registers values */ - u8 sensorsp; /* sensor presence bits - SEL_CORE & SEL_PLACE */ + u8 sensorsp; /* sensor presence bits - SEL_CORE, SEL_PLACE */ u32 temp[2][2]; /* core, place */ u8 swap_core_select; /* meaning of SEL_CORE is inverted */ u32 temp_offset; @@ -63,7 +62,7 @@ static struct k8temp_data *k8temp_update_device(struct device *dev) if (!data->valid || time_after(jiffies, data->last_updated + HZ)) { pci_read_config_byte(pdev, REG_TEMP, &tmp); - tmp &= ~(SEL_PLACE | SEL_CORE); /* Select sensor 0, core0 */ + tmp &= ~(SEL_PLACE | SEL_CORE); /* Select sensor 0, core0 */ pci_write_config_byte(pdev, REG_TEMP, tmp); pci_read_config_dword(pdev, REG_TEMP, &data->temp[0][0]); @@ -82,7 +81,7 @@ static struct k8temp_data *k8temp_update_device(struct device *dev) &data->temp[1][0]); if (data->sensorsp & SEL_PLACE) { - tmp |= SEL_PLACE; /* Select sensor 1, core1 */ + tmp |= SEL_PLACE; /* Select sensor 1, core1 */ pci_write_config_byte(pdev, REG_TEMP, tmp); pci_read_config_dword(pdev, REG_TEMP, &data->temp[1][1]); @@ -143,7 +142,7 @@ static const struct pci_device_id k8temp_ids[] = { MODULE_DEVICE_TABLE(pci, k8temp_ids); -static int __devinit is_rev_g_desktop(u8 model) +static int is_rev_g_desktop(u8 model) { u32 brandidx; @@ -174,7 +173,7 @@ static int __devinit is_rev_g_desktop(u8 model) return 1; } -static int __devinit k8temp_probe(struct pci_dev *pdev, +static int k8temp_probe(struct pci_dev *pdev, const struct pci_device_id *id) { int err; @@ -183,20 +182,17 @@ static int __devinit k8temp_probe(struct pci_dev *pdev, u8 model, stepping; struct k8temp_data *data; - if (!(data = kzalloc(sizeof(struct k8temp_data), GFP_KERNEL))) { - err = -ENOMEM; - goto exit; - } + data = devm_kzalloc(&pdev->dev, sizeof(struct k8temp_data), GFP_KERNEL); + if (!data) + return -ENOMEM; model = boot_cpu_data.x86_model; stepping = boot_cpu_data.x86_mask; /* feature available since SH-C0, exclude older revisions */ - if (((model == 4) && (stepping == 0)) || - ((model == 5) && (stepping <= 1))) { - err = -ENODEV; - goto exit_free; - } + if ((model == 4 && stepping == 0) || + (model == 5 && stepping <= 1)) + return -ENODEV; /* * AMD NPT family 0fh, i.e. RevF and RevG: @@ -204,8 +200,8 @@ static int __devinit k8temp_probe(struct pci_dev *pdev, */ if (model >= 0x40) { data->swap_core_select = 1; - dev_warn(&pdev->dev, "Temperature readouts might be wrong - " - "check erratum #141\n"); + dev_warn(&pdev->dev, + "Temperature readouts might be wrong - check erratum #141\n"); } /* @@ -217,14 +213,13 @@ static int __devinit k8temp_probe(struct pci_dev *pdev, data->temp_offset = 21000; pci_read_config_byte(pdev, REG_TEMP, &scfg); - scfg &= ~(SEL_PLACE | SEL_CORE); /* Select sensor 0, core0 */ + scfg &= ~(SEL_PLACE | SEL_CORE); /* Select sensor 0, core0 */ pci_write_config_byte(pdev, REG_TEMP, scfg); pci_read_config_byte(pdev, REG_TEMP, &scfg); if (scfg & (SEL_PLACE | SEL_CORE)) { dev_err(&pdev->dev, "Configuration bit(s) stuck at 1!\n"); - err = -ENODEV; - goto exit_free; + return -ENODEV; } scfg |= (SEL_PLACE | SEL_CORE); @@ -238,7 +233,7 @@ static int __devinit k8temp_probe(struct pci_dev *pdev, pci_write_config_byte(pdev, REG_TEMP, scfg); pci_read_config_dword(pdev, REG_TEMP, &temp); scfg |= SEL_CORE; /* prepare for next selection */ - if (!((temp >> 16) & 0xff)) /* if temp is 0 -49C is not likely */ + if (!((temp >> 16) & 0xff)) /* if temp is 0 -49C is unlikely */ data->sensorsp &= ~SEL_PLACE; } @@ -246,13 +241,13 @@ static int __devinit k8temp_probe(struct pci_dev *pdev, scfg &= ~SEL_PLACE; /* Select sensor 0, core1 */ pci_write_config_byte(pdev, REG_TEMP, scfg); pci_read_config_dword(pdev, REG_TEMP, &temp); - if (!((temp >> 16) & 0xff)) /* if temp is 0 -49C is not likely */ + if (!((temp >> 16) & 0xff)) /* if temp is 0 -49C is unlikely */ data->sensorsp &= ~SEL_CORE; } data->name = "k8temp"; mutex_init(&data->update_lock); - dev_set_drvdata(&pdev->dev, data); + pci_set_drvdata(pdev, data); /* Register sysfs hooks */ err = device_create_file(&pdev->dev, @@ -306,16 +301,12 @@ exit_remove: device_remove_file(&pdev->dev, &sensor_dev_attr_temp4_input.dev_attr); device_remove_file(&pdev->dev, &dev_attr_name); -exit_free: - dev_set_drvdata(&pdev->dev, NULL); - kfree(data); -exit: return err; } -static void __devexit k8temp_remove(struct pci_dev *pdev) +static void k8temp_remove(struct pci_dev *pdev) { - struct k8temp_data *data = dev_get_drvdata(&pdev->dev); + struct k8temp_data *data = pci_get_drvdata(pdev); hwmon_device_unregister(data->hwmon_dev); device_remove_file(&pdev->dev, @@ -327,30 +318,17 @@ static void __devexit k8temp_remove(struct pci_dev *pdev) device_remove_file(&pdev->dev, &sensor_dev_attr_temp4_input.dev_attr); device_remove_file(&pdev->dev, &dev_attr_name); - dev_set_drvdata(&pdev->dev, NULL); - kfree(data); } static struct pci_driver k8temp_driver = { .name = "k8temp", .id_table = k8temp_ids, .probe = k8temp_probe, - .remove = __devexit_p(k8temp_remove), + .remove = k8temp_remove, }; -static int __init k8temp_init(void) -{ - return pci_register_driver(&k8temp_driver); -} - -static void __exit k8temp_exit(void) -{ - pci_unregister_driver(&k8temp_driver); -} +module_pci_driver(k8temp_driver); MODULE_AUTHOR("Rudolf Marek <r.marek@assembler.cz>"); MODULE_DESCRIPTION("AMD K8 core temperature monitor"); MODULE_LICENSE("GPL"); - -module_init(k8temp_init) -module_exit(k8temp_exit) |
