Re: [PATCH] mfd: Implement devicetree support for AB8500 fg
Hi, On 09/10/2012 11:44 AM, Rajanikanth HV wrote: ... > +static int __devinit > +fg_of_probe(struct device *dev, > + struct device_node *np, > + struct abx500_bm_plat_data *bm_pdata) > +{ > + u8 val; > + u32 pval; > + int i; > + int ext_thermister, lion_battery, ret = 0; > + const char *bm_dev_name; > + struct abx500_fg_platform_data *fg = bm_pdata->fg; > + struct abx500_bm_data *bat; > + struct abx500_battery_type*btype; > + > + ret = of_property_read_u32(np, "num_supplicants", &pval); > + if (ret) { > + dev_err(dev, "missing property num_supplicants\n"); > + ret = -EINVAL; > + goto inval_pval; > + } > + fg->num_supplicants = pval; > + fg->supplied_to = > + devm_kzalloc(dev, fg->num_supplicants * > + sizeof(const char *), GFP_KERNEL); > + if (fg->supplied_to == NULL) { > + dev_err(dev, "%s no mem for supplied_to\n", __func__); > + ret = -ENOMEM; > + goto inval_pval; > + } > + for (val = 0; val < fg->num_supplicants; ++val) > + if (of_property_read_string_index > + (np, "supplied_to", val, &bm_dev_name) == 0) > + *(fg->supplied_to + val) = (char *)bm_dev_name; > + else { > + dev_err(dev, "insufficient number of supplied_to data > found\n"); > + ret = -EINVAL; > + goto free_dev_mem; > + } > + ret = of_property_read_u32(np, "thermister_on_batctrl", &pval); > + if (ret) { > + dev_err(dev, "missing property thermister_on_batctrl\n"); > + ret = -EINVAL; > + goto free_dev_mem; > + } > + bm_pdata->battery = &ab8500_bm_data; > + bat = bm_pdata->battery; > + ext_thermister = 0; > + if (pval == 0) { > + bat->n_btypes = 4; > + bat->bat_type = bat_type_ext_thermister; > + bat->adc_therm = ABx500_ADC_THERM_BATTEMP; > + ext_thermister = 1; > + } > + ret = of_property_read_u32(np, "li_ion_9100", &pval); > + if (ret) { > + dev_err(dev, "missing property li_ion_9100\n"); > + ret = -EINVAL; > + goto free_dev_mem; > + } > + lion_battery = 0; > + if (pval == 1) { > + bat->no_maintenance = true; > + bat->chg_unknown_bat = true; > + bat->bat_type[BATTERY_UNKNOWN].charge_full_design = 2600; > + bat->bat_type[BATTERY_UNKNOWN].termination_vol = 4150; > + bat->bat_type[BATTERY_UNKNOWN].recharge_vol = 4130; > + bat->bat_type[BATTERY_UNKNOWN].normal_cur_lvl = 520; > + bat->bat_type[BATTERY_UNKNOWN].normal_vol_lvl = 4200; > + lion_battery = 1; > + } > + /* select the battery resolution table */ > + for (i = 0; i < bat->n_btypes; ++i) { > + btype = (bat->bat_type + i); > + if (ext_thermister) { > + btype->batres_tbl = > + temp_to_batres_tbl_ext_thermister; > + } else if (lion_battery) { > + btype->batres_tbl = > + temp_to_batres_tbl_9100; > + } else { > + btype->batres_tbl = > + temp_to_batres_tbl_thermister; > + } > + } > + return ret; > +free_dev_mem: > + devm_kfree(dev, fg->supplied_to); > +inval_pval: > + return ret; > +} Since when fg_of_probe() fails, the driver probe function returns error, there is no need to devm_kfree() data allocated with devm_kzalloc(), so you can get rid of the goto statements > static int __devinit ab8500_fg_probe(struct platform_device *pdev) > { > int i, irq; > int ret = 0; > struct abx500_bm_plat_data *plat_data = pdev->dev.platform_data; > + struct device_node *np = pdev->dev.of_node; > struct ab8500_fg *di; > > + di = devm_kzalloc(&pdev->dev, sizeof(*di), GFP_KERNEL); > + if (!di) { > + dev_err(&pdev->dev, "%s no mem for ab8500_btemp\n", __func__); Copy&paste error, this is not btemp > + ret = -ENOMEM; > + goto err_no_mem; > + } > + if (np) { > + if (!plat_data) { > + plat_data = > + devm_kzalloc(&pdev->dev, sizeof(*plat_data), > GFP_KERNEL); > + if (!plat_data) { > + dev_err(&pdev->dev, > + "%s no mem for plat_data\n", __func__); > + ret = -ENOMEM; > + goto free_device_info; > + } > + plat_data->fg = devm_kzalloc(&pdev->dev, > + sizeof(*plat_data->fg), GFP_KERNEL); > + if (!pla
Re: mfd: Implement devicetree support for AB8500 Btemp
On 09/10/2012 01:21 PM, Rajanikanth HV wrote: ... > -static int __devinit ab8500_btemp_probe(struct platform_device *pdev) > +static int __devinit > +btemp_of_probe(struct device *dev, > + struct device_node *np, > + struct abx500_bm_plat_data *bm_pdata) > { > - int irq, i, ret = 0; > - u8 val; > - struct abx500_bm_plat_data *plat_data = pdev->dev.platform_data; > - struct ab8500_btemp *di; > - > - if (!plat_data) { > - dev_err(&pdev->dev, "No platform data\n"); > - return -EINVAL; > + u8 val; > + u32 pval; > + int i; > + int ext_thermister, lion_battery, ret = 0; > + const char *bm_dev_name; > + struct abx500_btemp_platform_data *btemp = bm_pdata->btemp; > + struct abx500_bm_data *bat; > + struct abx500_battery_type*btype; > + > + ret = of_property_read_u32(np, "num_supplicants", &pval); > + if (ret) { > + dev_err(dev, "missing property num_supplicants\n"); > + ret = -EINVAL; > + goto inval_pval; > } > - > - di = kzalloc(sizeof(*di), GFP_KERNEL); > - if (!di) > - return -ENOMEM; > - > - /* get parent data */ > - di->dev = &pdev->dev; > - di->parent = dev_get_drvdata(pdev->dev.parent); > - di->gpadc = ab8500_gpadc_get("ab8500-gpadc.0"); > - > - /* get btemp specific platform data */ > - di->pdata = plat_data->btemp; > - if (!di->pdata) { > - dev_err(di->dev, "no btemp platform data supplied\n"); > + btemp->num_supplicants = pval; > + btemp->supplied_to = > + devm_kzalloc(dev, btemp->num_supplicants * > + sizeof(const char *), GFP_KERNEL); > + if (btemp->supplied_to == NULL) { > + dev_err(dev, "%s no mem for supplied_to\n", __func__); > + ret = -ENOMEM; > + goto inval_pval; > + } > + for (val = 0; val < btemp->num_supplicants; ++val) > + if (of_property_read_string_index > + (np, "supplied_to", val, &bm_dev_name) == 0) > + *(btemp->supplied_to + val) = (char *)bm_dev_name; > + else { > + dev_err(dev, "insufficient number of supplied_to data > found\n"); > + ret = -EINVAL; > + goto free_dev_mem; > + } > + ret = of_property_read_u32(np, "thermister_on_batctrl", &pval); > + if (ret) { > + dev_err(dev, "missing property thermister_on_batctrl\n"); > ret = -EINVAL; > - goto free_device_info; > + goto free_dev_mem; > + } > + bm_pdata->battery = &ab8500_bm_data; > + bat = bm_pdata->battery; > + ext_thermister = 0; > + if (pval == 0) { > + bat->n_btypes = 4; > + bat->bat_type = bat_type_ext_thermister; > + bat->adc_therm = ABx500_ADC_THERM_BATTEMP; > + ext_thermister = 1; > + } > + ret = of_property_read_u32(np, "li_ion_9100", &pval); > + if (ret) { > + dev_err(dev, "missing property li_ion_9100\n"); > + ret = -EINVAL; > + goto free_dev_mem; > + } > + lion_battery = 0; > + if (pval == 1) { > + bat->no_maintenance = true; > + bat->chg_unknown_bat = true; > + bat->bat_type[BATTERY_UNKNOWN].charge_full_design = 2600; > + bat->bat_type[BATTERY_UNKNOWN].termination_vol = 4150; > + bat->bat_type[BATTERY_UNKNOWN].recharge_vol = 4130; > + bat->bat_type[BATTERY_UNKNOWN].normal_cur_lvl = 520; > + bat->bat_type[BATTERY_UNKNOWN].normal_vol_lvl = 4200; > + lion_battery = 1; > + } > + /* select the battery resolution table */ > + for (i = 0; i < bat->n_btypes; ++i) { > + btype = (bat->bat_type + i); > + if (ext_thermister) { > + btype->batres_tbl = > + temp_to_batres_tbl_ext_thermister; > + } else if (lion_battery) { > + btype->batres_tbl = > + temp_to_batres_tbl_9100; > + } else { > + btype->batres_tbl = > + temp_to_batres_tbl_thermister; > + } > + } > + return ret; > +free_dev_mem: > + devm_kfree(dev, btemp->supplied_to); > +inval_pval: > + return ret; > +} > + > +static int __devinit ab8500_btemp_probe(struct platform_device *pdev) > +{ > + u8 val; > + int i; > + int irq, ret = 0; > + struct abx500_bm_plat_data *pdata = pdev->dev.platform_data; > + struct device_node *np = pdev->dev.of_node; > + struct ab8500_btemp*di; > + > + di = devm_kzalloc(&pdev->dev, sizeof(*di), GFP_KERNEL); > + if (!di) { > + dev_err(&pdev->dev, "%s no mem for ab8500_btemp\n", __func__); > + ret = -ENOM
Re: [PATCH 1/3] acpi : move cpuidle_device field out of the acpi_processor_power structure
On Friday, September 14, 2012, Daniel Lezcano wrote: > Currently we have the cpuidle_device field in the acpi_processor_power > structure. > This adds a dependency between processor.h and cpuidle.h > > Although it is not a real problem, removing this dependency has the benefit of > separating a bit more the cpuidle code from the rest of the acpi code. > Also, the compilation should be a bit improved because we do no longer > include cpuidle.h in processor.h. The preprocessor was generating 30418 loc > and with this patch it generates 30256 loc for processor_thermal.c, a file > which is not concerned at all by cpuidle, like processor_perflib.c and > processor_throttling.c. > > That may sound ridiculous, but "small streams make big rivers" :P > > This patch moves this field into a static global per cpu variable like what is > done in the intel_idle driver. > > Signed-off-by: Daniel Lezcano I'm inclined to take this one for v3.7. Len, other ACPI guys, any objections, comments? Rafael > --- > drivers/acpi/processor_idle.c | 32 > include/acpi/processor.h |2 -- > 2 files changed, 24 insertions(+), 10 deletions(-) > > diff --git a/drivers/acpi/processor_idle.c b/drivers/acpi/processor_idle.c > index de89624..0a6405d 100644 > --- a/drivers/acpi/processor_idle.c > +++ b/drivers/acpi/processor_idle.c > @@ -79,6 +79,8 @@ module_param(bm_check_disable, uint, ); > static unsigned int latency_factor __read_mostly = 2; > module_param(latency_factor, uint, 0644); > > +static DEFINE_PER_CPU(struct cpuidle_device *, acpi_cpuidle_device); > + > static int disabled_by_idle_boot_param(void) > { > return boot_option_idle_override == IDLE_POLL || > @@ -998,7 +1000,7 @@ static int acpi_processor_setup_cpuidle_cx(struct > acpi_processor *pr) > int i, count = CPUIDLE_DRIVER_STATE_START; > struct acpi_processor_cx *cx; > struct cpuidle_state_usage *state_usage; > - struct cpuidle_device *dev = &pr->power.dev; > + struct cpuidle_device *dev = per_cpu(acpi_cpuidle_device, pr->id); > > if (!pr->flags.power_setup_done) > return -EINVAL; > @@ -1130,6 +1132,7 @@ static int acpi_processor_setup_cpuidle_states(struct > acpi_processor *pr) > int acpi_processor_hotplug(struct acpi_processor *pr) > { > int ret = 0; > + struct cpuidle_device *dev = per_cpu(acpi_cpuidle_device, pr->id); > > if (disabled_by_idle_boot_param()) > return 0; > @@ -1145,11 +1148,11 @@ int acpi_processor_hotplug(struct acpi_processor *pr) > return -ENODEV; > > cpuidle_pause_and_lock(); > - cpuidle_disable_device(&pr->power.dev); > + cpuidle_disable_device(dev); > acpi_processor_get_power_info(pr); > if (pr->flags.power) { > acpi_processor_setup_cpuidle_cx(pr); > - ret = cpuidle_enable_device(&pr->power.dev); > + ret = cpuidle_enable_device(dev); > } > cpuidle_resume_and_unlock(); > > @@ -1160,6 +1163,7 @@ int acpi_processor_cst_has_changed(struct > acpi_processor *pr) > { > int cpu; > struct acpi_processor *_pr; > + struct cpuidle_device *dev; > > if (disabled_by_idle_boot_param()) > return 0; > @@ -1190,7 +1194,8 @@ int acpi_processor_cst_has_changed(struct > acpi_processor *pr) > _pr = per_cpu(processors, cpu); > if (!_pr || !_pr->flags.power_setup_done) > continue; > - cpuidle_disable_device(&_pr->power.dev); > + dev = per_cpu(acpi_cpuidle_device, cpu); > + cpuidle_disable_device(dev); > } > > /* Populate Updated C-state information */ > @@ -1204,7 +1209,8 @@ int acpi_processor_cst_has_changed(struct > acpi_processor *pr) > acpi_processor_get_power_info(_pr); > if (_pr->flags.power) { > acpi_processor_setup_cpuidle_cx(_pr); > - cpuidle_enable_device(&_pr->power.dev); > + dev = per_cpu(acpi_cpuidle_device, cpu); > + cpuidle_enable_device(dev); > } > } > put_online_cpus(); > @@ -1221,6 +1227,7 @@ int __cpuinit acpi_processor_power_init(struct > acpi_processor *pr, > { > acpi_status status = 0; > int retval; > + struct cpuidle_device *dev; > static int first_run; > > if (disabled_by_idle_boot_param()) > @@ -1266,11 +1273,18 @@ int __cpuinit acpi_processor_power_init(struct > acpi_processor *pr, > printk(KERN_DEBUG "ACPI: %s registered with cpuidle\n", > acpi_idle_driver.name); > } > + > + dev = kzalloc(sizeof(*dev), GFP_KERNEL); > + if (!dev) > + return -ENOMEM; > +
Re: [PATCH 3/3] acpi : remove pointless variable initialization
On Friday, September 14, 2012, Daniel Lezcano wrote: > The 'errata' variable is a global variable which is set to zero, > no need to do that with a memset in the init function. > > Signed-off-by: Daniel Lezcano Applied to the linux-next branch of the linux-pm.git tree as v3.7 material. Thanks, Rafael > --- > drivers/acpi/processor_driver.c |2 -- > 1 files changed, 0 insertions(+), 2 deletions(-) > > diff --git a/drivers/acpi/processor_driver.c b/drivers/acpi/processor_driver.c > index 9c9288b..e78c2a5 100644 > --- a/drivers/acpi/processor_driver.c > +++ b/drivers/acpi/processor_driver.c > @@ -905,8 +905,6 @@ static int __init acpi_processor_init(void) > if (acpi_disabled) > return 0; > > - memset(&errata, 0, sizeof(errata)); > - > result = acpi_bus_register_driver(&acpi_processor_driver); > if (result < 0) > return result; > ___ linaro-dev mailing list linaro-dev@lists.linaro.org http://lists.linaro.org/mailman/listinfo/linaro-dev
Re: [PATCH 2/3] acpi : remove unused function parameter
On Friday, September 14, 2012, Daniel Lezcano wrote: > The 'device' parameter is not used neither in acpi_processor_power_init > and acpi_processor_power_exit. This patch removes it. > > Signed-off-by: Daniel Lezcano Applied to the linux-next branch of the linux-pm.git tree as v3.7 material. Thanks, Rafael > --- > drivers/acpi/processor_driver.c |6 +++--- > drivers/acpi/processor_idle.c |6 ++ > include/acpi/processor.h|6 ++ > 3 files changed, 7 insertions(+), 11 deletions(-) > > diff --git a/drivers/acpi/processor_driver.c b/drivers/acpi/processor_driver.c > index bfc31cb..9c9288b 100644 > --- a/drivers/acpi/processor_driver.c > +++ b/drivers/acpi/processor_driver.c > @@ -475,7 +475,7 @@ static __ref int acpi_processor_start(struct > acpi_processor *pr) > acpi_processor_get_limit_info(pr); > > if (!cpuidle_get_driver() || cpuidle_get_driver() == &acpi_idle_driver) > - acpi_processor_power_init(pr, device); > + acpi_processor_power_init(pr); > > pr->cdev = thermal_cooling_device_register("Processor", device, > &processor_cooling_ops); > @@ -509,7 +509,7 @@ err_remove_sysfs_thermal: > err_thermal_unregister: > thermal_cooling_device_unregister(pr->cdev); > err_power_exit: > - acpi_processor_power_exit(pr, device); > + acpi_processor_power_exit(pr); > > return result; > } > @@ -620,7 +620,7 @@ static int acpi_processor_remove(struct acpi_device > *device, int type) > return -EINVAL; > } > > - acpi_processor_power_exit(pr, device); > + acpi_processor_power_exit(pr); > > sysfs_remove_link(&device->dev.kobj, "sysdev"); > > diff --git a/drivers/acpi/processor_idle.c b/drivers/acpi/processor_idle.c > index 0a6405d..3655ab9 100644 > --- a/drivers/acpi/processor_idle.c > +++ b/drivers/acpi/processor_idle.c > @@ -1222,8 +1222,7 @@ int acpi_processor_cst_has_changed(struct > acpi_processor *pr) > > static int acpi_processor_registered; > > -int __cpuinit acpi_processor_power_init(struct acpi_processor *pr, > - struct acpi_device *device) > +int __cpuinit acpi_processor_power_init(struct acpi_processor *pr) > { > acpi_status status = 0; > int retval; > @@ -1295,8 +1294,7 @@ int __cpuinit acpi_processor_power_init(struct > acpi_processor *pr, > return 0; > } > > -int acpi_processor_power_exit(struct acpi_processor *pr, > - struct acpi_device *device) > +int acpi_processor_power_exit(struct acpi_processor *pr) > { > struct cpuidle_device *dev = per_cpu(acpi_cpuidle_device, pr->id); > > diff --git a/include/acpi/processor.h b/include/acpi/processor.h > index ddd1a44..555d033 100644 > --- a/include/acpi/processor.h > +++ b/include/acpi/processor.h > @@ -322,12 +322,10 @@ extern void acpi_processor_reevaluate_tstate(struct > acpi_processor *pr, > extern const struct file_operations acpi_processor_throttling_fops; > extern void acpi_processor_throttling_init(void); > /* in processor_idle.c */ > -int acpi_processor_power_init(struct acpi_processor *pr, > - struct acpi_device *device); > +int acpi_processor_power_init(struct acpi_processor *pr); > +int acpi_processor_power_exit(struct acpi_processor *pr); > int acpi_processor_cst_has_changed(struct acpi_processor *pr); > int acpi_processor_hotplug(struct acpi_processor *pr); > -int acpi_processor_power_exit(struct acpi_processor *pr, > - struct acpi_device *device); > int acpi_processor_suspend(struct device *dev); > int acpi_processor_resume(struct device *dev); > extern struct cpuidle_driver acpi_idle_driver; > ___ linaro-dev mailing list linaro-dev@lists.linaro.org http://lists.linaro.org/mailman/listinfo/linaro-dev