cpufreq: kryo: Add module remove and exit
Subsystems (2)
PATCH 1/1 cpufreq: kryo: Add module remove and exit
From: Ilia Lin <[email protected]>
Add device remove and module exit code to make the driver functioning as a loadable module.
--- drivers/cpufreq/qcom-cpufreq-kryo.c | 24 +++++++++++++++++++++--- 1 file changed, 21 insertions(+), 3 deletions(-)
drivers/cpufreq/qcom-cpufreq-kryo.c +21 -3
@@ -71,10 +71,10 @@ static enum _msm8996_version __init qcom_cpufreq_kryo_get_msm_id(void)return version; } +struct platform_device *cpufreq_dt_pdev;static int qcom_cpufreq_kryo_probe (struct platform_device *pdev) {struct opp_table *opp_tables[NR_CPUS ] = {0 }; -struct platform_device *cpufreq_dt_pdev;enum _msm8996_version msm8996_version;struct nvmem_cell *speedbin_nvmem;struct device_node *np;
@@ -115,6 +115,8 @@ static int qcom_cpufreq_kryo_probe(struct platform_device *pdev) speedbin =nvmem_cell_read (speedbin_nvmem, &len);nvmem_cell_put (speedbin_nvmem); +if (IS_ERR (speedbin)) +return PTR_ERR (speedbin);switch (msm8996_version) {case MSM8996_V3 :
@@ -162,8 +164,15 @@ static int qcom_cpufreq_kryo_probe(struct platform_device *pdev)return ret; } +static int qcom_cpufreq_kryo_remove (struct platform_device *pdev) +{ +platform_device_unregister (cpufreq_dt_pdev); +return 0 ; +} +static struct platform_driver qcom_cpufreq_kryo_driver = { .probe = qcom_cpufreq_kryo_probe, + .remove = qcom_cpufreq_kryo_remove, .driver = { .name ="qcom-cpufreq-kryo" , },
@@ -174,6 +183,7 @@ static const struct of_device_id qcom_cpufreq_kryo_match_list[] __initconst = { { .compatible = "qcom,msm8996", }, }; +struct platform_device *kryo_cpufreq_pdev;/* * Since the driver depends on smem and nvmem drivers, which may * return EPROBE_DEFER, all the real activity is done in the probe,
@@ -198,8 +208,9 @@ static int __init qcom_cpufreq_kryo_init(void)if (unlikely (ret <0 ))return ret; - ret =PTR_ERR_OR_ZERO (platform_device_register_simple ( -"qcom-cpufreq-kryo" ,-1 ,NULL ,0 )); + kryo_cpufreq_pdev =platform_device_register_simple ( +"qcom-cpufreq-kryo" ,-1 ,NULL ,0 ); + ret =PTR_ERR_OR_ZERO (kryo_cpufreq_pdev);if (0 == ret)return 0 ;
@@ -208,5 +219,12 @@ static int __init qcom_cpufreq_kryo_init(void) }module_init (qcom_cpufreq_kryo_init); +static void __init qcom_cpufreq_kryo_exit (void ) +{ +platform_device_unregister (kryo_cpufreq_pdev); +platform_driver_unregister (&qcom_cpufreq_kryo_driver); +} +module_exit (qcom_cpufreq_kryo_exit); +MODULE_DESCRIPTION ("Qualcomm Technologies, Inc. Kryo CPUfreq driver" );MODULE_LICENSE ("GPL v2" );
Signature · 1 line
2.11.0
Viresh Kumar
maintainerQuoted 16 lines · On 07-06-18, 20:58, [email protected] wrote:
From: Ilia Lin <[email protected]>
Add device remove and module exit code to make the driver functioning as a loadable module.
Fixes ac28927659be (cpufreq: kryo: allow building as a loadable module)Signed-off-by Ilia Lin <[email protected]>--- drivers/cpufreq/qcom-cpufreq-kryo.c | 24 +++++++++++++++++++++--- 1 file changed, 21 insertions(+), 3 deletions(-)drivers/cpufreq/qcom-cpufreq-kryo.c +0
-0
drivers/cpufreq/qcom-cpufreq-kryo.c static enum _msm8996_version __init qcom_cpufreq_kryo_get_msm_id(void) · line 74
Quoted 4 lines
drivers/cpufreq/qcom-cpufreq-kryo.c +1
-0@@ -71,10 +71,10 @@ static enum _msm8996_version __init qcom_cpufreq_kryo_get_msm_id(void)return version; } +struct platform_device *cpufreq_dt_pdev;
Move this and the other platform device pointer at the top of the file after the enum declarations. They don't look nice in the middle of nowhere.
drivers/cpufreq/qcom-cpufreq-kryo.c static int qcom_cpufreq_kryo_probe(struct platform_device *pdev) · line 119
Quoted 13 lines
drivers/cpufreq/qcom-cpufreq-kryo.c +2
-1static int qcom_cpufreq_kryo_probe (struct platform_device *pdev) {struct opp_table *opp_tables[NR_CPUS ] = {0 }; -struct platform_device *cpufreq_dt_pdev;enum _msm8996_version msm8996_version;struct nvmem_cell *speedbin_nvmem;struct device_node *np;@@ -115,6 +115,8 @@ static int qcom_cpufreq_kryo_probe(struct platform_device *pdev) speedbin =nvmem_cell_read (speedbin_nvmem, &len);nvmem_cell_put (speedbin_nvmem); +if (IS_ERR (speedbin)) +return PTR_ERR (speedbin);
This doesn't look related to this patch. Should it be a different commit ?
And I just saw definition of nvmem_cell_read() and it says the returned buffer must be freed by caller using kfree(). I dont' see you doing that. Please also check if any other such resources are there which you forgot to free.
Quoted 52 lines
drivers/cpufreq/qcom-cpufreq-kryo.c +18
-2switch (msm8996_version) {case MSM8996_V3 :@@ -162,8 +164,15 @@ static int qcom_cpufreq_kryo_probe(struct platform_device *pdev)return ret; } +static int qcom_cpufreq_kryo_remove (struct platform_device *pdev) +{ +platform_device_unregister (cpufreq_dt_pdev); +return 0 ; +} +static struct platform_driver qcom_cpufreq_kryo_driver = { .probe = qcom_cpufreq_kryo_probe, + .remove = qcom_cpufreq_kryo_remove, .driver = { .name ="qcom-cpufreq-kryo" , },@@ -174,6 +183,7 @@ static const struct of_device_id qcom_cpufreq_kryo_match_list[] __initconst = { { .compatible = "qcom,msm8996", }, }; +struct platform_device *kryo_cpufreq_pdev;/* * Since the driver depends on smem and nvmem drivers, which may * return EPROBE_DEFER, all the real activity is done in the probe, @@ -198,8 +208,9 @@ static int __init qcom_cpufreq_kryo_init(void)if (unlikely (ret <0 ))return ret; - ret =PTR_ERR_OR_ZERO (platform_device_register_simple ( -"qcom-cpufreq-kryo" ,-1 ,NULL ,0 )); + kryo_cpufreq_pdev =platform_device_register_simple ( +"qcom-cpufreq-kryo" ,-1 ,NULL ,0 ); + ret =PTR_ERR_OR_ZERO (kryo_cpufreq_pdev);if (0 == ret)return 0 ;@@ -208,5 +219,12 @@ static int __init qcom_cpufreq_kryo_init(void) }module_init (qcom_cpufreq_kryo_init); +static void __init qcom_cpufreq_kryo_exit (void ) +{ +platform_device_unregister (kryo_cpufreq_pdev); +platform_driver_unregister (&qcom_cpufreq_kryo_driver); +} +module_exit (qcom_cpufreq_kryo_exit); +MODULE_DESCRIPTION ("Qualcomm Technologies, Inc. Kryo CPUfreq driver" );MODULE_LICENSE ("GPL v2" );
Signature · 1 line
viresh
PATCH v2 1/1 cpufreq: kryo: Add module remove and exit
In reply to [email protected]From: Ilia Lin <[email protected]>
Add device remove and module exit code to make the driver functioning as a loadable module.
--- drivers/cpufreq/qcom-cpufreq-kryo.c | 23 ++++++++++++++++++++--- 1 file changed, 20 insertions(+), 3 deletions(-)
drivers/cpufreq/qcom-cpufreq-kryo.c +20 -3
@@ -42,6 +42,8 @@ enum _msm8996_version { NUM_OF_MSM8996_VERSIONS, }; +struct platform_device *cpufreq_dt_pdev, *kryo_cpufreq_pdev; +static enum _msm8996_version __init qcom_cpufreq_kryo_get_msm_id (void ) {size_t len;
@@ -74,7 +76,6 @@ static enum _msm8996_version __init qcom_cpufreq_kryo_get_msm_id(void)static int qcom_cpufreq_kryo_probe (struct platform_device *pdev) {struct opp_table *opp_tables[NR_CPUS ] = {0 }; -struct platform_device *cpufreq_dt_pdev;enum _msm8996_version msm8996_version;struct nvmem_cell *speedbin_nvmem;struct device_node *np;
@@ -129,6 +130,7 @@ static int qcom_cpufreq_kryo_probe(struct platform_device *pdev)BUG ();break ; } +kfree (speedbin);for_each_possible_cpu (cpu) { cpu_dev =get_cpu_device (cpu);
@@ -164,8 +166,15 @@ static int qcom_cpufreq_kryo_probe(struct platform_device *pdev)return ret; } +static int qcom_cpufreq_kryo_remove (struct platform_device *pdev) +{ +platform_device_unregister (cpufreq_dt_pdev); +return 0 ; +} +static struct platform_driver qcom_cpufreq_kryo_driver = { .probe = qcom_cpufreq_kryo_probe, + .remove = qcom_cpufreq_kryo_remove, .driver = { .name ="qcom-cpufreq-kryo" , },
@@ -200,8 +209,9 @@ static int __init qcom_cpufreq_kryo_init(void)if (unlikely (ret <0 ))return ret; - ret =PTR_ERR_OR_ZERO (platform_device_register_simple ( -"qcom-cpufreq-kryo" ,-1 ,NULL ,0 )); + kryo_cpufreq_pdev =platform_device_register_simple ( +"qcom-cpufreq-kryo" ,-1 ,NULL ,0 ); + ret =PTR_ERR_OR_ZERO (kryo_cpufreq_pdev);if (0 == ret)return 0 ;
@@ -210,5 +220,12 @@ static int __init qcom_cpufreq_kryo_init(void) }module_init (qcom_cpufreq_kryo_init); +static void __init qcom_cpufreq_kryo_exit (void ) +{ +platform_device_unregister (kryo_cpufreq_pdev); +platform_driver_unregister (&qcom_cpufreq_kryo_driver); +} +module_exit (qcom_cpufreq_kryo_exit); +MODULE_DESCRIPTION ("Qualcomm Technologies, Inc. Kryo CPUfreq driver" );MODULE_LICENSE ("GPL v2" );
Signature · 1 line
2.11.0
Viresh Kumar
maintainerQuoted 33 lines · On 14-06-18, 22:42, [email protected] wrote:
From: Ilia Lin <[email protected]>
Add device remove and module exit code to make the driver functioning as a loadable module.
Fixes ac28927659be (cpufreq: kryo: allow building as a loadable module)Signed-off-by Ilia Lin <[email protected]>--- drivers/cpufreq/qcom-cpufreq-kryo.c | 23 ++++++++++++++++++++--- 1 file changed, 20 insertions(+), 3 deletions(-)drivers/cpufreq/qcom-cpufreq-kryo.c +2
-1@@ -42,6 +42,8 @@ enum _msm8996_version { NUM_OF_MSM8996_VERSIONS, }; +struct platform_device *cpufreq_dt_pdev, *kryo_cpufreq_pdev; +static enum _msm8996_version __init qcom_cpufreq_kryo_get_msm_id (void ) {size_t len;@@ -74,7 +76,6 @@ static enum _msm8996_version __init qcom_cpufreq_kryo_get_msm_id(void)static int qcom_cpufreq_kryo_probe (struct platform_device *pdev) {struct opp_table *opp_tables[NR_CPUS ] = {0 }; -struct platform_device *cpufreq_dt_pdev;enum _msm8996_version msm8996_version;struct nvmem_cell *speedbin_nvmem;struct device_node *np;
drivers/cpufreq/qcom-cpufreq-kryo.c static int qcom_cpufreq_kryo_probe(struct platform_device *pdev) · line 133
Quoted 4 lines
drivers/cpufreq/qcom-cpufreq-kryo.c +1
-0@@ -129,6 +130,7 @@ static int qcom_cpufreq_kryo_probe(struct platform_device *pdev)BUG ();break ; } +kfree (speedbin);
Again, stuff like this can't go in this patch itself. It is a separate bug fix and you should send it with a matching fixes tag separately.
Quoted 46 lines
drivers/cpufreq/qcom-cpufreq-kryo.c +17
-2for_each_possible_cpu (cpu) { cpu_dev =get_cpu_device (cpu);@@ -164,8 +166,15 @@ static int qcom_cpufreq_kryo_probe(struct platform_device *pdev)return ret; } +static int qcom_cpufreq_kryo_remove (struct platform_device *pdev) +{ +platform_device_unregister (cpufreq_dt_pdev); +return 0 ; +} +static struct platform_driver qcom_cpufreq_kryo_driver = { .probe = qcom_cpufreq_kryo_probe, + .remove = qcom_cpufreq_kryo_remove, .driver = { .name ="qcom-cpufreq-kryo" , },@@ -200,8 +209,9 @@ static int __init qcom_cpufreq_kryo_init(void)if (unlikely (ret <0 ))return ret; - ret =PTR_ERR_OR_ZERO (platform_device_register_simple ( -"qcom-cpufreq-kryo" ,-1 ,NULL ,0 )); + kryo_cpufreq_pdev =platform_device_register_simple ( +"qcom-cpufreq-kryo" ,-1 ,NULL ,0 ); + ret =PTR_ERR_OR_ZERO (kryo_cpufreq_pdev);if (0 == ret)return 0 ;@@ -210,5 +220,12 @@ static int __init qcom_cpufreq_kryo_init(void) }module_init (qcom_cpufreq_kryo_init); +static void __init qcom_cpufreq_kryo_exit (void ) +{ +platform_device_unregister (kryo_cpufreq_pdev); +platform_driver_unregister (&qcom_cpufreq_kryo_driver); +} +module_exit (qcom_cpufreq_kryo_exit); +MODULE_DESCRIPTION ("Qualcomm Technologies, Inc. Kryo CPUfreq driver" );MODULE_LICENSE ("GPL v2" );Signature · 1 line
2.11.0
Signature · 1 line
viresh
PATCH v3 1/1 cpufreq: kryo: Add module remove and exit
In reply to [email protected]From: Ilia Lin <[email protected]>
Add device remove and module exit code to make the driver functioning as a loadable module.
--- drivers/cpufreq/qcom-cpufreq-kryo.c | 22 +++++++++++++++++++--- 1 file changed, 19 insertions(+), 3 deletions(-)
drivers/cpufreq/qcom-cpufreq-kryo.c +19 -3
@@ -42,6 +42,8 @@ enum _msm8996_version { NUM_OF_MSM8996_VERSIONS, }; +struct platform_device *cpufreq_dt_pdev, *kryo_cpufreq_pdev; +static enum _msm8996_version __init qcom_cpufreq_kryo_get_msm_id (void ) {size_t len;
@@ -74,7 +76,6 @@ static enum _msm8996_version __init qcom_cpufreq_kryo_get_msm_id(void)static int qcom_cpufreq_kryo_probe (struct platform_device *pdev) {struct opp_table *opp_tables[NR_CPUS ] = {0 }; -struct platform_device *cpufreq_dt_pdev;enum _msm8996_version msm8996_version;struct nvmem_cell *speedbin_nvmem;struct device_node *np;
@@ -165,8 +166,15 @@ static int qcom_cpufreq_kryo_probe(struct platform_device *pdev)return ret; } +static int qcom_cpufreq_kryo_remove (struct platform_device *pdev) +{ +platform_device_unregister (cpufreq_dt_pdev); +return 0 ; +} +static struct platform_driver qcom_cpufreq_kryo_driver = { .probe = qcom_cpufreq_kryo_probe, + .remove = qcom_cpufreq_kryo_remove, .driver = { .name ="qcom-cpufreq-kryo" , },
@@ -201,8 +209,9 @@ static int __init qcom_cpufreq_kryo_init(void)if (unlikely (ret <0 ))return ret; - ret =PTR_ERR_OR_ZERO (platform_device_register_simple ( -"qcom-cpufreq-kryo" ,-1 ,NULL ,0 )); + kryo_cpufreq_pdev =platform_device_register_simple ( +"qcom-cpufreq-kryo" ,-1 ,NULL ,0 ); + ret =PTR_ERR_OR_ZERO (kryo_cpufreq_pdev);if (0 == ret)return 0 ;
@@ -211,5 +220,12 @@ static int __init qcom_cpufreq_kryo_init(void) }module_init (qcom_cpufreq_kryo_init); +static void __init qcom_cpufreq_kryo_exit (void ) +{ +platform_device_unregister (kryo_cpufreq_pdev); +platform_driver_unregister (&qcom_cpufreq_kryo_driver); +} +module_exit (qcom_cpufreq_kryo_exit); +MODULE_DESCRIPTION ("Qualcomm Technologies, Inc. Kryo CPUfreq driver" );MODULE_LICENSE ("GPL v2" );
Signature · 1 line
2.11.0
Quoted 63 lines · On 17-06-18, 22:01, [email protected] wrote:
From: Ilia Lin <[email protected]>
Add device remove and module exit code to make the driver functioning as a loadable module.
Fixes ac28927659be (cpufreq: kryo: allow building as a loadable module)Signed-off-by Ilia Lin <[email protected]>--- drivers/cpufreq/qcom-cpufreq-kryo.c | 22 +++++++++++++++++++--- 1 file changed, 19 insertions(+), 3 deletions(-)drivers/cpufreq/qcom-cpufreq-kryo.c +12
-3@@ -42,6 +42,8 @@ enum _msm8996_version { NUM_OF_MSM8996_VERSIONS, }; +struct platform_device *cpufreq_dt_pdev, *kryo_cpufreq_pdev; +static enum _msm8996_version __init qcom_cpufreq_kryo_get_msm_id (void ) {size_t len;@@ -74,7 +76,6 @@ static enum _msm8996_version __init qcom_cpufreq_kryo_get_msm_id(void)static int qcom_cpufreq_kryo_probe (struct platform_device *pdev) {struct opp_table *opp_tables[NR_CPUS ] = {0 }; -struct platform_device *cpufreq_dt_pdev;enum _msm8996_version msm8996_version;struct nvmem_cell *speedbin_nvmem;struct device_node *np;@@ -165,8 +166,15 @@ static int qcom_cpufreq_kryo_probe(struct platform_device *pdev)return ret; } +static int qcom_cpufreq_kryo_remove (struct platform_device *pdev) +{ +platform_device_unregister (cpufreq_dt_pdev); +return 0 ; +} +static struct platform_driver qcom_cpufreq_kryo_driver = { .probe = qcom_cpufreq_kryo_probe, + .remove = qcom_cpufreq_kryo_remove, .driver = { .name ="qcom-cpufreq-kryo" , },@@ -201,8 +209,9 @@ static int __init qcom_cpufreq_kryo_init(void)if (unlikely (ret <0 ))return ret; - ret =PTR_ERR_OR_ZERO (platform_device_register_simple ( -"qcom-cpufreq-kryo" ,-1 ,NULL ,0 )); + kryo_cpufreq_pdev =platform_device_register_simple ( +"qcom-cpufreq-kryo" ,-1 ,NULL ,0 ); + ret =PTR_ERR_OR_ZERO (kryo_cpufreq_pdev);if (0 == ret)return 0 ;@@ -211,5 +220,12 @@ static int __init qcom_cpufreq_kryo_init(void) }module_init (qcom_cpufreq_kryo_init);
drivers/cpufreq/qcom-cpufreq-kryo.c static int __init qcom_cpufreq_kryo_init(void) · line 231
Quoted 10 lines
drivers/cpufreq/qcom-cpufreq-kryo.c +7
-0+static void __init qcom_cpufreq_kryo_exit (void ) +{ +platform_device_unregister (kryo_cpufreq_pdev); +platform_driver_unregister (&qcom_cpufreq_kryo_driver); +} +module_exit (qcom_cpufreq_kryo_exit); +MODULE_DESCRIPTION ("Qualcomm Technologies, Inc. Kryo CPUfreq driver" );MODULE_LICENSE ("GPL v2" );
Signature · 1 line
viresh
Quoted 65 lines · CEST Viresh Kumar
Quoted 64 lines · On 17-06-18, 22:01, [email protected] wrote:
From: Ilia Lin <[email protected]>
Add device remove and module exit code to make the driver functioning as a loadable module.
Fixes ac28927659be (cpufreq: kryo: allow building as a loadable module)Signed-off-by Ilia Lin <[email protected]>--- drivers/cpufreq/qcom-cpufreq-kryo.c | 22 +++++++++++++++++++--- 1 file changed, 19 insertions(+), 3 deletions(-)drivers/cpufreq/qcom-cpufreq-kryo.c +12
-3@@ -42,6 +42,8 @@ enum _msm8996_version { NUM_OF_MSM8996_VERSIONS, }; +struct platform_device *cpufreq_dt_pdev, *kryo_cpufreq_pdev; +static enum _msm8996_version __init qcom_cpufreq_kryo_get_msm_id (void ) {size_t len;@@ -74,7 +76,6 @@ static enum _msm8996_version __init qcom_cpufreq_kryo_get_msm_id(void)static int qcom_cpufreq_kryo_probe (struct platform_device *pdev) {struct opp_table *opp_tables[NR_CPUS ] = {0 }; -struct platform_device *cpufreq_dt_pdev;enum _msm8996_version msm8996_version;struct nvmem_cell *speedbin_nvmem;struct device_node *np;@@ -165,8 +166,15 @@ static int qcom_cpufreq_kryo_probe(struct platform_device *pdev)return ret; } +static int qcom_cpufreq_kryo_remove (struct platform_device *pdev) +{ +platform_device_unregister (cpufreq_dt_pdev); +return 0 ; +} +static struct platform_driver qcom_cpufreq_kryo_driver = { .probe = qcom_cpufreq_kryo_probe, + .remove = qcom_cpufreq_kryo_remove, .driver = { .name ="qcom-cpufreq-kryo" , },@@ -201,8 +209,9 @@ static int __init qcom_cpufreq_kryo_init(void)if (unlikely (ret <0 ))return ret; - ret =PTR_ERR_OR_ZERO (platform_device_register_simple ( -"qcom-cpufreq-kryo" ,-1 ,NULL ,0 )); + kryo_cpufreq_pdev =platform_device_register_simple ( +"qcom-cpufreq-kryo" ,-1 ,NULL ,0 ); + ret =PTR_ERR_OR_ZERO (kryo_cpufreq_pdev);if (0 == ret)return 0 ;@@ -211,5 +220,12 @@ static int __init qcom_cpufreq_kryo_init(void) }module_init (qcom_cpufreq_kryo_init);
Quoted 11 lines
drivers/cpufreq/qcom-cpufreq-kryo.c static int __init qcom_cpufreq_kryo_init(void) · line 231
Quoted 9 lines
drivers/cpufreq/qcom-cpufreq-kryo.c +7
-0+static void __init qcom_cpufreq_kryo_exit (void ) +{ +platform_device_unregister (kryo_cpufreq_pdev); +platform_driver_unregister (&qcom_cpufreq_kryo_driver); +} +module_exit (qcom_cpufreq_kryo_exit); +MODULE_DESCRIPTION ("Qualcomm Technologies, Inc. Kryo CPUfreq driver" );MODULE_LICENSE ("GPL v2" );Acked-by Viresh Kumar <[email protected]>
Patch applied, thanks!