Re: [PATCH] media: Convert to using %pOF instead of full_name

2017-07-19 Thread Frank Rowand
On 07/19/17 09:02, Rob Herring wrote:
> On Wed, Jul 19, 2017 at 4:41 AM, Sylwester Nawrocki
>  wrote:
>> On 07/18/2017 11:43 PM, Rob Herring wrote:
>>> Now that we have a custom printf format specifier, convert users of
>>> full_name to use %pOF instead. This is preparation to remove storing
>>> of the full path string for each node.
>>>
>>> Signed-off-by: Rob Herring 
>>
>>> ---

< snip >

>>> diff --git a/drivers/media/v4l2-core/v4l2-async.c 
>>> b/drivers/media/v4l2-core/v4l2-async.c
>>> index 851f128eba22..0a385d1ff28c 100644
>>> --- a/drivers/media/v4l2-core/v4l2-async.c
>>> +++ b/drivers/media/v4l2-core/v4l2-async.c
>>> @@ -47,9 +47,7 @@ static bool match_fwnode(struct v4l2_subdev *sd, struct 
>>> v4l2_async_subdev *asd)
>>>   if (!is_of_node(sd->fwnode) || !is_of_node(asd->match.fwnode.fwnode))
>>>   return sd->fwnode == asd->match.fwnode.fwnode;
>>>
>>> - return !of_node_cmp(of_node_full_name(to_of_node(sd->fwnode)),
>>> - of_node_full_name(
>>> - to_of_node(asd->match.fwnode.fwnode)));
>>> + return to_of_node(sd->fwnode) == to_of_node(asd->match.fwnode.fwnode);
>>
>> I'm afraid this will not work, please see commit d2180e0cf77dc7a7049671d5d57d
>> "[media] v4l: async: make v4l2 coexist with devicetree nodes in a dt overlay"

Commit d2180e0cf77dc7a7049671d5d57d seems to have a fundamental
misunderstanding of overlays, if I understand the implications of that
commit.

When an overlay (1) is removed, all uses and references to the nodes and
properties in that overlay are no longer valid.  Any driver that uses any
information from the overlay _must_ stop using any data from the overlay.
Any driver that is bound to a new node in the overlay _must_ unbind.  Any
driver that became bound to a pre-existing node that was modified by the
overlay (became bound after the overlay was applied) _must_ adjust itself
to account for any changes to that node when the overlay is removed.  One
way to do this is to unbind when notified that the overlay is about to
be removed, then to re-bind after the overlay is completely removed.

If an overlay (2) is subsequently applied, a node with the same
full_name as from overlay (1) may exist.  There is no guarantee
that overlay (1) and overlay (2) are the same overlay, even if
that node has the same full_name in both cases.


> Maybe I'm missing something, but how does that work exactly? Before
> the overlay is applied, the remote endpoint node (and its parent)
> can't be resolved. In the commit example, the endpoint in the
> media_bridge would also have to be part of the overlay. If you apply
> and un-apply the overlay, then the of_node (and fw_node) in the
> overlay is once again invalid. IOW, you should be in the same state as
> before the overlay was applied. The node is still around because of
> paranoia that actually freeing nodes would break things. It seems this
> paranoia is real, so i think we need to do something to prevent this
> from spreading.

My understanding is that nodes from an un-applied overlay will be
freed if the expanded device tree that was used to create it has
its reference counts drop to zero.  But I wouldn't count on me
remembering this correctly without actually walking through all
the code.  And as far as I know, there is no example of this
in the mainline tree.


> Furthermore, it does not appear that any media driver supports
> overlays and we have no general way to apply them in mainline yet
> (other than an in kernel API). So really this scenario is not one we
> have to support yet.
> 
> Rob
> 



Re: [PATCH] gpu: Convert to using %pOF instead of full_name

2017-07-19 Thread Laurent Pinchart
Hi Rob,

Thank you for the patch.

On Tuesday 18 Jul 2017 16:43:04 Rob Herring wrote:
> Now that we have a custom printf format specifier, convert users of
> full_name to use %pOF instead. This is preparation to remove storing
> of the full path string for each node.
> 
> Signed-off-by: Rob Herring 
> Cc: Russell King 
> Cc: David Airlie 
> Cc: Daniel Vetter 
> Cc: Jani Nikula 
> Cc: Sean Paul 
> Cc: Inki Dae 
> Cc: Joonyoung Shim 
> Cc: Seung-Woo Kim 
> Cc: Kyungmin Park 
> Cc: Kukjin Kim 
> Cc: Krzysztof Kozlowski 
> Cc: Javier Martinez Canillas 
> Cc: Xinliang Liu 
> Cc: Rongrong Zou 
> Cc: Xinwei Kong 
> Cc: Chen Feng 
> Cc: CK Hu 
> Cc: Philipp Zabel 
> Cc: Matthias Brugger 
> Cc: Neil Armstrong 
> Cc: Carlo Caione 
> Cc: Kevin Hilman 
> Cc: Thierry Reding 
> Cc: Laurent Pinchart 
> Cc: Mark Yao 
> Cc: Heiko Stuebner 
> Cc: Maxime Ripard 
> Cc: Chen-Yu Tsai 
> Cc: Jyri Sarha 
> Cc: Tomi Valkeinen 
> Cc: dri-de...@lists.freedesktop.org
> Cc: linux-arm-ker...@lists.infradead.org
> Cc: linux-samsung-...@vger.kernel.org
> Cc: linux-media...@lists.infradead.org
> Cc: linux-amlo...@lists.infradead.org
> Cc: linux-renesas-soc@vger.kernel.org
> Cc: linux-rockc...@lists.infradead.org
> ---
[snip]
>  drivers/gpu/drm/drm_mipi_dsi.c  |  6 +++---
>  drivers/gpu/drm/drm_modes.c |  4 ++--
>  drivers/gpu/drm/drm_of.c|  4 ++--
[snip]
>  drivers/gpu/drm/panel/panel-lvds.c  | 16 
>  drivers/gpu/drm/rcar-du/rcar_du_encoder.c   |  4 ++--
>  drivers/gpu/drm/rcar-du/rcar_du_kms.c   | 16 

For all the above,

Reviewed-by: Laurent Pinchart 

-- 
Regards,

Laurent Pinchart



Re: [PATCH] pinctrl: Convert to using %pOF instead of full_name

2017-07-19 Thread Eric Anholt
Rob Herring  writes:

> Now that we have a custom printf format specifier, convert users of
> full_name to use %pOF instead. This is preparation to remove storing
> of the full path string for each node.

For bcm283x:

Acked-by: Eric Anholt 


signature.asc
Description: PGP signature


[renesas-drivers:topic/rcar2-cpg-mssr-dt-v2 2/9] arch/arm/boot/dts/r8a7791.dtsi:13:48: fatal error: dt-bindings/clock/r8a7791-cpg-mssr.h: No such file or directory

2017-07-19 Thread kbuild test robot
tree:   
https://git.kernel.org/pub/scm/linux/kernel/git/geert/renesas-drivers.git 
topic/rcar2-cpg-mssr-dt-v2
head:   719d66878b5366748b076ab8b7e3a0ed6012033c
commit: 00dc7a102c7df46d30520d53002c77d9c75ce862 [2/9] ARM: dts: r8a7791: 
Convert to new CPG/MSSR bindings
config: arm-at91_dt_defconfig (attached as .config)
compiler: arm-linux-gnueabi-gcc (Debian 6.1.1-9) 6.1.1 20160705
reproduce:
wget 
https://raw.githubusercontent.com/01org/lkp-tests/master/sbin/make.cross -O 
~/bin/make.cross
chmod +x ~/bin/make.cross
git checkout 00dc7a102c7df46d30520d53002c77d9c75ce862
# save the attached .config to linux build tree
make.cross ARCH=arm 

All errors (new ones prefixed by >>):

   In file included from arch/arm/boot/dts/r8a7791-porter.dts:23:0:
>> arch/arm/boot/dts/r8a7791.dtsi:13:48: fatal error: 
>> dt-bindings/clock/r8a7791-cpg-mssr.h: No such file or directory
#include 
   ^
   compilation terminated.

vim +13 arch/arm/boot/dts/r8a7791.dtsi

  > 13  #include 
14  #include 
15  #include 
16  #include 
17  

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


.config.gz
Description: application/gzip


Re: [PATCH] media: Convert to using %pOF instead of full_name

2017-07-19 Thread Rob Herring
On Wed, Jul 19, 2017 at 4:41 AM, Sylwester Nawrocki
 wrote:
> On 07/18/2017 11:43 PM, Rob Herring wrote:
>> Now that we have a custom printf format specifier, convert users of
>> full_name to use %pOF instead. This is preparation to remove storing
>> of the full path string for each node.
>>
>> Signed-off-by: Rob Herring 
>
>> ---
>>   drivers/media/i2c/s5c73m3/s5c73m3-core.c   |  3 +-
>>   drivers/media/i2c/s5k5baf.c|  7 ++--
>>   drivers/media/platform/am437x/am437x-vpfe.c|  4 +-
>>   drivers/media/platform/atmel/atmel-isc.c   |  4 +-
>>   drivers/media/platform/davinci/vpif_capture.c  | 16 
>>   drivers/media/platform/exynos4-is/fimc-is.c|  8 ++--
>>   drivers/media/platform/exynos4-is/fimc-lite.c  |  3 +-
>>   drivers/media/platform/exynos4-is/media-dev.c  |  8 ++--
>>   drivers/media/platform/exynos4-is/mipi-csis.c  |  4 +-
>>   drivers/media/platform/mtk-mdp/mtk_mdp_comp.c  |  6 +--
>>   drivers/media/platform/mtk-mdp/mtk_mdp_core.c  |  8 ++--
>>   drivers/media/platform/omap3isp/isp.c  |  8 ++--
>>   drivers/media/platform/pxa_camera.c|  2 +-
>>   drivers/media/platform/rcar-vin/rcar-core.c|  4 +-
>>   drivers/media/platform/soc_camera/soc_camera.c |  6 +--
>>   drivers/media/platform/xilinx/xilinx-vipp.c| 52 
>> +-
>>   drivers/media/v4l2-core/v4l2-async.c   |  4 +-
>>   drivers/media/v4l2-core/v4l2-clk.c |  3 +-
>>   include/media/v4l2-clk.h   |  4 +-
>>   19 files changed, 71 insertions(+), 83 deletions(-)
>
>> diff --git a/drivers/media/platform/xilinx/xilinx-vipp.c 
>> b/drivers/media/platform/xilinx/xilinx-vipp.c
>> index ac4704388920..9233ad0b1b6b 100644
>> --- a/drivers/media/platform/xilinx/xilinx-vipp.c
>> +++ b/drivers/media/platform/xilinx/xilinx-vipp.c
>
>> @@ -144,9 +144,8 @@ static int xvip_graph_build_one(struct 
>> xvip_composite_device *xdev,
>>   remote = ent->entity;
>>
>>   if (link.remote_port >= remote->num_pads) {
>> - dev_err(xdev->dev, "invalid port number %u on %s\n",
>> - link.remote_port,
>> - to_of_node(link.remote_node)->full_name);
>> + dev_err(xdev->dev, "invalid port number %u on %pOF\n",
>> + link.remote_port, link.remote_node);
>
> Shouldn't there be to_of_node(link.remote_node) instead of link.remote_node ?

Humm, yes. I thought I fixed that.

>
>>   v4l2_fwnode_put_link();
>>   ret = -EINVAL;
>>   break;
>
>> @@ -242,17 +241,17 @@ static int xvip_graph_build_dma(struct 
>> xvip_composite_device *xdev)
>>   ent = xvip_graph_find_entity(xdev,
>>to_of_node(link.remote_node));
>>   if (ent == NULL) {
>> - dev_err(xdev->dev, "no entity found for %s\n",
>> - to_of_node(link.remote_node)->full_name);
>> + dev_err(xdev->dev, "no entity found for %pOF\n",
>> + to_of_node(link.remote_node));
>>   v4l2_fwnode_put_link();
>>   ret = -ENODEV;
>>   break;
>>   }
>
>> diff --git a/drivers/media/v4l2-core/v4l2-async.c 
>> b/drivers/media/v4l2-core/v4l2-async.c
>> index 851f128eba22..0a385d1ff28c 100644
>> --- a/drivers/media/v4l2-core/v4l2-async.c
>> +++ b/drivers/media/v4l2-core/v4l2-async.c
>> @@ -47,9 +47,7 @@ static bool match_fwnode(struct v4l2_subdev *sd, struct 
>> v4l2_async_subdev *asd)
>>   if (!is_of_node(sd->fwnode) || !is_of_node(asd->match.fwnode.fwnode))
>>   return sd->fwnode == asd->match.fwnode.fwnode;
>>
>> - return !of_node_cmp(of_node_full_name(to_of_node(sd->fwnode)),
>> - of_node_full_name(
>> - to_of_node(asd->match.fwnode.fwnode)));
>> + return to_of_node(sd->fwnode) == to_of_node(asd->match.fwnode.fwnode);
>
> I'm afraid this will not work, please see commit d2180e0cf77dc7a7049671d5d57d
> "[media] v4l: async: make v4l2 coexist with devicetree nodes in a dt overlay"

Maybe I'm missing something, but how does that work exactly? Before
the overlay is applied, the remote endpoint node (and its parent)
can't be resolved. In the commit example, the endpoint in the
media_bridge would also have to be part of the overlay. If you apply
and un-apply the overlay, then the of_node (and fw_node) in the
overlay is once again invalid. IOW, you should be in the same state as
before the overlay was applied. The node is still around because of
paranoia that actually freeing nodes would break things. It seems this
paranoia is real, so i think we need to do something to prevent this
from spreading.

Furthermore, it does not appear that any media driver supports
overlays and we have no 

Re: [renesas-drivers:topic/rcar2-cpg-mssr-dt-v2 1/9] arch/arm/boot/dts/r8a7790.dtsi:13:48: fatal error: dt-bindings/clock/r8a7790-cpg-mssr.h: No such file or directory

2017-07-19 Thread Geert Uytterhoeven
On Wed, Jul 19, 2017 at 5:54 PM, kbuild test robot
 wrote:
> tree:   
> https://git.kernel.org/pub/scm/linux/kernel/git/geert/renesas-drivers.git 
> topic/rcar2-cpg-mssr-dt-v2
> head:   719d66878b5366748b076ab8b7e3a0ed6012033c
> commit: 09edb9fc52b0323c57747413da258d35f6a80495 [1/9] ARM: dts: r8a7790: 
> Convert to new CPG/MSSR bindings
> config: arm-at91_dt_defconfig (attached as .config)
> compiler: arm-linux-gnueabi-gcc (Debian 6.1.1-9) 6.1.1 20160705
> reproduce:
> wget 
> https://raw.githubusercontent.com/01org/lkp-tests/master/sbin/make.cross -O 
> ~/bin/make.cross
> chmod +x ~/bin/make.cross
> git checkout 09edb9fc52b0323c57747413da258d35f6a80495
> # save the attached .config to linux build tree
> make.cross ARCH=arm
>
> All errors (new ones prefixed by >>):
>
>In file included from arch/arm/boot/dts/r8a7790-lager.dts:42:0:
>>> arch/arm/boot/dts/r8a7790.dtsi:13:48: fatal error: 
>>> dt-bindings/clock/r8a7790-cpg-mssr.h: No such file or directory
> #include 
>^
>compilation terminated.

Woops, forgot to merge v4.13-rc1 into Simon's devel branch, which is
still at v4.12.

Gr{oetje,eeting}s,

Geert

--
Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- ge...@linux-m68k.org

In personal conversations with technical people, I call myself a hacker. But
when I'm talking to journalists I just say "programmer" or something like that.
-- Linus Torvalds


[renesas-drivers:topic/rcar2-cpg-mssr-dt-v2 1/9] arch/arm/boot/dts/r8a7790.dtsi:13:48: fatal error: dt-bindings/clock/r8a7790-cpg-mssr.h: No such file or directory

2017-07-19 Thread kbuild test robot
tree:   
https://git.kernel.org/pub/scm/linux/kernel/git/geert/renesas-drivers.git 
topic/rcar2-cpg-mssr-dt-v2
head:   719d66878b5366748b076ab8b7e3a0ed6012033c
commit: 09edb9fc52b0323c57747413da258d35f6a80495 [1/9] ARM: dts: r8a7790: 
Convert to new CPG/MSSR bindings
config: arm-at91_dt_defconfig (attached as .config)
compiler: arm-linux-gnueabi-gcc (Debian 6.1.1-9) 6.1.1 20160705
reproduce:
wget 
https://raw.githubusercontent.com/01org/lkp-tests/master/sbin/make.cross -O 
~/bin/make.cross
chmod +x ~/bin/make.cross
git checkout 09edb9fc52b0323c57747413da258d35f6a80495
# save the attached .config to linux build tree
make.cross ARCH=arm 

All errors (new ones prefixed by >>):

   In file included from arch/arm/boot/dts/r8a7790-lager.dts:42:0:
>> arch/arm/boot/dts/r8a7790.dtsi:13:48: fatal error: 
>> dt-bindings/clock/r8a7790-cpg-mssr.h: No such file or directory
#include 
   ^
   compilation terminated.

vim +13 arch/arm/boot/dts/r8a7790.dtsi

  > 13  #include 
14  #include 
15  #include 
16  #include 
17  

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


.config.gz
Description: application/gzip


Re: [PATCH] ARM: Convert to using %pOF instead of full_name

2017-07-19 Thread Rob Herring
On Wed, Jul 19, 2017 at 1:22 AM, Uwe Kleine-König
 wrote:
> On Tue, Jul 18, 2017 at 04:42:41PM -0500, Rob Herring wrote:
>> Now that we have a custom printf format specifier, convert users of
>> full_name to use %pOF instead. This is preparation to remove storing
>
> Oh nice. If the commit adding %pOF is already set in stone, i'd suggest
> to mention the commit id here in the commit log.

It is in 4.13, but I'm not really eager to update all 60 patches and
I'd prefer consistency in the commit msg as quite a few have already
been applied.

>> of the full path string for each node.

[...]

>> @@ -103,8 +103,8 @@ void __init arm_dt_init_cpu_maps(void)
>>*/
>>   cell = of_get_property(cpu, "reg", _bytes);
>>   if (!cell || prop_bytes < sizeof(*cell)) {
>> - pr_debug(" * %s missing reg property\n",
>> -  cpu->full_name);
>> + pr_debug(" * %pOF missing reg property\n",
>> +  cpu);
>
> You could join lines here and in the next hunk. And there are two more
> further down.

Okay. I did that generally, but missed a few.

Rob


Re: [RFC v2 5/6] max9260: add driver for i2c over GMSL passthrough

2017-07-19 Thread Wolfram Sang
Hi Uli,

> +struct max9260_device {
> + struct serdev_device *serdev;
> + u8 *rx_buf;
> + int rx_len;
> + int rx_state;
> + wait_queue_head_t rx_wq;
> + struct i2c_adapter adap;
> +};
> +
> +static void wait_for_transaction(struct max9260_device *dev)

max9260_ prefix as well?

> +{
> + wait_event_interruptible_timeout(dev->rx_wq,
> + dev->rx_state <= RX_FRAME_ERROR,
> + HZ/2);

I'd suggest to drop the interruptible. It can be done but it is usually
not trivial to abort the operation gracefully when a signal comes in.

Also, timeout is superfluous since you don't get the return value?

> +static int max9260_setup(struct max9260_device *dev)
> +{
> + int ret;
> +
> + ret = max9260_read_reg(dev, 0x1e);
> +
> + if (ret != 0x02) {
> + dev_err(>serdev->dev,
> + "device does not identify as MAX9260\n");
> + return -EINVAL;

I think -ENODEV is the proper errno for a not-found device. Also, the
error message could probably go.

> + }
> +
> + return 0;
> +}
> +
> +static void max9260_uart_write_wakeup(struct serdev_device *serdev)
> +{

Maybe a FIXME comment for this empty function?

> +static u32 max9260_i2c_func(struct i2c_adapter *adapter)
> +{
> + return I2C_FUNC_SMBUS_BYTE|I2C_FUNC_SMBUS_BYTE_DATA;

Spaces around operators.

> + dev = kzalloc(sizeof(*dev), GFP_KERNEL);
> + if (!dev)
> + return -ENOMEM;

You don't like devm_* it seems ;)

Rest looks good to me!

Regards,

   Wolfram


signature.asc
Description: PGP signature


[PATCH v2 3/7] drm/rcar-du: Use new iterator macros, v2.

2017-07-19 Thread Maarten Lankhorst
for_each_obj_in_state is about to be removed, so use the correct new
iterator macros.

Also look at new_plane_state instead of plane->state when looking up
the hw planes in use. They should be the same except when reallocating,
(in which case this code is skipped) and we should really stop looking
at obj->state whenever possible.

Changes since v1:
- Actually compile correctly.

Signed-off-by: Maarten Lankhorst 
Cc: Laurent Pinchart 
Cc: linux-renesas-soc@vger.kernel.org
---
 drivers/gpu/drm/rcar-du/rcar_du_plane.c | 57 -
 1 file changed, 28 insertions(+), 29 deletions(-)

diff --git a/drivers/gpu/drm/rcar-du/rcar_du_plane.c 
b/drivers/gpu/drm/rcar-du/rcar_du_plane.c
index dcde6288da6c..50fd793c38d1 100644
--- a/drivers/gpu/drm/rcar-du/rcar_du_plane.c
+++ b/drivers/gpu/drm/rcar-du/rcar_du_plane.c
@@ -51,12 +51,9 @@
  */
 
 static bool rcar_du_plane_needs_realloc(struct rcar_du_plane *plane,
+   const struct rcar_du_plane_state 
*cur_state,
struct rcar_du_plane_state *new_state)
 {
-   struct rcar_du_plane_state *cur_state;
-
-   cur_state = to_rcar_plane_state(plane->plane.state);
-
/* Lowering the number of planes doesn't strictly require reallocation
 * as the extra hardware plane will be freed when committing, but doing
 * so could lead to more fragmentation.
@@ -141,16 +138,17 @@ int rcar_du_atomic_check_planes(struct drm_device *dev,
unsigned int groups = 0;
unsigned int i;
struct drm_plane *drm_plane;
-   struct drm_plane_state *drm_plane_state;
+   struct drm_plane_state *old_drm_plane_state, *new_drm_plane_state;
 
/* Check if hardware planes need to be reallocated. */
-   for_each_plane_in_state(state, drm_plane, drm_plane_state, i) {
-   struct rcar_du_plane_state *plane_state;
+   for_each_oldnew_plane_in_state(state, drm_plane, old_drm_plane_state, 
new_drm_plane_state, i) {
+   struct rcar_du_plane_state *old_plane_state, *new_plane_state;
struct rcar_du_plane *plane;
unsigned int index;
 
plane = to_rcar_plane(drm_plane);
-   plane_state = to_rcar_plane_state(drm_plane_state);
+   old_plane_state = to_rcar_plane_state(old_drm_plane_state);
+   new_plane_state = to_rcar_plane_state(new_drm_plane_state);
 
dev_dbg(rcdu->dev, "%s: checking plane (%u,%tu)\n", __func__,
plane->group->index, plane - plane->group->planes);
@@ -159,19 +157,19 @@ int rcar_du_atomic_check_planes(struct drm_device *dev,
 * the full reallocation procedure. Just mark the hardware
 * plane(s) as freed.
 */
-   if (!plane_state->format) {
+   if (!new_plane_state->format) {
dev_dbg(rcdu->dev, "%s: plane is being disabled\n",
__func__);
index = plane - plane->group->planes;
group_freed_planes[plane->group->index] |= 1 << index;
-   plane_state->hwindex = -1;
+   new_plane_state->hwindex = -1;
continue;
}
 
/* If the plane needs to be reallocated mark it as such, and
 * mark the hardware plane(s) as free.
 */
-   if (rcar_du_plane_needs_realloc(plane, plane_state)) {
+   if (rcar_du_plane_needs_realloc(plane, old_plane_state, 
new_plane_state)) {
dev_dbg(rcdu->dev, "%s: plane needs reallocation\n",
__func__);
groups |= 1 << plane->group->index;
@@ -179,7 +177,7 @@ int rcar_du_atomic_check_planes(struct drm_device *dev,
 
index = plane - plane->group->planes;
group_freed_planes[plane->group->index] |= 1 << index;
-   plane_state->hwindex = -1;
+   new_plane_state->hwindex = -1;
}
}
 
@@ -204,7 +202,7 @@ int rcar_du_atomic_check_planes(struct drm_device *dev,
 
for (i = 0; i < group->num_planes; ++i) {
struct rcar_du_plane *plane = >planes[i];
-   struct rcar_du_plane_state *plane_state;
+   struct rcar_du_plane_state *new_plane_state;
struct drm_plane_state *s;
 
s = drm_atomic_get_plane_state(state, >plane);
@@ -226,16 +224,16 @@ int rcar_du_atomic_check_planes(struct drm_device *dev,
continue;
}
 
-   plane_state = to_rcar_plane_state(plane->plane.state);
-   used_planes |= 

Re: [PATCH] watchdog: asm9260_wdt: don't round closest with get_timeleft

2017-07-19 Thread Guenter Roeck

On 07/17/2017 10:12 AM, Wolfram Sang wrote:

We should never return more time left than there actually is. So, switch
to a plain divider instead of DIV_ROUND_CLOSEST.

Signed-off-by: Wolfram Sang 


Reviewed-by: Guenter Roeck 


---

This is similar to a patch for the renesas-rwdt[1]. I think it makes sense to
remove this pattern from the whole subsystem, if we can agree on the behaviour
stated in the patch description. So, this is the other driver using
DIV_ROUND_CLOSEST.

Note: This driver and the lpc18xx_wdt.c extremly likely drive the same IP core.
They would ideally be merged.

[1] https://patchwork.kernel.org/patch/9845459/

  drivers/watchdog/asm9260_wdt.c | 2 +-
  1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/watchdog/asm9260_wdt.c b/drivers/watchdog/asm9260_wdt.c
index 53da001f0838ee..f40dd71c904bef 100644
--- a/drivers/watchdog/asm9260_wdt.c
+++ b/drivers/watchdog/asm9260_wdt.c
@@ -82,7 +82,7 @@ static unsigned int asm9260_wdt_gettimeleft(struct 
watchdog_device *wdd)
  
  	counter = ioread32(priv->iobase + HW_WDTV);
  
-	return DIV_ROUND_CLOSEST(counter, priv->wdt_freq);

+   return counter / priv->wdt_freq;
  }
  
  static int asm9260_wdt_updatetimeout(struct watchdog_device *wdd)






Re: [PATCH v5 0/4] v4l2-async: add subnotifier registration for subdevices

2017-07-19 Thread Maxime Ripard
Hi Niklas,

On Wed, Jul 19, 2017 at 12:49:42PM +0200, Niklas Söderlund wrote:
> Hi,
> 
> I know Sakari have posted a series '[RFC 00/19] Async sub-notifiers and 
> how to use them' which address similar problems as this series. This is 
> not intended to compete whit his work and Sakari includes one of my v3 
> patches in his series. Never the less I post this updated series since 
> it fixes some issues in my v3 implementation and contains some other 
> fixes for the v4l2-async framework which are not addressed in Sakaris 
> patches. I think the correct solution to the problems we both try to fix 
> is a mix of our two series, would you agree Sakari?
> 
> This series enables incremental async find and bind of subdevices,
> please se patch 4/4 for a more detailed description. This is a rewrite 
> of the feature since v3, see changelog in this cover letter for the 
> differences to v3. The two primary reasons for a new implementation 
> where:
> 
> 1. Hans expressed an interest having the async complete() callbacks to
>happen only once all notifiers in the pipeline where complete. To do
>this a stronger connection between the notifiers where needed, hence
>the subnotifier is now embedded in struct v4l2_subdev.
> 
>Whit this change it is possible to check all notifiers in a pipeline
>is complete before calling any of them.
> 
> 2. There where concerns that the v3 solution was a bit to complex and
>hard to refactor in the future if other issues in the v4l2-async
>framework where to be addressed. By hiding the notifier in the struct
>v4l2_subdev and adding a new function to set that structure the
>interface towards drivers are minimized while everything else happens
>in the v4l2-async framework. This leaves the interface in a good
>position for possible changes in v4l2-async.
> 
> This is tested on Renesas H3 and M3-W together with the Renesas CSI-2
> and VIN Gen3 driver (posted separately). It is based on top of the media-tree.

Thanks for the new iteration, you can add my
Tested-by: Maxime Ripard 

On the cadence CSI2 RX driver I sent earlier.

Thanks!
Maxime

-- 
Maxime Ripard, Free Electrons
Embedded Linux and Kernel engineering
http://free-electrons.com


signature.asc
Description: PGP signature


Re: [PATCH v5 0/4] v4l2-async: add subnotifier registration for subdevices

2017-07-19 Thread Niklas Söderlund
Hi Hans,

Thanks for your feedback.

On 2017-07-19 13:02:14 +0200, Hans Verkuil wrote:
> On 19/07/17 12:49, Niklas Söderlund wrote:
> > * Changes since v4
> > - Add patch which aborts v4l2_async_notifier_unregister() if the memory 
> >   allocation for the device cache fails instead of trying to do as much 
> >   as possible but still leave the system in a semi good state.
> 
> Since you are working with this code I would very much appreciate it if you
> can make another patch that adds comments to this reprobing stuff, including
> why device_reprobe() cannot be used here.

I could do that.

I think it makes most sens to break out patch 1-3 plus this new patch to 
a new series 'v4l2-async: clean up v4l2_async_notifier_unregister()' or 
something similar and post separate from the subnotifer work as me and 
Sakari are still bashing out a common solution to that.

Do this make sens to you or do you wish for me to keep these patches 
together in this series?

> 
> That will help in the future.
> 
> Regards,
> 
>   Hans

-- 
Regards,
Niklas Söderlund


Re: [PATCH] ARM: Convert to using %pOF instead of full_name

2017-07-19 Thread Gregory CLEMENT
Hi Rob,
 
 On mar., juil. 18 2017, Rob Herring  wrote:

> Now that we have a custom printf format specifier, convert users of
> full_name to use %pOF instead. This is preparation to remove storing
> of the full path string for each node.
>
> Signed-off-by: Rob Herring 
> Cc: Russell King 
> Cc: Kukjin Kim 
> Cc: Krzysztof Kozlowski 
> Cc: Javier Martinez Canillas 
> Cc: Shawn Guo 
> Cc: Sascha Hauer 
> Cc: Fabio Estevam 
> Cc: Jason Cooper 
> Cc: Andrew Lunn 
> Cc: Gregory Clement 
> Cc: Sebastian Hesselbarth 
> Cc: Tony Lindgren 
> Cc: "Benoît Cousson" 
> Cc: Paul Walmsley 
> Cc: Heiko Stuebner 
> Cc: Simon Horman 
> Cc: Magnus Damm 
> Cc: linux-arm-ker...@lists.infradead.org
> Cc: linux-samsung-...@vger.kernel.org
> Cc: linux-o...@vger.kernel.org
> Cc: linux-rockc...@lists.infradead.org
> Cc: linux-renesas-soc@vger.kernel.org
> ---
>  arch/arm/kernel/cpuidle.c| 4 ++--
>  arch/arm/kernel/devtree.c| 6 +++---
>  arch/arm/kernel/topology.c   | 4 ++--
>  arch/arm/mach-exynos/suspend.c   | 8 
>  arch/arm/mach-imx/gpc.c  | 4 ++--
>  arch/arm/mach-mvebu/kirkwood.c   | 4 ++--

For the krkwood part
Acked-by: Gregory CLEMENT 

Thanks,

Gregory

>  arch/arm/mach-omap2/omap-wakeupgen.c | 4 ++--
>  arch/arm/mach-omap2/omap_hwmod.c | 4 ++--
>  arch/arm/mach-rockchip/platsmp.c | 4 ++--
>  arch/arm/mach-shmobile/pm-rmobile.c  | 8 
>  10 files changed, 25 insertions(+), 25 deletions(-)
>
> diff --git a/arch/arm/kernel/cpuidle.c b/arch/arm/kernel/cpuidle.c
> index a3308ad1a024..fda5579123a8 100644
> --- a/arch/arm/kernel/cpuidle.c
> +++ b/arch/arm/kernel/cpuidle.c
> @@ -101,8 +101,8 @@ static int __init arm_cpuidle_read_ops(struct device_node 
> *dn, int cpu)
>
>   ops = arm_cpuidle_get_ops(enable_method);
>   if (!ops) {
> - pr_warn("%s: unsupported enable-method property: %s\n",
> - dn->full_name, enable_method);
> + pr_warn("%pOF: unsupported enable-method property: %s\n",
> + dn, enable_method);
>   return -EOPNOTSUPP;
>   }
>
> diff --git a/arch/arm/kernel/devtree.c b/arch/arm/kernel/devtree.c
> index f676febbb270..28174c9a94ac 100644
> --- a/arch/arm/kernel/devtree.c
> +++ b/arch/arm/kernel/devtree.c
> @@ -95,7 +95,7 @@ void __init arm_dt_init_cpu_maps(void)
>   if (of_node_cmp(cpu->type, "cpu"))
>   continue;
>
> - pr_debug(" * %s...\n", cpu->full_name);
> + pr_debug(" * %pOF...\n", cpu);
>   /*
>* A device tree containing CPU nodes with missing "reg"
>* properties is considered invalid to build the
> @@ -103,8 +103,8 @@ void __init arm_dt_init_cpu_maps(void)
>*/
>   cell = of_get_property(cpu, "reg", _bytes);
>   if (!cell || prop_bytes < sizeof(*cell)) {
> - pr_debug(" * %s missing reg property\n",
> -  cpu->full_name);
> + pr_debug(" * %pOF missing reg property\n",
> +  cpu);
>   of_node_put(cpu);
>   return;
>   }
> diff --git a/arch/arm/kernel/topology.c b/arch/arm/kernel/topology.c
> index bf949a763dbe..e596c5b8f931 100644
> --- a/arch/arm/kernel/topology.c
> +++ b/arch/arm/kernel/topology.c
> @@ -127,8 +127,8 @@ static void __init parse_dt_topology(void)
>
>   rate = of_get_property(cn, "clock-frequency", );
>   if (!rate || len != 4) {
> - pr_err("%s missing clock-frequency property\n",
> - cn->full_name);
> + pr_err("%pOF missing clock-frequency property\n",
> + cn);
>   continue;
>   }
>
> diff --git a/arch/arm/mach-exynos/suspend.c b/arch/arm/mach-exynos/suspend.c
> index 748cfb8d5212..3c7b66c22697 100644
> --- a/arch/arm/mach-exynos/suspend.c
> +++ b/arch/arm/mach-exynos/suspend.c
> @@ -187,21 +187,21 @@ static int __init exynos_pmu_irq_init(struct 
> device_node *node,
>   struct irq_domain *parent_domain, *domain;
>
>   if (!parent) {
> - pr_err("%s: no parent, giving up\n", node->full_name);
> + pr_err("%pOF: no parent, giving up\n", node);
>   return -ENODEV;
>   }
>
>   parent_domain = irq_find_host(parent);
>   if (!parent_domain) {
> - pr_err("%s: unable to obtain parent domain\n", 

Re: [PATCH] media: Convert to using %pOF instead of full_name

2017-07-19 Thread Nicolas Ferre
On 18/07/2017 at 23:43, Rob Herring wrote:
> Now that we have a custom printf format specifier, convert users of
> full_name to use %pOF instead. This is preparation to remove storing
> of the full path string for each node.
> 
> Signed-off-by: Rob Herring 
> Cc: Kyungmin Park 
> Cc: Andrzej Hajda 
> Cc: Mauro Carvalho Chehab 
> Cc: "Lad, Prabhakar" 
> Cc: Songjun Wu 
> Cc: Sylwester Nawrocki 
> Cc: Kukjin Kim 
> Cc: Krzysztof Kozlowski 
> Cc: Javier Martinez Canillas 
> Cc: Minghsiu Tsai 
> Cc: Houlong Wei 
> Cc: Andrew-CT Chen 
> Cc: Matthias Brugger 
> Cc: Laurent Pinchart 
> Cc: "Niklas Söderlund" 
> Cc: Guennadi Liakhovetski 
> Cc: Hyun Kwon 
> Cc: Michal Simek 
> Cc: "Sören Brinkmann" 
> Cc: linux-me...@vger.kernel.org
> Cc: linux-arm-ker...@lists.infradead.org
> Cc: linux-samsung-...@vger.kernel.org
> Cc: linux-media...@lists.infradead.org
> Cc: linux-renesas-soc@vger.kernel.org
> ---
>  drivers/media/i2c/s5c73m3/s5c73m3-core.c   |  3 +-
>  drivers/media/i2c/s5k5baf.c|  7 ++--
>  drivers/media/platform/am437x/am437x-vpfe.c|  4 +-
>  drivers/media/platform/atmel/atmel-isc.c   |  4 +-

Instead of Songjun, here is my:
Acked-by: Nicolas Ferre 


>  drivers/media/platform/davinci/vpif_capture.c  | 16 
>  drivers/media/platform/exynos4-is/fimc-is.c|  8 ++--
>  drivers/media/platform/exynos4-is/fimc-lite.c  |  3 +-
>  drivers/media/platform/exynos4-is/media-dev.c  |  8 ++--
>  drivers/media/platform/exynos4-is/mipi-csis.c  |  4 +-
>  drivers/media/platform/mtk-mdp/mtk_mdp_comp.c  |  6 +--
>  drivers/media/platform/mtk-mdp/mtk_mdp_core.c  |  8 ++--
>  drivers/media/platform/omap3isp/isp.c  |  8 ++--
>  drivers/media/platform/pxa_camera.c|  2 +-
>  drivers/media/platform/rcar-vin/rcar-core.c|  4 +-
>  drivers/media/platform/soc_camera/soc_camera.c |  6 +--
>  drivers/media/platform/xilinx/xilinx-vipp.c| 52 
> +-
>  drivers/media/v4l2-core/v4l2-async.c   |  4 +-
>  drivers/media/v4l2-core/v4l2-clk.c |  3 +-
>  include/media/v4l2-clk.h   |  4 +-
>  19 files changed, 71 insertions(+), 83 deletions(-)
> 
> diff --git a/drivers/media/i2c/s5c73m3/s5c73m3-core.c 
> b/drivers/media/i2c/s5c73m3/s5c73m3-core.c
> index f434fb2ee6fc..cdc4f2392ef9 100644
> --- a/drivers/media/i2c/s5c73m3/s5c73m3-core.c
> +++ b/drivers/media/i2c/s5c73m3/s5c73m3-core.c
> @@ -1635,8 +1635,7 @@ static int s5c73m3_get_platform_data(struct s5c73m3 
> *state)
> 
>   node_ep = of_graph_get_next_endpoint(node, NULL);
>   if (!node_ep) {
> - dev_warn(dev, "no endpoint defined for node: %s\n",
> - node->full_name);
> + dev_warn(dev, "no endpoint defined for node: %pOF\n", node);
>   return 0;
>   }
> 
> diff --git a/drivers/media/i2c/s5k5baf.c b/drivers/media/i2c/s5k5baf.c
> index 962051b9939d..9c22fc963901 100644
> --- a/drivers/media/i2c/s5k5baf.c
> +++ b/drivers/media/i2c/s5k5baf.c
> @@ -1863,8 +1863,7 @@ static int s5k5baf_parse_device_node(struct s5k5baf 
> *state, struct device *dev)
> 
>   node_ep = of_graph_get_next_endpoint(node, NULL);
>   if (!node_ep) {
> - dev_err(dev, "no endpoint defined at node %s\n",
> - node->full_name);
> + dev_err(dev, "no endpoint defined at node %pOF\n", node);
>   return -EINVAL;
>   }
> 
> @@ -1882,8 +1881,8 @@ static int s5k5baf_parse_device_node(struct s5k5baf 
> *state, struct device *dev)
>   case V4L2_MBUS_PARALLEL:
>   break;
>   default:
> - dev_err(dev, "unsupported bus in endpoint defined at node %s\n",
> - node->full_name);
> + dev_err(dev, "unsupported bus in endpoint defined at node 
> %pOF\n",
> + node);
>   return -EINVAL;
>   }
> 
> diff --git a/drivers/media/platform/am437x/am437x-vpfe.c 
> b/drivers/media/platform/am437x/am437x-vpfe.c
> index 466aba8b0e00..dfcc484cab89 100644
> --- a/drivers/media/platform/am437x/am437x-vpfe.c
> +++ b/drivers/media/platform/am437x/am437x-vpfe.c
> @@ -2490,8 +2490,8 @@ vpfe_get_pdata(struct platform_device *pdev)
> 
>   rem = of_graph_get_remote_port_parent(endpoint);
>   if (!rem) {
> - dev_err(>dev, "Remote device at %s not found\n",
> - endpoint->full_name);
> + 

Re: [PATCH v5 0/4] v4l2-async: add subnotifier registration for subdevices

2017-07-19 Thread Hans Verkuil
On 19/07/17 12:49, Niklas Söderlund wrote:
> * Changes since v4
> - Add patch which aborts v4l2_async_notifier_unregister() if the memory 
>   allocation for the device cache fails instead of trying to do as much 
>   as possible but still leave the system in a semi good state.

Since you are working with this code I would very much appreciate it if you
can make another patch that adds comments to this reprobing stuff, including
why device_reprobe() cannot be used here.

That will help in the future.

Regards,

Hans


[PATCH v5 3/4] v4l: async: do not hold list_lock when re-probing devices

2017-07-19 Thread Niklas Söderlund
There is no good reason to hold the list_lock when re-probing the
devices and it prevents a clean implementation of subdevice notifiers.
Move the actual release of the devices outside of the loop which
requires the lock to be held.

Signed-off-by: Niklas Söderlund 
---
 drivers/media/v4l2-core/v4l2-async.c | 19 +--
 1 file changed, 9 insertions(+), 10 deletions(-)

diff --git a/drivers/media/v4l2-core/v4l2-async.c 
b/drivers/media/v4l2-core/v4l2-async.c
index 67852f0f2d3000c9..d91ff0a33fd3eaff 100644
--- a/drivers/media/v4l2-core/v4l2-async.c
+++ b/drivers/media/v4l2-core/v4l2-async.c
@@ -206,7 +206,7 @@ void v4l2_async_notifier_unregister(struct 
v4l2_async_notifier *notifier)
unsigned int notif_n_subdev = notifier->num_subdevs;
unsigned int n_subdev = min(notif_n_subdev, V4L2_MAX_SUBDEVS);
struct device **dev;
-   int i = 0;
+   int i, count = 0;
 
if (!notifier->v4l2_dev)
return;
@@ -223,27 +223,26 @@ void v4l2_async_notifier_unregister(struct 
v4l2_async_notifier *notifier)
list_del(>list);
 
list_for_each_entry_safe(sd, tmp, >done, async_list) {
-   struct device *d;
-
-   d = get_device(sd->dev);
+   dev[count] = get_device(sd->dev);
+   count++;
 
if (notifier->unbind)
notifier->unbind(notifier, sd, sd->asd);
 
v4l2_async_cleanup(sd);
-
-   /* If we handled USB devices, we'd have to lock the parent too 
*/
-   device_release_driver(d);
-
-   dev[i++] = d;
}
 
mutex_unlock(_lock);
 
+   for (i = 0; i < count; i++) {
+   /* If we handled USB devices, we'd have to lock the parent too 
*/
+   device_release_driver(dev[i]);
+   }
+
/*
 * Call device_attach() to reprobe devices
 */
-   while (i--) {
+   for (i = 0; i < count; i++) {
struct device *d = dev[i];
 
if (d && device_attach(d) < 0) {
-- 
2.13.1



[PATCH v5 4/4] v4l: async: add subnotifier to subdevices

2017-07-19 Thread Niklas Söderlund
Add a subdevice specific notifier which can be used by a subdevice
driver to complement the master device notifier to extend the subdevice
discovery.

The master device registers the subdevices closest to itself in its
notifier while the subdevice(s) register notifiers for their closest
neighboring devices. Subdevice drivers configure a notifier at probe
time which is registered by the v4l2-async framework once the subdevice
itself is registered, since it's only at this point the v4l2_dev is
available to the subnotifier.

Using this incremental approach two problems can be solved:

1. The master device no longer has to care how many devices exist in
   the pipeline. It only needs to care about its closest subdevice and
   arbitrary long pipelines can be created without having to adapt the
   master device for each case.

2. Subdevices which are represented as a single DT node but register
   more than one subdevice can use this to improve the pipeline
   discovery, since the subdevice driver is the only one who knows which
   of its subdevices is linked with which subdevice of a neighboring DT
   node.

To allow subdevices to provide their own list of subdevices to the
v4l2-async framework v4l2_async_subdev_notifier_register() is added.
This new function must be called before the subdevice itself is
registered with the v4l2-async framework using
v4l2_async_register_subdev().

Signed-off-by: Niklas Söderlund 
---
 Documentation/media/kapi/v4l2-subdev.rst |  12 +++
 drivers/media/v4l2-core/v4l2-async.c | 142 +++
 include/media/v4l2-async.h   |  25 ++
 include/media/v4l2-subdev.h  |   5 ++
 4 files changed, 169 insertions(+), 15 deletions(-)

diff --git a/Documentation/media/kapi/v4l2-subdev.rst 
b/Documentation/media/kapi/v4l2-subdev.rst
index e1f0b726e438f963..ec9e7b7fb78f226d 100644
--- a/Documentation/media/kapi/v4l2-subdev.rst
+++ b/Documentation/media/kapi/v4l2-subdev.rst
@@ -262,6 +262,18 @@ is called. After all subdevices have been located the 
.complete() callback is
 called. When a subdevice is removed from the system the .unbind() method is
 called. All three callbacks are optional.
 
+Subdevice drivers might in turn register subnotifier objects with an
+array of other subdevice descriptors that the subdevice needs for its
+own operation. Subnotifiers are an extension of the bridge drivers
+notifier to allow for a incremental registering and matching of
+subdevices. This is useful when a driver only has information about
+which subdevice is closest to itself and would require knowledge from the
+driver of that subdevice to know which other subdevice(s) lie beyond.
+By registering subnotifiers drivers can incrementally move the subdevice
+matching down the chain of drivers. This is performed using the
+:c:func:`v4l2_async_subdev_notifier_register` call which must be performed
+before registering the subdevice using :c:func:`v4l2_async_register_subdev`.
+
 V4L2 sub-device userspace API
 -
 
diff --git a/drivers/media/v4l2-core/v4l2-async.c 
b/drivers/media/v4l2-core/v4l2-async.c
index d91ff0a33fd3eaff..0cafb13025b5cbb6 100644
--- a/drivers/media/v4l2-core/v4l2-async.c
+++ b/drivers/media/v4l2-core/v4l2-async.c
@@ -100,6 +100,60 @@ static struct v4l2_async_subdev *v4l2_async_belongs(struct 
v4l2_async_notifier *
return NULL;
 }
 
+static int v4l2_async_notifier_complete(struct v4l2_async_notifier *notifier)
+{
+   struct v4l2_subdev *sd, *tmp;
+
+   if (!notifier->num_subdevs)
+   return 0;
+
+   list_for_each_entry_safe(sd, tmp, >done, async_list)
+   v4l2_async_notifier_complete(>subnotifier);
+
+   if (notifier->complete)
+   return notifier->complete(notifier);
+
+   return 0;
+}
+
+static bool
+v4l2_async_is_notifier_complete(struct v4l2_async_notifier *notifier)
+{
+   struct v4l2_subdev *sd, *tmp;
+
+   if (!list_empty(>waiting))
+   return false;
+
+   list_for_each_entry_safe(sd, tmp, >done, async_list) {
+   /* Don't consider empty subnotifiers */
+   if (!sd->subnotifier.num_subdevs)
+   continue;
+
+   if (!v4l2_async_is_notifier_complete(>subnotifier))
+   return false;
+   }
+
+   return true;
+}
+
+static int
+v4l2_async_try_complete_notifier(struct v4l2_async_notifier *notifier)
+{
+   struct v4l2_async_notifier *root = notifier;
+
+   while (root->subnotifier) {
+   root = subnotifier_to_v4l2_subdev(root)->notifier;
+   /* No root notifier can be found at this time */
+   if (!root)
+   return 0;
+   }
+
+   if (v4l2_async_is_notifier_complete(root))
+   return v4l2_async_notifier_complete(root);
+
+   return 0;
+}
+
 static int v4l2_async_test_notify(struct v4l2_async_notifier *notifier,

[PATCH v5 0/4] v4l2-async: add subnotifier registration for subdevices

2017-07-19 Thread Niklas Söderlund
Hi,

I know Sakari have posted a series '[RFC 00/19] Async sub-notifiers and 
how to use them' which address similar problems as this series. This is 
not intended to compete whit his work and Sakari includes one of my v3 
patches in his series. Never the less I post this updated series since 
it fixes some issues in my v3 implementation and contains some other 
fixes for the v4l2-async framework which are not addressed in Sakaris 
patches. I think the correct solution to the problems we both try to fix 
is a mix of our two series, would you agree Sakari?

This series enables incremental async find and bind of subdevices,
please se patch 4/4 for a more detailed description. This is a rewrite 
of the feature since v3, see changelog in this cover letter for the 
differences to v3. The two primary reasons for a new implementation 
where:

1. Hans expressed an interest having the async complete() callbacks to
   happen only once all notifiers in the pipeline where complete. To do
   this a stronger connection between the notifiers where needed, hence
   the subnotifier is now embedded in struct v4l2_subdev.

   Whit this change it is possible to check all notifiers in a pipeline
   is complete before calling any of them.

2. There where concerns that the v3 solution was a bit to complex and
   hard to refactor in the future if other issues in the v4l2-async
   framework where to be addressed. By hiding the notifier in the struct
   v4l2_subdev and adding a new function to set that structure the
   interface towards drivers are minimized while everything else happens
   in the v4l2-async framework. This leaves the interface in a good
   position for possible changes in v4l2-async.

This is tested on Renesas H3 and M3-W together with the Renesas CSI-2
and VIN Gen3 driver (posted separately). It is based on top of the media-tree.

* Changes since v4
- Add patch which aborts v4l2_async_notifier_unregister() if the memory 
  allocation for the device cache fails instead of trying to do as much 
  as possible but still leave the system in a semi good state.
- Rename v4l2_async_subdev_register_notifier() to 
  v4l2_async_subdev_notifier_register().
- Add more error checks in v4l2_async_subdev_notifier_register().
- Fix code style issues pointed out by Hans.
- Fix spelling mistakes pointed out by Hans.

* Changes since v3
- Almost a complete rewrite, so drop all Ack-ed by tags.
- Do not add new functions to register/unregister subnotifiers from 
  callbacks. Instead have have the subdevice drivers populate the
  subnotifer list at probe time and have the v4l2-async framework handle
  the (un)registration of the notifiers.
- Synchronize the call off the complete() callbacks. They will now all 
  happens once all notifiers in a pipeline are all complete and from the
  edge towards the root device.
- Add a new function v4l2_async_subdev_register_notifier() to hide the 
  setup of the subnotifier internals to ease improvements later.

* Changes since v2
- Fixed lots of spelling mistakes, thanks Hans!
- Used a goto instead if state variable when restarting iteration over
  subdev list as suggested by Sakari. Thank you it's much easier read
  now.
- Added Acked-by from Sakari and Hans, thanks!
- Rebased to latest media-tree.

* Changes since v1:
- Added a pre-patch which adds an error check which was previously in
  the new incremental async code but is more useful on its own.
- Added documentation to Documentation/media/kapi/v4l2-subdev.rst.
- Fixed data type of bool variable.
- Added call to lockdep_assert_held(), thanks Sakari.
- Fixed commit messages typo, thanks Sakari.

Niklas Söderlund (4):
  v4l: async: fix unbind error in v4l2_async_notifier_unregister()
  v4l: async: abort if memory allocation fails when unregistering
notifiers
  v4l: async: do not hold list_lock when re-probing devices
  v4l: async: add subnotifier to subdevices

 Documentation/media/kapi/v4l2-subdev.rst |  12 +++
 drivers/media/v4l2-core/v4l2-async.c | 170 ---
 include/media/v4l2-async.h   |  25 +
 include/media/v4l2-subdev.h  |   5 +
 4 files changed, 178 insertions(+), 34 deletions(-)

-- 
2.13.1



[PATCH v5 2/4] v4l: async: abort if memory allocation fails when unregistering notifiers

2017-07-19 Thread Niklas Söderlund
Instead of trying to cope with the failed memory allocation and still
leaving the kernel in a semi-broken state (the subdevices will be
released but never re-probed) simply abort. The kernel have already
printed a warning about allocation failure but keep the error printout
to ease pinpointing the problem if it happens.

By doing this we can increase the readability of this complex function
which puts it in a better state to separate the v4l2 housekeeping tasks
from the re-probing of devices. It also serves to prepare for adding
subnotifers.

Signed-off-by: Niklas Söderlund 
---
 drivers/media/v4l2-core/v4l2-async.c | 13 ++---
 1 file changed, 2 insertions(+), 11 deletions(-)

diff --git a/drivers/media/v4l2-core/v4l2-async.c 
b/drivers/media/v4l2-core/v4l2-async.c
index 0acf288d7227ba97..67852f0f2d3000c9 100644
--- a/drivers/media/v4l2-core/v4l2-async.c
+++ b/drivers/media/v4l2-core/v4l2-async.c
@@ -215,6 +215,7 @@ void v4l2_async_notifier_unregister(struct 
v4l2_async_notifier *notifier)
if (!dev) {
dev_err(notifier->v4l2_dev->dev,
"Failed to allocate device cache!\n");
+   return;
}
 
mutex_lock(_lock);
@@ -234,23 +235,13 @@ void v4l2_async_notifier_unregister(struct 
v4l2_async_notifier *notifier)
/* If we handled USB devices, we'd have to lock the parent too 
*/
device_release_driver(d);
 
-   /*
-* Store device at the device cache, in order to call
-* put_device() on the final step
-*/
-   if (dev)
-   dev[i++] = d;
-   else
-   put_device(d);
+   dev[i++] = d;
}
 
mutex_unlock(_lock);
 
/*
 * Call device_attach() to reprobe devices
-*
-* NOTE: If dev allocation fails, i is 0, and the whole loop won't be
-* executed.
 */
while (i--) {
struct device *d = dev[i];
-- 
2.13.1



[PATCH v5 1/4] v4l: async: fix unbind error in v4l2_async_notifier_unregister()

2017-07-19 Thread Niklas Söderlund
The call to v4l2_async_cleanup() will set sd->asd to NULL so passing it
to notifier->unbind() have no effect and leaves the notifier confused.
Call the unbind() callback prior to cleaning up the subdevice to avoid
this.

Signed-off-by: Niklas Söderlund 
---
 drivers/media/v4l2-core/v4l2-async.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/drivers/media/v4l2-core/v4l2-async.c 
b/drivers/media/v4l2-core/v4l2-async.c
index 851f128eba2219ad..0acf288d7227ba97 100644
--- a/drivers/media/v4l2-core/v4l2-async.c
+++ b/drivers/media/v4l2-core/v4l2-async.c
@@ -226,14 +226,14 @@ void v4l2_async_notifier_unregister(struct 
v4l2_async_notifier *notifier)
 
d = get_device(sd->dev);
 
+   if (notifier->unbind)
+   notifier->unbind(notifier, sd, sd->asd);
+
v4l2_async_cleanup(sd);
 
/* If we handled USB devices, we'd have to lock the parent too 
*/
device_release_driver(d);
 
-   if (notifier->unbind)
-   notifier->unbind(notifier, sd, sd->asd);
-
/*
 * Store device at the device cache, in order to call
 * put_device() on the final step
-- 
2.13.1



Re: [PATCH] clk: Convert to using %pOF instead of full_name

2017-07-19 Thread Matthias Brugger



On 07/18/2017 11:42 PM, Rob Herring wrote:

Now that we have a custom printf format specifier, convert users of
full_name to use %pOF instead. This is preparation to remove storing
of the full path string for each node.

Signed-off-by: Rob Herring 
Cc: Michael Turquette 
Cc: Stephen Boyd 
Cc: Maxime Coquelin 
Cc: Alexandre Torgue 
Cc: Russell King 
Cc: Matthias Brugger 
Cc: Geert Uytterhoeven 
Cc: Maxime Ripard 
Cc: Chen-Yu Tsai 
Cc: "Emilio López" 
Cc: Peter De Schrijver 
Cc: Prashant Gaikwad 
Cc: Thierry Reding 
Cc: Jonathan Hunter 
Cc: Tero Kristo 
Cc: linux-...@vger.kernel.org
Cc: linux-arm-ker...@lists.infradead.org
Cc: linux-media...@lists.infradead.org
Cc: linux-renesas-soc@vger.kernel.org
Cc: linux-te...@vger.kernel.org
Cc: linux-o...@vger.kernel.org
---
  drivers/clk/berlin/bg2.c |  3 +--
  drivers/clk/berlin/bg2q.c|  7 +++
  drivers/clk/clk-asm9260.c|  4 ++--
  drivers/clk/clk-conf.c   | 16 
  drivers/clk/clk-moxart.c | 12 ++--
  drivers/clk/clk-qoriq.c  |  7 +++
  drivers/clk/clk-stm32f4.c|  4 ++--
  drivers/clk/clk-xgene.c  | 15 ++-
  drivers/clk/clk.c|  4 ++--
  drivers/clk/clkdev.c |  4 ++--
  drivers/clk/mediatek/clk-cpumux.c|  2 +-
  drivers/clk/mediatek/clk-mtk.c   |  2 +-
  drivers/clk/mediatek/reset.c |  2 +-


Reviewed-by: Matthias Brugger 

For the mediatek parts.

Thanks,
Matthias


Re: [PATCH] soc: Convert to using %pOF instead of full_name

2017-07-19 Thread Matthias Brugger



On 07/18/2017 11:43 PM, Rob Herring wrote:

Now that we have a custom printf format specifier, convert users of
full_name to use %pOF instead. This is preparation to remove storing
of the full path string for each node.

Signed-off-by: Rob Herring 
Cc: Scott Wood 
Cc: Qiang Zhao 
Cc: Matthias Brugger 
Cc: Simon Horman 
Cc: Magnus Damm 
Cc: Kukjin Kim 
Cc: Krzysztof Kozlowski 
Cc: Javier Martinez Canillas 
Cc: linuxppc-...@lists.ozlabs.org
Cc: linux-arm-ker...@lists.infradead.org
Cc: linux-media...@lists.infradead.org
Cc: linux-renesas-soc@vger.kernel.org
Cc: linux-samsung-...@vger.kernel.org
---
  drivers/soc/fsl/qbman/bman_ccsr.c| 10 +-
  drivers/soc/fsl/qbman/bman_portal.c  |  8 +++-
  drivers/soc/fsl/qbman/qman_ccsr.c| 12 ++--
  drivers/soc/fsl/qbman/qman_portal.c  | 11 ---
  drivers/soc/fsl/qe/gpio.c|  4 ++--
  drivers/soc/mediatek/mtk-pmic-wrap.c |  4 ++--


For Mediatek:

Acked-by: Matthias Brugger 


Re: [PATCH] media: Convert to using %pOF instead of full_name

2017-07-19 Thread Matthias Brugger



On 07/18/2017 11:43 PM, Rob Herring wrote:

Now that we have a custom printf format specifier, convert users of
full_name to use %pOF instead. This is preparation to remove storing
of the full path string for each node.

Signed-off-by: Rob Herring 
Cc: Kyungmin Park 
Cc: Andrzej Hajda 
Cc: Mauro Carvalho Chehab 
Cc: "Lad, Prabhakar" 
Cc: Songjun Wu 
Cc: Sylwester Nawrocki 
Cc: Kukjin Kim 
Cc: Krzysztof Kozlowski 
Cc: Javier Martinez Canillas 
Cc: Minghsiu Tsai 
Cc: Houlong Wei 
Cc: Andrew-CT Chen 
Cc: Matthias Brugger 
Cc: Laurent Pinchart 
Cc: "Niklas Söderlund" 
Cc: Guennadi Liakhovetski 
Cc: Hyun Kwon 
Cc: Michal Simek 
Cc: "Sören Brinkmann" 
Cc: linux-me...@vger.kernel.org
Cc: linux-arm-ker...@lists.infradead.org
Cc: linux-samsung-...@vger.kernel.org
Cc: linux-media...@lists.infradead.org
Cc: linux-renesas-soc@vger.kernel.org
---
  drivers/media/i2c/s5c73m3/s5c73m3-core.c   |  3 +-
  drivers/media/i2c/s5k5baf.c|  7 ++--
  drivers/media/platform/am437x/am437x-vpfe.c|  4 +-
  drivers/media/platform/atmel/atmel-isc.c   |  4 +-
  drivers/media/platform/davinci/vpif_capture.c  | 16 
  drivers/media/platform/exynos4-is/fimc-is.c|  8 ++--
  drivers/media/platform/exynos4-is/fimc-lite.c  |  3 +-
  drivers/media/platform/exynos4-is/media-dev.c  |  8 ++--
  drivers/media/platform/exynos4-is/mipi-csis.c  |  4 +-
  drivers/media/platform/mtk-mdp/mtk_mdp_comp.c  |  6 +--
  drivers/media/platform/mtk-mdp/mtk_mdp_core.c  |  8 ++--


For mediatek parts:

Reviewed-by: Matthias Brugger 


Re: [PATCH v3 4/4] i2c: rcar: check for DMA-capable buffers

2017-07-19 Thread Niklas Söderlund
Hi Wolfram,

On 2017-07-18 12:23:39 +0200, Wolfram Sang wrote:
> Handling this is special for this driver. Because the hardware needs to
> initialize the next message in interrupt context, we cannot use the
> i2c_check_msg_for_dma() directly. This helper only works reliably in
> process context. So, we need to check during initial preparation of the
> whole transfer and need to disable DMA completely for the whole transfer
> once a message with a not-DMA-capable buffer is found.
> 
> Signed-off-by: Wolfram Sang 
> ---
>  drivers/i2c/busses/i2c-rcar.c | 18 +-
>  1 file changed, 13 insertions(+), 5 deletions(-)
> 
> diff --git a/drivers/i2c/busses/i2c-rcar.c b/drivers/i2c/busses/i2c-rcar.c
> index 93c1a54981df08..5d0e820d708853 100644
> --- a/drivers/i2c/busses/i2c-rcar.c
> +++ b/drivers/i2c/busses/i2c-rcar.c
> @@ -111,8 +111,11 @@
>  #define ID_ARBLOST   (1 << 3)
>  #define ID_NACK  (1 << 4)
>  /* persistent flags */
> +#define ID_P_NODMA   (1 << 30)
>  #define ID_P_PM_BLOCKED  (1 << 31)
> -#define ID_P_MASKID_P_PM_BLOCKED
> +#define ID_P_MASK(ID_P_PM_BLOCKED | ID_P_NODMA)
> +
> +#define RCAR_DMA_THRESHOLD 8
>  
>  enum rcar_i2c_type {
>   I2C_RCAR_GEN1,
> @@ -358,8 +361,7 @@ static void rcar_i2c_dma(struct rcar_i2c_priv *priv)
>   unsigned char *buf;
>   int len;
>  
> - /* Do not use DMA if it's not available or for messages < 8 bytes */
> - if (IS_ERR(chan) || msg->len < 8)
> + if (IS_ERR(chan) || msg->len < RCAR_DMA_THRESHOLD || priv->flags & 
> ID_P_NODMA)
>   return;
>  
>   if (read) {
> @@ -657,11 +659,15 @@ static void rcar_i2c_request_dma(struct rcar_i2c_priv 
> *priv,
>struct i2c_msg *msg)
>  {
>   struct device *dev = rcar_i2c_priv_to_dev(priv);
> - bool read;
> + bool read = msg->flags & I2C_M_RD;
>   struct dma_chan *chan;
>   enum dma_transfer_direction dir;
>  
> - read = msg->flags & I2C_M_RD;
> + /* we need to check here because we need the 'current' context */

Maybe extend the comment here explaining that the check is primary here 
to make sure the msg->buf is valid for DMA and that the bounce buffer 
can't be used due to the special hardware feature? Else someone might be 
tempted to try and enable the bounce buffer feature in the future?

Nitpicking aside:

Reviewed-by: Niklas Söderlund 

> + if (i2c_check_msg_for_dma(msg, RCAR_DMA_THRESHOLD, NULL) == -EFAULT) {
> + dev_dbg(dev, "skipping DMA for this whole transfer\n");
> + priv->flags |= ID_P_NODMA;
> + }
>  
>   chan = read ? priv->dma_rx : priv->dma_tx;
>   if (PTR_ERR(chan) != -EPROBE_DEFER)
> @@ -740,6 +746,8 @@ static int rcar_i2c_master_xfer(struct i2c_adapter *adap,
>   if (ret < 0 && ret != -ENXIO)
>   dev_err(dev, "error %d : %x\n", ret, priv->flags);
>  
> + priv->flags &= ~ID_P_NODMA;
> +
>   return ret;
>  }
>  
> -- 
> 2.11.0
> 

-- 
Regards,
Niklas Söderlund


Re: [PATCH] media: Convert to using %pOF instead of full_name

2017-07-19 Thread Sylwester Nawrocki
On 07/18/2017 11:43 PM, Rob Herring wrote:
> Now that we have a custom printf format specifier, convert users of
> full_name to use %pOF instead. This is preparation to remove storing
> of the full path string for each node.
> 
> Signed-off-by: Rob Herring 

> ---
>   drivers/media/i2c/s5c73m3/s5c73m3-core.c   |  3 +-
>   drivers/media/i2c/s5k5baf.c|  7 ++--
>   drivers/media/platform/am437x/am437x-vpfe.c|  4 +-
>   drivers/media/platform/atmel/atmel-isc.c   |  4 +-
>   drivers/media/platform/davinci/vpif_capture.c  | 16 
>   drivers/media/platform/exynos4-is/fimc-is.c|  8 ++--
>   drivers/media/platform/exynos4-is/fimc-lite.c  |  3 +-
>   drivers/media/platform/exynos4-is/media-dev.c  |  8 ++--
>   drivers/media/platform/exynos4-is/mipi-csis.c  |  4 +-
>   drivers/media/platform/mtk-mdp/mtk_mdp_comp.c  |  6 +--
>   drivers/media/platform/mtk-mdp/mtk_mdp_core.c  |  8 ++--
>   drivers/media/platform/omap3isp/isp.c  |  8 ++--
>   drivers/media/platform/pxa_camera.c|  2 +-
>   drivers/media/platform/rcar-vin/rcar-core.c|  4 +-
>   drivers/media/platform/soc_camera/soc_camera.c |  6 +--
>   drivers/media/platform/xilinx/xilinx-vipp.c| 52 
> +-
>   drivers/media/v4l2-core/v4l2-async.c   |  4 +-
>   drivers/media/v4l2-core/v4l2-clk.c |  3 +-
>   include/media/v4l2-clk.h   |  4 +-
>   19 files changed, 71 insertions(+), 83 deletions(-)

> diff --git a/drivers/media/platform/xilinx/xilinx-vipp.c 
> b/drivers/media/platform/xilinx/xilinx-vipp.c
> index ac4704388920..9233ad0b1b6b 100644
> --- a/drivers/media/platform/xilinx/xilinx-vipp.c
> +++ b/drivers/media/platform/xilinx/xilinx-vipp.c

> @@ -144,9 +144,8 @@ static int xvip_graph_build_one(struct 
> xvip_composite_device *xdev,
>   remote = ent->entity;
> 
>   if (link.remote_port >= remote->num_pads) {
> - dev_err(xdev->dev, "invalid port number %u on %s\n",
> - link.remote_port,
> - to_of_node(link.remote_node)->full_name);
> + dev_err(xdev->dev, "invalid port number %u on %pOF\n",
> + link.remote_port, link.remote_node);

Shouldn't there be to_of_node(link.remote_node) instead of link.remote_node ?

>   v4l2_fwnode_put_link();
>   ret = -EINVAL;
>   break;

> @@ -242,17 +241,17 @@ static int xvip_graph_build_dma(struct 
> xvip_composite_device *xdev)
>   ent = xvip_graph_find_entity(xdev,
>to_of_node(link.remote_node));
>   if (ent == NULL) {
> - dev_err(xdev->dev, "no entity found for %s\n",
> - to_of_node(link.remote_node)->full_name);
> + dev_err(xdev->dev, "no entity found for %pOF\n",
> + to_of_node(link.remote_node));
>   v4l2_fwnode_put_link();
>   ret = -ENODEV;
>   break;
>   }

> diff --git a/drivers/media/v4l2-core/v4l2-async.c 
> b/drivers/media/v4l2-core/v4l2-async.c
> index 851f128eba22..0a385d1ff28c 100644
> --- a/drivers/media/v4l2-core/v4l2-async.c
> +++ b/drivers/media/v4l2-core/v4l2-async.c
> @@ -47,9 +47,7 @@ static bool match_fwnode(struct v4l2_subdev *sd, struct 
> v4l2_async_subdev *asd)
>   if (!is_of_node(sd->fwnode) || !is_of_node(asd->match.fwnode.fwnode))
>   return sd->fwnode == asd->match.fwnode.fwnode;
> 
> - return !of_node_cmp(of_node_full_name(to_of_node(sd->fwnode)),
> - of_node_full_name(
> - to_of_node(asd->match.fwnode.fwnode)));
> + return to_of_node(sd->fwnode) == to_of_node(asd->match.fwnode.fwnode);

I'm afraid this will not work, please see commit d2180e0cf77dc7a7049671d5d57d
"[media] v4l: async: make v4l2 coexist with devicetree nodes in a dt overlay"

--
Regards,
Sylwester


Re: [PATCH] clk: Convert to using %pOF instead of full_name

2017-07-19 Thread Alexandre Torgue



On 07/18/2017 11:42 PM, Rob Herring wrote:

Now that we have a custom printf format specifier, convert users of
full_name to use %pOF instead. This is preparation to remove storing
of the full path string for each node.

Signed-off-by: Rob Herring 
Cc: Michael Turquette 
Cc: Stephen Boyd 
Cc: Maxime Coquelin 
Cc: Alexandre Torgue 
Cc: Russell King 
Cc: Matthias Brugger 
Cc: Geert Uytterhoeven 
Cc: Maxime Ripard 
Cc: Chen-Yu Tsai 
Cc: "Emilio López" 
Cc: Peter De Schrijver 
Cc: Prashant Gaikwad 
Cc: Thierry Reding 
Cc: Jonathan Hunter 
Cc: Tero Kristo 
Cc: linux-...@vger.kernel.org
Cc: linux-arm-ker...@lists.infradead.org
Cc: linux-media...@lists.infradead.org
Cc: linux-renesas-soc@vger.kernel.org
Cc: linux-te...@vger.kernel.org
Cc: linux-o...@vger.kernel.org
---
  drivers/clk/berlin/bg2.c |  3 +--
  drivers/clk/berlin/bg2q.c|  7 +++
  drivers/clk/clk-asm9260.c|  4 ++--
  drivers/clk/clk-conf.c   | 16 
  drivers/clk/clk-moxart.c | 12 ++--
  drivers/clk/clk-qoriq.c  |  7 +++
  drivers/clk/clk-stm32f4.c|  4 ++--
  drivers/clk/clk-xgene.c  | 15 ++-
  drivers/clk/clk.c|  4 ++--
  drivers/clk/clkdev.c |  4 ++--
  drivers/clk/mediatek/clk-cpumux.c|  2 +-
  drivers/clk/mediatek/clk-mtk.c   |  2 +-
  drivers/clk/mediatek/reset.c |  2 +-
  drivers/clk/renesas/clk-mstp.c   |  2 +-
  drivers/clk/renesas/clk-rcar-gen2.c  |  3 +--
  drivers/clk/sunxi-ng/ccu-sun5i.c |  3 +--
  drivers/clk/sunxi-ng/ccu-sun6i-a31.c |  3 +--
  drivers/clk/sunxi-ng/ccu-sun8i-a23.c |  3 +--
  drivers/clk/sunxi-ng/ccu-sun8i-a33.c |  3 +--
  drivers/clk/sunxi-ng/ccu-sun8i-h3.c  |  3 +--
  drivers/clk/sunxi-ng/ccu-sun8i-r.c   |  3 +--
  drivers/clk/sunxi-ng/ccu-sun8i-v3s.c |  3 +--
  drivers/clk/sunxi/clk-sunxi.c| 17 +++--
  drivers/clk/tegra/clk-emc.c  | 12 +---
  drivers/clk/ti/clockdomain.c |  4 ++--
  25 files changed, 61 insertions(+), 80 deletions(-)


For clk/clk-stm32f4.c

Acked-by: Alexandre TORGUE 

Regards
Alex



diff --git a/drivers/clk/berlin/bg2.c b/drivers/clk/berlin/bg2.c
index 1d99292e2039..e7331ace0337 100644
--- a/drivers/clk/berlin/bg2.c
+++ b/drivers/clk/berlin/bg2.c
@@ -679,8 +679,7 @@ static void __init berlin2_clock_setup(struct device_node 
*np)
if (!IS_ERR(hws[n]))
continue;

-   pr_err("%s: Unable to register leaf clock %d\n",
-  np->full_name, n);
+   pr_err("%pOF: Unable to register leaf clock %d\n", np, n);
goto bg2_fail;
}

diff --git a/drivers/clk/berlin/bg2q.c b/drivers/clk/berlin/bg2q.c
index 3b784b593afd..67c270b143f7 100644
--- a/drivers/clk/berlin/bg2q.c
+++ b/drivers/clk/berlin/bg2q.c
@@ -304,14 +304,14 @@ static void __init berlin2q_clock_setup(struct 
device_node *np)

gbase = of_iomap(parent_np, 0);
if (!gbase) {
-   pr_err("%s: Unable to map global base\n", np->full_name);
+   pr_err("%pOF: Unable to map global base\n", np);
return;
}

/* BG2Q CPU PLL is not part of global registers */
cpupll_base = of_iomap(parent_np, 1);
if (!cpupll_base) {
-   pr_err("%s: Unable to map cpupll base\n", np->full_name);
+   pr_err("%pOF: Unable to map cpupll base\n", np);
iounmap(gbase);
return;
}
@@ -376,8 +376,7 @@ static void __init berlin2q_clock_setup(struct device_node 
*np)
if (!IS_ERR(hws[n]))
continue;

-   pr_err("%s: Unable to register leaf clock %d\n",
-  np->full_name, n);
+   pr_err("%pOF: Unable to register leaf clock %d\n", np, n);
goto bg2q_fail;
}

diff --git a/drivers/clk/clk-asm9260.c b/drivers/clk/clk-asm9260.c
index ea8568536193..bf0582cbbf38 100644
--- a/drivers/clk/clk-asm9260.c
+++ b/drivers/clk/clk-asm9260.c
@@ -338,8 +338,8 @@ static void __init asm9260_acc_init(struct device_node *np)
if (!IS_ERR(hws[n]))
continue;

-   pr_err("%s: Unable to register leaf clock %d\n",
-   np->full_name, n);
+   pr_err("%pOF: Unable to register leaf clock %d\n",
+   np, n);
goto fail;
}

diff --git a/drivers/clk/clk-conf.c b/drivers/clk/clk-conf.c
index 

Re: [PATCH v3 3/4] i2c: sh_mobile: use helper to decide if DMA is useful

2017-07-19 Thread Niklas Söderlund
Hi Wolfram,

On 2017-07-18 12:23:38 +0200, Wolfram Sang wrote:
> This ensures that we fall back to PIO if the buffer is too small for DMA
> being useful. Otherwise, we use DMA. A bounce buffer might be applied if
> the original message buffer is not DMA safe
> 
> Signed-off-by: Wolfram Sang 
> ---
>  drivers/i2c/busses/i2c-sh_mobile.c | 8 ++--
>  1 file changed, 6 insertions(+), 2 deletions(-)
> 
> diff --git a/drivers/i2c/busses/i2c-sh_mobile.c 
> b/drivers/i2c/busses/i2c-sh_mobile.c
> index 2e097d97d258bc..19f45bcd9b35ca 100644
> --- a/drivers/i2c/busses/i2c-sh_mobile.c
> +++ b/drivers/i2c/busses/i2c-sh_mobile.c
> @@ -145,6 +145,7 @@ struct sh_mobile_i2c_data {
>   struct dma_chan *dma_rx;
>   struct scatterlist sg;
>   enum dma_data_direction dma_direction;
> + u8 *bounce_buf;
>  };
>  
>  struct sh_mobile_dt_config {
> @@ -548,6 +549,8 @@ static void sh_mobile_i2c_dma_callback(void *data)
>   pd->pos = pd->msg->len;
>   pd->stop_after_dma = true;
>  
> + i2c_release_dma_bounce_buf(pd->msg, pd->bounce_buf);
> +
>   iic_set_clr(pd, ICIC, 0, ICIC_TDMAE | ICIC_RDMAE);
>  }
>  
> @@ -595,6 +598,7 @@ static void sh_mobile_i2c_xfer_dma(struct 
> sh_mobile_i2c_data *pd)
>   struct dma_async_tx_descriptor *txdesc;
>   dma_addr_t dma_addr;
>   dma_cookie_t cookie;
> + u8 *dma_buf = pd->bounce_buf ?: pd->msg->buf;

This looked funny and I had to look it up, I learnt something new today 
:-)

>  
>   if (PTR_ERR(chan) == -EPROBE_DEFER) {
>   if (read)
> @@ -608,7 +612,7 @@ static void sh_mobile_i2c_xfer_dma(struct 
> sh_mobile_i2c_data *pd)
>   if (IS_ERR(chan))
>   return;
>  
> - dma_addr = dma_map_single(chan->device->dev, pd->msg->buf, 
> pd->msg->len, dir);
> + dma_addr = dma_map_single(chan->device->dev, dma_buf, pd->msg->len, 
> dir);
>   if (dma_mapping_error(chan->device->dev, dma_addr)) {
>   dev_dbg(pd->dev, "dma map failed, using PIO\n");
>   return;
> @@ -665,7 +669,7 @@ static int start_ch(struct sh_mobile_i2c_data *pd, struct 
> i2c_msg *usr_msg,
>   pd->pos = -1;
>   pd->sr = 0;
>  
> - if (pd->msg->len > 8)
> + if (i2c_check_msg_for_dma(pd->msg, 8, >bounce_buf) == 0)

Maybe the 8 should be declared in a define to explain the value, like 
you do in patch 4/4?

This nitpick aside:

Reviewed-by: Niklas Söderlund 

>   sh_mobile_i2c_xfer_dma(pd);
>  
>   /* Enable all interrupts to begin with */
> -- 
> 2.11.0
> 

-- 
Regards,
Niklas Söderlund


Re: [PATCH v3 2/4] i2c: add docs to clarify DMA handling

2017-07-19 Thread Niklas Söderlund
Hi Wolfram,

On 2017-07-18 12:23:37 +0200, Wolfram Sang wrote:
> Signed-off-by: Wolfram Sang 

Reviewed-by: Niklas Söderlund 

> ---
> Changes since v2:
> 
> * documentation updates. Hopefully better wording now
> 
>  Documentation/i2c/DMA-considerations | 38 
> 
>  1 file changed, 38 insertions(+)
>  create mode 100644 Documentation/i2c/DMA-considerations
> 
> diff --git a/Documentation/i2c/DMA-considerations 
> b/Documentation/i2c/DMA-considerations
> new file mode 100644
> index 00..e46c24d65c8556
> --- /dev/null
> +++ b/Documentation/i2c/DMA-considerations
> @@ -0,0 +1,38 @@
> +Linux I2C and DMA
> +-
> +
> +Given that I2C is a low-speed bus where largely small messages are 
> transferred,
> +it is not considered a prime user of DMA access. At this time of writing, 
> only
> +10% of I2C bus master drivers have DMA support implemented. And the vast
> +majority of transactions are so small that setting up DMA for it will likely
> +add more overhead than a plain PIO transfer.
> +
> +Therefore, it is *not* mandatory that the buffer of an I2C message is DMA 
> safe.
> +It does not seem reasonable to apply additional burdens when the feature is 
> so
> +rarely used. However, it is recommended to use a DMA-safe buffer if your
> +message size is likely applicable for DMA. Most drivers have this threshold
> +around 8 bytes. As of today, this is mostly an educated guess, however.
> +
> +To support this scenario, drivers wishing to implement DMA can use helper
> +functions from the I2C core. One checks if a message is DMA capable in terms 
> of
> +size and memory type. It can optionally also create a bounce buffer:
> +
> + i2c_check_msg_for_dma(msg, threshold, _buf);
> +
> +The bounce buffer handling from the core is generic and simple. It will 
> always
> +allocate a new bounce buffer. If you want a more sophisticated handling (e.g.
> +reusing pre-allocated buffers), you can leave the pointer to the bounce 
> buffer
> +empty and implement your own handling based on the return value of the above
> +function.
> +
> +The other helper function releases the bounce buffer. It ensures data is 
> copied
> +back to the message:
> +
> + i2c_release_dma_bounce_buf(msg, bounce_buf);
> +
> +Please check the in-kernel documentation for details. The i2c-sh_mobile 
> driver
> +can be used as a reference example.
> +
> +If you plan to use DMA with I2C (or with any other bus, actually) make sure 
> you
> +have CONFIG_DMA_API_DEBUG enabled during development. It can help you find
> +various issues which can be complex to debug otherwise.
> -- 
> 2.11.0
> 

-- 
Regards,
Niklas Söderlund


Re: [PATCH] ARM: Convert to using %pOF instead of full_name

2017-07-19 Thread Geert Uytterhoeven
On Tue, Jul 18, 2017 at 11:42 PM, Rob Herring  wrote:
> Now that we have a custom printf format specifier, convert users of
> full_name to use %pOF instead. This is preparation to remove storing
> of the full path string for each node.
>
> Signed-off-by: Rob Herring 

Reviewed-by: Geert Uytterhoeven 

Gr{oetje,eeting}s,

Geert

--
Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- ge...@linux-m68k.org

In personal conversations with technical people, I call myself a hacker. But
when I'm talking to journalists I just say "programmer" or something like that.
-- Linus Torvalds


Re: [PATCH] media: Convert to using %pOF instead of full_name

2017-07-19 Thread Laurent Pinchart
Hi Rob,

Thank you for the patch.

On Tuesday 18 Jul 2017 16:43:13 Rob Herring wrote:
> Now that we have a custom printf format specifier, convert users of
> full_name to use %pOF instead. This is preparation to remove storing
> of the full path string for each node.
> 
> Signed-off-by: Rob Herring 
> Cc: Kyungmin Park 
> Cc: Andrzej Hajda 
> Cc: Mauro Carvalho Chehab 
> Cc: "Lad, Prabhakar" 
> Cc: Songjun Wu 
> Cc: Sylwester Nawrocki 
> Cc: Kukjin Kim 
> Cc: Krzysztof Kozlowski 
> Cc: Javier Martinez Canillas 
> Cc: Minghsiu Tsai 
> Cc: Houlong Wei 
> Cc: Andrew-CT Chen 
> Cc: Matthias Brugger 
> Cc: Laurent Pinchart 
> Cc: "Niklas Söderlund" 
> Cc: Guennadi Liakhovetski 
> Cc: Hyun Kwon 
> Cc: Michal Simek 
> Cc: "Sören Brinkmann" 
> Cc: linux-me...@vger.kernel.org
> Cc: linux-arm-ker...@lists.infradead.org
> Cc: linux-samsung-...@vger.kernel.org
> Cc: linux-media...@lists.infradead.org
> Cc: linux-renesas-soc@vger.kernel.org
> ---
>  drivers/media/i2c/s5c73m3/s5c73m3-core.c   |  3 +-
>  drivers/media/i2c/s5k5baf.c|  7 ++--
>  drivers/media/platform/am437x/am437x-vpfe.c|  4 +-
>  drivers/media/platform/atmel/atmel-isc.c   |  4 +-
>  drivers/media/platform/davinci/vpif_capture.c  | 16 
>  drivers/media/platform/exynos4-is/fimc-is.c|  8 ++--
>  drivers/media/platform/exynos4-is/fimc-lite.c  |  3 +-
>  drivers/media/platform/exynos4-is/media-dev.c  |  8 ++--
>  drivers/media/platform/exynos4-is/mipi-csis.c  |  4 +-
>  drivers/media/platform/mtk-mdp/mtk_mdp_comp.c  |  6 +--
>  drivers/media/platform/mtk-mdp/mtk_mdp_core.c  |  8 ++--
>  drivers/media/platform/omap3isp/isp.c  |  8 ++--
>  drivers/media/platform/pxa_camera.c|  2 +-
>  drivers/media/platform/rcar-vin/rcar-core.c|  4 +-
>  drivers/media/platform/soc_camera/soc_camera.c |  6 +--
>  drivers/media/platform/xilinx/xilinx-vipp.c| 52 +++---
>  drivers/media/v4l2-core/v4l2-async.c   |  4 +-
>  drivers/media/v4l2-core/v4l2-clk.c |  3 +-
>  include/media/v4l2-clk.h   |  4 +-
>  19 files changed, 71 insertions(+), 83 deletions(-)

For omap3isp and xilinx,

Acked-by: Laurent Pinchart 

-- 
Regards,

Laurent Pinchart



Re: [PATCH] media: Convert to using %pOF instead of full_name

2017-07-19 Thread Niklas Söderlund
On 2017-07-18 16:43:13 -0500, Rob Herring wrote:
> Now that we have a custom printf format specifier, convert users of
> full_name to use %pOF instead. This is preparation to remove storing
> of the full path string for each node.
> 
> Signed-off-by: Rob Herring 
> Cc: Kyungmin Park 
> Cc: Andrzej Hajda 
> Cc: Mauro Carvalho Chehab 
> Cc: "Lad, Prabhakar" 
> Cc: Songjun Wu 
> Cc: Sylwester Nawrocki 
> Cc: Kukjin Kim 
> Cc: Krzysztof Kozlowski 
> Cc: Javier Martinez Canillas 
> Cc: Minghsiu Tsai 
> Cc: Houlong Wei 
> Cc: Andrew-CT Chen 
> Cc: Matthias Brugger 
> Cc: Laurent Pinchart 
> Cc: "Niklas Söderlund" 
> Cc: Guennadi Liakhovetski 
> Cc: Hyun Kwon 
> Cc: Michal Simek 
> Cc: "Sören Brinkmann" 
> Cc: linux-me...@vger.kernel.org
> Cc: linux-arm-ker...@lists.infradead.org
> Cc: linux-samsung-...@vger.kernel.org
> Cc: linux-media...@lists.infradead.org
> Cc: linux-renesas-soc@vger.kernel.org

For rcar-vin/rcar-core.c:
Acked-by: Niklas Söderlund 

> ---
>  drivers/media/i2c/s5c73m3/s5c73m3-core.c   |  3 +-
>  drivers/media/i2c/s5k5baf.c|  7 ++--
>  drivers/media/platform/am437x/am437x-vpfe.c|  4 +-
>  drivers/media/platform/atmel/atmel-isc.c   |  4 +-
>  drivers/media/platform/davinci/vpif_capture.c  | 16 
>  drivers/media/platform/exynos4-is/fimc-is.c|  8 ++--
>  drivers/media/platform/exynos4-is/fimc-lite.c  |  3 +-
>  drivers/media/platform/exynos4-is/media-dev.c  |  8 ++--
>  drivers/media/platform/exynos4-is/mipi-csis.c  |  4 +-
>  drivers/media/platform/mtk-mdp/mtk_mdp_comp.c  |  6 +--
>  drivers/media/platform/mtk-mdp/mtk_mdp_core.c  |  8 ++--
>  drivers/media/platform/omap3isp/isp.c  |  8 ++--
>  drivers/media/platform/pxa_camera.c|  2 +-
>  drivers/media/platform/rcar-vin/rcar-core.c|  4 +-
>  drivers/media/platform/soc_camera/soc_camera.c |  6 +--
>  drivers/media/platform/xilinx/xilinx-vipp.c| 52 
> +-
>  drivers/media/v4l2-core/v4l2-async.c   |  4 +-
>  drivers/media/v4l2-core/v4l2-clk.c |  3 +-
>  include/media/v4l2-clk.h   |  4 +-
>  19 files changed, 71 insertions(+), 83 deletions(-)
> 
> diff --git a/drivers/media/i2c/s5c73m3/s5c73m3-core.c 
> b/drivers/media/i2c/s5c73m3/s5c73m3-core.c
> index f434fb2ee6fc..cdc4f2392ef9 100644
> --- a/drivers/media/i2c/s5c73m3/s5c73m3-core.c
> +++ b/drivers/media/i2c/s5c73m3/s5c73m3-core.c
> @@ -1635,8 +1635,7 @@ static int s5c73m3_get_platform_data(struct s5c73m3 
> *state)
> 
>   node_ep = of_graph_get_next_endpoint(node, NULL);
>   if (!node_ep) {
> - dev_warn(dev, "no endpoint defined for node: %s\n",
> - node->full_name);
> + dev_warn(dev, "no endpoint defined for node: %pOF\n", node);
>   return 0;
>   }
> 
> diff --git a/drivers/media/i2c/s5k5baf.c b/drivers/media/i2c/s5k5baf.c
> index 962051b9939d..9c22fc963901 100644
> --- a/drivers/media/i2c/s5k5baf.c
> +++ b/drivers/media/i2c/s5k5baf.c
> @@ -1863,8 +1863,7 @@ static int s5k5baf_parse_device_node(struct s5k5baf 
> *state, struct device *dev)
> 
>   node_ep = of_graph_get_next_endpoint(node, NULL);
>   if (!node_ep) {
> - dev_err(dev, "no endpoint defined at node %s\n",
> - node->full_name);
> + dev_err(dev, "no endpoint defined at node %pOF\n", node);
>   return -EINVAL;
>   }
> 
> @@ -1882,8 +1881,8 @@ static int s5k5baf_parse_device_node(struct s5k5baf 
> *state, struct device *dev)
>   case V4L2_MBUS_PARALLEL:
>   break;
>   default:
> - dev_err(dev, "unsupported bus in endpoint defined at node %s\n",
> - node->full_name);
> + dev_err(dev, "unsupported bus in endpoint defined at node 
> %pOF\n",
> + node);
>   return -EINVAL;
>   }
> 
> diff --git a/drivers/media/platform/am437x/am437x-vpfe.c 
> b/drivers/media/platform/am437x/am437x-vpfe.c
> index 466aba8b0e00..dfcc484cab89 100644
> --- a/drivers/media/platform/am437x/am437x-vpfe.c
> +++ b/drivers/media/platform/am437x/am437x-vpfe.c
> @@ -2490,8 +2490,8 @@ vpfe_get_pdata(struct platform_device *pdev)
> 
>   rem = of_graph_get_remote_port_parent(endpoint);
>   if (!rem) {
> - dev_err(>dev, "Remote device at %s not found\n",
> - endpoint->full_name);
> +

[PATCH v2 2/5] watchdog: renesas_wdt: check rate also for upper limit

2017-07-19 Thread Wolfram Sang
When checking the clock rate, ensure also that counting all 16 bits
takes at least one second to match the granularity of the framework.

Reviewed-by: Guenter Roeck 
Signed-off-by: Wolfram Sang 
---
 drivers/watchdog/renesas_wdt.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/watchdog/renesas_wdt.c b/drivers/watchdog/renesas_wdt.c
index 22b0348826deb1..8437dd52153208 100644
--- a/drivers/watchdog/renesas_wdt.c
+++ b/drivers/watchdog/renesas_wdt.c
@@ -134,14 +134,14 @@ static int rwdt_probe(struct platform_device *pdev)
 
for (i = ARRAY_SIZE(clk_divs) - 1; i >= 0; i--) {
clks_per_sec = DIV_ROUND_UP(rate, clk_divs[i]);
-   if (clks_per_sec) {
+   if (clks_per_sec && clks_per_sec < 65536) {
priv->clks_per_sec = clks_per_sec;
priv->cks = i;
break;
}
}
 
-   if (!clks_per_sec) {
+   if (i < 0) {
dev_err(>dev, "Can't find suitable clock divider\n");
return -ERANGE;
}
-- 
2.11.0



[PATCH v2 3/5] watchdog: renesas_wdt: don't round closest with get_timeleft

2017-07-19 Thread Wolfram Sang
We should never return more time left than there actually is. So, switch
to a plain divider instead of DIV_ROUND_CLOSEST.

Reviewed-by: Guenter Roeck 
Signed-off-by: Wolfram Sang 
---
 drivers/watchdog/renesas_wdt.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/watchdog/renesas_wdt.c b/drivers/watchdog/renesas_wdt.c
index 8437dd52153208..3763437cd0b015 100644
--- a/drivers/watchdog/renesas_wdt.c
+++ b/drivers/watchdog/renesas_wdt.c
@@ -92,7 +92,7 @@ static unsigned int rwdt_get_timeleft(struct watchdog_device 
*wdev)
struct rwdt_priv *priv = watchdog_get_drvdata(wdev);
u16 val = readw_relaxed(priv->base + RWTCNT);
 
-   return DIV_ROUND_CLOSEST(65536 - val, priv->clks_per_sec);
+   return (65536 - val) / priv->clks_per_sec;
 }
 
 static const struct watchdog_info rwdt_ident = {
-- 
2.11.0



[PATCH v2 4/5] watchdog: renesas_wdt: apply better precision

2017-07-19 Thread Wolfram Sang
The error margin of the clks_per_second variable was too large and
caused offsets when used with clock frequencies which left a remainder
after applying the dividers. Now we always calculate directly using the
clock rate and the divider using some helper macros. That also means
that DIV_ROUND_UP moves from probe to the multiplication macro. In
probe, we don't need to ensure anymore that 'clks_per_sec' would go too
fast but rather ensure that the lower limit is really at least 1 to
certainly get a full cycle.

Reviewed-by: Guenter Roeck 
Signed-off-by: Wolfram Sang 
---
 drivers/watchdog/renesas_wdt.c | 28 +++-
 1 file changed, 19 insertions(+), 9 deletions(-)

diff --git a/drivers/watchdog/renesas_wdt.c b/drivers/watchdog/renesas_wdt.c
index 3763437cd0b015..599ba5aaa0536f 100644
--- a/drivers/watchdog/renesas_wdt.c
+++ b/drivers/watchdog/renesas_wdt.c
@@ -26,6 +26,17 @@
 
 #define RWDT_DEFAULT_TIMEOUT 60U
 
+/*
+ * In probe, clk_rate is checked to be not more than 16 bit * biggest clock
+ * divider (10 bits). d is only a factor to fully utilize the WDT counter and
+ * will not exceed its 16 bits. Thus, no overflow, we stay below 32 bits.
+ */
+#define MUL_BY_CLKS_PER_SEC(p, d) \
+   DIV_ROUND_UP((d) * (p)->clk_rate, clk_divs[(p)->cks])
+
+/* d is 16 bit, clk_divs 10 bit -> no 32 bit overflow */
+#define DIV_BY_CLKS_PER_SEC(p, d) ((d) * clk_divs[(p)->cks] / (p)->clk_rate)
+
 static const unsigned int clk_divs[] = { 1, 4, 16, 32, 64, 128, 1024 };
 
 static bool nowayout = WATCHDOG_NOWAYOUT;
@@ -37,7 +48,7 @@ struct rwdt_priv {
void __iomem *base;
struct watchdog_device wdev;
struct clk *clk;
-   unsigned long clks_per_sec;
+   unsigned long clk_rate;
u8 cks;
 };
 
@@ -55,7 +66,7 @@ static int rwdt_init_timeout(struct watchdog_device *wdev)
 {
struct rwdt_priv *priv = watchdog_get_drvdata(wdev);
 
-   rwdt_write(priv, 65536 - wdev->timeout * priv->clks_per_sec, RWTCNT);
+   rwdt_write(priv, 65536 - MUL_BY_CLKS_PER_SEC(priv, wdev->timeout), 
RWTCNT);
 
return 0;
 }
@@ -92,7 +103,7 @@ static unsigned int rwdt_get_timeleft(struct watchdog_device 
*wdev)
struct rwdt_priv *priv = watchdog_get_drvdata(wdev);
u16 val = readw_relaxed(priv->base + RWTCNT);
 
-   return (65536 - val) / priv->clks_per_sec;
+   return DIV_BY_CLKS_PER_SEC(priv, 65536 - val);
 }
 
 static const struct watchdog_info rwdt_ident = {
@@ -112,7 +123,7 @@ static int rwdt_probe(struct platform_device *pdev)
 {
struct rwdt_priv *priv;
struct resource *res;
-   unsigned long rate, clks_per_sec;
+   unsigned long clks_per_sec;
int ret, i;
 
priv = devm_kzalloc(>dev, sizeof(*priv), GFP_KERNEL);
@@ -128,14 +139,13 @@ static int rwdt_probe(struct platform_device *pdev)
if (IS_ERR(priv->clk))
return PTR_ERR(priv->clk);
 
-   rate = clk_get_rate(priv->clk);
-   if (!rate)
+   priv->clk_rate = clk_get_rate(priv->clk);
+   if (!priv->clk_rate)
return -ENOENT;
 
for (i = ARRAY_SIZE(clk_divs) - 1; i >= 0; i--) {
-   clks_per_sec = DIV_ROUND_UP(rate, clk_divs[i]);
+   clks_per_sec = priv->clk_rate / clk_divs[i];
if (clks_per_sec && clks_per_sec < 65536) {
-   priv->clks_per_sec = clks_per_sec;
priv->cks = i;
break;
}
@@ -153,7 +163,7 @@ static int rwdt_probe(struct platform_device *pdev)
priv->wdev.ops = _ops,
priv->wdev.parent = >dev;
priv->wdev.min_timeout = 1;
-   priv->wdev.max_timeout = 65536 / clks_per_sec;
+   priv->wdev.max_timeout = DIV_BY_CLKS_PER_SEC(priv, 65536);
priv->wdev.timeout = min(priv->wdev.max_timeout, RWDT_DEFAULT_TIMEOUT);
 
platform_set_drvdata(pdev, priv);
-- 
2.11.0



[PATCH v2 1/5] watchdog: renesas_wdt: avoid (theoretical) type overflow

2017-07-19 Thread Wolfram Sang
Because the smallest clock divider we can select is 1, 'clks_per_sec'
must be the same type as 'rate'.

Reviewed-by: Guenter Roeck 
Signed-off-by: Wolfram Sang 
---
Changes since V1:

* use proper type also in the private struct

 drivers/watchdog/renesas_wdt.c | 5 ++---
 1 file changed, 2 insertions(+), 3 deletions(-)

diff --git a/drivers/watchdog/renesas_wdt.c b/drivers/watchdog/renesas_wdt.c
index cf61c92f7ecd63..22b0348826deb1 100644
--- a/drivers/watchdog/renesas_wdt.c
+++ b/drivers/watchdog/renesas_wdt.c
@@ -37,7 +37,7 @@ struct rwdt_priv {
void __iomem *base;
struct watchdog_device wdev;
struct clk *clk;
-   unsigned int clks_per_sec;
+   unsigned long clks_per_sec;
u8 cks;
 };
 
@@ -112,8 +112,7 @@ static int rwdt_probe(struct platform_device *pdev)
 {
struct rwdt_priv *priv;
struct resource *res;
-   unsigned long rate;
-   unsigned int clks_per_sec;
+   unsigned long rate, clks_per_sec;
int ret, i;
 
priv = devm_kzalloc(>dev, sizeof(*priv), GFP_KERNEL);
-- 
2.11.0



[PATCH v2 0/5] watchdog: renesas_wdt: improve precision

2017-07-19 Thread Wolfram Sang
Currently, the renesas-rwdt driver is not precise with input clocks which have
a remainder after the clock divisors are applied. This series should fix the
situation and also pays attention to ensure variables have proper types and are
divided properly. As a cherry on top, we also get a new divider value to allow
for higher max_timeout :)

Originally brought to attention by this BSP patch:
https://git.kernel.org/pub/scm/linux/kernel/git/horms/renesas-bsp.git/commit/?id=7d56256a4d189a83e278ec2013eb1f3648bc7411

Tested with a Salvator-X (R-Car M3-W) and the clock driver hacked to supply the
internal clock of 32552 Hz instead of the externally supplied 32768 Hz.

A branch can be found here:

git://git.kernel.org/pub/scm/linux/kernel/git/wsa/linux.git 
renesas/watchdog-fixes

Please comment or apply...

Thanks,

   Wolfram

Changes since V1:

* add Guenter's Reviewed-by
* in patch 1, use proper type also in the private struct

Wolfram Sang (5):
  watchdog: renesas_wdt: avoid (theoretical) type overflow
  watchdog: renesas_wdt: check rate also for upper limit
  watchdog: renesas_wdt: don't round closest with get_timeleft
  watchdog: renesas_wdt: apply better precision
  watchdog: renesas_wdt: add another divider option

 drivers/watchdog/renesas_wdt.c | 37 -
 1 file changed, 24 insertions(+), 13 deletions(-)

-- 
2.11.0



[PATCH v2 5/5] watchdog: renesas_wdt: add another divider option

2017-07-19 Thread Wolfram Sang
If we set RWTCSRB to 0, we can gain 4096 as another divider value. This
is supported by all R-Car Gen2 and Gen3 devices which we aim to support.

Reviewed-by: Guenter Roeck 
Signed-off-by: Wolfram Sang 
---
 drivers/watchdog/renesas_wdt.c | 8 +---
 1 file changed, 5 insertions(+), 3 deletions(-)

diff --git a/drivers/watchdog/renesas_wdt.c b/drivers/watchdog/renesas_wdt.c
index 599ba5aaa0536f..e3f204bb8802aa 100644
--- a/drivers/watchdog/renesas_wdt.c
+++ b/drivers/watchdog/renesas_wdt.c
@@ -23,21 +23,22 @@
 #define RWTCSRA_WOVF   BIT(4)
 #define RWTCSRA_WRFLG  BIT(5)
 #define RWTCSRA_TMEBIT(7)
+#define RWTCSRB8
 
 #define RWDT_DEFAULT_TIMEOUT 60U
 
 /*
  * In probe, clk_rate is checked to be not more than 16 bit * biggest clock
- * divider (10 bits). d is only a factor to fully utilize the WDT counter and
+ * divider (12 bits). d is only a factor to fully utilize the WDT counter and
  * will not exceed its 16 bits. Thus, no overflow, we stay below 32 bits.
  */
 #define MUL_BY_CLKS_PER_SEC(p, d) \
DIV_ROUND_UP((d) * (p)->clk_rate, clk_divs[(p)->cks])
 
-/* d is 16 bit, clk_divs 10 bit -> no 32 bit overflow */
+/* d is 16 bit, clk_divs 12 bit -> no 32 bit overflow */
 #define DIV_BY_CLKS_PER_SEC(p, d) ((d) * clk_divs[(p)->cks] / (p)->clk_rate)
 
-static const unsigned int clk_divs[] = { 1, 4, 16, 32, 64, 128, 1024 };
+static const unsigned int clk_divs[] = { 1, 4, 16, 32, 64, 128, 1024, 4096 };
 
 static bool nowayout = WATCHDOG_NOWAYOUT;
 module_param(nowayout, bool, 0);
@@ -77,6 +78,7 @@ static int rwdt_start(struct watchdog_device *wdev)
 
clk_prepare_enable(priv->clk);
 
+   rwdt_write(priv, 0, RWTCSRB);
rwdt_write(priv, priv->cks, RWTCSRA);
rwdt_init_timeout(wdev);
 
-- 
2.11.0



Re: [RFC PATCH 2/2] clk: renesas: rcar-gen3-cpg.c: refactor checks for accessing the div table

2017-07-19 Thread Geert Uytterhoeven
On Tue, Jul 18, 2017 at 6:44 PM, Wolfram Sang
 wrote:
> Do the checks for accessing the SD divider table only when the rate gets
> updated, namely on init and set_rate. In all other cases, reuse the last
> value. This simplifies code, runtime load, and error reporting.
>
> Signed-off-by: Wolfram Sang 

Reviewed-by: Geert Uytterhoeven 
i.e. will queue in clk-renesas-for-v4.14.

Gr{oetje,eeting}s,

Geert

--
Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- ge...@linux-m68k.org

In personal conversations with technical people, I call myself a hacker. But
when I'm talking to journalists I just say "programmer" or something like that.
-- Linus Torvalds


Re: [PATCH] gpu: Convert to using %pOF instead of full_name

2017-07-19 Thread Philipp Zabel
On Tue, 2017-07-18 at 16:43 -0500, Rob Herring wrote:
> Now that we have a custom printf format specifier, convert users of
> full_name to use %pOF instead. This is preparation to remove storing
> of the full path string for each node.
> 
> Signed-off-by: Rob Herring 
> Cc: Russell King 
> Cc: David Airlie 
> Cc: Daniel Vetter 
> Cc: Jani Nikula 
> Cc: Sean Paul 
> Cc: Inki Dae 
> Cc: Joonyoung Shim 
> Cc: Seung-Woo Kim 
> Cc: Kyungmin Park 
> Cc: Kukjin Kim 
> Cc: Krzysztof Kozlowski 
> Cc: Javier Martinez Canillas 
> Cc: Xinliang Liu 
> Cc: Rongrong Zou 
> Cc: Xinwei Kong 
> Cc: Chen Feng 
> Cc: CK Hu 
> Cc: Philipp Zabel 
> Cc: Matthias Brugger 
> Cc: Neil Armstrong 
> Cc: Carlo Caione 
> Cc: Kevin Hilman 
> Cc: Thierry Reding 
> Cc: Laurent Pinchart 
> Cc: Mark Yao 
> Cc: Heiko Stuebner 
> Cc: Maxime Ripard 
> Cc: Chen-Yu Tsai 
> Cc: Jyri Sarha 
> Cc: Tomi Valkeinen 
> Cc: dri-de...@lists.freedesktop.org
> Cc: linux-arm-ker...@lists.infradead.org
> Cc: linux-samsung-...@vger.kernel.org
> Cc: linux-media...@lists.infradead.org
> Cc: linux-amlo...@lists.infradead.org
> Cc: linux-renesas-soc@vger.kernel.org
> Cc: linux-rockc...@lists.infradead.org
> ---

Reviewed-by: Philipp Zabel 

regards
Philipp




Re: [RFC PATCH 0/2] clk: renesas: rcar-gen3-cpg: refactor accessing the SD div table

2017-07-19 Thread Wolfram Sang

> > Please let me know if this is what you had in mind and if you can think of
> > other ways of testing this change.

Glad you like it :)

I forgot to mention that I checked 'clk_summary' with the different
SD card types and the applied values were as before.



signature.asc
Description: PGP signature


Re: [PATCH] ARM: Convert to using %pOF instead of full_name

2017-07-19 Thread Heiko Stuebner
Am Dienstag, 18. Juli 2017, 16:42:41 CEST schrieb Rob Herring:
> Now that we have a custom printf format specifier, convert users of
> full_name to use %pOF instead. This is preparation to remove storing
> of the full path string for each node.
> 
> Signed-off-by: Rob Herring 

for the Rockchip part
Acked-by: Heiko Stuebner 

> diff --git a/arch/arm/mach-rockchip/platsmp.c 
> b/arch/arm/mach-rockchip/platsmp.c
> index 3abafdbdd7f4..2b5b0e43d657 100644
> --- a/arch/arm/mach-rockchip/platsmp.c
> +++ b/arch/arm/mach-rockchip/platsmp.c
> @@ -182,8 +182,8 @@ static int __init rockchip_smp_prepare_sram(struct 
> device_node *node)
> 
>   ret = of_address_to_resource(node, 0, );
>   if (ret < 0) {
> - pr_err("%s: could not get address for node %s\n",
> -__func__, node->full_name);
> + pr_err("%s: could not get address for node %pOF\n",
> +__func__, node);
>   return ret;
>   }
> 



Re: [PATCH] soc: Convert to using %pOF instead of full_name

2017-07-19 Thread Geert Uytterhoeven
On Tue, Jul 18, 2017 at 11:43 PM, Rob Herring  wrote:
> Now that we have a custom printf format specifier, convert users of
> full_name to use %pOF instead. This is preparation to remove storing
> of the full path string for each node.
>
> Signed-off-by: Rob Herring 

Reviewed-by: Geert Uytterhoeven 

Gr{oetje,eeting}s,

Geert

--
Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- ge...@linux-m68k.org

In personal conversations with technical people, I call myself a hacker. But
when I'm talking to journalists I just say "programmer" or something like that.
-- Linus Torvalds


Re: [RFC PATCH 1/2] clk: renesas: rcar-gen3-cpg: drop superfluous variable

2017-07-19 Thread Geert Uytterhoeven
On Tue, Jul 18, 2017 at 6:44 PM, Wolfram Sang
 wrote:
> 'rate' is not used, so we can use 'parent_rate' directly.
>
> Signed-off-by: Wolfram Sang 

Reviewed-by: Geert Uytterhoeven 
i.e. will queue in clk-renesas-for-4.14.

Gr{oetje,eeting}s,

Geert

--
Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- ge...@linux-m68k.org

In personal conversations with technical people, I call myself a hacker. But
when I'm talking to journalists I just say "programmer" or something like that.
-- Linus Torvalds


Re: [PATCH] clk: Convert to using %pOF instead of full_name

2017-07-19 Thread Geert Uytterhoeven
On Tue, Jul 18, 2017 at 11:42 PM, Rob Herring  wrote:
> Now that we have a custom printf format specifier, convert users of
> full_name to use %pOF instead. This is preparation to remove storing
> of the full path string for each node.
>
> Signed-off-by: Rob Herring 

Reviewed-by: Geert Uytterhoeven 

>  drivers/clk/renesas/clk-mstp.c   |  2 +-
>  drivers/clk/renesas/clk-rcar-gen2.c  |  3 +--

For clk/renesas:
Acked-by: Geert Uytterhoeven 

Gr{oetje,eeting}s,

Geert

--
Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- ge...@linux-m68k.org

In personal conversations with technical people, I call myself a hacker. But
when I'm talking to journalists I just say "programmer" or something like that.
-- Linus Torvalds


Re: [PATCH] pinctrl: Convert to using %pOF instead of full_name

2017-07-19 Thread Geert Uytterhoeven
On Tue, Jul 18, 2017 at 11:43 PM, Rob Herring  wrote:
> Now that we have a custom printf format specifier, convert users of
> full_name to use %pOF instead. This is preparation to remove storing
> of the full path string for each node.
>
> Signed-off-by: Rob Herring 

Reviewed-by: Geert Uytterhoeven 

>  drivers/pinctrl/sh-pfc/pinctrl.c  |  2 +-

For the sh-pfc part:
Acked-by: Geert Uytterhoeven 

Gr{oetje,eeting}s,

Geert

--
Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- ge...@linux-m68k.org

In personal conversations with technical people, I call myself a hacker. But
when I'm talking to journalists I just say "programmer" or something like that.
-- Linus Torvalds


Re: [RFC v2 3/6] serdev: add multiplexer support

2017-07-19 Thread Peter Rosin
On 2017-07-17 17:24, Ulrich Hecht wrote:
> Adds an interface for slave device multiplexing using the mux subsystem.
> 
> Signed-off-by: Ulrich Hecht 
> ---
>  drivers/tty/serdev/Kconfig  |  3 +++
>  drivers/tty/serdev/Makefile |  1 +
>  drivers/tty/serdev/core.c   | 14 +-
>  drivers/tty/serdev/mux.c| 66 
> +
>  include/linux/serdev.h  | 16 ---
>  5 files changed, 96 insertions(+), 4 deletions(-)
>  create mode 100644 drivers/tty/serdev/mux.c
> 
> diff --git a/drivers/tty/serdev/Kconfig b/drivers/tty/serdev/Kconfig
> index cdc6b82..9096b71 100644
> --- a/drivers/tty/serdev/Kconfig
> +++ b/drivers/tty/serdev/Kconfig
> @@ -13,4 +13,7 @@ config SERIAL_DEV_CTRL_TTYPORT
>   depends on TTY
>   depends on SERIAL_DEV_BUS != m
>  
> +config SERIAL_DEV_MUX
> + bool "Serial device multiplexer support"

Here, you should

select MULTIPLEXER

And, instead of adding a config option, you might want to consider
making the mux optional instead. See

https://lkml.org/lkml/2017/7/14/655

> +
>  endif
> diff --git a/drivers/tty/serdev/Makefile b/drivers/tty/serdev/Makefile
> index 0cbdb94..d713381 100644
> --- a/drivers/tty/serdev/Makefile
> +++ b/drivers/tty/serdev/Makefile
> @@ -1,5 +1,6 @@
>  serdev-objs := core.o
>  
>  obj-$(CONFIG_SERIAL_DEV_BUS) += serdev.o
> +obj-$(CONFIG_SERIAL_DEV_MUX) += mux.o
>  
>  obj-$(CONFIG_SERIAL_DEV_CTRL_TTYPORT) += serdev-ttyport.o
> diff --git a/drivers/tty/serdev/core.c b/drivers/tty/serdev/core.c
> index 1fbaa4c..92c5bfa 100644
> --- a/drivers/tty/serdev/core.c
> +++ b/drivers/tty/serdev/core.c
> @@ -305,7 +305,8 @@ struct serdev_device *serdev_device_alloc(struct 
> serdev_controller *ctrl)
>   return NULL;
>  
>   serdev->ctrl = ctrl;
> - ctrl->serdev = serdev;
> + if (!ctrl->serdev)
> + ctrl->serdev = serdev;
>   device_initialize(>dev);
>   serdev->dev.parent = >dev;
>   serdev->dev.bus = _bus_type;
> @@ -368,6 +369,8 @@ static int of_serdev_register_devices(struct 
> serdev_controller *ctrl)
>   struct serdev_device *serdev = NULL;
>   int err;
>   bool found = false;
> + int nr = 0;
> + u32 reg;
>  
>   for_each_available_child_of_node(ctrl->dev.of_node, node) {
>   if (!of_get_property(node, "compatible", NULL))
> @@ -380,6 +383,10 @@ static int of_serdev_register_devices(struct 
> serdev_controller *ctrl)
>   continue;
>  
>   serdev->dev.of_node = node;
> + serdev->nr = nr++;
> +
> + if (!of_property_read_u32(node, "reg", ))
> + serdev->mux_addr = reg;
>  
>   err = serdev_device_add(serdev);
>   if (err) {
> @@ -414,6 +421,11 @@ int serdev_controller_add(struct serdev_controller *ctrl)
>   if (ret)
>   return ret;
>  
> +#ifdef CONFIG_SERIAL_DEV_MUX
> + if (of_serdev_register_mux(ctrl) == -EPROBE_DEFER)
> + return -EPROBE_DEFER;
> +#endif
> +
>   ret = of_serdev_register_devices(ctrl);
>   if (ret)
>   goto out_dev_del;
> diff --git a/drivers/tty/serdev/mux.c b/drivers/tty/serdev/mux.c
> new file mode 100644
> index 000..fc9405b
> --- /dev/null
> +++ b/drivers/tty/serdev/mux.c
> @@ -0,0 +1,66 @@
> +/*
> + * Copyright (C) 2017 Ulrich Hecht
> + *
> + * This program is free software; you can redistribute it and/or modify
> + * it under the terms of the GNU General Public License version 2 and
> + * only version 2 as published by the Free Software Foundation.
> + *
> + * This program is distributed in the hope that it will be useful,
> + * but WITHOUT ANY WARRANTY; without even the implied warranty of
> + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
> + * GNU General Public License for more details.
> + */
> +
> +#include 
> +#include 
> +#include 
> +#include 
> +#include 
> +
> +int serdev_device_mux_select(struct serdev_device *serdev)
> +{
> + struct mux_control *mux = serdev->ctrl->mux;
> + int ret;
> +
> + if (!mux)
> + return -EINVAL;
> +
> + ret = mux_control_select(mux, serdev->mux_addr);
> + serdev->ctrl->mux_do_not_deselect = ret < 0;
> +
> + serdev->ctrl->serdev = serdev;
> +
> + return ret;
> +}
> +
> +int serdev_device_mux_deselect(struct serdev_device *serdev)
> +{
> + struct mux_control *mux = serdev->ctrl->mux;
> +
> + if (!mux)
> + return -EINVAL;
> +
> + if (!serdev->ctrl->mux_do_not_deselect)
> + return mux_control_deselect(mux);
> + else
> + return 0;
> +}
> +
> +int of_serdev_register_mux(struct serdev_controller *ctrl)
> +{
> + struct mux_control *mux;
> + struct device *dev = >dev;
> +
> + mux = devm_mux_control_get(dev, NULL);
> +
> + if (IS_ERR(mux)) {
> + if (PTR_ERR(mux) != -EPROBE_DEFER)
> + dev_err(dev, "failed to get control mux\n");
> +  

[PATCH 2/2] usb: renesas_usbhs: gadget: disable all eps when the driver stops

2017-07-19 Thread Yoshihiro Shimoda
A gadget driver will not disable eps immediately when ->disconnect()
is called. But, since this driver assumes all eps stop after
the ->disconnect(), unexpected behavior happens (especially in system
suspend).
So, this patch disables all eps in usbhsg_try_stop(). After disabling
eps by renesas_usbhs driver, since some functions will be called by
both a gadget and renesas_usbhs driver, renesas_usbhs driver should
protect uep->pipe. To protect uep->pipe easily, this patch adds a new
lock in struct usbhsg_uep.

Fixes: 2f98382dc ("usb: renesas_usbhs: Add Renesas USBHS Gadget")
Cc:  # v3.0+
Signed-off-by: Yoshihiro Shimoda 
---
 drivers/usb/renesas_usbhs/mod_gadget.c | 31 ---
 1 file changed, 24 insertions(+), 7 deletions(-)

diff --git a/drivers/usb/renesas_usbhs/mod_gadget.c 
b/drivers/usb/renesas_usbhs/mod_gadget.c
index 5bc7a61..93fba90 100644
--- a/drivers/usb/renesas_usbhs/mod_gadget.c
+++ b/drivers/usb/renesas_usbhs/mod_gadget.c
@@ -37,6 +37,7 @@ struct usbhsg_request {
 struct usbhsg_uep {
struct usb_epep;
struct usbhs_pipe   *pipe;
+   spinlock_t  lock;   /* protect the pipe */
 
char ep_name[EP_NAME_SIZE];
 
@@ -636,10 +637,16 @@ static int usbhsg_ep_enable(struct usb_ep *ep,
 static int usbhsg_ep_disable(struct usb_ep *ep)
 {
struct usbhsg_uep *uep = usbhsg_ep_to_uep(ep);
-   struct usbhs_pipe *pipe = usbhsg_uep_to_pipe(uep);
+   struct usbhs_pipe *pipe;
+   unsigned long flags;
+   int ret = 0;
 
-   if (!pipe)
-   return -EINVAL;
+   spin_lock_irqsave(>lock, flags);
+   pipe = usbhsg_uep_to_pipe(uep);
+   if (!pipe) {
+   ret = -EINVAL;
+   goto out;
+   }
 
usbhsg_pipe_disable(uep);
usbhs_pipe_free(pipe);
@@ -647,6 +654,9 @@ static int usbhsg_ep_disable(struct usb_ep *ep)
uep->pipe->mod_private  = NULL;
uep->pipe   = NULL;
 
+out:
+   spin_unlock_irqrestore(>lock, flags);
+
return 0;
 }
 
@@ -696,8 +706,11 @@ static int usbhsg_ep_dequeue(struct usb_ep *ep, struct 
usb_request *req)
 {
struct usbhsg_uep *uep = usbhsg_ep_to_uep(ep);
struct usbhsg_request *ureq = usbhsg_req_to_ureq(req);
-   struct usbhs_pipe *pipe = usbhsg_uep_to_pipe(uep);
+   struct usbhs_pipe *pipe;
+   unsigned long flags;
 
+   spin_lock_irqsave(>lock, flags);
+   pipe = usbhsg_uep_to_pipe(uep);
if (pipe)
usbhs_pkt_pop(pipe, usbhsg_ureq_to_pkt(ureq));
 
@@ -706,6 +719,7 @@ static int usbhsg_ep_dequeue(struct usb_ep *ep, struct 
usb_request *req)
 * even if the pipe is NULL.
 */
usbhsg_queue_pop(uep, ureq, -ECONNRESET);
+   spin_unlock_irqrestore(>lock, flags);
 
return 0;
 }
@@ -852,10 +866,10 @@ static int usbhsg_try_stop(struct usbhs_priv *priv, u32 
status)
 {
struct usbhsg_gpriv *gpriv = usbhsg_priv_to_gpriv(priv);
struct usbhs_mod *mod = usbhs_mod_get_current(priv);
-   struct usbhsg_uep *dcp = usbhsg_gpriv_to_dcp(gpriv);
+   struct usbhsg_uep *uep;
struct device *dev = usbhs_priv_to_dev(priv);
unsigned long flags;
-   int ret = 0;
+   int ret = 0, i;
 
/  spin lock /
usbhs_lock(priv, flags);
@@ -887,7 +901,9 @@ static int usbhsg_try_stop(struct usbhs_priv *priv, u32 
status)
usbhs_sys_set_test_mode(priv, 0);
usbhs_sys_function_ctrl(priv, 0);
 
-   usbhsg_ep_disable(>ep);
+   /* disable all eps */
+   usbhsg_for_each_uep_with_dcp(uep, gpriv, i)
+   usbhsg_ep_disable(>ep);
 
dev_dbg(dev, "stop gadget\n");
 
@@ -1069,6 +1085,7 @@ int usbhs_mod_gadget_probe(struct usbhs_priv *priv)
ret = -ENOMEM;
goto usbhs_mod_gadget_probe_err_gpriv;
}
+   spin_lock_init(>lock);
 
gpriv->transceiver = usb_get_phy(USB_PHY_TYPE_UNDEFINED);
dev_info(dev, "%stransceiver found\n",
-- 
1.9.1



[PATCH 0/2] usb: renesas_usbhs: fixes for system suspend/resume

2017-07-19 Thread Yoshihiro Shimoda
This patch set is based on the latest Felipe's usb.git / testing/fixes branch
(the commit id = 781001ff9678e5df048cca3d4290c1638a28cafa).

Yoshihiro Shimoda (2):
  usb: renesas_usbhs: fix usbhsc_resume() for !USBHSF_RUNTIME_PWCTRL
  usb: renesas_usbhs: gadget: disable all eps when the driver stops

 drivers/usb/renesas_usbhs/common.c |  4 +++-
 drivers/usb/renesas_usbhs/mod_gadget.c | 31 ---
 2 files changed, 27 insertions(+), 8 deletions(-)

-- 
1.9.1



Re: [PATCH] pinctrl: Convert to using %pOF instead of full_name

2017-07-19 Thread Patrice CHOTARD


On 07/18/2017 11:43 PM, Rob Herring wrote:
> Now that we have a custom printf format specifier, convert users of
> full_name to use %pOF instead. This is preparation to remove storing
> of the full path string for each node.
> 
> Signed-off-by: Rob Herring 
> Cc: Linus Walleij 
> Cc: Lee Jones 
> Cc: Eric Anholt 
> Cc: Stefan Wahren 
> Cc: Florian Fainelli 
> Cc: Ray Jui 
> Cc: Scott Branden 
> Cc: bcm-kernel-feedback-l...@broadcom.com
> Cc: Ludovic Desroches 
> Cc: Patrice Chotard 
> Cc: Tomasz Figa 
> Cc: Krzysztof Kozlowski 
> Cc: Sylwester Nawrocki 
> Cc: Laurent Pinchart 
> Cc: Geert Uytterhoeven 
> Cc: Barry Song 
> Cc: linux-g...@vger.kernel.org
> Cc: linux-rpi-ker...@lists.infradead.org
> Cc: linux-arm-ker...@lists.infradead.org
> Cc: ker...@stlinux.com
> Cc: linux-samsung-...@vger.kernel.org
> Cc: linux-renesas-soc@vger.kernel.org
> ---
>   drivers/pinctrl/bcm/pinctrl-bcm2835.c | 25 +++--
>   drivers/pinctrl/devicetree.c  |  4 ++--
>   drivers/pinctrl/freescale/pinctrl-imx.c   |  8 +++-
>   drivers/pinctrl/pinconf-generic.c |  7 +++
>   drivers/pinctrl/pinctrl-at91-pio4.c   | 11 +--
>   drivers/pinctrl/pinctrl-st.c  |  2 +-
>   drivers/pinctrl/pinctrl-tb10x.c   |  4 ++--
>   drivers/pinctrl/samsung/pinctrl-samsung.c |  6 +++---
>   drivers/pinctrl/sh-pfc/pinctrl.c  |  2 +-
>   drivers/pinctrl/sirf/pinctrl-sirf.c   |  6 +++---
>   10 files changed, 34 insertions(+), 41 deletions(-)
> 
> diff --git a/drivers/pinctrl/bcm/pinctrl-bcm2835.c 
> b/drivers/pinctrl/bcm/pinctrl-bcm2835.c
> index 230883168e99..3e71e5d782ee 100644
> --- a/drivers/pinctrl/bcm/pinctrl-bcm2835.c
> +++ b/drivers/pinctrl/bcm/pinctrl-bcm2835.c
> @@ -692,8 +692,7 @@ static int bcm2835_pctl_dt_node_to_map_func(struct 
> bcm2835_pinctrl *pc,
>   struct pinctrl_map *map = *maps;
> 
>   if (fnum >= ARRAY_SIZE(bcm2835_functions)) {
> - dev_err(pc->dev, "%s: invalid brcm,function %d\n",
> - of_node_full_name(np), fnum);
> + dev_err(pc->dev, "%pOF: invalid brcm,function %d\n", np, fnum);
>   return -EINVAL;
>   }
> 
> @@ -713,8 +712,7 @@ static int bcm2835_pctl_dt_node_to_map_pull(struct 
> bcm2835_pinctrl *pc,
>   unsigned long *configs;
> 
>   if (pull > 2) {
> - dev_err(pc->dev, "%s: invalid brcm,pull %d\n",
> - of_node_full_name(np), pull);
> + dev_err(pc->dev, "%pOF: invalid brcm,pull %d\n", np, pull);
>   return -EINVAL;
>   }
> 
> @@ -745,8 +743,7 @@ static int bcm2835_pctl_dt_node_to_map(struct pinctrl_dev 
> *pctldev,
> 
>   pins = of_find_property(np, "brcm,pins", NULL);
>   if (!pins) {
> - dev_err(pc->dev, "%s: missing brcm,pins property\n",
> - of_node_full_name(np));
> + dev_err(pc->dev, "%pOF: missing brcm,pins property\n", np);
>   return -EINVAL;
>   }
> 
> @@ -755,8 +752,8 @@ static int bcm2835_pctl_dt_node_to_map(struct pinctrl_dev 
> *pctldev,
> 
>   if (!funcs && !pulls) {
>   dev_err(pc->dev,
> - "%s: neither brcm,function nor brcm,pull specified\n",
> - of_node_full_name(np));
> + "%pOF: neither brcm,function nor brcm,pull specified\n",
> + np);
>   return -EINVAL;
>   }
> 
> @@ -766,15 +763,15 @@ static int bcm2835_pctl_dt_node_to_map(struct 
> pinctrl_dev *pctldev,
> 
>   if (num_funcs > 1 && num_funcs != num_pins) {
>   dev_err(pc->dev,
> - "%s: brcm,function must have 1 or %d entries\n",
> - of_node_full_name(np), num_pins);
> + "%pOF: brcm,function must have 1 or %d entries\n",
> + np, num_pins);
>   return -EINVAL;
>   }
> 
>   if (num_pulls > 1 && num_pulls != num_pins) {
>   dev_err(pc->dev,
> - "%s: brcm,pull must have 1 or %d entries\n",
> - of_node_full_name(np), num_pins);
> + "%pOF: brcm,pull must have 1 or %d entries\n",
> + np, num_pins);
>   return -EINVAL;
>   }
> 
> @@ -793,8 +790,8 @@ static int bcm2835_pctl_dt_node_to_map(struct pinctrl_dev 
> *pctldev,
>   if (err)
>   goto out;
>   if (pin >= ARRAY_SIZE(bcm2835_gpio_pins)) {
> - dev_err(pc->dev, "%s: invalid brcm,pins value %d\n",
> - of_node_full_name(np), pin);

Re: [PATCH] ARM: Convert to using %pOF instead of full_name

2017-07-19 Thread Uwe Kleine-König
On Tue, Jul 18, 2017 at 04:42:41PM -0500, Rob Herring wrote:
> Now that we have a custom printf format specifier, convert users of
> full_name to use %pOF instead. This is preparation to remove storing

Oh nice. If the commit adding %pOF is already set in stone, i'd suggest
to mention the commit id here in the commit log.

> of the full path string for each node.
> 
> Signed-off-by: Rob Herring 
> Cc: Russell King 
> Cc: Kukjin Kim 
> Cc: Krzysztof Kozlowski 
> Cc: Javier Martinez Canillas 
> Cc: Shawn Guo 
> Cc: Sascha Hauer 
> Cc: Fabio Estevam 
> Cc: Jason Cooper 
> Cc: Andrew Lunn 
> Cc: Gregory Clement 
> Cc: Sebastian Hesselbarth 
> Cc: Tony Lindgren 
> Cc: "Benoît Cousson" 
> Cc: Paul Walmsley 
> Cc: Heiko Stuebner 
> Cc: Simon Horman 
> Cc: Magnus Damm 
> Cc: linux-arm-ker...@lists.infradead.org
> Cc: linux-samsung-...@vger.kernel.org
> Cc: linux-o...@vger.kernel.org
> Cc: linux-rockc...@lists.infradead.org
> Cc: linux-renesas-soc@vger.kernel.org
> ---
>  arch/arm/kernel/cpuidle.c| 4 ++--
>  arch/arm/kernel/devtree.c| 6 +++---
>  arch/arm/kernel/topology.c   | 4 ++--
>  arch/arm/mach-exynos/suspend.c   | 8 
>  arch/arm/mach-imx/gpc.c  | 4 ++--
>  arch/arm/mach-mvebu/kirkwood.c   | 4 ++--
>  arch/arm/mach-omap2/omap-wakeupgen.c | 4 ++--
>  arch/arm/mach-omap2/omap_hwmod.c | 4 ++--
>  arch/arm/mach-rockchip/platsmp.c | 4 ++--
>  arch/arm/mach-shmobile/pm-rmobile.c  | 8 
>  10 files changed, 25 insertions(+), 25 deletions(-)
> 
> diff --git a/arch/arm/kernel/cpuidle.c b/arch/arm/kernel/cpuidle.c
> index a3308ad1a024..fda5579123a8 100644
> --- a/arch/arm/kernel/cpuidle.c
> +++ b/arch/arm/kernel/cpuidle.c
> @@ -101,8 +101,8 @@ static int __init arm_cpuidle_read_ops(struct device_node 
> *dn, int cpu)
> 
>   ops = arm_cpuidle_get_ops(enable_method);
>   if (!ops) {
> - pr_warn("%s: unsupported enable-method property: %s\n",
> - dn->full_name, enable_method);
> + pr_warn("%pOF: unsupported enable-method property: %s\n",
> + dn, enable_method);
>   return -EOPNOTSUPP;
>   }
> 
> diff --git a/arch/arm/kernel/devtree.c b/arch/arm/kernel/devtree.c
> index f676febbb270..28174c9a94ac 100644
> --- a/arch/arm/kernel/devtree.c
> +++ b/arch/arm/kernel/devtree.c
> @@ -95,7 +95,7 @@ void __init arm_dt_init_cpu_maps(void)
>   if (of_node_cmp(cpu->type, "cpu"))
>   continue;
> 
> - pr_debug(" * %s...\n", cpu->full_name);
> + pr_debug(" * %pOF...\n", cpu);
>   /*
>* A device tree containing CPU nodes with missing "reg"
>* properties is considered invalid to build the
> @@ -103,8 +103,8 @@ void __init arm_dt_init_cpu_maps(void)
>*/
>   cell = of_get_property(cpu, "reg", _bytes);
>   if (!cell || prop_bytes < sizeof(*cell)) {
> - pr_debug(" * %s missing reg property\n",
> -  cpu->full_name);
> + pr_debug(" * %pOF missing reg property\n",
> +  cpu);

You could join lines here and in the next hunk. And there are two more
further down.

>   of_node_put(cpu);
>   return;
>   }
> diff --git a/arch/arm/kernel/topology.c b/arch/arm/kernel/topology.c
> index bf949a763dbe..e596c5b8f931 100644
> --- a/arch/arm/kernel/topology.c
> +++ b/arch/arm/kernel/topology.c
> @@ -127,8 +127,8 @@ static void __init parse_dt_topology(void)
> 
>   rate = of_get_property(cn, "clock-frequency", );
>   if (!rate || len != 4) {
> - pr_err("%s missing clock-frequency property\n",
> - cn->full_name);
> + pr_err("%pOF missing clock-frequency property\n",
> + cn);
>   continue;
>   }
> 

Best regards
Uwe

-- 
Pengutronix e.K.   | Uwe Kleine-König|
Industrial Linux Solutions | http://www.pengutronix.de/  |


Re: [PATCH] gpu: Convert to using %pOF instead of full_name

2017-07-19 Thread Maxime Ripard
On Tue, Jul 18, 2017 at 04:43:04PM -0500, Rob Herring wrote:
> Now that we have a custom printf format specifier, convert users of
> full_name to use %pOF instead. This is preparation to remove storing
> of the full path string for each node.
> 
> Signed-off-by: Rob Herring 
> Cc: Russell King 
> Cc: David Airlie 
> Cc: Daniel Vetter 
> Cc: Jani Nikula 
> Cc: Sean Paul 
> Cc: Inki Dae 
> Cc: Joonyoung Shim 
> Cc: Seung-Woo Kim 
> Cc: Kyungmin Park 
> Cc: Kukjin Kim 
> Cc: Krzysztof Kozlowski 
> Cc: Javier Martinez Canillas 
> Cc: Xinliang Liu 
> Cc: Rongrong Zou 
> Cc: Xinwei Kong 
> Cc: Chen Feng 
> Cc: CK Hu 
> Cc: Philipp Zabel 
> Cc: Matthias Brugger 
> Cc: Neil Armstrong 
> Cc: Carlo Caione 
> Cc: Kevin Hilman 
> Cc: Thierry Reding 
> Cc: Laurent Pinchart 
> Cc: Mark Yao 
> Cc: Heiko Stuebner 
> Cc: Maxime Ripard 
> Cc: Chen-Yu Tsai 
> Cc: Jyri Sarha 
> Cc: Tomi Valkeinen 
> Cc: dri-de...@lists.freedesktop.org
> Cc: linux-arm-ker...@lists.infradead.org
> Cc: linux-samsung-...@vger.kernel.org
> Cc: linux-media...@lists.infradead.org
> Cc: linux-amlo...@lists.infradead.org
> Cc: linux-renesas-soc@vger.kernel.org
> Cc: linux-rockc...@lists.infradead.org
> ---
>  drivers/gpu/drm/armada/armada_crtc.c|  3 +--
>  drivers/gpu/drm/armada/armada_drv.c |  4 ++--
>  drivers/gpu/drm/drm_mipi_dsi.c  |  6 +++---
>  drivers/gpu/drm/drm_modes.c |  4 ++--
>  drivers/gpu/drm/drm_of.c|  4 ++--
>  drivers/gpu/drm/exynos/exynos_drm_dsi.c |  3 +--
>  drivers/gpu/drm/hisilicon/kirin/kirin_drm_ade.c |  3 +--
>  drivers/gpu/drm/mediatek/mtk_disp_color.c   |  4 ++--
>  drivers/gpu/drm/mediatek/mtk_disp_ovl.c |  4 ++--
>  drivers/gpu/drm/mediatek/mtk_disp_rdma.c|  4 ++--
>  drivers/gpu/drm/mediatek/mtk_dpi.c  |  6 +++---
>  drivers/gpu/drm/mediatek/mtk_drm_crtc.c |  7 +++
>  drivers/gpu/drm/mediatek/mtk_drm_ddp_comp.c |  6 ++
>  drivers/gpu/drm/mediatek/mtk_drm_drv.c  | 16 
>  drivers/gpu/drm/mediatek/mtk_dsi.c  |  4 ++--
>  drivers/gpu/drm/mediatek/mtk_hdmi.c |  8 
>  drivers/gpu/drm/meson/meson_drv.c   |  5 ++---
>  drivers/gpu/drm/panel/panel-lvds.c  | 16 
>  drivers/gpu/drm/rcar-du/rcar_du_encoder.c   |  4 ++--
>  drivers/gpu/drm/rcar-du/rcar_du_kms.c   | 16 
>  drivers/gpu/drm/rockchip/rockchip_drm_drv.c |  4 ++--
>  drivers/gpu/drm/rockchip/rockchip_drm_vop.c |  4 ++--
>  drivers/gpu/drm/stm/ltdc.c  |  3 +--
>  drivers/gpu/drm/sun4i/sun4i_drv.c   |  9 -

For sun4i-drm:
Acked-by: Maxime Ripard 

Thanks!
Maxime

-- 
Maxime Ripard, Free Electrons
Embedded Linux and Kernel engineering
http://free-electrons.com


signature.asc
Description: PGP signature


Re: [PATCH] clk: Convert to using %pOF instead of full_name

2017-07-19 Thread Maxime Ripard
On Tue, Jul 18, 2017 at 04:42:52PM -0500, Rob Herring wrote:
> Now that we have a custom printf format specifier, convert users of
> full_name to use %pOF instead. This is preparation to remove storing
> of the full path string for each node.
> 
> Signed-off-by: Rob Herring 
> Cc: Michael Turquette 
> Cc: Stephen Boyd 
> Cc: Maxime Coquelin 
> Cc: Alexandre Torgue 
> Cc: Russell King 
> Cc: Matthias Brugger 
> Cc: Geert Uytterhoeven 
> Cc: Maxime Ripard 
> Cc: Chen-Yu Tsai 
> Cc: "Emilio López" 
> Cc: Peter De Schrijver 
> Cc: Prashant Gaikwad 
> Cc: Thierry Reding 
> Cc: Jonathan Hunter 
> Cc: Tero Kristo 
> Cc: linux-...@vger.kernel.org
> Cc: linux-arm-ker...@lists.infradead.org
> Cc: linux-media...@lists.infradead.org
> Cc: linux-renesas-soc@vger.kernel.org
> Cc: linux-te...@vger.kernel.org
> Cc: linux-o...@vger.kernel.org
> ---
>  drivers/clk/berlin/bg2.c |  3 +--
>  drivers/clk/berlin/bg2q.c|  7 +++
>  drivers/clk/clk-asm9260.c|  4 ++--
>  drivers/clk/clk-conf.c   | 16 
>  drivers/clk/clk-moxart.c | 12 ++--
>  drivers/clk/clk-qoriq.c  |  7 +++
>  drivers/clk/clk-stm32f4.c|  4 ++--
>  drivers/clk/clk-xgene.c  | 15 ++-
>  drivers/clk/clk.c|  4 ++--
>  drivers/clk/clkdev.c |  4 ++--
>  drivers/clk/mediatek/clk-cpumux.c|  2 +-
>  drivers/clk/mediatek/clk-mtk.c   |  2 +-
>  drivers/clk/mediatek/reset.c |  2 +-
>  drivers/clk/renesas/clk-mstp.c   |  2 +-
>  drivers/clk/renesas/clk-rcar-gen2.c  |  3 +--
>  drivers/clk/sunxi-ng/ccu-sun5i.c |  3 +--
>  drivers/clk/sunxi-ng/ccu-sun6i-a31.c |  3 +--
>  drivers/clk/sunxi-ng/ccu-sun8i-a23.c |  3 +--
>  drivers/clk/sunxi-ng/ccu-sun8i-a33.c |  3 +--
>  drivers/clk/sunxi-ng/ccu-sun8i-h3.c  |  3 +--
>  drivers/clk/sunxi-ng/ccu-sun8i-r.c   |  3 +--
>  drivers/clk/sunxi-ng/ccu-sun8i-v3s.c |  3 +--
>  drivers/clk/sunxi/clk-sunxi.c| 17 +++--

For the sunxi and sunxi-ng clocks:
Acked-by: Maxime Ripard 

Thanks!
Maxime

-- 
Maxime Ripard, Free Electrons
Embedded Linux and Kernel engineering
http://free-electrons.com


signature.asc
Description: PGP signature