diff options
Diffstat (limited to 'arch/arm/mach-omap2/smartreflex.c')
-rw-r--r-- | arch/arm/mach-omap2/smartreflex.c | 62 |
1 files changed, 32 insertions, 30 deletions
diff --git a/arch/arm/mach-omap2/smartreflex.c b/arch/arm/mach-omap2/smartreflex.c index 95ac336fe3f7..0ab4dd5081ee 100644 --- a/arch/arm/mach-omap2/smartreflex.c +++ b/arch/arm/mach-omap2/smartreflex.c | |||
@@ -54,6 +54,7 @@ struct omap_sr { | |||
54 | struct list_head node; | 54 | struct list_head node; |
55 | struct omap_sr_nvalue_table *nvalue_table; | 55 | struct omap_sr_nvalue_table *nvalue_table; |
56 | struct voltagedomain *voltdm; | 56 | struct voltagedomain *voltdm; |
57 | struct dentry *dbg_dir; | ||
57 | }; | 58 | }; |
58 | 59 | ||
59 | /* sr_list contains all the instances of smartreflex module */ | 60 | /* sr_list contains all the instances of smartreflex module */ |
@@ -260,9 +261,11 @@ static int sr_late_init(struct omap_sr *sr_info) | |||
260 | if (sr_class->class_type == SR_CLASS2 && | 261 | if (sr_class->class_type == SR_CLASS2 && |
261 | sr_class->notify_flags && sr_info->irq) { | 262 | sr_class->notify_flags && sr_info->irq) { |
262 | 263 | ||
263 | name = kzalloc(SMARTREFLEX_NAME_LEN + 1, GFP_KERNEL); | 264 | name = kasprintf(GFP_KERNEL, "sr_%s", sr_info->voltdm->name); |
264 | strcpy(name, "sr_"); | 265 | if (name == NULL) { |
265 | strcat(name, sr_info->voltdm->name); | 266 | ret = -ENOMEM; |
267 | goto error; | ||
268 | } | ||
266 | ret = request_irq(sr_info->irq, sr_interrupt, | 269 | ret = request_irq(sr_info->irq, sr_interrupt, |
267 | 0, name, (void *)sr_info); | 270 | 0, name, (void *)sr_info); |
268 | if (ret) | 271 | if (ret) |
@@ -282,6 +285,7 @@ error: | |||
282 | dev_err(&sr_info->pdev->dev, "%s: ERROR in registering" | 285 | dev_err(&sr_info->pdev->dev, "%s: ERROR in registering" |
283 | "interrupt handler. Smartreflex will" | 286 | "interrupt handler. Smartreflex will" |
284 | "not function as desired\n", __func__); | 287 | "not function as desired\n", __func__); |
288 | kfree(name); | ||
285 | kfree(sr_info); | 289 | kfree(sr_info); |
286 | return ret; | 290 | return ret; |
287 | } | 291 | } |
@@ -820,7 +824,7 @@ static int __init omap_sr_probe(struct platform_device *pdev) | |||
820 | struct omap_sr *sr_info = kzalloc(sizeof(struct omap_sr), GFP_KERNEL); | 824 | struct omap_sr *sr_info = kzalloc(sizeof(struct omap_sr), GFP_KERNEL); |
821 | struct omap_sr_data *pdata = pdev->dev.platform_data; | 825 | struct omap_sr_data *pdata = pdev->dev.platform_data; |
822 | struct resource *mem, *irq; | 826 | struct resource *mem, *irq; |
823 | struct dentry *vdd_dbg_dir, *dbg_dir, *nvalue_dir; | 827 | struct dentry *vdd_dbg_dir, *nvalue_dir; |
824 | struct omap_volt_data *volt_data; | 828 | struct omap_volt_data *volt_data; |
825 | int i, ret = 0; | 829 | int i, ret = 0; |
826 | 830 | ||
@@ -879,7 +883,7 @@ static int __init omap_sr_probe(struct platform_device *pdev) | |||
879 | ret = sr_late_init(sr_info); | 883 | ret = sr_late_init(sr_info); |
880 | if (ret) { | 884 | if (ret) { |
881 | pr_warning("%s: Error in SR late init\n", __func__); | 885 | pr_warning("%s: Error in SR late init\n", __func__); |
882 | return ret; | 886 | goto err_release_region; |
883 | } | 887 | } |
884 | } | 888 | } |
885 | 889 | ||
@@ -890,30 +894,34 @@ static int __init omap_sr_probe(struct platform_device *pdev) | |||
890 | * not try to create rest of the debugfs entries. | 894 | * not try to create rest of the debugfs entries. |
891 | */ | 895 | */ |
892 | vdd_dbg_dir = omap_voltage_get_dbgdir(sr_info->voltdm); | 896 | vdd_dbg_dir = omap_voltage_get_dbgdir(sr_info->voltdm); |
893 | if (!vdd_dbg_dir) | 897 | if (!vdd_dbg_dir) { |
894 | return -EINVAL; | 898 | ret = -EINVAL; |
899 | goto err_release_region; | ||
900 | } | ||
895 | 901 | ||
896 | dbg_dir = debugfs_create_dir("smartreflex", vdd_dbg_dir); | 902 | sr_info->dbg_dir = debugfs_create_dir("smartreflex", vdd_dbg_dir); |
897 | if (IS_ERR(dbg_dir)) { | 903 | if (IS_ERR(sr_info->dbg_dir)) { |
898 | dev_err(&pdev->dev, "%s: Unable to create debugfs directory\n", | 904 | dev_err(&pdev->dev, "%s: Unable to create debugfs directory\n", |
899 | __func__); | 905 | __func__); |
900 | return PTR_ERR(dbg_dir); | 906 | ret = PTR_ERR(sr_info->dbg_dir); |
907 | goto err_release_region; | ||
901 | } | 908 | } |
902 | 909 | ||
903 | (void) debugfs_create_file("autocomp", S_IRUGO | S_IWUSR, dbg_dir, | 910 | (void) debugfs_create_file("autocomp", S_IRUGO | S_IWUSR, |
904 | (void *)sr_info, &pm_sr_fops); | 911 | sr_info->dbg_dir, (void *)sr_info, &pm_sr_fops); |
905 | (void) debugfs_create_x32("errweight", S_IRUGO, dbg_dir, | 912 | (void) debugfs_create_x32("errweight", S_IRUGO, sr_info->dbg_dir, |
906 | &sr_info->err_weight); | 913 | &sr_info->err_weight); |
907 | (void) debugfs_create_x32("errmaxlimit", S_IRUGO, dbg_dir, | 914 | (void) debugfs_create_x32("errmaxlimit", S_IRUGO, sr_info->dbg_dir, |
908 | &sr_info->err_maxlimit); | 915 | &sr_info->err_maxlimit); |
909 | (void) debugfs_create_x32("errminlimit", S_IRUGO, dbg_dir, | 916 | (void) debugfs_create_x32("errminlimit", S_IRUGO, sr_info->dbg_dir, |
910 | &sr_info->err_minlimit); | 917 | &sr_info->err_minlimit); |
911 | 918 | ||
912 | nvalue_dir = debugfs_create_dir("nvalue", dbg_dir); | 919 | nvalue_dir = debugfs_create_dir("nvalue", sr_info->dbg_dir); |
913 | if (IS_ERR(nvalue_dir)) { | 920 | if (IS_ERR(nvalue_dir)) { |
914 | dev_err(&pdev->dev, "%s: Unable to create debugfs directory" | 921 | dev_err(&pdev->dev, "%s: Unable to create debugfs directory" |
915 | "for n-values\n", __func__); | 922 | "for n-values\n", __func__); |
916 | return PTR_ERR(nvalue_dir); | 923 | ret = PTR_ERR(nvalue_dir); |
924 | goto err_release_region; | ||
917 | } | 925 | } |
918 | 926 | ||
919 | omap_voltage_get_volttable(sr_info->voltdm, &volt_data); | 927 | omap_voltage_get_volttable(sr_info->voltdm, &volt_data); |
@@ -922,23 +930,15 @@ static int __init omap_sr_probe(struct platform_device *pdev) | |||
922 | " corresponding vdd vdd_%s. Cannot create debugfs" | 930 | " corresponding vdd vdd_%s. Cannot create debugfs" |
923 | "entries for n-values\n", | 931 | "entries for n-values\n", |
924 | __func__, sr_info->voltdm->name); | 932 | __func__, sr_info->voltdm->name); |
925 | return -ENODATA; | 933 | ret = -ENODATA; |
934 | goto err_release_region; | ||
926 | } | 935 | } |
927 | 936 | ||
928 | for (i = 0; i < sr_info->nvalue_count; i++) { | 937 | for (i = 0; i < sr_info->nvalue_count; i++) { |
929 | char *name; | 938 | char name[NVALUE_NAME_LEN + 1]; |
930 | char volt_name[32]; | ||
931 | |||
932 | name = kzalloc(NVALUE_NAME_LEN + 1, GFP_KERNEL); | ||
933 | if (!name) { | ||
934 | dev_err(&pdev->dev, "%s: Unable to allocate memory" | ||
935 | " for n-value directory name\n", __func__); | ||
936 | return -ENOMEM; | ||
937 | } | ||
938 | 939 | ||
939 | strcpy(name, "volt_"); | 940 | snprintf(name, sizeof(name), "volt_%d", |
940 | sprintf(volt_name, "%d", volt_data[i].volt_nominal); | 941 | volt_data[i].volt_nominal); |
941 | strcat(name, volt_name); | ||
942 | (void) debugfs_create_x32(name, S_IRUGO | S_IWUSR, nvalue_dir, | 942 | (void) debugfs_create_x32(name, S_IRUGO | S_IWUSR, nvalue_dir, |
943 | &(sr_info->nvalue_table[i].nvalue)); | 943 | &(sr_info->nvalue_table[i].nvalue)); |
944 | } | 944 | } |
@@ -973,6 +973,8 @@ static int __devexit omap_sr_remove(struct platform_device *pdev) | |||
973 | 973 | ||
974 | if (sr_info->autocomp_active) | 974 | if (sr_info->autocomp_active) |
975 | sr_stop_vddautocomp(sr_info); | 975 | sr_stop_vddautocomp(sr_info); |
976 | if (sr_info->dbg_dir) | ||
977 | debugfs_remove_recursive(sr_info->dbg_dir); | ||
976 | 978 | ||
977 | list_del(&sr_info->node); | 979 | list_del(&sr_info->node); |
978 | iounmap(sr_info->base); | 980 | iounmap(sr_info->base); |