mbox series

[v5,00/13] clk: hisilicon: Migrate devm APIs

Message ID 20230723162245.35033-1-mmyangfl@gmail.com (mailing list archive)
Headers show
Series clk: hisilicon: Migrate devm APIs | expand

Message

David Yang July 23, 2023, 4:22 p.m. UTC
Migrate devm APIs for HiSilicon clock drivers and remove redundant codes.

This series is a partial improvement of [1]

v2: fix test robot error
v3:
  * size_t for all these num types
  * hisi_clk_unregister() change into separate patch
  * keep relevant header inclusions
  * split driver files changes into separate patches
  * explain hisi_clk_register_fn() checkpatch warnings
  * not fixed: MODULE_LICENSE("GPL v2"), as stated in SPDX-License-Identifier
  * not fixed: "hisilicon,hip04-clock" un-documented, as none of dts files in
    arch/ use it, better to ask hisi people why they pushed this driver
v4:
  * typo: hisi_clocks_get_nr() should check clks->nr first
  * unexport hisi_clk_unregister_fn() as no one use them outside
v5: catch up with remove_new refactoring

Links:
[1]: https://lore.kernel.org/r/20230322164201.2454771-1-mmyangfl@gmail.com
v1: https://lore.kernel.org/r/20230326052757.297551-1-mmyangfl@gmail.com
v2: https://lore.kernel.org/r/20230329075104.165176-1-mmyangfl@gmail.com
v3: https://lore.kernel.org/r/20230410110733.192151-1-mmyangfl@gmail.com
v4: https://lore.kernel.org/r/20230411174329.424763-1-mmyangfl@gmail.com

David Yang (13):
  clk: hisilicon: Add helper functions for platform driver
  clk: hisilicon: hi3516cv300: Use helper functions
  clk: hisilicon: hi3798cv200: Use helper functions
  clk: hisilicon: Remove hisi_crg_funcs
  clk: hisilicon: hi3519: Use helper functions
  clk: hisilicon: hi3559a: Use helper functions
  clk: hisilicon: hi3660: Convert into module
  clk: hisilicon: hi3670: Convert into module
  clk: hisilicon: hi3620: Convert into platform driver module
  clk: hisilicon: hi6220: Convert into platform driver module
  clk: hisilicon: hip04: Convert into platform driver module
  clk: hisilicon: hix5hd2: Convert into platform driver module
  clk: hisilicon: Migrate devm APIs

 drivers/clk/hisilicon/clk-hi3519.c        | 127 +-----
 drivers/clk/hisilicon/clk-hi3559a.c       | 252 +++---------
 drivers/clk/hisilicon/clk-hi3620.c        | 212 +++++-----
 drivers/clk/hisilicon/clk-hi3660.c        | 192 +++------
 drivers/clk/hisilicon/clk-hi3670.c        | 248 ++++--------
 drivers/clk/hisilicon/clk-hi6220-stub.c   |   9 +-
 drivers/clk/hisilicon/clk-hi6220.c        | 229 ++++++-----
 drivers/clk/hisilicon/clk-hip04.c         |  39 +-
 drivers/clk/hisilicon/clk-hisi-phase.c    |  13 +-
 drivers/clk/hisilicon/clk-hix5hd2.c       |  98 +++--
 drivers/clk/hisilicon/clk.c               | 457 +++++++++++-----------
 drivers/clk/hisilicon/clk.h               | 141 ++++---
 drivers/clk/hisilicon/clkdivider-hi6220.c |  24 +-
 drivers/clk/hisilicon/clkgate-separated.c |  26 +-
 drivers/clk/hisilicon/crg-hi3516cv300.c   | 171 +-------
 drivers/clk/hisilicon/crg-hi3798cv200.c   | 196 +---------
 drivers/clk/hisilicon/crg.h               |  11 +-
 drivers/clk/hisilicon/reset.c             |  42 ++
 18 files changed, 937 insertions(+), 1550 deletions(-)


base-commit: c2782531397f5cb19ca3f8f9c17727f1cdf5bee8

Comments

Stephen Boyd July 28, 2023, 7:59 p.m. UTC | #1
Quoting David Yang (2023-07-23 09:22:25)
> Migrate devm APIs for HiSilicon clock drivers and remove redundant codes.
> 
> This series is a partial improvement of [1]
> 

Thanks for resending. Can you fix these checkpatch and compilation errors?

	WARNING: Macros with flow control statements should be avoided
	#581: FILE: drivers/clk/hisilicon/clk.c:165:
	+#define hisi_clk_register_fn(fn, type, stmt) \
	+int fn(struct device *dev, const struct type *clks, \
	+       size_t num, struct hisi_clock_data *data) \
	+{ \
	+       void __iomem *base = data->base; \
	+\
	+       for (int i = 0; i < num; i++) { \
	+               const struct type *p_clk = &clks[i]; \
	+               struct clk_hw *clk = stmt; \
	+\
	+               if (IS_ERR(clk)) { \
	+                       pr_err("%s: failed to register clock %s\n", \
	+                              __func__, p_clk->name); \
	+                       return PTR_ERR(clk); \
	+               } \
	+\
	+               if (p_clk->alias) \
	+                       clk_hw_register_clkdev(clk, p_clk->alias, NULL); \
	+\
	+               data->clk_data->hws[p_clk->id] = clk; \
	+       } \
	+\
	+       return 0; \
	+} \
	+EXPORT_SYMBOL_GPL(fn);

	WARNING: macros should not use a trailing semicolon
	#581: FILE: drivers/clk/hisilicon/clk.c:165:
	+#define hisi_clk_register_fn(fn, type, stmt) \
	+int fn(struct device *dev, const struct type *clks, \
	+       size_t num, struct hisi_clock_data *data) \
	+{ \
	+       void __iomem *base = data->base; \
	+\
	+       for (int i = 0; i < num; i++) { \
	+               const struct type *p_clk = &clks[i]; \
	+               struct clk_hw *clk = stmt; \
	+\
	+               if (IS_ERR(clk)) { \
	+                       pr_err("%s: failed to register clock %s\n", \
	+                              __func__, p_clk->name); \
	+                       return PTR_ERR(clk); \
	+               } \
	+\
	+               if (p_clk->alias) \
	+                       clk_hw_register_clkdev(clk, p_clk->alias, NULL); \
	+\
	+               data->clk_data->hws[p_clk->id] = clk; \
	+       } \
	+\
	+       return 0; \
	+} \
	+EXPORT_SYMBOL_GPL(fn);

These look like instead of macros just write the functions out.

	total: 0 errors, 2 warnings, 1002 lines checked
	in patch 'clk: hisilicon: Migrate devm APIs' (74cb486e14c6)
	WARNING: Prefer "GPL" over "GPL v2" - see commit bf7fbeeae6db ("module: Cure the MODULE_LICENSE "GPL" vs. "GPL v2" bogosity")
	#174: FILE: drivers/clk/hisilicon/clk-hix5hd2.c:337:
	+MODULE_LICENSE("GPL v2");

	total: 0 errors, 1 warnings, 150 lines checked
	in patch 'clk: hisilicon: hix5hd2: Convert into platform driver module' (f40d4d59c265)
	WARNING: DT compatible string "hisilicon,hip04-clock" appears un-documented -- check ./Documentation/devicetree/bindings/
	#46: FILE: drivers/clk/hisilicon/clk-hip04.c:33:
	+       { .compatible = "hisilicon,hip04-clock",

	total: 0 errors, 1 warnings, 51 lines checked
	in patch 'clk: hisilicon: hip04: Convert into platform driver module' (fc919e7f3f7b)
	WARNING: Prefer "GPL" over "GPL v2" - see commit bf7fbeeae6db ("module: Cure the MODULE_LICENSE "GPL" vs. "GPL v2" bogosity")
	#353: FILE: drivers/clk/hisilicon/clk-hi6220.c:299:
	+MODULE_LICENSE("GPL v2");

	total: 0 errors, 1 warnings, 324 lines checked
	in patch 'clk: hisilicon: hi6220: Convert into platform driver module' (85c1694448a3)
	WARNING: Prefer "GPL" over "GPL v2" - see commit bf7fbeeae6db ("module: Cure the MODULE_LICENSE "GPL" vs. "GPL v2" bogosity")
	#298: FILE: drivers/clk/hisilicon/clk-hi3670.c:917:
	+MODULE_LICENSE("GPL v2");

	total: 0 errors, 1 warnings, 278 lines checked
	in patch 'clk: hisilicon: hi3670: Convert into module' (934dee9208ea)
	WARNING: Prefer "GPL" over "GPL v2" - see commit bf7fbeeae6db ("module: Cure the MODULE_LICENSE "GPL" vs. "GPL v2" bogosity")
	#251: FILE: drivers/clk/hisilicon/clk-hi3660.c:550:
	+MODULE_LICENSE("GPL v2");

	total: 0 errors, 1 warnings, 231 lines checked
	in patch 'clk: hisilicon: hi3660: Convert into module' (1ac1cef160ff)

	drivers/clk/hisilicon/clk-hi3559a.c: In function ‘hi3559av100_shub_default_clk_set’:
	drivers/clk/hisilicon/clk-hi3559a.c:628:53: error: ‘SZ_4K’ undeclared (first use in this function)
	  628 |         crg_base = devm_ioremap(dev, CRG_BASE_ADDR, SZ_4K);
	      |                                                     ^~~~~