[lm-sensors] [PATCH 3/4] hwmon: (coretemp) some cleanup work

Guenter Roeck guenter.roeck at ericsson.com
Thu Jul 15 08:13:11 CEST 2010


On Wed, Jul 14, 2010 at 10:46:43PM -0400, Chen Gong wrote:
> cleanup some redundant codes in coretemp.c.
> 
> Signed-off-by: Chen Gong <gong.chen at linux.intel.com>
> ---
>  drivers/hwmon/coretemp.c |   18 ++++--------------
>  1 files changed, 4 insertions(+), 14 deletions(-)
> 
> diff --git a/drivers/hwmon/coretemp.c b/drivers/hwmon/coretemp.c
> index 7b7c5b8..728e9c3 100644
> --- a/drivers/hwmon/coretemp.c
> +++ b/drivers/hwmon/coretemp.c
> @@ -54,13 +54,13 @@ struct coretemp_data {
>  	const char *name;
>  	u32 id;
>  	u16 core_id;
> +	u8 alarm;
>  	char valid;		/* zero until following fields are valid */
>  	unsigned long last_updated;	/* in jiffies */
>  	int temp;
>  	int pkg_temp;
>  	int tjmax;
>  	int ttarget;
> -	u8 alarm;
>  };
>  
>  /*
> @@ -320,14 +320,14 @@ static int __devinit coretemp_probe(struct platform_device *pdev)
>  #ifdef CONFIG_SMP
>  	data->core_id = c->cpu_core_id;
>  #endif
> -	data->name = "coretemp";
> +	data->name = DRVNAME;
>  	mutex_init(&data->update_lock);
>  
>  	/* test if we can access the THERM_STATUS MSR */
>  	err = rdmsr_safe_on_cpu(data->id, MSR_IA32_THERM_STATUS, &eax, &edx);
>  	if (err) {
>  		dev_err(&pdev->dev,
> -			"Unable to access THERM_STATUS MSR, giving up\n");
> +				"Unable to access THERM_STATUS MSR, giving up\n");

This creates a line longer than 80 characters. What was wrong with the old formatting ?

>  		goto exit_free;
>  	}
>  
> @@ -555,8 +555,7 @@ static int __init coretemp_init(void)
>  		if (c->cpuid_level >= 6 && (cpuid_eax(0x06) & 0x01)) {
>  			err = coretemp_device_add(i);
>  			if (err)
> -				goto exit_devices_unreg;
> -
> +				goto exit;
>  		} else {
>  			printk(KERN_INFO DRVNAME ": CPU (model=0x%x)"
>  				" has no thermal sensor.\n", c->x86_model);
> @@ -567,15 +566,6 @@ static int __init coretemp_init(void)
>  	register_hotcpu_notifier(&coretemp_cpu_notifier);
>  #endif
>  	return 0;
> -
> -exit_devices_unreg:
> -	mutex_lock(&pdev_list_mutex);
> -	list_for_each_entry_safe(p, n, &pdev_list, list) {
> -		platform_device_unregister(p->pdev);
> -		list_del(&p->list);
> -		kfree(p);
> -	}
> -	mutex_unlock(&pdev_list_mutex);

Ah, guess that explains the previous patch. Seems to be a bit unusual, though,
not to remove created devices if an error occurs in init. Is that really ok ?

>  exit:
>  	return err;
>  }
> -- 
> 1.7.1.571.gba4d01
> 
> 
> _______________________________________________
> lm-sensors mailing list
> lm-sensors at lm-sensors.org
> http://lists.lm-sensors.org/mailman/listinfo/lm-sensors




More information about the lm-sensors mailing list