cpufreq: exynos: Adding cpufreq driver for exynos5440
Subsystems (5)
PATCH v3 1/4 cpufreq: exynos: Adding cpufreq driver for exynos5440
This patch adds dvfs support for exynos5440 SOC. This soc has 4 cores and they scale at same frequency. The nature of exynos5440 clock controller is different from previous exynos controllers so not using the common exynos cpufreq framework. The major difference being interrupt notfication for frequency change. Also, OPP library is used for device tree parsing to get different parameters like frequency, voltage etc. Since the opp library sorts the frequency table in ascending order so they are again re-arranged in descending order. This will have one-to-one mapping with the clock controller state management logic.
---
Changes in V3:
* Converted the driver to probe based as suggested by Viresh. This is also beneficial for multiplatform kernel.
* Other coding guidelines related changes.
Changes in V2:
* Added OPP library support to parse DT parameters.
* Removed a hack to handle interrupts in bootup.
* Implemented other review comments from Viresh and Inder.
All these patches are dependent on Thomas Abraham common clock patches.
(http://www.mail-archive.com/[email protected]/msg15860.html)
This whole patch series is based on 3.9-rc1.
.../bindings/cpufreq/cpufreq-exynos5440.txt | 29 ++ drivers/cpufreq/Kconfig.arm | 9 + drivers/cpufreq/Makefile | 1 + drivers/cpufreq/exynos5440-cpufreq.c | 467 ++++++++++++++++++++ 4 files changed, 506 insertions(+), 0 deletions(-) create mode 100644 Documentation/devicetree/bindings/cpufreq/cpufreq-exynos5440.txt create mode 100644 drivers/cpufreq/exynos5440-cpufreq.c
Documentation/devicetree/bindings/cpufreq/cpufreq-exynos5440.txt new file +29 -0
@@ -0,0 +1,29 @@ + +Exynos5440 cpufreq driver +------------------- + +Exynos5440 SoC cpufreq driver for CPU frequency scaling. + +Required properties: +- interrupts: Interrupt to know the completion of cpu frequency change. +- operating-points: Table of frequencies and voltage CPU could be transitioned into, + in the decreasing order. Frequency should be in KHZ units and voltage + should be in microvolts. + +Optional properties: +- clock-latency: Clock monitor latency in microsecond. + +All the required listed above must be defined under node cpufreq. + +Example: +-------- + cpufreq@160000 { + compatible = "samsung,exynos5440-cpufreq"; + reg = <0x160000 0x1000>; + interrupts = <0 57 0>; + operating-points = < + 1000000 975000 + 800000 925000>; + clock-latency = <100000>; + }; +
drivers/cpufreq/Kconfig.arm +9 -0
@@ -77,6 +77,15 @@ config ARM_EXYNOS5250_CPUFREQ This adds the CPUFreq driver for Samsung EXYNOS5250 SoC. +config ARM_EXYNOS5440_CPUFREQ + def_bool SOC_EXYNOS5440 + depends on HAVE_CLK && PM_OPP && OF + help + This adds the CPUFreq driver for Samsung EXYNOS5440 + SoC. The nature of exynos5440 clock controller is + different than previous exynos controllers so not using + the common exynos framework. + config ARM_KIRKWOOD_CPUFREQ def_bool ARCH_KIRKWOOD && OF help
drivers/cpufreq/Makefile +1 -0
@@ -52,6 +52,7 @@ obj-$(CONFIG_ARM_EXYNOS_CPUFREQ) += exynos-cpufreq.o obj-$(CONFIG_ARM_EXYNOS4210_CPUFREQ) += exynos4210-cpufreq.o obj-$(CONFIG_ARM_EXYNOS4X12_CPUFREQ) += exynos4x12-cpufreq.o obj-$(CONFIG_ARM_EXYNOS5250_CPUFREQ) += exynos5250-cpufreq.o +obj-$(CONFIG_ARM_EXYNOS5440_CPUFREQ) += exynos5440-cpufreq.o obj-$(CONFIG_ARM_KIRKWOOD_CPUFREQ) += kirkwood-cpufreq.o obj-$(CONFIG_ARM_OMAP2PLUS_CPUFREQ) += omap-cpufreq.o obj-$(CONFIG_ARM_SPEAR_CPUFREQ) += spear-cpufreq.o
drivers/cpufreq/exynos5440-cpufreq.c new file +467 -0
467 lines not on this page · raw message
Signature · 1 line
1.7.1
PATCH v3 2/4 cpufreq: exynos: Remove error return even if no soc is found
This patch helps to have single binary for exynos5440 and previous exynos soc's. This change is needed for adding exynos5440 cpufreq driver which does not uses exynos-cpufreq common file and adds it own driver.
--- drivers/cpufreq/exynos-cpufreq.c | 2 +- 1 files changed, 1 insertions(+), 1 deletions(-)
drivers/cpufreq/exynos-cpufreq.c +1 -1
@@ -297,7 +297,7 @@ static int __init exynos_cpufreq_init(void)else if (soc_is_exynos5250 ()) ret =exynos5250_cpufreq_init (exynos_info);else -pr_err ("%s: CPU type not found\n" , __func__); +return 0 ;if (ret) goto err_vdd_arm;
Signature · 1 line
1.7.1
PATCH v3 3/4 arm: exynos: Enable OPP library support for exynos5440
In reply to Amit Daniel KachhapThe OPP library support is needed for exynos5440 cpu frequency dynamic scaling driver.
--- arch/arm/mach-exynos/Kconfig | 2 ++ 1 files changed, 2 insertions(+), 0 deletions(-)
arch/arm/mach-exynos/Kconfig +2 -0
@@ -72,10 +72,12 @@ config SOC_EXYNOS5440 bool "SAMSUNG EXYNOS5440" default y depends on ARCH_EXYNOS5 + select ARCH_HAS_OPP select ARM_ARCH_TIMER select AUTO_ZRELADDR select PINCTRL select PINCTRL_EXYNOS5440 + select PM_OPP help Enable EXYNOS5440 SoC support
Signature · 1 line
1.7.1
PATCH v3 4/4 dts: Add cpufreq controller node for Exynos5440 SoC
In reply to Amit Daniel KachhapAdd cpufreq controller device node for Exynos5440 SoC for passing parameters like controller base address, interrupt and cpufreq table. This node is added outside cpu0 as this driver is now a platform driver and a new device structure is needed.
---
Changes in V3:
* Moved the DT node outside cpu0 node as the driver is now a platform driver.
arch/arm/boot/dts/exynos5440.dtsi | 12 ++++++++++++ arch/arm/mach-exynos/mach-exynos5-dt.c | 2 ++ 2 files changed, 14 insertions(+), 0 deletions(-)
arch/arm/boot/dts/exynos5440.dtsi +12 -0
@@ -63,6 +63,18 @@ }; + cpufreq@160000 { + compatible = "samsung,exynos5440-cpufreq"; + reg = <0x160000 0x1000>; + interrupts = <0 57 0>; + operating-points = < + /* KHZ uV */ + 1200000 1025000 + 1000000 975000 + 800000 925000 + >; + }; + serial@B0000 { compatible = "samsung,exynos4210-uart"; reg = <0xB0000 0x1000>;
arch/arm/mach-exynos/mach-exynos5-dt.c +2 -0
@@ -145,6 +145,8 @@ static const struct of_dev_auxdata exynos5250_auxdata_lookup[] __initconst = {static const struct of_dev_auxdata exynos5440_auxdata_lookup[]__initconst = {OF_DEV_AUXDATA ("samsung,exynos4210-uart" ,EXYNOS5440_PA_UART0 ,"exynos4210-uart.0" ,NULL ), +OF_DEV_AUXDATA ("samsung,exynos5440-cpufreq" ,0x160000 , +"exynos5440-cpufreq" ,NULL ), {}, };
Signature · 1 line
1.7.1
Quoted 1 line · Amit Daniel Kachhap
+/* Register definations */
s/definations/definitions
drivers/cpufreq/exynos5440-cpufreq.c line 37
Quoted 8 lines
drivers/cpufreq/exynos5440-cpufreq.c new file +8
-0+#define XMU_DVFS_CTRL 0x0060 +#define XMU_PMU_P0_7 0x0064 +#define XMU_C0_3_PSTATE 0x0090 +#define XMU_P_LIMIT 0x00A0 +#define XMU_P_STATUS 0x00A4 +#define XMU_PMUEVTEN 0x00D0 +#define XMU_PMUIRQEN 0x00D4 +#define XMU_PMUIRQ 0x00D8
Keeping all hex numbers lower case might be a good idea.
Quoted 16 lines
drivers/cpufreq/exynos5440-cpufreq.c new file +16
-0+ +/* PMU mask and shift definations */ +#define P_VALUE_MASK 0x7 + +#define XMU_DVFS_CTRL_EN_SHIFT 0 + +#define P0_7_CPUCLKDEV_SHIFT 21 +#define P0_7_CPUCLKDEV_MASK 0x7 +#define P0_7_ATBCLKDEV_SHIFT 18 +#define P0_7_ATBCLKDEV_MASK 0x7 +#define P0_7_CSCLKDEV_SHIFT 15 +#define P0_7_CSCLKDEV_MASK 0x7 +#define P0_7_CPUEMA_SHIFT 28 +#define P0_7_CPUEMA_MASK 0xf +#define P0_7_L2EMA_SHIFT 24 +#define P0_7_L2EMA_MASK 0xf
...
Quoted 14 lines
drivers/cpufreq/exynos5440-cpufreq.c new file +14
-0+static int exynos_cpufreq_probe (struct platform_device *pdev) +{ +int ret = -EINVAL ; +struct device_node *np; +struct resource res; + + np =of_find_compatible_node (NULL ,NULL ,"samsung,exynos5440-cpufreq" ); +if (!np) +return -ENODEV ; + + dvfs_info =devm_kzalloc (&pdev->dev,sizeof (*dvfs_info),GFP_KERNEL ); +if (!dvfs_info) { + ret = -ENOMEM ; + goto err_put_node;
drivers/cpufreq/exynos5440-cpufreq.c line 367
Quoted 10 lines
drivers/cpufreq/exynos5440-cpufreq.c new file +10
-0+ } + + dvfs_info->dev = &pdev->dev; + dvfs_info->dev->of_node = np; + + ret =of_address_to_resource (np,0 , &res); +if (ret) + goto err_put_node; + + dvfs_info->base = devm_ioremap(dvfs_info->dev, res.start,
There is a devm_ioremap_resource() function that has been introduced recently. It could simplify this code a bit and is preferred over devm_ioremap().
drivers/cpufreq/exynos5440-cpufreq.c line 377
Quoted 10 lines
drivers/cpufreq/exynos5440-cpufreq.c new file +10
-0+ resource_size(&res)); +if (!dvfs_info->base) { +pr_err ("No cpufreq memory map found\n" ); + ret = -ENODEV ; + goto err_put_node; + } + + dvfs_info->irq =irq_of_parse_and_map (np,0 ); +if (dvfs_info->irq ==0 ) { +pr_err ("No cpufreq irq found\n" );
Wouldn't dev_err() be more appropriate here ?
Quoted 13 lines
drivers/cpufreq/exynos5440-cpufreq.c new file +13
-0+ ret = -ENODEV ; + goto err_put_node; + } + + ret =of_init_opp_table (dvfs_info->dev); +if (ret) { +pr_err ("failed to init OPP table: %d\n" , ret); + goto err_put_node; + } + + ret =opp_init_cpufreq_table (dvfs_info->dev, &dvfs_info->freq_table); +if (ret) { +pr_err ("failed to init cpufreq table: %d\n" , ret);
drivers/cpufreq/exynos5440-cpufreq.c line 400
Quoted 10 lines
drivers/cpufreq/exynos5440-cpufreq.c new file +10
-0+ goto err_put_node; + } + dvfs_info->freq_count =opp_get_opp_count (dvfs_info->dev); +exynos_sort_descend_freq_table (); + +if (of_property_read_u32 (np,"clock-latency" , &dvfs_info->latency)) + dvfs_info->latency =DEF_TRANS_LATENCY ; + + dvfs_info->cpu_clk =devm_clk_get (dvfs_info->dev,"armclk" ); +if (IS_ERR_OR_NULL (dvfs_info->cpu_clk)) {
devm_clk_get() return value needs to be checked with IS_ERR(), not IS_ERR_OR_NULL().
Quoted 27 lines
drivers/cpufreq/exynos5440-cpufreq.c new file +27
-0+pr_err ("Failed to get cpu clock\n" ); + ret =PTR_ERR (dvfs_info->cpu_clk); + goto err_free_table; + } + + dvfs_info->cur_frequency =clk_get_rate (dvfs_info->cpu_clk); +if (!dvfs_info->cur_frequency) { +pr_err ("Failed to get clock rate\n" ); + ret = -EINVAL ; + goto err_free_table; + } + dvfs_info->cur_frequency /=1000 ; + +INIT_WORK (&dvfs_info->irq_work, exynos_cpufreq_work); +if (devm_request_irq (dvfs_info->dev, dvfs_info->irq, exynos_cpufreq_irq, +IRQF_TRIGGER_NONE ,CPUFREQ_NAME , dvfs_info)) { +pr_err ("Failed to register IRQ\n" ); + ret = -ENODEV ; + goto err_free_table; + } + + ret =init_div_table (); +if (ret) { +pr_err ("Failed to initialise div table\n" ); + goto err_free_table; + } +
drivers/cpufreq/exynos5440-cpufreq.c line 437
Quoted 10 lines
drivers/cpufreq/exynos5440-cpufreq.c new file +10
-0+exynos_enable_dvfs (); + ret =cpufreq_register_driver (&exynos_driver); +if (ret) { +pr_err ("%s: failed to register cpufreq driver\n" , __func__); + goto err_free_table; + } + +of_node_put (np); + dvfs_info->dvfs_enable = true; +pr_info ("exynos5440 DVFS initialized.\n" );
dev_info() ?
drivers/cpufreq/exynos5440-cpufreq.c line 444
Quoted 7 lines
drivers/cpufreq/exynos5440-cpufreq.c new file +7
-0+return 0 ; + +err_free_table: +opp_free_cpufreq_table (dvfs_info->dev, &dvfs_info->freq_table); +err_put_node: +of_node_put (np); +pr_err ("%s: failed initialization\n" , __func__);
Is this really needed ? This failure will be logged by the driver core anyway.
Quoted 2 lines
(quoted diff) +2
-0+ return ret; +
Quoted 10 lines · Sylwester Nawrocki
drivers/cpufreq/exynos5440-cpufreq.c line 400
Quoted 2 lines · Amit Daniel Kachhap
drivers/cpufreq/exynos5440-cpufreq.c new file +2
-0+ dvfs_info->cpu_clk =devm_clk_get (dvfs_info->dev,"armclk" ); +if (IS_ERR_OR_NULL (dvfs_info->cpu_clk)) {
devm_clk_get()return value needs to be checked withIS_ERR(), notIS_ERR_OR_NULL().drivers/cpufreq/exynos5440-cpufreq.c line 403
Quoted 3 lines
drivers/cpufreq/exynos5440-cpufreq.c new file +3
-0+pr_err ("Failed to get cpu clock\n" ); + ret =PTR_ERR (dvfs_info->cpu_clk); + goto err_free_table;
Amit, to illustrate why this is wrong, consider this:
1. Set cpu_clk to NULL.
2. Realise IS_ERR_OR_NULL(NULL) is true.
3. What is the value of PTR_ERR(NULL) ?
4. What effect does that have when you jump to err_free_table ?
5. What value is returned from this function in that case ?
6. What does that return value mean to the driver core ?
Viresh Kumar
maintainerdrivers/cpufreq/exynos5440-cpufreq.c line 110
Quoted 12 lines · Amit Daniel Kachhap
drivers/cpufreq/exynos5440-cpufreq.c +11
-0+struct exynos_dvfs_data { +void __iomem *base; +struct resource *mem; +int irq; +struct clk *cpu_clk; +unsigned int cur_frequency; +unsigned int latency; +struct cpufreq_frequency_table *freq_table; +unsigned int freq_count; +struct device *dev; +bool dvfs_enable;
s/enable/enabled?
drivers/cpufreq/exynos5440-cpufreq.c line 400
Quoted 4 lines
drivers/cpufreq/exynos5440-cpufreq.c +3
-0+static int exynos_cpufreq_probe (struct platform_device *pdev) + dvfs_info->cpu_clk = devm_clk_get(dvfs_info->dev, "armclk"); +if (IS_ERR_OR_NULL (dvfs_info->cpu_clk)) {
s/IS_ERR_OR_NULL/IS_ERR
drivers/cpufreq/exynos5440-cpufreq.c line 418
Quoted 4 lines
drivers/cpufreq/exynos5440-cpufreq.c +4
-0+if (devm_request_irq (dvfs_info->dev, dvfs_info->irq, exynos_cpufreq_irq, +IRQF_TRIGGER_NONE ,CPUFREQ_NAME , dvfs_info)) { +pr_err ("Failed to register IRQ\n" ); + ret = -ENODEV ;
use the value returned from this function rather than creating your own.. true for all
other calls too, unless they return NULL on error.
Quoted 1 line
+}
Hi Sylwester,
Thanks for the review. Will update with your suggestion in the next version,
Thanks,
Amit D
Quoted 4 lines · Sylwester Nawrocki
Quoted 1 line · Amit Daniel Kachhap
+/* Register definations */
s/definations/definitions
ok
Quoted 11 lines
drivers/cpufreq/exynos5440-cpufreq.c line 37
Quoted 9 lines
drivers/cpufreq/exynos5440-cpufreq.c new file +8
-0+#define XMU_DVFS_CTRL 0x0060 +#define XMU_PMU_P0_7 0x0064 +#define XMU_C0_3_PSTATE 0x0090 +#define XMU_P_LIMIT 0x00A0 +#define XMU_P_STATUS 0x00A4 +#define XMU_PMUEVTEN 0x00D0 +#define XMU_PMUIRQEN 0x00D4 +#define XMU_PMUIRQ 0x00D8Keeping all hex numbers lower case might be a good idea.
Ok
Quoted 38 lines
Quoted 17 lines
drivers/cpufreq/exynos5440-cpufreq.c new file +16
-0+ +/* PMU mask and shift definations */ +#define P_VALUE_MASK 0x7 + +#define XMU_DVFS_CTRL_EN_SHIFT 0 + +#define P0_7_CPUCLKDEV_SHIFT 21 +#define P0_7_CPUCLKDEV_MASK 0x7 +#define P0_7_ATBCLKDEV_SHIFT 18 +#define P0_7_ATBCLKDEV_MASK 0x7 +#define P0_7_CSCLKDEV_SHIFT 15 +#define P0_7_CSCLKDEV_MASK 0x7 +#define P0_7_CPUEMA_SHIFT 28 +#define P0_7_CPUEMA_MASK 0xf +#define P0_7_L2EMA_SHIFT 24 +#define P0_7_L2EMA_MASK 0xf...
Quoted 20 lines
drivers/cpufreq/exynos5440-cpufreq.c new file +20
-0+static int exynos_cpufreq_probe (struct platform_device *pdev) +{ +int ret = -EINVAL ; +struct device_node *np; +struct resource res; + + np =of_find_compatible_node (NULL ,NULL ,"samsung,exynos5440-cpufreq" ); +if (!np) +return -ENODEV ; + + dvfs_info =devm_kzalloc (&pdev->dev,sizeof (*dvfs_info),GFP_KERNEL ); +if (!dvfs_info) { + ret = -ENOMEM ; + goto err_put_node; + } + + dvfs_info->dev = &pdev->dev; + dvfs_info->dev->of_node = np; + + ret =of_address_to_resource (np,0 , &res);
Quoted 8 lines
drivers/cpufreq/exynos5440-cpufreq.c line 367
Quoted 4 lines
drivers/cpufreq/exynos5440-cpufreq.c new file +4
-0+if (ret) + goto err_put_node; + + dvfs_info->base = devm_ioremap(dvfs_info->dev, res.start,There is a
devm_ioremap_resource()function that has been introduced recently. It could simplify this code a bit and is preferred overdevm_ioremap().
yes right. I somehow missed this api.
Quoted 12 lines
drivers/cpufreq/exynos5440-cpufreq.c line 377
Quoted 11 lines
drivers/cpufreq/exynos5440-cpufreq.c new file +10
-0+ resource_size(&res)); +if (!dvfs_info->base) { +pr_err ("No cpufreq memory map found\n" ); + ret = -ENODEV ; + goto err_put_node; + } + + dvfs_info->irq =irq_of_parse_and_map (np,0 ); +if (dvfs_info->irq ==0 ) { +pr_err ("No cpufreq irq found\n" );
Quoted 1 line
Wouldn't
dev_err()be more appropriate here ?
Ok
Quoted 19 lines
Quoted 19 lines
drivers/cpufreq/exynos5440-cpufreq.c new file +18
-0+ ret = -ENODEV ; + goto err_put_node; + } + + ret =of_init_opp_table (dvfs_info->dev); +if (ret) { +pr_err ("failed to init OPP table: %d\n" , ret); + goto err_put_node; + } + + ret =opp_init_cpufreq_table (dvfs_info->dev, &dvfs_info->freq_table); +if (ret) { +pr_err ("failed to init cpufreq table: %d\n" , ret); + goto err_put_node; + } + dvfs_info->freq_count =opp_get_opp_count (dvfs_info->dev); +exynos_sort_descend_freq_table (); +
Quoted 8 lines
drivers/cpufreq/exynos5440-cpufreq.c line 400
Quoted 5 lines
drivers/cpufreq/exynos5440-cpufreq.c new file +5
-0+if (of_property_read_u32 (np,"clock-latency" , &dvfs_info->latency)) + dvfs_info->latency =DEF_TRANS_LATENCY ; + + dvfs_info->cpu_clk =devm_clk_get (dvfs_info->dev,"armclk" ); +if (IS_ERR_OR_NULL (dvfs_info->cpu_clk)) {
devm_clk_get()return value needs to be checked withIS_ERR(), notIS_ERR_OR_NULL().
ok
Quoted 58 lines
Quoted 28 lines
drivers/cpufreq/exynos5440-cpufreq.c new file +27
-0+pr_err ("Failed to get cpu clock\n" ); + ret =PTR_ERR (dvfs_info->cpu_clk); + goto err_free_table; + } + + dvfs_info->cur_frequency =clk_get_rate (dvfs_info->cpu_clk); +if (!dvfs_info->cur_frequency) { +pr_err ("Failed to get clock rate\n" ); + ret = -EINVAL ; + goto err_free_table; + } + dvfs_info->cur_frequency /=1000 ; + +INIT_WORK (&dvfs_info->irq_work, exynos_cpufreq_work); +if (devm_request_irq (dvfs_info->dev, dvfs_info->irq, exynos_cpufreq_irq, +IRQF_TRIGGER_NONE ,CPUFREQ_NAME , dvfs_info)) { +pr_err ("Failed to register IRQ\n" ); + ret = -ENODEV ; + goto err_free_table; + } + + ret =init_div_table (); +if (ret) { +pr_err ("Failed to initialise div table\n" ); + goto err_free_table; + } +drivers/cpufreq/exynos5440-cpufreq.c line 437
Quoted 10 lines
drivers/cpufreq/exynos5440-cpufreq.c new file +10
-0+exynos_enable_dvfs (); + ret =cpufreq_register_driver (&exynos_driver); +if (ret) { +pr_err ("%s: failed to register cpufreq driver\n" , __func__); + goto err_free_table; + } + +of_node_put (np); + dvfs_info->dvfs_enable = true; +pr_info ("exynos5440 DVFS initialized.\n" );
dev_info()?drivers/cpufreq/exynos5440-cpufreq.c line 444
Quoted 7 lines
drivers/cpufreq/exynos5440-cpufreq.c new file +7
-0+return 0 ; + +err_free_table: +opp_free_cpufreq_table (dvfs_info->dev, &dvfs_info->freq_table); +err_put_node: +of_node_put (np); +pr_err ("%s: failed initialization\n" , __func__);Is this really needed ? This failure will be logged by the driver core anyway.
Review
Quoted 2 lines
(quoted diff) +2
-0+ return ret; +--
To unsubscribe from this list: send the line "unsubscribe linux-samsung-soc" in the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html
Hi Russell,
Quoted 12 lines · Russell King - ARM Linux
Quoted 10 lines · Sylwester Nawrocki
drivers/cpufreq/exynos5440-cpufreq.c line 400
Quoted 2 lines · Amit Daniel Kachhap
drivers/cpufreq/exynos5440-cpufreq.c new file +2
-0+ dvfs_info->cpu_clk =devm_clk_get (dvfs_info->dev,"armclk" ); +if (IS_ERR_OR_NULL (dvfs_info->cpu_clk)) {
devm_clk_get()return value needs to be checked withIS_ERR(), notIS_ERR_OR_NULL().Quoted 3 lines
drivers/cpufreq/exynos5440-cpufreq.c new file +3
-0+pr_err ("Failed to get cpu clock\n" ); + ret =PTR_ERR (dvfs_info->cpu_clk); + goto err_free_table;
Quoted 7 lines
Amit, to illustrate why this is wrong, consider this:
1. Setcpu_clkto NULL.
2. RealiseIS_ERR_OR_NULL(NULL)is true.
3. What is the value ofPTR_ERR(NULL)?
4. What effect does that have when you jump toerr_free_table?
5. What value is returned from this function in that case ?
6. What does that return value mean to the driver core ?
Thanks for the detailed explaination. Usage of IS_ERR_OR_NULL is not suitable here.
Thanks,
Amit D
Quoted 5 lines
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/
Hi Viresh,
Quoted 15 lines · Viresh Kumar
drivers/cpufreq/exynos5440-cpufreq.c line 110
Quoted 12 lines · Amit Daniel Kachhap
drivers/cpufreq/exynos5440-cpufreq.c +11
-0+struct exynos_dvfs_data { +void __iomem *base; +struct resource *mem; +int irq; +struct clk *cpu_clk; +unsigned int cur_frequency; +unsigned int latency; +struct cpufreq_frequency_table *freq_table; +unsigned int freq_count; +struct device *dev; +bool dvfs_enable;s/enable/enabled?
Ok
Quoted 7 lines
drivers/cpufreq/exynos5440-cpufreq.c line 400
Quoted 5 lines
drivers/cpufreq/exynos5440-cpufreq.c +3
-0+static int exynos_cpufreq_probe (struct platform_device *pdev) + dvfs_info->cpu_clk = devm_clk_get(dvfs_info->dev, "armclk"); +if (IS_ERR_OR_NULL (dvfs_info->cpu_clk)) {s/IS_ERR_OR_NULL/IS_ERR
Ok.
Quoted 10 lines
drivers/cpufreq/exynos5440-cpufreq.c line 418
Quoted 5 lines
drivers/cpufreq/exynos5440-cpufreq.c +4
-0+if (devm_request_irq (dvfs_info->dev, dvfs_info->irq, exynos_cpufreq_irq, +IRQF_TRIGGER_NONE ,CPUFREQ_NAME , dvfs_info)) { +pr_err ("Failed to register IRQ\n" ); + ret = -ENODEV ;use the value returned from this function rather than creating your own.. true for all
other calls too, unless they return NULL on error.
Will integrate your suggestions in the next version.
Thanks,
Amit D
Quoted 5 lines
Quoted 1 line
+}
--
To unsubscribe from this list: send the line "unsubscribe linux-samsung-soc" in the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html