[PATCH v2 04/18] drm/sun4i: tcon-top: Cleanup clock handling

2018-07-11 Thread Jernej Skrabec
There is no need to acquire reference to clock just to get its name.

This commit just cleans up the code. There is no functional change.

Reviewed-by: Chen-Yu Tsai 
Signed-off-by: Jernej Skrabec 
---
 drivers/gpu/drm/sun4i/sun8i_tcon_top.c | 48 ++
 1 file changed, 11 insertions(+), 37 deletions(-)

diff --git a/drivers/gpu/drm/sun4i/sun8i_tcon_top.c 
b/drivers/gpu/drm/sun4i/sun8i_tcon_top.c
index 8da0460e0028..9fb51940156f 100644
--- a/drivers/gpu/drm/sun4i/sun8i_tcon_top.c
+++ b/drivers/gpu/drm/sun4i/sun8i_tcon_top.c
@@ -44,15 +44,20 @@ static int sun8i_tcon_top_get_connected_ep_id(struct 
device_node *node,
 }
 
 static struct clk_hw *sun8i_tcon_top_register_gate(struct device *dev,
-  struct clk *parent,
+  const char *parent,
   void __iomem *regs,
   spinlock_t *lock,
   u8 bit, int name_index)
 {
const char *clk_name, *parent_name;
-   int ret;
+   int ret, index;
+
+   index = of_property_match_string(dev->of_node, "clock-names", parent);
+   if (IS_ERR_VALUE(index))
+   return ERR_PTR(index);
+
+   parent_name = of_clk_get_parent_name(dev->of_node, index);
 
-   parent_name = __clk_get_name(parent);
ret = of_property_read_string_index(dev->of_node,
"clock-output-names", name_index,
&clk_name);
@@ -69,7 +74,6 @@ static int sun8i_tcon_top_bind(struct device *dev, struct 
device *master,
   void *data)
 {
struct platform_device *pdev = to_platform_device(dev);
-   struct clk *dsi, *tcon_tv0, *tcon_tv1, *tve0, *tve1;
struct clk_hw_onecell_data *clk_data;
struct sun8i_tcon_top *tcon_top;
bool mixer0_unused = false;
@@ -103,36 +107,6 @@ static int sun8i_tcon_top_bind(struct device *dev, struct 
device *master,
return PTR_ERR(tcon_top->bus);
}
 
-   dsi = devm_clk_get(dev, "dsi");
-   if (IS_ERR(dsi)) {
-   dev_err(dev, "Couldn't get the dsi clock\n");
-   return PTR_ERR(dsi);
-   }
-
-   tcon_tv0 = devm_clk_get(dev, "tcon-tv0");
-   if (IS_ERR(tcon_tv0)) {
-   dev_err(dev, "Couldn't get the tcon-tv0 clock\n");
-   return PTR_ERR(tcon_tv0);
-   }
-
-   tcon_tv1 = devm_clk_get(dev, "tcon-tv1");
-   if (IS_ERR(tcon_tv1)) {
-   dev_err(dev, "Couldn't get the tcon-tv1 clock\n");
-   return PTR_ERR(tcon_tv1);
-   }
-
-   tve0 = devm_clk_get(dev, "tve0");
-   if (IS_ERR(tve0)) {
-   dev_err(dev, "Couldn't get the tve0 clock\n");
-   return PTR_ERR(tve0);
-   }
-
-   tve1 = devm_clk_get(dev, "tve1");
-   if (IS_ERR(tve1)) {
-   dev_err(dev, "Couldn't get the tve1 clock\n");
-   return PTR_ERR(tve1);
-   }
-
res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
regs = devm_ioremap_resource(dev, res);
if (IS_ERR(regs))
@@ -203,17 +177,17 @@ static int sun8i_tcon_top_bind(struct device *dev, struct 
device *master,
 * to TVE clock parent.
 */
clk_data->hws[CLK_TCON_TOP_TV0] =
-   sun8i_tcon_top_register_gate(dev, tcon_tv0, regs,
+   sun8i_tcon_top_register_gate(dev, "tcon-tv0", regs,
 &tcon_top->reg_lock,
 TCON_TOP_TCON_TV0_GATE, 0);
 
clk_data->hws[CLK_TCON_TOP_TV1] =
-   sun8i_tcon_top_register_gate(dev, tcon_tv1, regs,
+   sun8i_tcon_top_register_gate(dev, "tcon-tv1", regs,
 &tcon_top->reg_lock,
 TCON_TOP_TCON_TV1_GATE, 1);
 
clk_data->hws[CLK_TCON_TOP_DSI] =
-   sun8i_tcon_top_register_gate(dev, dsi, regs,
+   sun8i_tcon_top_register_gate(dev, "dsi", regs,
 &tcon_top->reg_lock,
 TCON_TOP_TCON_DSI_GATE, 2);
 
-- 
2.18.0

___
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel


Re: [PATCH v2 04/18] drm/sun4i: tcon-top: Cleanup clock handling

2018-07-10 Thread Chen-Yu Tsai
On Wed, Jul 11, 2018 at 7:20 AM, kbuild test robot  wrote:
> Hi Jernej,
>
> Thank you for the patch! Perhaps something to improve:
>
> [auto build test WARNING on next-20180710]
> [cannot apply to sunxi/sunxi/for-next drm/drm-next robh/for-next v4.18-rc4 
> v4.18-rc3 v4.18-rc2 v4.18-rc4]
> [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/Jernej-Skrabec/Allwinner-R40-HDMI-refactoring/20180711-043932
> config: arm64-allyesconfig (attached as .config)
> compiler: aarch64-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
> GCC_VERSION=7.2.0 make.cross ARCH=arm64
>
> All warnings (new ones prefixed by >>):
>
>In file included from include/linux/kernel.h:10:0,
> from include/linux/list.h:9,
> from include/linux/agp_backend.h:33,
> from include/drm/drmP.h:35,
> from drivers/gpu//drm/sun4i/sun8i_tcon_top.c:4:
>drivers/gpu//drm/sun4i/sun8i_tcon_top.c: In function 
> 'sun8i_tcon_top_register_gate':
>include/linux/err.h:22:49: warning: cast to pointer from integer of 
> different size [-Wint-to-pointer-cast]
> #define IS_ERR_VALUE(x) unlikely((unsigned long)(void *)(x) >= (unsigned 
> long)-MAX_ERRNO)
> ^
>include/linux/compiler.h:77:42: note: in definition of macro 'unlikely'
> # define unlikely(x) __builtin_expect(!!(x), 0)
>  ^
>>> drivers/gpu//drm/sun4i/sun8i_tcon_top.c:56:6: note: in expansion of macro 
>>> 'IS_ERR_VALUE'
>  if (IS_ERR_VALUE(index))
>  ^~~~
>
> vim +/IS_ERR_VALUE +56 drivers/gpu//drm/sun4i/sun8i_tcon_top.c
>
>  3
>> 4  #include 
>  5
>  6  #include 
>  7
>  8  #include 
>  9  #include 
> 10  #include 
> 11  #include 
> 12  #include 
> 13  #include 
> 14
> 15  #include "sun8i_tcon_top.h"
> 16
> 17  static int sun8i_tcon_top_get_connected_ep_id(struct device_node 
> *node,
> 18int port_id)
> 19  {
> 20  struct device_node *ep, *remote, *port;
> 21  struct of_endpoint endpoint;
> 22
> 23  port = of_graph_get_port_by_id(node, port_id);
> 24  if (!port)
> 25  return -ENOENT;
> 26
> 27  for_each_available_child_of_node(port, ep) {
> 28  remote = of_graph_get_remote_port_parent(ep);
> 29  if (!remote)
> 30  continue;
> 31
> 32  if (of_device_is_available(remote)) {
> 33  of_graph_parse_endpoint(ep, &endpoint);
> 34
> 35  of_node_put(remote);
> 36
> 37  return endpoint.id;
> 38  }
> 39
> 40  of_node_put(remote);
> 41  }
> 42
> 43  return -ENOENT;
> 44  }
> 45
> 46  static struct clk_hw *sun8i_tcon_top_register_gate(struct device *dev,
> 47 const char *parent,
> 48 void __iomem *regs,
> 49 spinlock_t *lock,
> 50 u8 bit, int 
> name_index)
> 51  {
> 52  const char *clk_name, *parent_name;
> 53  int ret, index;
> 54
> 55  index = of_property_match_string(dev->of_node, "clock-names", 
> parent);
>   > 56  if (IS_ERR_VALUE(index))

Yeah. This is incorrect usage. IS_ERR_VALUE should be used on pointers.
Checking for a negative value here should suffice.

ChenYu

> 57  return ERR_PTR(index);
> 58
> 59  parent_name = of_clk_get_parent_name(dev->of_node, index);
> 60
> 61  ret = of_property_read_string_index(dev->of_node,
> 62  "clock-output-names", 
> name_index,
> 63  &clk_name);
> 64  if (ret)
> 65  return ERR_PTR(ret);
> 66
> 67  return clk_hw_register_gate(dev, clk_name, parent_name,
> 68  CLK_SET_RATE_PARENT,
> 69  regs + TCON_TOP_GATE_SRC_REG,
> 70  bit, 0, lock);
> 71  };
> 72
>
> ---
> 0-DAY kernel test infrastructureOpen Source Technology Center
> https://lists.01.org/pipermail/kbuild-all

Re: [PATCH v2 04/18] drm/sun4i: tcon-top: Cleanup clock handling

2018-07-10 Thread kbuild test robot
Hi Jernej,

Thank you for the patch! Perhaps something to improve:

[auto build test WARNING on next-20180710]
[cannot apply to sunxi/sunxi/for-next drm/drm-next robh/for-next v4.18-rc4 
v4.18-rc3 v4.18-rc2 v4.18-rc4]
[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/Jernej-Skrabec/Allwinner-R40-HDMI-refactoring/20180711-043932
config: arm64-allyesconfig (attached as .config)
compiler: aarch64-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
GCC_VERSION=7.2.0 make.cross ARCH=arm64 

All warnings (new ones prefixed by >>):

   In file included from include/linux/kernel.h:10:0,
from include/linux/list.h:9,
from include/linux/agp_backend.h:33,
from include/drm/drmP.h:35,
from drivers/gpu//drm/sun4i/sun8i_tcon_top.c:4:
   drivers/gpu//drm/sun4i/sun8i_tcon_top.c: In function 
'sun8i_tcon_top_register_gate':
   include/linux/err.h:22:49: warning: cast to pointer from integer of 
different size [-Wint-to-pointer-cast]
#define IS_ERR_VALUE(x) unlikely((unsigned long)(void *)(x) >= (unsigned 
long)-MAX_ERRNO)
^
   include/linux/compiler.h:77:42: note: in definition of macro 'unlikely'
# define unlikely(x) __builtin_expect(!!(x), 0)
 ^
>> drivers/gpu//drm/sun4i/sun8i_tcon_top.c:56:6: note: in expansion of macro 
>> 'IS_ERR_VALUE'
 if (IS_ERR_VALUE(index))
 ^~~~

vim +/IS_ERR_VALUE +56 drivers/gpu//drm/sun4i/sun8i_tcon_top.c

 3  
   > 4  #include 
 5  
 6  #include 
 7  
 8  #include 
 9  #include 
10  #include 
11  #include 
12  #include 
13  #include 
14  
15  #include "sun8i_tcon_top.h"
16  
17  static int sun8i_tcon_top_get_connected_ep_id(struct device_node *node,
18int port_id)
19  {
20  struct device_node *ep, *remote, *port;
21  struct of_endpoint endpoint;
22  
23  port = of_graph_get_port_by_id(node, port_id);
24  if (!port)
25  return -ENOENT;
26  
27  for_each_available_child_of_node(port, ep) {
28  remote = of_graph_get_remote_port_parent(ep);
29  if (!remote)
30  continue;
31  
32  if (of_device_is_available(remote)) {
33  of_graph_parse_endpoint(ep, &endpoint);
34  
35  of_node_put(remote);
36  
37  return endpoint.id;
38  }
39  
40  of_node_put(remote);
41  }
42  
43  return -ENOENT;
44  }
45  
46  static struct clk_hw *sun8i_tcon_top_register_gate(struct device *dev,
47 const char *parent,
48 void __iomem *regs,
49 spinlock_t *lock,
50 u8 bit, int 
name_index)
51  {
52  const char *clk_name, *parent_name;
53  int ret, index;
54  
55  index = of_property_match_string(dev->of_node, "clock-names", 
parent);
  > 56  if (IS_ERR_VALUE(index))
57  return ERR_PTR(index);
58  
59  parent_name = of_clk_get_parent_name(dev->of_node, index);
60  
61  ret = of_property_read_string_index(dev->of_node,
62  "clock-output-names", 
name_index,
63  &clk_name);
64  if (ret)
65  return ERR_PTR(ret);
66  
67  return clk_hw_register_gate(dev, clk_name, parent_name,
68  CLK_SET_RATE_PARENT,
69  regs + TCON_TOP_GATE_SRC_REG,
70  bit, 0, lock);
71  };
72  

---
0-DAY kernel test infrastructureOpen Source Technology Center
https://lists.01.org/pipermail/kbuild-all   Intel Corporation


.config.gz
Description: application/gzip
___
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel