Message ID | 1519055046-2399-9-git-send-email-m.purski@samsung.com (mailing list archive) |
---|---|
State | Not Applicable |
Headers | show |
Hi Maciej, Thank you for the patch! Perhaps something to improve: [auto build test WARNING on linuxtv-media/master] [also build test WARNING on v4.16-rc2 next-20180219] [if your patch is applied to the wrong git tree, please drop us a note to help improve the system] url: https://github.com/0day-ci/linux/commits/Maciej-Purski/Use-clk-bulk-API-in-exynos5433-drivers/20180220-054431 base: git://linuxtv.org/media_tree.git master config: sparc64-allmodconfig (attached as .config) compiler: sparc64-linux-gnu-gcc (Debian 7.2.0-11) 7.2.0 reproduce: wget https://raw.githubusercontent.com/intel/lkp-tests/master/sbin/make.cross -O ~/bin/make.cross chmod +x ~/bin/make.cross # save the attached .config to linux build tree make.cross ARCH=sparc64 All warnings (new ones prefixed by >>): drivers/media/platform/s5p-mfc/s5p_mfc_pm.c: In function 's5p_mfc_init_pm': >> drivers/media/platform/s5p-mfc/s5p_mfc_pm.c:39:7: warning: passing argument 3 of 'devm_clk_bulk_alloc' discards 'const' qualifier from pointer target type [-Wdiscarded-qualifiers] pm->clk_names); ^~ In file included from drivers/media/platform/s5p-mfc/s5p_mfc_pm.c:13:0: include/linux/clk.h:654:37: note: expected 'const char **' but argument is of type 'const char * const*' static inline struct clk_bulk_data *devm_clk_bulk_alloc(struct device *dev, ^~~~~~~~~~~~~~~~~~~ vim +39 drivers/media/platform/s5p-mfc/s5p_mfc_pm.c 24 25 int s5p_mfc_init_pm(struct s5p_mfc_dev *dev) 26 { 27 int ret; 28 29 pm = &dev->pm; 30 p_dev = dev; 31 32 pm->num_clocks = dev->variant->num_clocks; 33 pm->clk_names = dev->variant->clk_names; 34 pm->device = &dev->plat_dev->dev; 35 pm->clock_gate = NULL; 36 37 /* clock control */ 38 pm->clocks = devm_clk_bulk_alloc(pm->device, pm->num_clocks, > 39 pm->clk_names); 40 if (IS_ERR(pm->clocks)) 41 return PTR_ERR(pm->clocks); 42 43 ret = devm_clk_bulk_get(pm->device, pm->num_clocks, pm->clocks); 44 if (ret < 0) 45 return ret; 46 47 if (dev->variant->use_clock_gating) 48 pm->clock_gate = pm->clocks[0].clk; 49 50 pm_runtime_enable(pm->device); 51 atomic_set(&clk_ref, 0); 52 return 0; 53 } 54 --- 0-DAY kernel test infrastructure Open Source Technology Center https://lists.01.org/pipermail/kbuild-all Intel Corporation
diff --git a/drivers/media/platform/s5p-mfc/s5p_mfc_common.h b/drivers/media/platform/s5p-mfc/s5p_mfc_common.h index 76119a8..da3f0b3 100644 --- a/drivers/media/platform/s5p-mfc/s5p_mfc_common.h +++ b/drivers/media/platform/s5p-mfc/s5p_mfc_common.h @@ -192,9 +192,9 @@ struct s5p_mfc_buf { * struct s5p_mfc_pm - power management data structure */ struct s5p_mfc_pm { - struct clk *clock_gate; - const char * const *clk_names; - struct clk *clocks[MFC_MAX_CLOCKS]; + struct clk *clock_gate; + const char * const *clk_names; + struct clk_bulk_data *clocks; int num_clocks; bool use_clock_gating; diff --git a/drivers/media/platform/s5p-mfc/s5p_mfc_pm.c b/drivers/media/platform/s5p-mfc/s5p_mfc_pm.c index eb85ced..857f6ea 100644 --- a/drivers/media/platform/s5p-mfc/s5p_mfc_pm.c +++ b/drivers/media/platform/s5p-mfc/s5p_mfc_pm.c @@ -24,7 +24,7 @@ static atomic_t clk_ref; int s5p_mfc_init_pm(struct s5p_mfc_dev *dev) { - int i; + int ret; pm = &dev->pm; p_dev = dev; @@ -35,17 +35,17 @@ int s5p_mfc_init_pm(struct s5p_mfc_dev *dev) pm->clock_gate = NULL; /* clock control */ - for (i = 0; i < pm->num_clocks; i++) { - pm->clocks[i] = devm_clk_get(pm->device, pm->clk_names[i]); - if (IS_ERR(pm->clocks[i])) { - mfc_err("Failed to get clock: %s\n", - pm->clk_names[i]); - return PTR_ERR(pm->clocks[i]); - } - } + pm->clocks = devm_clk_bulk_alloc(pm->device, pm->num_clocks, + pm->clk_names); + if (IS_ERR(pm->clocks)) + return PTR_ERR(pm->clocks); + + ret = devm_clk_bulk_get(pm->device, pm->num_clocks, pm->clocks); + if (ret < 0) + return ret; if (dev->variant->use_clock_gating) - pm->clock_gate = pm->clocks[0]; + pm->clock_gate = pm->clocks[0].clk; pm_runtime_enable(pm->device); atomic_set(&clk_ref, 0); @@ -75,43 +75,32 @@ void s5p_mfc_clock_off(void) int s5p_mfc_power_on(void) { - int i, ret = 0; + int ret = 0; ret = pm_runtime_get_sync(pm->device); if (ret < 0) return ret; /* clock control */ - for (i = 0; i < pm->num_clocks; i++) { - ret = clk_prepare_enable(pm->clocks[i]); - if (ret < 0) { - mfc_err("clock prepare failed for clock: %s\n", - pm->clk_names[i]); - i++; - goto err; - } - } + ret = clk_bulk_prepare_enable(pm->num_clocks, pm->clocks); + if (ret < 0) + goto err; /* prepare for software clock gating */ clk_disable(pm->clock_gate); return 0; err: - while (--i > 0) - clk_disable_unprepare(pm->clocks[i]); pm_runtime_put(pm->device); return ret; } int s5p_mfc_power_off(void) { - int i; - /* finish software clock gating */ clk_enable(pm->clock_gate); - for (i = 0; i < pm->num_clocks; i++) - clk_disable_unprepare(pm->clocks[i]); + clk_bulk_disable_unprepare(pm->num_clocks, pm->clocks); return pm_runtime_put_sync(pm->device); }
Using bulk clk functions simplifies the driver's code. Use devm_clk_bulk functions instead of iterating over an array of clks. Signed-off-by: Maciej Purski <m.purski@samsung.com> --- drivers/media/platform/s5p-mfc/s5p_mfc_common.h | 6 ++-- drivers/media/platform/s5p-mfc/s5p_mfc_pm.c | 41 +++++++++---------------- 2 files changed, 18 insertions(+), 29 deletions(-)