Re: [media] RedRat3: Use kcalloc() in two functions?

2016-10-13 Thread SF Markus Elfring
> Markus, please stop being _so_ mechanical and use your
> brain a little too.  By definition, sizeof(char) == 1.
> 
> This _really_ should be kzalloc(RR3_FW_VERSION_LEN + 1,...)

Do you expect that function call examples like the following will be equivalent?

zbuffer = kzalloc(123, …);
cbuffer = kcalloc(123, 1, …);

Regards,
Markus
--
To unsubscribe from this list: send the line "unsubscribe linux-media" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


cron job: media_tree daily build: ERRORS

2016-10-13 Thread Hans Verkuil
This message is generated daily by a cron job that builds media_tree for
the kernels and architectures in the list below.

Results of the daily build of media_tree:

date:   Fri Oct 14 05:00:14 CEST 2016
media-tree git hash:9fce0c226536fc36c7fb0a8ca38a995be43e
media_build git hash:   ecfc9bfca3012b0c6e19967ce90f621f71a6da94
v4l-utils git hash: 79186f9d3d9d3b6bee4a611bd92435d11807
gcc version:i686-linux-gcc (GCC) 6.2.0
sparse version: v0.5.0-3553-g78b2ea6
smatch version: v0.5.0-3553-g78b2ea6
host hardware:  x86_64
host os:4.7.0-164

linux-git-arm-at91: OK
linux-git-arm-davinci: OK
linux-git-arm-multi: OK
linux-git-arm-pxa: OK
linux-git-blackfin-bf561: OK
linux-git-i686: OK
linux-git-m32r: WARNINGS
linux-git-mips: OK
linux-git-powerpc64: OK
linux-git-sh: OK
linux-git-x86_64: OK
linux-2.6.36.4-i686: WARNINGS
linux-2.6.37.6-i686: WARNINGS
linux-2.6.38.8-i686: ERRORS
linux-2.6.39.4-i686: WARNINGS
linux-3.0.60-i686: WARNINGS
linux-3.1.10-i686: ERRORS
linux-3.2.37-i686: ERRORS
linux-3.3.8-i686: ERRORS
linux-3.4.27-i686: WARNINGS
linux-3.5.7-i686: WARNINGS
linux-3.6.11-i686: WARNINGS
linux-3.7.4-i686: WARNINGS
linux-3.8-i686: WARNINGS
linux-3.9.2-i686: WARNINGS
linux-3.10.1-i686: WARNINGS
linux-3.11.1-i686: OK
linux-3.13.11-i686: WARNINGS
linux-3.14.9-i686: WARNINGS
linux-3.15.2-i686: WARNINGS
linux-3.16.7-i686: WARNINGS
linux-3.17.8-i686: WARNINGS
linux-3.18.7-i686: WARNINGS
linux-3.19-i686: WARNINGS
linux-4.0.9-i686: WARNINGS
linux-4.1.33-i686: WARNINGS
linux-4.2.8-i686: WARNINGS
linux-4.3.6-i686: WARNINGS
linux-4.4.22-i686: WARNINGS
linux-4.5.7-i686: WARNINGS
linux-4.6.7-i686: WARNINGS
linux-4.7.5-i686: WARNINGS
linux-4.8-i686: OK
linux-2.6.36.4-x86_64: WARNINGS
linux-2.6.37.6-x86_64: WARNINGS
linux-2.6.38.8-x86_64: ERRORS
linux-2.6.39.4-x86_64: WARNINGS
linux-3.0.60-x86_64: WARNINGS
linux-3.1.10-x86_64: ERRORS
linux-3.2.37-x86_64: ERRORS
linux-3.3.8-x86_64: ERRORS
linux-3.4.27-x86_64: WARNINGS
linux-3.5.7-x86_64: WARNINGS
linux-3.6.11-x86_64: WARNINGS
linux-3.7.4-x86_64: WARNINGS
linux-3.8-x86_64: WARNINGS
linux-3.9.2-x86_64: WARNINGS
linux-3.10.1-x86_64: WARNINGS
linux-3.11.1-x86_64: OK
linux-3.13.11-x86_64: WARNINGS
linux-3.14.9-x86_64: WARNINGS
linux-3.15.2-x86_64: WARNINGS
linux-3.16.7-x86_64: WARNINGS
linux-3.17.8-x86_64: WARNINGS
linux-3.18.7-x86_64: WARNINGS
linux-3.19-x86_64: WARNINGS
linux-4.0.9-x86_64: WARNINGS
linux-4.1.33-x86_64: WARNINGS
linux-4.2.8-x86_64: WARNINGS
linux-4.3.6-x86_64: WARNINGS
linux-4.4.22-x86_64: WARNINGS
linux-4.5.7-x86_64: WARNINGS
linux-4.6.7-x86_64: WARNINGS
linux-4.7.5-x86_64: WARNINGS
linux-4.8-x86_64: OK
apps: WARNINGS
spec-git: OK
smatch: ERRORS
sparse: WARNINGS

Detailed results are available here:

http://www.xs4all.nl/~hverkuil/logs/Friday.log

Full logs are available here:

http://www.xs4all.nl/~hverkuil/logs/Friday.tar.bz2

The Media Infrastructure API from this daily build is here:

http://www.xs4all.nl/~hverkuil/spec/index.html
--
To unsubscribe from this list: send the line "unsubscribe linux-media" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH 12/18] [media] RedRat3: Move a variable assignment in redrat3_init_rc_dev()

2016-10-13 Thread Sean Young
On Thu, Oct 13, 2016 at 06:39:23PM +0200, SF Markus Elfring wrote:
> From: Markus Elfring 
> Date: Thu, 13 Oct 2016 14:50:05 +0200
> 
> Move the assignment for the local variable "prod" behind the source code
> for a memory allocation by this function.

The redrat3 driver shouldn't be adding the usb vendor/product id to the
device name. A better patch would be to remove those from the snprintf
completely and to away with the local variable.

Sean

> 
> Signed-off-by: Markus Elfring 
> ---
>  drivers/media/rc/redrat3.c | 3 ++-
>  1 file changed, 2 insertions(+), 1 deletion(-)
> 
> diff --git a/drivers/media/rc/redrat3.c b/drivers/media/rc/redrat3.c
> index b23a8bb..002030f 100644
> --- a/drivers/media/rc/redrat3.c
> +++ b/drivers/media/rc/redrat3.c
> @@ -856,12 +856,13 @@ static struct rc_dev *redrat3_init_rc_dev(struct 
> redrat3_dev *rr3)
>  {
>   struct rc_dev *rc;
>   int ret;
> - u16 prod = le16_to_cpu(rr3->udev->descriptor.idProduct);
> + u16 prod;
>  
>   rc = rc_allocate_device();
>   if (!rc)
>   goto out;
>  
> + prod = le16_to_cpu(rr3->udev->descriptor.idProduct);
>   snprintf(rr3->name, sizeof(rr3->name), "RedRat3%s "
>"Infrared Remote Transceiver (%04x:%04x)",
>prod == USB_RR3IIUSB_PRODUCT_ID ? "-II" : "",
> -- 
> 2.10.1
> 
> --
> To unsubscribe from this list: send the line "unsubscribe linux-media" in
> the body of a message to majord...@vger.kernel.org
> More majordomo info at  http://vger.kernel.org/majordomo-info.html
--
To unsubscribe from this list: send the line "unsubscribe linux-media" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH] [media] dib0700: fix nec repeat handling

2016-10-13 Thread Sean Young
When receiving a nec repeat, ensure the correct scancode is repeated
rather than a random value from the stack. This removes the need
for the bogus uninitialized_var() and also fixes the warnings:

drivers/media/usb/dvb-usb/dib0700_core.c: In function 
‘dib0700_rc_urb_completion’:
drivers/media/usb/dvb-usb/dib0700_core.c:679: warning: ‘protocol’ may be 
used uninitialized in this function

Signed-off-by: Sean Young 
---
 drivers/media/usb/dvb-usb/dib0700_core.c | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

diff --git a/drivers/media/usb/dvb-usb/dib0700_core.c 
b/drivers/media/usb/dvb-usb/dib0700_core.c
index f319665..5bb23ef 100644
--- a/drivers/media/usb/dvb-usb/dib0700_core.c
+++ b/drivers/media/usb/dvb-usb/dib0700_core.c
@@ -677,7 +677,7 @@ static void dib0700_rc_urb_completion(struct urb *purb)
struct dvb_usb_device *d = purb->context;
struct dib0700_rc_response *poll_reply;
enum rc_type protocol;
-   u32 uninitialized_var(keycode);
+   u32 keycode;
u8 toggle;
 
deb_info("%s()\n", __func__);
@@ -718,7 +718,8 @@ static void dib0700_rc_urb_completion(struct urb *purb)
poll_reply->nec.data   == 0x00 &&
poll_reply->nec.not_data   == 0xff) {
poll_reply->data_state = 2;
-   break;
+   rc_repeat(d->rc_dev);
+   goto resubmit;
}
 
if ((poll_reply->nec.data ^ poll_reply->nec.not_data) != 0xff) {
-- 
2.7.4

--
To unsubscribe from this list: send the line "unsubscribe linux-media" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH] [media] dib0700: Fix uninitialized protocol for NEC repeat codes

2016-10-13 Thread Sean Young
On Thu, Oct 13, 2016 at 03:51:39PM +0200, Geert Uytterhoeven wrote:
> drivers/media/usb/dvb-usb/dib0700_core.c: In function 
> ‘dib0700_rc_urb_completion’:
> drivers/media/usb/dvb-usb/dib0700_core.c:679: warning: ‘protocol’ may be 
> used uninitialized in this function
> 
> When receiving an NEC repeat code, protocol is indeed not initialized.
> Set it to RC_TYPE_NECX to fix this.
> 
> Fixes: 2ceeca0499d74521 ("[media] rc: split nec protocol into its three 
> variants")
> Signed-off-by: Geert Uytterhoeven 
> ---
> Is RC_TYPE_NECX correct, or should it be RC_TYPE_NEC?
> I used RC_TYPE_NECX based on the checks for {,not_}data and
> {,not_}system for the other cases.

It should be the protocol that the last scancode was received with. This
code path is very broken; it calls:

rc_keydown(d->rc_dev, protocol, keycode, toggle);

But keycode in this codepath is never set. Luckily keycode is declared as:

u32 uninitialized_var(keycode);

I've got another patch for this which I'll send as a reply to this.


Sean


> ---
>  drivers/media/usb/dvb-usb/dib0700_core.c | 1 +
>  1 file changed, 1 insertion(+)
> 
> diff --git a/drivers/media/usb/dvb-usb/dib0700_core.c 
> b/drivers/media/usb/dvb-usb/dib0700_core.c
> index f3196658fb700706..5878ae4d20ad27ed 100644
> --- a/drivers/media/usb/dvb-usb/dib0700_core.c
> +++ b/drivers/media/usb/dvb-usb/dib0700_core.c
> @@ -718,6 +718,7 @@ static void dib0700_rc_urb_completion(struct urb *purb)
>   poll_reply->nec.data   == 0x00 &&
>   poll_reply->nec.not_data   == 0xff) {
>   poll_reply->data_state = 2;
> + protocol = RC_TYPE_NECX;
>   break;
>   }
>  
> -- 
> 1.9.1
> 
> --
> To unsubscribe from this list: send the line "unsubscribe linux-media" in
> the body of a message to majord...@vger.kernel.org
> More majordomo info at  http://vger.kernel.org/majordomo-info.html
--
To unsubscribe from this list: send the line "unsubscribe linux-media" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [RFC PATCH 00/11] Introduce writeback connectors

2016-10-13 Thread Eric Anholt
Brian Starkey  writes:

> Hi Eric,
>
> On Tue, Oct 11, 2016 at 12:01:14PM -0700, Eric Anholt wrote:
>>Brian Starkey  writes:
>>
>>> Hi,
>>>
>>> This RFC series introduces a new connector type:
>>>  DRM_MODE_CONNECTOR_WRITEBACK
>>> It is a follow-on from a previous discussion: [1]
>>>
>>> Writeback connectors are used to expose the memory writeback engines
>>> found in some display controllers, which can write a CRTC's
>>> composition result to a memory buffer.
>>> This is useful e.g. for testing, screen-recording, screenshots,
>>> wireless display, display cloning, memory-to-memory composition.
>>>
>>> Patches 1-7 include the core framework changes required, and patches
>>> 8-11 implement a writeback connector for the Mali-DP writeback engine.
>>> The Mali-DP patches depend on this other series: [2].
>>>
>>> The connector is given the FB_ID property for the output framebuffer,
>>> and two new read-only properties: PIXEL_FORMATS and
>>> PIXEL_FORMATS_SIZE, which expose the supported framebuffer pixel
>>> formats of the engine.
>>>
>>> The EDID property is not exposed for writeback connectors.
>>>
>>> Writeback connector usage:
>>> --
>>> Due to connector routing changes being treated as "full modeset"
>>> operations, any client which wishes to use a writeback connector
>>> should include the connector in every modeset. The writeback will not
>>> actually become active until a framebuffer is attached.
>>>
>>> The writeback itself is enabled by attaching a framebuffer to the
>>> FB_ID property of the connector. The driver must then ensure that the
>>> CRTC content of that atomic commit is written into the framebuffer.
>>>
>>> The writeback works in a one-shot mode with each atomic commit. This
>>> prevents the same content from being written multiple times.
>>> In some cases (front-buffer rendering) there might be a desire for
>>> continuous operation - I think a property could be added later for
>>> this kind of control.
>>>
>>> Writeback can be disabled by setting FB_ID to zero.
>>
>>I think this sounds great, and the interface is just right IMO.
>>
>
> Thanks, glad you like it! Hopefully you're equally agreeable with the
> changes Daniel has been suggesting.

Haven't seen anything objectionable there.

>>> Known issues:
>>> -
>>>  * I'm not sure what "DPMS" should mean for writeback connectors.
>>>It could be used to disable writeback (even when a framebuffer is
>>>attached), or it could be hidden entirely (which would break the
>>>legacy DPMS call for writeback connectors).
>>>  * With Daniel's recent re-iteration of the userspace API rules, I
>>>fully expect to provide some userspace code to support this. The
>>>question is what, and where? We want to use writeback for testing,
>>>so perhaps some tests in igt is suitable.
>>>  * Documentation. Probably some portion of this cover letter needs to
>>>make it into Documentation/
>>>  * Synchronisation. Our hardware will finish the writeback by the next
>>>vsync. I've not implemented fence support here, but it would be an
>>>obvious addition.
>>
>>My hardware won't necessarily finish by the next vsync -- it trickles
>>out at whatever rate it can find memory bandwidth to get the job done,
>>and fires an interrupt when it's finished.
>>
>
> Is it bounded? You presumably have to finish the write-out before you
> can change any input buffers?

Yeah, I'm not sure what it would mean to try to swap my display list
while write-out was happening.  Each CRTC (each of which can only
support one encoder at a time) has its own display list, though, so it
could avoid blocking other modesets.

>>So I would like some definition for how syncing works.  One answer would
>>be that these flips don't trigger their pageflip events until the
>>writeback is done (so I need to collect both the vsync irq and the
>>writeback irq before sending).  Another would be that manage an
>>independent fence for the writeback fb, so that you still immediately
>>know when framebuffers from the previous scanout-only frame are idle.
>>
>
> I much prefer the sound of the explicit fence approach.
>
> Hopefully we can agree that a new atomic commit can't be completed
> whilst there's a writeback ongoing, otherwise managing the fence and
> framebuffer lifetime sounds really tricky - they'd need to be decoupled
> from the atomic_state and outlive the commit that spawned them.

Oh, good point.

I'm fine with that, but then my anticipated usecases for writeback are
testing (don't care about performance) and fallback plane-squashing when
a complicated modeset exceeds limits (in which case you have no simpler
plane config to modeset to until the writeback is completed, anyway).


signature.asc
Description: PGP signature


[PATCH 11/18] [media] RedRat3: Delete the variable "dev" in redrat3_init_rc_dev()

2016-10-13 Thread SF Markus Elfring
From: Markus Elfring 
Date: Thu, 13 Oct 2016 14:40:11 +0200

Use the data structure member "dev" directly without assigning it
to an intermediate variable.
Thus delete the extra variable definition at the beginning.

Signed-off-by: Markus Elfring 
---
 drivers/media/rc/redrat3.c | 5 ++---
 1 file changed, 2 insertions(+), 3 deletions(-)

diff --git a/drivers/media/rc/redrat3.c b/drivers/media/rc/redrat3.c
index c43f43b..b23a8bb 100644
--- a/drivers/media/rc/redrat3.c
+++ b/drivers/media/rc/redrat3.c
@@ -854,7 +854,6 @@ static void redrat3_led_complete(struct urb *urb)
 
 static struct rc_dev *redrat3_init_rc_dev(struct redrat3_dev *rr3)
 {
-   struct device *dev = rr3->dev;
struct rc_dev *rc;
int ret;
u16 prod = le16_to_cpu(rr3->udev->descriptor.idProduct);
@@ -873,7 +872,7 @@ static struct rc_dev *redrat3_init_rc_dev(struct 
redrat3_dev *rr3)
rc->input_name = rr3->name;
rc->input_phys = rr3->phys;
usb_to_input_id(rr3->udev, >input_id);
-   rc->dev.parent = dev;
+   rc->dev.parent = rr3->dev;
rc->priv = rr3;
rc->driver_type = RC_DRIVER_IR_RAW;
rc->allowed_protocols = RC_BIT_ALL;
@@ -889,7 +888,7 @@ static struct rc_dev *redrat3_init_rc_dev(struct 
redrat3_dev *rr3)
 
ret = rc_register_device(rc);
if (ret < 0) {
-   dev_err(dev, "remote dev registration failed\n");
+   dev_err(rr3->dev, "remote dev registration failed\n");
goto out;
}
 
-- 
2.10.1

--
To unsubscribe from this list: send the line "unsubscribe linux-media" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH 13/18] [media] RedRat3: Return directly after a failed rc_allocate_device() in redrat3_init_rc_dev()

2016-10-13 Thread SF Markus Elfring
From: Markus Elfring 
Date: Thu, 13 Oct 2016 14:54:46 +0200

Return directly after a call of the function "rc_allocate_device" failed
at the beginning.

Signed-off-by: Markus Elfring 
---
 drivers/media/rc/redrat3.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/media/rc/redrat3.c b/drivers/media/rc/redrat3.c
index 002030f..74d93dd 100644
--- a/drivers/media/rc/redrat3.c
+++ b/drivers/media/rc/redrat3.c
@@ -860,7 +860,7 @@ static struct rc_dev *redrat3_init_rc_dev(struct 
redrat3_dev *rr3)
 
rc = rc_allocate_device();
if (!rc)
-   goto out;
+   return NULL;
 
prod = le16_to_cpu(rr3->udev->descriptor.idProduct);
snprintf(rr3->name, sizeof(rr3->name), "RedRat3%s "
-- 
2.10.1

--
To unsubscribe from this list: send the line "unsubscribe linux-media" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH 18/18] [media] RedRat3: Combine substrings for six messages

2016-10-13 Thread SF Markus Elfring
From: Markus Elfring 
Date: Thu, 13 Oct 2016 17:50:11 +0200

The script "checkpatch.pl" pointed information out like the following.

WARNING: quoted string split across lines

Thus fix the affected source code places.

Signed-off-by: Markus Elfring 
---
 drivers/media/rc/redrat3.c | 19 +++
 1 file changed, 7 insertions(+), 12 deletions(-)

diff --git a/drivers/media/rc/redrat3.c b/drivers/media/rc/redrat3.c
index a09d5cb..b8c4b98 100644
--- a/drivers/media/rc/redrat3.c
+++ b/drivers/media/rc/redrat3.c
@@ -233,8 +233,7 @@ static void redrat3_dump_fw_error(struct redrat3_dev *rr3, 
int code)
 
/* Codes 0x20 through 0x2f are IR Firmware Errors */
case 0x20:
-   pr_cont("Initial signal pulse not long enough "
-   "to measure carrier frequency\n");
+   pr_cont("Initial signal pulse not long enough to measure 
carrier frequency\n");
break;
case 0x21:
pr_cont("Not enough length values allocated for signal\n");
@@ -246,18 +245,15 @@ static void redrat3_dump_fw_error(struct redrat3_dev 
*rr3, int code)
pr_cont("Too many signal repeats\n");
break;
case 0x28:
-   pr_cont("Insufficient memory available for IR signal "
-   "data memory allocation\n");
+   pr_cont("Insufficient memory available for IR signal data 
memory allocation\n");
break;
case 0x29:
-   pr_cont("Insufficient memory available "
-   "for IrDa signal data memory allocation\n");
+   pr_cont("Insufficient memory available for IrDa signal data 
memory allocation\n");
break;
 
/* Codes 0x30 through 0x3f are USB Firmware Errors */
case 0x30:
-   pr_cont("Insufficient memory available for bulk "
-   "transfer structure\n");
+   pr_cont("Insufficient memory available for bulk transfer 
structure\n");
break;
 
/*
@@ -269,8 +265,7 @@ static void redrat3_dump_fw_error(struct redrat3_dev *rr3, 
int code)
pr_cont("Signal capture has been terminated\n");
break;
case 0x41:
-   pr_cont("Attempt to set/get and unknown signal I/O "
-   "algorithm parameter\n");
+   pr_cont("Attempt to set/get and unknown signal I/O algorithm 
parameter\n");
break;
case 0x42:
pr_cont("Signal capture already started\n");
@@ -866,8 +861,8 @@ static struct rc_dev *redrat3_init_rc_dev(struct 
redrat3_dev *rr3)
return NULL;
 
prod = le16_to_cpu(rr3->udev->descriptor.idProduct);
-   snprintf(rr3->name, sizeof(rr3->name), "RedRat3%s "
-"Infrared Remote Transceiver (%04x:%04x)",
+   snprintf(rr3->name, sizeof(rr3->name),
+"RedRat3%s Infrared Remote Transceiver (%04x:%04x)",
 prod == USB_RR3IIUSB_PRODUCT_ID ? "-II" : "",
 le16_to_cpu(rr3->udev->descriptor.idVendor), prod);
 
-- 
2.10.1

--
To unsubscribe from this list: send the line "unsubscribe linux-media" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH 00/18] [media] RedRat3: Fine-tuning for several function implementations

2016-10-13 Thread SF Markus Elfring
From: Markus Elfring 
Date: Thu, 13 Oct 2016 18:06:18 +0200

Several update suggestions were taken into account
from static source code analysis.

Markus Elfring (18):
  Use kcalloc() in two functions
  Move two assignments in redrat3_transmit_ir()
  Return directly after a failed kcalloc() in redrat3_transmit_ir()
  One function call less in redrat3_transmit_ir() after error detection
  Delete six messages for a failed memory allocation
  Delete an unnecessary variable initialisation in redrat3_get_firmware_rev()
  Improve another size determination in redrat3_reset()
  Improve another size determination in redrat3_send_cmd()
  Move a variable assignment in redrat3_dev_probe()
  Delete an unnecessary variable initialisation in redrat3_init_rc_dev()
  Delete the variable "dev" in redrat3_init_rc_dev()
  Move a variable assignment in redrat3_init_rc_dev()
  Return directly after a failed rc_allocate_device() in redrat3_init_rc_dev()
  Rename a jump label in redrat3_init_rc_dev()
  Delete two variables in redrat3_set_timeout()
  Move a variable assignment in redrat3_set_timeout()
  Adjust two checks for null pointers in redrat3_dev_probe()
  Combine substrings for six messages

 drivers/media/rc/redrat3.c | 146 +
 1 file changed, 67 insertions(+), 79 deletions(-)

-- 
2.10.1

--
To unsubscribe from this list: send the line "unsubscribe linux-media" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH 17/18] [media] RedRat3: Adjust two checks for null pointers in redrat3_dev_probe()

2016-10-13 Thread SF Markus Elfring
From: Markus Elfring 
Date: Thu, 13 Oct 2016 17:40:34 +0200
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

The script "checkpatch.pl" pointed information out like the following.

Comparison to NULL could be written !…

Thus fix the affected source code places.

Signed-off-by: Markus Elfring 
---
 drivers/media/rc/redrat3.c | 5 ++---
 1 file changed, 2 insertions(+), 3 deletions(-)

diff --git a/drivers/media/rc/redrat3.c b/drivers/media/rc/redrat3.c
index 06c9eea..a09d5cb 100644
--- a/drivers/media/rc/redrat3.c
+++ b/drivers/media/rc/redrat3.c
@@ -923,8 +923,7 @@ static int redrat3_dev_probe(struct usb_interface *intf,
ep = >endpoint[i].desc;
addr = ep->bEndpointAddress;
attrs = ep->bmAttributes;
-
-   if ((ep_in == NULL) &&
+   if (!ep_in &&
((addr & USB_ENDPOINT_DIR_MASK) == USB_DIR_IN) &&
((attrs & USB_ENDPOINT_XFERTYPE_MASK) ==
 USB_ENDPOINT_XFER_BULK)) {
@@ -935,7 +934,7 @@ static int redrat3_dev_probe(struct usb_interface *intf,
ep_in = ep;
}
 
-   if ((ep_out == NULL) &&
+   if (!ep_out &&
((addr & USB_ENDPOINT_DIR_MASK) == USB_DIR_OUT) &&
((attrs & USB_ENDPOINT_XFERTYPE_MASK) ==
 USB_ENDPOINT_XFER_BULK)) {
-- 
2.10.1

--
To unsubscribe from this list: send the line "unsubscribe linux-media" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH 16/18] [media] RedRat3: Move a variable assignment in redrat3_set_timeout()

2016-10-13 Thread SF Markus Elfring
From: Markus Elfring 
Date: Thu, 13 Oct 2016 17:13:41 +0200

Move the assignment for the local variable "rr3" behind the source code
for a memory allocation by this function.

Signed-off-by: Markus Elfring 
---
 drivers/media/rc/redrat3.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/drivers/media/rc/redrat3.c b/drivers/media/rc/redrat3.c
index e46a92a..06c9eea 100644
--- a/drivers/media/rc/redrat3.c
+++ b/drivers/media/rc/redrat3.c
@@ -475,7 +475,7 @@ static u32 redrat3_get_timeout(struct redrat3_dev *rr3)
 
 static int redrat3_set_timeout(struct rc_dev *rc_dev, unsigned int timeoutns)
 {
-   struct redrat3_dev *rr3 = rc_dev->priv;
+   struct redrat3_dev *rr3;
__be32 *timeout;
int ret;
 
@@ -484,6 +484,7 @@ static int redrat3_set_timeout(struct rc_dev *rc_dev, 
unsigned int timeoutns)
return -ENOMEM;
 
*timeout = cpu_to_be32(redrat3_us_to_len(timeoutns / 1000));
+   rr3 = rc_dev->priv;
ret = usb_control_msg(rr3->udev,
  usb_sndctrlpipe(rr3->udev, 0),
  RR3_SET_IR_PARAM,
-- 
2.10.1

--
To unsubscribe from this list: send the line "unsubscribe linux-media" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH 12/18] [media] RedRat3: Move a variable assignment in redrat3_init_rc_dev()

2016-10-13 Thread SF Markus Elfring
From: Markus Elfring 
Date: Thu, 13 Oct 2016 14:50:05 +0200

Move the assignment for the local variable "prod" behind the source code
for a memory allocation by this function.

Signed-off-by: Markus Elfring 
---
 drivers/media/rc/redrat3.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/drivers/media/rc/redrat3.c b/drivers/media/rc/redrat3.c
index b23a8bb..002030f 100644
--- a/drivers/media/rc/redrat3.c
+++ b/drivers/media/rc/redrat3.c
@@ -856,12 +856,13 @@ static struct rc_dev *redrat3_init_rc_dev(struct 
redrat3_dev *rr3)
 {
struct rc_dev *rc;
int ret;
-   u16 prod = le16_to_cpu(rr3->udev->descriptor.idProduct);
+   u16 prod;
 
rc = rc_allocate_device();
if (!rc)
goto out;
 
+   prod = le16_to_cpu(rr3->udev->descriptor.idProduct);
snprintf(rr3->name, sizeof(rr3->name), "RedRat3%s "
 "Infrared Remote Transceiver (%04x:%04x)",
 prod == USB_RR3IIUSB_PRODUCT_ID ? "-II" : "",
-- 
2.10.1

--
To unsubscribe from this list: send the line "unsubscribe linux-media" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH 15/18] [media] RedRat3: Delete two variables in redrat3_set_timeout()

2016-10-13 Thread SF Markus Elfring
From: Markus Elfring 
Date: Thu, 13 Oct 2016 15:40:33 +0200

* Use the data structure members "dev" and "udev" directly
  without assigning them to intermediate variables.
  Thus delete the extra variable definitions at the beginning.

* Fix indentation for the parameters of two function calls.

Signed-off-by: Markus Elfring 
---
 drivers/media/rc/redrat3.c | 20 +++-
 1 file changed, 11 insertions(+), 9 deletions(-)

diff --git a/drivers/media/rc/redrat3.c b/drivers/media/rc/redrat3.c
index 055f214..e46a92a 100644
--- a/drivers/media/rc/redrat3.c
+++ b/drivers/media/rc/redrat3.c
@@ -476,8 +476,6 @@ static u32 redrat3_get_timeout(struct redrat3_dev *rr3)
 static int redrat3_set_timeout(struct rc_dev *rc_dev, unsigned int timeoutns)
 {
struct redrat3_dev *rr3 = rc_dev->priv;
-   struct usb_device *udev = rr3->udev;
-   struct device *dev = rr3->dev;
__be32 *timeout;
int ret;
 
@@ -486,13 +484,17 @@ static int redrat3_set_timeout(struct rc_dev *rc_dev, 
unsigned int timeoutns)
return -ENOMEM;
 
*timeout = cpu_to_be32(redrat3_us_to_len(timeoutns / 1000));
-   ret = usb_control_msg(udev, usb_sndctrlpipe(udev, 0), RR3_SET_IR_PARAM,
-USB_TYPE_VENDOR | USB_RECIP_DEVICE | USB_DIR_OUT,
-RR3_IR_IO_SIG_TIMEOUT, 0, timeout, sizeof(*timeout),
-HZ * 25);
-   dev_dbg(dev, "set ir parm timeout %d ret 0x%02x\n",
-   be32_to_cpu(*timeout), ret);
-
+   ret = usb_control_msg(rr3->udev,
+ usb_sndctrlpipe(rr3->udev, 0),
+ RR3_SET_IR_PARAM,
+ USB_TYPE_VENDOR | USB_RECIP_DEVICE | USB_DIR_OUT,
+ RR3_IR_IO_SIG_TIMEOUT,
+ 0,
+ timeout,
+ sizeof(*timeout),
+ HZ * 25);
+   dev_dbg(rr3->dev, "set ir parm timeout %d ret 0x%02x\n",
+   be32_to_cpu(*timeout), ret);
if (ret == sizeof(*timeout)) {
rr3->hw_timeout = timeoutns / 1000;
ret = 0;
-- 
2.10.1

--
To unsubscribe from this list: send the line "unsubscribe linux-media" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH 10/18] [media] RedRat3: Delete an unnecessary variable initialisation in redrat3_init_rc_dev()

2016-10-13 Thread SF Markus Elfring
From: Markus Elfring 
Date: Thu, 13 Oct 2016 14:17:43 +0200

The local variable "ret" will be set to an appropriate value a bit later.
Thus omit the explicit initialisation at the beginning.

Signed-off-by: Markus Elfring 
---
 drivers/media/rc/redrat3.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/media/rc/redrat3.c b/drivers/media/rc/redrat3.c
index f85117b..c43f43b 100644
--- a/drivers/media/rc/redrat3.c
+++ b/drivers/media/rc/redrat3.c
@@ -856,7 +856,7 @@ static struct rc_dev *redrat3_init_rc_dev(struct 
redrat3_dev *rr3)
 {
struct device *dev = rr3->dev;
struct rc_dev *rc;
-   int ret = -ENODEV;
+   int ret;
u16 prod = le16_to_cpu(rr3->udev->descriptor.idProduct);
 
rc = rc_allocate_device();
-- 
2.10.1

--
To unsubscribe from this list: send the line "unsubscribe linux-media" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH 14/18] [media] RedRat3: Rename a jump label in redrat3_init_rc_dev()

2016-10-13 Thread SF Markus Elfring
From: Markus Elfring 
Date: Thu, 13 Oct 2016 15:00:12 +0200

Adjust a jump label according to the Linux coding style convention.

Signed-off-by: Markus Elfring 
---
 drivers/media/rc/redrat3.c | 5 ++---
 1 file changed, 2 insertions(+), 3 deletions(-)

diff --git a/drivers/media/rc/redrat3.c b/drivers/media/rc/redrat3.c
index 74d93dd..055f214 100644
--- a/drivers/media/rc/redrat3.c
+++ b/drivers/media/rc/redrat3.c
@@ -890,12 +890,11 @@ static struct rc_dev *redrat3_init_rc_dev(struct 
redrat3_dev *rr3)
ret = rc_register_device(rc);
if (ret < 0) {
dev_err(rr3->dev, "remote dev registration failed\n");
-   goto out;
+   goto free_device;
}
 
return rc;
-
-out:
+free_device:
rc_free_device(rc);
return NULL;
 }
-- 
2.10.1

--
To unsubscribe from this list: send the line "unsubscribe linux-media" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH 01/18] [media] RedRat3: Use kcalloc() in two functions

2016-10-13 Thread Joe Perches
On Thu, 2016-10-13 at 18:18 +0200, SF Markus Elfring wrote:
> diff --git a/drivers/media/rc/redrat3.c b/drivers/media/rc/redrat3.c
[]
> @@ -549,7 +549,7 @@ static void redrat3_get_firmware_rev(struct redrat3_dev 
> *rr3)
>   int rc = 0;
>   char *buffer;
>  
> - buffer = kzalloc(sizeof(char) * (RR3_FW_VERSION_LEN + 1), GFP_KERNEL);
> + buffer = kcalloc(RR3_FW_VERSION_LEN + 1, sizeof(*buffer), GFP_KERNEL);
>   if (!buffer) {
>   dev_err(rr3->dev, "Memory allocation failure\n");
>   return;,

Markus, please stop being _so_ mechanical and use your
brain a little too.  By definition, sizeof(char) == 1.

This _really_ should be kzalloc(RR3_FW_VERSION_LEN + 1,...)

--
To unsubscribe from this list: send the line "unsubscribe linux-media" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH 08/18] [media] RedRat3: Improve another size determination in redrat3_send_cmd()

2016-10-13 Thread SF Markus Elfring
From: Markus Elfring 
Date: Thu, 13 Oct 2016 13:31:17 +0200

Replace the specification of a data type by a pointer dereference
as the parameter for the operator "sizeof" to make the corresponding size
determination a bit safer.

Signed-off-by: Markus Elfring 
---
 drivers/media/rc/redrat3.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/media/rc/redrat3.c b/drivers/media/rc/redrat3.c
index 5832e6f..f6c21a1 100644
--- a/drivers/media/rc/redrat3.c
+++ b/drivers/media/rc/redrat3.c
@@ -388,7 +388,7 @@ static int redrat3_send_cmd(int cmd, struct redrat3_dev 
*rr3)
u8 *data;
int res;
 
-   data = kzalloc(sizeof(u8), GFP_KERNEL);
+   data = kzalloc(sizeof(*data), GFP_KERNEL);
if (!data)
return -ENOMEM;
 
-- 
2.10.1

--
To unsubscribe from this list: send the line "unsubscribe linux-media" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH 07/18] [media] RedRat3: Improve another size determination in redrat3_reset()

2016-10-13 Thread SF Markus Elfring
From: Markus Elfring 
Date: Thu, 13 Oct 2016 13:23:22 +0200

Replace the specification of a data type by a pointer dereference
as the parameter for the operator "sizeof" to make the corresponding size
determination a bit safer.

Signed-off-by: Markus Elfring 
---
 drivers/media/rc/redrat3.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/media/rc/redrat3.c b/drivers/media/rc/redrat3.c
index 0ac96a4..5832e6f 100644
--- a/drivers/media/rc/redrat3.c
+++ b/drivers/media/rc/redrat3.c
@@ -510,7 +510,7 @@ static void redrat3_reset(struct redrat3_dev *rr3)
struct device *dev = rr3->dev;
int rc, rxpipe, txpipe;
u8 *val;
-   int len = sizeof(u8);
+   size_t const len = sizeof(*val);
 
rxpipe = usb_rcvctrlpipe(udev, 0);
txpipe = usb_sndctrlpipe(udev, 0);
-- 
2.10.1

--
To unsubscribe from this list: send the line "unsubscribe linux-media" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH 09/18] [media] RedRat3: Move a variable assignment in redrat3_dev_probe()

2016-10-13 Thread SF Markus Elfring
From: Markus Elfring 
Date: Thu, 13 Oct 2016 14:07:03 +0200

* One local variable was set to an error code before a concrete
  error situation was detected. Thus move the corresponding assignment
  into three if branches to indicate a memory allocation failure there.

* Adjust a jump label according to the Linux coding style convention.

Signed-off-by: Markus Elfring 
---
 drivers/media/rc/redrat3.c | 24 +++-
 1 file changed, 15 insertions(+), 9 deletions(-)

diff --git a/drivers/media/rc/redrat3.c b/drivers/media/rc/redrat3.c
index f6c21a1..f85117b 100644
--- a/drivers/media/rc/redrat3.c
+++ b/drivers/media/rc/redrat3.c
@@ -912,7 +912,7 @@ static int redrat3_dev_probe(struct usb_interface *intf,
struct usb_endpoint_descriptor *ep_out = NULL;
u8 addr, attrs;
int pipe, i;
-   int retval = -ENOMEM;
+   int retval;
 
uhi = intf->cur_altsetting;
 
@@ -951,21 +951,27 @@ static int redrat3_dev_probe(struct usb_interface *intf,
 
/* allocate memory for our device state and initialize it */
rr3 = kzalloc(sizeof(*rr3), GFP_KERNEL);
-   if (!rr3)
+   if (!rr3) {
+   retval = -ENOMEM;
goto no_endpoints;
+   }
 
rr3->dev = >dev;
 
/* set up bulk-in endpoint */
rr3->read_urb = usb_alloc_urb(0, GFP_KERNEL);
-   if (!rr3->read_urb)
-   goto error;
+   if (!rr3->read_urb) {
+   retval = -ENOMEM;
+   goto delete_rr;
+   }
 
rr3->ep_in = ep_in;
rr3->bulk_in_buf = usb_alloc_coherent(udev,
le16_to_cpu(ep_in->wMaxPacketSize), GFP_KERNEL, >dma_in);
-   if (!rr3->bulk_in_buf)
-   goto error;
+   if (!rr3->bulk_in_buf) {
+   retval = -ENOMEM;
+   goto delete_rr;
+   }
 
pipe = usb_rcvbulkpipe(udev, ep_in->bEndpointAddress);
usb_fill_bulk_urb(rr3->read_urb, udev, pipe, rr3->bulk_in_buf,
@@ -982,7 +988,7 @@ static int redrat3_dev_probe(struct usb_interface *intf,
/* might be all we need to do? */
retval = redrat3_enable_detector(rr3);
if (retval < 0)
-   goto error;
+   goto delete_rr;
 
/* store current hardware timeout, in µs */
rr3->hw_timeout = redrat3_get_timeout(rr3);
@@ -996,7 +1002,7 @@ static int redrat3_dev_probe(struct usb_interface *intf,
rr3->led.brightness_set = redrat3_brightness_set;
retval = led_classdev_register(>dev, >led);
if (retval)
-   goto error;
+   goto delete_rr;
 
atomic_set(>flash, 0);
rr3->flash_urb = usb_alloc_urb(0, GFP_KERNEL);
@@ -1028,7 +1034,7 @@ static int redrat3_dev_probe(struct usb_interface *intf,
 
 led_free_error:
led_classdev_unregister(>led);
-error:
+delete_rr:
redrat3_delete(rr3, rr3->udev);
 
 no_endpoints:
-- 
2.10.1

--
To unsubscribe from this list: send the line "unsubscribe linux-media" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH 03/18] [media] RedRat3: Return directly after a failed kcalloc() in redrat3_transmit_ir()

2016-10-13 Thread SF Markus Elfring
From: Markus Elfring 
Date: Thu, 13 Oct 2016 10:34:29 +0200

* Return directly after a call of the function "kcalloc" failed
  at the beginning.

* Reorder two calls for the function "kfree" at the end.

Signed-off-by: Markus Elfring 
---
 drivers/media/rc/redrat3.c | 8 +++-
 1 file changed, 3 insertions(+), 5 deletions(-)

diff --git a/drivers/media/rc/redrat3.c b/drivers/media/rc/redrat3.c
index f5a6850..7ae2ced 100644
--- a/drivers/media/rc/redrat3.c
+++ b/drivers/media/rc/redrat3.c
@@ -741,10 +741,8 @@ static int redrat3_transmit_ir(struct rc_dev *rcdev, 
unsigned *txbuf,
sample_lens = kcalloc(RR3_DRIVER_MAXLENS,
  sizeof(*sample_lens),
  GFP_KERNEL);
-   if (!sample_lens) {
-   ret = -ENOMEM;
-   goto out;
-   }
+   if (!sample_lens)
+   return -ENOMEM;
 
irdata = kzalloc(sizeof(*irdata), GFP_KERNEL);
if (!irdata) {
@@ -815,8 +813,8 @@ static int redrat3_transmit_ir(struct rc_dev *rcdev, 
unsigned *txbuf,
ret = count;
 
 out:
-   kfree(sample_lens);
kfree(irdata);
+   kfree(sample_lens);
 
rr3->transmitting = false;
/* rr3 re-enables rc detector because it was enabled before */
-- 
2.10.1

--
To unsubscribe from this list: send the line "unsubscribe linux-media" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH 06/18] [media] RedRat3: Delete an unnecessary variable initialisation in redrat3_get_firmware_rev()

2016-10-13 Thread SF Markus Elfring
From: Markus Elfring 
Date: Thu, 13 Oct 2016 13:21:55 +0200

The local variable "rc" will be set to an appropriate value a bit later.
Thus omit the explicit initialisation at the beginning.

Signed-off-by: Markus Elfring 
---
 drivers/media/rc/redrat3.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/media/rc/redrat3.c b/drivers/media/rc/redrat3.c
index 2e31c18..0ac96a4 100644
--- a/drivers/media/rc/redrat3.c
+++ b/drivers/media/rc/redrat3.c
@@ -542,7 +542,7 @@ static void redrat3_reset(struct redrat3_dev *rr3)
 
 static void redrat3_get_firmware_rev(struct redrat3_dev *rr3)
 {
-   int rc = 0;
+   int rc;
char *buffer;
 
buffer = kcalloc(RR3_FW_VERSION_LEN + 1, sizeof(*buffer), GFP_KERNEL);
-- 
2.10.1

--
To unsubscribe from this list: send the line "unsubscribe linux-media" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH 05/18] [media] RedRat3: Delete six messages for a failed memory allocation

2016-10-13 Thread SF Markus Elfring
From: Markus Elfring 
Date: Thu, 13 Oct 2016 13:20:19 +0200

The script "checkpatch.pl" pointed information out like the following.

WARNING: Possible unnecessary 'out of memory' message

Thus remove such a logging statement in five functions.

Link: 
http://events.linuxfoundation.org/sites/events/files/slides/LCJ16-Refactor_Strings-WSang_0.pdf
Signed-off-by: Markus Elfring 
---
 drivers/media/rc/redrat3.c | 24 ++--
 1 file changed, 6 insertions(+), 18 deletions(-)

diff --git a/drivers/media/rc/redrat3.c b/drivers/media/rc/redrat3.c
index 71e901d..2e31c18 100644
--- a/drivers/media/rc/redrat3.c
+++ b/drivers/media/rc/redrat3.c
@@ -453,10 +453,8 @@ static u32 redrat3_get_timeout(struct redrat3_dev *rr3)
 
len = sizeof(*tmp);
tmp = kzalloc(len, GFP_KERNEL);
-   if (!tmp) {
-   dev_warn(rr3->dev, "Memory allocation faillure\n");
+   if (!tmp)
return timeout;
-   }
 
pipe = usb_rcvctrlpipe(rr3->udev, 0);
ret = usb_control_msg(rr3->udev, pipe, RR3_GET_IR_PARAM,
@@ -518,10 +516,8 @@ static void redrat3_reset(struct redrat3_dev *rr3)
txpipe = usb_sndctrlpipe(udev, 0);
 
val = kmalloc(len, GFP_KERNEL);
-   if (!val) {
-   dev_err(dev, "Memory allocation failure\n");
+   if (!val)
return;
-   }
 
*val = 0x01;
rc = usb_control_msg(udev, rxpipe, RR3_RESET,
@@ -550,10 +546,8 @@ static void redrat3_get_firmware_rev(struct redrat3_dev 
*rr3)
char *buffer;
 
buffer = kcalloc(RR3_FW_VERSION_LEN + 1, sizeof(*buffer), GFP_KERNEL);
-   if (!buffer) {
-   dev_err(rr3->dev, "Memory allocation failure\n");
+   if (!buffer)
return;
-   }
 
rc = usb_control_msg(rr3->udev, usb_rcvctrlpipe(rr3->udev, 0),
 RR3_FW_VERSION,
@@ -866,10 +860,8 @@ static struct rc_dev *redrat3_init_rc_dev(struct 
redrat3_dev *rr3)
u16 prod = le16_to_cpu(rr3->udev->descriptor.idProduct);
 
rc = rc_allocate_device();
-   if (!rc) {
-   dev_err(dev, "remote input dev allocation failed\n");
+   if (!rc)
goto out;
-   }
 
snprintf(rr3->name, sizeof(rr3->name), "RedRat3%s "
 "Infrared Remote Transceiver (%04x:%04x)",
@@ -959,10 +951,8 @@ static int redrat3_dev_probe(struct usb_interface *intf,
 
/* allocate memory for our device state and initialize it */
rr3 = kzalloc(sizeof(*rr3), GFP_KERNEL);
-   if (rr3 == NULL) {
-   dev_err(dev, "Memory allocation failure\n");
+   if (!rr3)
goto no_endpoints;
-   }
 
rr3->dev = >dev;
 
@@ -974,10 +964,8 @@ static int redrat3_dev_probe(struct usb_interface *intf,
rr3->ep_in = ep_in;
rr3->bulk_in_buf = usb_alloc_coherent(udev,
le16_to_cpu(ep_in->wMaxPacketSize), GFP_KERNEL, >dma_in);
-   if (!rr3->bulk_in_buf) {
-   dev_err(dev, "Read buffer allocation failure\n");
+   if (!rr3->bulk_in_buf)
goto error;
-   }
 
pipe = usb_rcvbulkpipe(udev, ep_in->bEndpointAddress);
usb_fill_bulk_urb(rr3->read_urb, udev, pipe, rr3->bulk_in_buf,
-- 
2.10.1

--
To unsubscribe from this list: send the line "unsubscribe linux-media" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH 04/18] [media] RedRat3: One function call less in redrat3_transmit_ir() after error detection

2016-10-13 Thread SF Markus Elfring
From: Markus Elfring 
Date: Thu, 13 Oct 2016 10:50:24 +0200

The kfree() function was called in one case by the
redrat3_transmit_ir() function during error handling
even if the passed variable contained a null pointer.

* Adjust jump targets according to the Linux coding style convention.

* Move the resetting for the data structure member "transmitting"
  at the end.

* Delete initialisations for the variables "irdata" and "sample_lens"
  at the beginning which became unnecessary with this refactoring.

Signed-off-by: Markus Elfring 
---
 drivers/media/rc/redrat3.c | 18 --
 1 file changed, 8 insertions(+), 10 deletions(-)

diff --git a/drivers/media/rc/redrat3.c b/drivers/media/rc/redrat3.c
index 7ae2ced..71e901d 100644
--- a/drivers/media/rc/redrat3.c
+++ b/drivers/media/rc/redrat3.c
@@ -723,10 +723,10 @@ static int redrat3_transmit_ir(struct rc_dev *rcdev, 
unsigned *txbuf,
 {
struct redrat3_dev *rr3 = rcdev->priv;
struct device *dev = rr3->dev;
-   struct redrat3_irdata *irdata = NULL;
+   struct redrat3_irdata *irdata;
int ret, ret_len;
int lencheck, cur_sample_len, pipe;
-   int *sample_lens = NULL;
+   int *sample_lens;
u8 curlencheck;
unsigned i, sendbuf_len;
 
@@ -747,7 +747,7 @@ static int redrat3_transmit_ir(struct rc_dev *rcdev, 
unsigned *txbuf,
irdata = kzalloc(sizeof(*irdata), GFP_KERNEL);
if (!irdata) {
ret = -ENOMEM;
-   goto out;
+   goto free_sample;
}
 
/* rr3 will disable rc detector on transmit */
@@ -776,7 +776,7 @@ static int redrat3_transmit_ir(struct rc_dev *rcdev, 
unsigned *txbuf,
curlencheck++;
} else {
ret = -EINVAL;
-   goto out;
+   goto reset_member;
}
}
irdata->sigdata[i] = lencheck;
@@ -811,14 +811,12 @@ static int redrat3_transmit_ir(struct rc_dev *rcdev, 
unsigned *txbuf,
dev_err(dev, "Error: control msg send failed, rc %d\n", ret);
else
ret = count;
-
-out:
-   kfree(irdata);
-   kfree(sample_lens);
-
+reset_member:
rr3->transmitting = false;
/* rr3 re-enables rc detector because it was enabled before */
-
+   kfree(irdata);
+free_sample:
+   kfree(sample_lens);
return ret;
 }
 
-- 
2.10.1

--
To unsubscribe from this list: send the line "unsubscribe linux-media" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH 02/18] [media] RedRat3: Move two assignments in redrat3_transmit_ir()

2016-10-13 Thread SF Markus Elfring
From: Markus Elfring 
Date: Thu, 13 Oct 2016 10:25:57 +0200

Move the assignment for the data structure member "transmitting"
and the local variable "curlencheck" behind the source code
for memory allocations by this function.

Signed-off-by: Markus Elfring 
---
 drivers/media/rc/redrat3.c | 8 
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/drivers/media/rc/redrat3.c b/drivers/media/rc/redrat3.c
index d89958b..f5a6850 100644
--- a/drivers/media/rc/redrat3.c
+++ b/drivers/media/rc/redrat3.c
@@ -727,7 +727,7 @@ static int redrat3_transmit_ir(struct rc_dev *rcdev, 
unsigned *txbuf,
int ret, ret_len;
int lencheck, cur_sample_len, pipe;
int *sample_lens = NULL;
-   u8 curlencheck = 0;
+   u8 curlencheck;
unsigned i, sendbuf_len;
 
if (rr3->transmitting) {
@@ -738,9 +738,6 @@ static int redrat3_transmit_ir(struct rc_dev *rcdev, 
unsigned *txbuf,
if (count > RR3_MAX_SIG_SIZE - RR3_TX_TRAILER_LEN)
return -EINVAL;
 
-   /* rr3 will disable rc detector on transmit */
-   rr3->transmitting = true;
-
sample_lens = kcalloc(RR3_DRIVER_MAXLENS,
  sizeof(*sample_lens),
  GFP_KERNEL);
@@ -755,6 +752,9 @@ static int redrat3_transmit_ir(struct rc_dev *rcdev, 
unsigned *txbuf,
goto out;
}
 
+   /* rr3 will disable rc detector on transmit */
+   rr3->transmitting = true;
+   curlencheck = 0;
for (i = 0; i < count; i++) {
cur_sample_len = redrat3_us_to_len(txbuf[i]);
if (cur_sample_len > 0x) {
-- 
2.10.1

--
To unsubscribe from this list: send the line "unsubscribe linux-media" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH 01/18] [media] RedRat3: Use kcalloc() in two functions

2016-10-13 Thread SF Markus Elfring
From: Markus Elfring 
Date: Thu, 13 Oct 2016 08:35:57 +0200

* Multiplications for the size determination of memory allocations
  indicated that array data structures should be processed.
  Thus use the corresponding function "kcalloc".

  This issue was detected by using the Coccinelle software.

* Replace the specification of data types by pointer dereferences
  to make the corresponding size determination a bit safer according to
  the Linux coding style convention.

Signed-off-by: Markus Elfring 
---
 drivers/media/rc/redrat3.c | 6 --
 1 file changed, 4 insertions(+), 2 deletions(-)

diff --git a/drivers/media/rc/redrat3.c b/drivers/media/rc/redrat3.c
index 8d7df6d..d89958b 100644
--- a/drivers/media/rc/redrat3.c
+++ b/drivers/media/rc/redrat3.c
@@ -549,7 +549,7 @@ static void redrat3_get_firmware_rev(struct redrat3_dev 
*rr3)
int rc = 0;
char *buffer;
 
-   buffer = kzalloc(sizeof(char) * (RR3_FW_VERSION_LEN + 1), GFP_KERNEL);
+   buffer = kcalloc(RR3_FW_VERSION_LEN + 1, sizeof(*buffer), GFP_KERNEL);
if (!buffer) {
dev_err(rr3->dev, "Memory allocation failure\n");
return;
@@ -741,7 +741,9 @@ static int redrat3_transmit_ir(struct rc_dev *rcdev, 
unsigned *txbuf,
/* rr3 will disable rc detector on transmit */
rr3->transmitting = true;
 
-   sample_lens = kzalloc(sizeof(int) * RR3_DRIVER_MAXLENS, GFP_KERNEL);
+   sample_lens = kcalloc(RR3_DRIVER_MAXLENS,
+ sizeof(*sample_lens),
+ GFP_KERNEL);
if (!sample_lens) {
ret = -ENOMEM;
goto out;
-- 
2.10.1

--
To unsubscribe from this list: send the line "unsubscribe linux-media" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH] [media] s5p-cec: mark PM functions as __maybe_unused again

2016-10-13 Thread Arnd Bergmann
A bugfix removed the two callers of s5p_cec_runtime_suspend
and s5p_cec_runtime_resume, leading to the return of a harmless
warning that I had previously fixed in commit aee8937089b1
("[media] s5p_cec: mark suspend/resume as __maybe_unused"):

staging/media/s5p-cec/s5p_cec.c:234:12: error: ‘s5p_cec_runtime_suspend’ 
defined but not used [-Werror=unused-function]
staging/media/s5p-cec/s5p_cec.c:242:12: error: ‘s5p_cec_runtime_resume’ defined 
but not used [-Werror=unused-function]

This adds the __maybe_unused annotations to the function that
were not removed and that are now unused when CONFIG_PM
is disabled.

Fixes: 57b978ada073 ("[media] s5p-cec: fix system and runtime PM integration")
Signed-off-by: Arnd Bergmann 
---
 drivers/staging/media/s5p-cec/s5p_cec.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/staging/media/s5p-cec/s5p_cec.c 
b/drivers/staging/media/s5p-cec/s5p_cec.c
index 1780a08b73c9..58d756231136 100644
--- a/drivers/staging/media/s5p-cec/s5p_cec.c
+++ b/drivers/staging/media/s5p-cec/s5p_cec.c
@@ -231,7 +231,7 @@ static int s5p_cec_remove(struct platform_device *pdev)
return 0;
 }
 
-static int s5p_cec_runtime_suspend(struct device *dev)
+static int __maybe_unused s5p_cec_runtime_suspend(struct device *dev)
 {
struct s5p_cec_dev *cec = dev_get_drvdata(dev);
 
@@ -239,7 +239,7 @@ static int s5p_cec_runtime_suspend(struct device *dev)
return 0;
 }
 
-static int s5p_cec_runtime_resume(struct device *dev)
+static int __maybe_unused s5p_cec_runtime_resume(struct device *dev)
 {
struct s5p_cec_dev *cec = dev_get_drvdata(dev);
int ret;
-- 
2.9.0

--
To unsubscribe from this list: send the line "unsubscribe linux-media" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH v4l-utils 7/7 v7.1] Add a libv4l plugin for Exynos4 camera

2016-10-13 Thread Jacek Anaszewski

Forgot to add changelog:

Changes since v7:

- fixed and improved ctrl ioctl handlers

Best regards,
Jacek Anaszewski

On 10/13/2016 04:19 PM, Jacek Anaszewski wrote:

The plugin provides support for the media device on Exynos4 SoC.
It performs single plane <-> multi plane API conversion,
video pipeline linking and takes care of automatic data format
negotiation for the whole pipeline, after intercepting
VIDIOC_S_FMT or VIDIOC_TRY_FMT ioctls.

Signed-off-by: Jacek Anaszewski 
Acked-by: Kyungmin Park 
---

--
To unsubscribe from this list: send the line "unsubscribe linux-media" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH v4l-utils 7/7 v7.1] Add a libv4l plugin for Exynos4 camera

2016-10-13 Thread Jacek Anaszewski
The plugin provides support for the media device on Exynos4 SoC.
It performs single plane <-> multi plane API conversion,
video pipeline linking and takes care of automatic data format
negotiation for the whole pipeline, after intercepting
VIDIOC_S_FMT or VIDIOC_TRY_FMT ioctls.

Signed-off-by: Jacek Anaszewski 
Acked-by: Kyungmin Park 
---
 configure.ac  |1 +
 lib/Makefile.am   |5 +
 lib/libv4l-exynos4-camera/Makefile.am |   19 +
 lib/libv4l-exynos4-camera/libv4l-exynos4-camera.c | 1335 +
 4 files changed, 1360 insertions(+)
 create mode 100644 lib/libv4l-exynos4-camera/Makefile.am
 create mode 100644 lib/libv4l-exynos4-camera/libv4l-exynos4-camera.c

diff --git a/configure.ac b/configure.ac
index 8447f05..692718a 100644
--- a/configure.ac
+++ b/configure.ac
@@ -17,6 +17,7 @@ AC_CONFIG_FILES([Makefile
lib/libdvbv5/Makefile
lib/libv4l2rds/Makefile
lib/libv4l-mplane/Makefile
+   lib/libv4l-exynos4-camera/Makefile
 
utils/Makefile
utils/libv4l2util/Makefile
diff --git a/lib/Makefile.am b/lib/Makefile.am
index a105c95..b5e52db 100644
--- a/lib/Makefile.am
+++ b/lib/Makefile.am
@@ -5,6 +5,11 @@ SUBDIRS = \
libv4l2rds \
libv4l-mplane
 
+if WITH_V4LUTILS
+SUBDIRS += \
+   libv4l-exynos4-camera
+endif
+
 if WITH_LIBDVBV5
 SUBDIRS += \
libdvbv5
diff --git a/lib/libv4l-exynos4-camera/Makefile.am 
b/lib/libv4l-exynos4-camera/Makefile.am
new file mode 100644
index 000..c38b7f6
--- /dev/null
+++ b/lib/libv4l-exynos4-camera/Makefile.am
@@ -0,0 +1,19 @@
+if WITH_V4L_PLUGINS
+libv4l2plugin_LTLIBRARIES = libv4l-exynos4-camera.la
+endif
+
+media-bus-format-names.h: ../../include/linux/media-bus-format.h
+   sed -e '/#define MEDIA_BUS_FMT/ ! d; s/.*FMT_//; /FIXED/ d; s/\t.*//; 
s/.*/{ \"&\", MEDIA_BUS_FMT_& },/;' \
+   < $< > $@
+
+media-bus-format-codes.h: ../../include/linux/media-bus-format.h
+   sed -e '/#define MEDIA_BUS_FMT/ ! d; s/.*#define //; /FIXED/ d; 
s/\t.*//; s/.*/ &,/;' \
+   < $< > $@
+
+BUILT_SOURCES = media-bus-format-names.h media-bus-format-codes.h
+CLEANFILES = $(BUILT_SOURCES)
+
+nodist_libv4l_exynos4_camera_la_SOURCES = $(BUILT_SOURCES)
+libv4l_exynos4_camera_la_SOURCES = libv4l-exynos4-camera.c 
../../utils/media-ctl/libmediactl.c ../../utils/media-ctl/libv4l2subdev.c 
../../utils/media-ctl/mediatext.c
+libv4l_exynos4_camera_la_CFLAGS = -fvisibility=hidden -std=gnu99
+libv4l_exynos4_camera_la_LDFLAGS = -avoid-version -module -shared 
-export-dynamic -lpthread
diff --git a/lib/libv4l-exynos4-camera/libv4l-exynos4-camera.c 
b/lib/libv4l-exynos4-camera/libv4l-exynos4-camera.c
new file mode 100644
index 000..c2c4c6e
--- /dev/null
+++ b/lib/libv4l-exynos4-camera/libv4l-exynos4-camera.c
@@ -0,0 +1,1335 @@
+/*
+ * Copyright (c) 2016 Samsung Electronics Co., Ltd.
+ *  http://www.samsung.com
+ *
+ * Author: Jacek Anaszewski 
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License as published by
+ * the Free Software Foundation; either version 2.1 of the License, or
+ * (at your option) any later version.
+ *
+ * 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
+ * Lesser General Public License for more details.
+ */
+
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+
+#include "../../utils/media-ctl/mediactl.h"
+#include "../../utils/media-ctl/mediatext.h"
+#include "../../utils/media-ctl/v4l2subdev.h"
+#include "libv4l-plugin.h"
+
+#define DEBUG
+#ifdef DEBUG
+#define V4L2_EXYNOS4_DBG(format, ARG...)\
+   printf("[%s:%d] [%s] " format " \n", __FILE__, __LINE__, __func__, 
##ARG)
+#else
+#define V4L2_EXYNOS4_DBG(format, ARG...)
+#endif
+
+#define V4L2_EXYNOS4_ERR(format, ARG...)\
+   fprintf(stderr, "Libv4l Exynos4 camera plugin: "format "\n", ##ARG)
+
+#define V4L2_EXYNOS4_LOG(format, ARG...)\
+   fprintf(stdout, "Libv4l Exynos4 camera plugin: "format "\n", ##ARG)
+
+#define VIDIOC_CTRL(type)  \
+   ((type) == VIDIOC_S_CTRL ? "VIDIOC_S_CTRL" :\
+  "VIDIOC_G_CTRL")
+
+#define VIDIOC_EXT_CTRL(type)  \
+   ((type) == VIDIOC_S_EXT_CTRLS ? \
+   "VIDIOC_S_EXT_CTRLS":   \
+   ((type) == VIDIOC_G_EXT_CTRLS ?\
+   "VIDIOC_G_EXT_CTRLS" :  \
+   "VIDIOC_TRY_EXT_CTRLS"))
+
+#if HAVE_VISIBILITY
+#define PLUGIN_PUBLIC __attribute__ ((visibility("default")))
+#else

[PATCH] [media] s5p_cec: Mark runtime suspend/resume as __maybe_unused

2016-10-13 Thread Geert Uytterhoeven
If CONFIG_PM_SLEEP=n:

drivers/staging/media/s5p-cec/s5p_cec.c:235: warning: 
‘s5p_cec_runtime_suspend’ defined but not used
drivers/staging/media/s5p-cec/s5p_cec.c:243: warning: 
‘s5p_cec_runtime_resume’ defined but not used

Mark these functions as__maybe_unused to fix this without introducing
an #ifdef.

Fixes: 57b978ada073106d ("[media] s5p-cec: fix system and runtime PM 
integration")
Signed-off-by: Geert Uytterhoeven 
---
The above commit didn't take into account Arnd's previous fix...

 drivers/staging/media/s5p-cec/s5p_cec.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/staging/media/s5p-cec/s5p_cec.c 
b/drivers/staging/media/s5p-cec/s5p_cec.c
index 1780a08b73c96193..58d7562311360b7f 100644
--- a/drivers/staging/media/s5p-cec/s5p_cec.c
+++ b/drivers/staging/media/s5p-cec/s5p_cec.c
@@ -231,7 +231,7 @@ static int s5p_cec_remove(struct platform_device *pdev)
return 0;
 }
 
-static int s5p_cec_runtime_suspend(struct device *dev)
+static int __maybe_unused s5p_cec_runtime_suspend(struct device *dev)
 {
struct s5p_cec_dev *cec = dev_get_drvdata(dev);
 
@@ -239,7 +239,7 @@ static int s5p_cec_runtime_suspend(struct device *dev)
return 0;
 }
 
-static int s5p_cec_runtime_resume(struct device *dev)
+static int __maybe_unused s5p_cec_runtime_resume(struct device *dev)
 {
struct s5p_cec_dev *cec = dev_get_drvdata(dev);
int ret;
-- 
1.9.1

--
To unsubscribe from this list: send the line "unsubscribe linux-media" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH] [media] dib0700: Fix uninitialized protocol for NEC repeat codes

2016-10-13 Thread Geert Uytterhoeven
drivers/media/usb/dvb-usb/dib0700_core.c: In function 
‘dib0700_rc_urb_completion’:
drivers/media/usb/dvb-usb/dib0700_core.c:679: warning: ‘protocol’ may be 
used uninitialized in this function

When receiving an NEC repeat code, protocol is indeed not initialized.
Set it to RC_TYPE_NECX to fix this.

Fixes: 2ceeca0499d74521 ("[media] rc: split nec protocol into its three 
variants")
Signed-off-by: Geert Uytterhoeven 
---
Is RC_TYPE_NECX correct, or should it be RC_TYPE_NEC?
I used RC_TYPE_NECX based on the checks for {,not_}data and
{,not_}system for the other cases.
---
 drivers/media/usb/dvb-usb/dib0700_core.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/drivers/media/usb/dvb-usb/dib0700_core.c 
b/drivers/media/usb/dvb-usb/dib0700_core.c
index f3196658fb700706..5878ae4d20ad27ed 100644
--- a/drivers/media/usb/dvb-usb/dib0700_core.c
+++ b/drivers/media/usb/dvb-usb/dib0700_core.c
@@ -718,6 +718,7 @@ static void dib0700_rc_urb_completion(struct urb *purb)
poll_reply->nec.data   == 0x00 &&
poll_reply->nec.not_data   == 0xff) {
poll_reply->data_state = 2;
+   protocol = RC_TYPE_NECX;
break;
}
 
-- 
1.9.1

--
To unsubscribe from this list: send the line "unsubscribe linux-media" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH 00/10] mm: adjust get_user_pages* functions to explicitly pass FOLL_* flags

2016-10-13 Thread Christian König

Am 13.10.2016 um 02:20 schrieb Lorenzo Stoakes:

This patch series adjusts functions in the get_user_pages* family such that
desired FOLL_* flags are passed as an argument rather than implied by flags.

The purpose of this change is to make the use of FOLL_FORCE explicit so it is
easier to grep for and clearer to callers that this flag is being used. The use
of FOLL_FORCE is an issue as it overrides missing VM_READ/VM_WRITE flags for the
VMA whose pages we are reading from/writing to, which can result in surprising
behaviour.

The patch series came out of the discussion around commit 38e0885, which
addressed a BUG_ON() being triggered when a page was faulted in with PROT_NONE
set but having been overridden by FOLL_FORCE. do_numa_page() was run on the
assumption the page _must_ be one marked for NUMA node migration as an actual
PROT_NONE page would have been dealt with prior to this code path, however
FOLL_FORCE introduced a situation where this assumption did not hold.

See https://marc.info/?l=linux-mm=147585445805166 for the patch proposal.

Lorenzo Stoakes (10):
   mm: remove write/force parameters from __get_user_pages_locked()
   mm: remove write/force parameters from __get_user_pages_unlocked()
   mm: replace get_user_pages_unlocked() write/force parameters with gup_flags
   mm: replace get_user_pages_locked() write/force parameters with gup_flags
   mm: replace get_vaddr_frames() write/force parameters with gup_flags
   mm: replace get_user_pages() write/force parameters with gup_flags
   mm: replace get_user_pages_remote() write/force parameters with gup_flags
   mm: replace __access_remote_vm() write parameter with gup_flags
   mm: replace access_remote_vm() write parameter with gup_flags
   mm: replace access_process_vm() write parameter with gup_flags


Patch number 6 in this series (which touches drivers I co-maintain) is 
Acked-by: Christian König .


In general looks like a very nice cleanup to me, but I'm not enlightened 
enough to full judge.


Regards,
Christian.



  arch/alpha/kernel/ptrace.c |  9 ++--
  arch/blackfin/kernel/ptrace.c  |  5 ++-
  arch/cris/arch-v32/drivers/cryptocop.c |  4 +-
  arch/cris/arch-v32/kernel/ptrace.c |  4 +-
  arch/ia64/kernel/err_inject.c  |  2 +-
  arch/ia64/kernel/ptrace.c  | 14 +++---
  arch/m32r/kernel/ptrace.c  | 15 ---
  arch/mips/kernel/ptrace32.c|  5 ++-
  arch/mips/mm/gup.c |  2 +-
  arch/powerpc/kernel/ptrace32.c |  5 ++-
  arch/s390/mm/gup.c |  3 +-
  arch/score/kernel/ptrace.c | 10 +++--
  arch/sh/mm/gup.c   |  3 +-
  arch/sparc/kernel/ptrace_64.c  | 24 +++
  arch/sparc/mm/gup.c|  3 +-
  arch/x86/kernel/step.c |  3 +-
  arch/x86/mm/gup.c  |  2 +-
  arch/x86/mm/mpx.c  |  5 +--
  arch/x86/um/ptrace_32.c|  3 +-
  arch/x86/um/ptrace_64.c|  3 +-
  drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c|  7 ++-
  drivers/gpu/drm/etnaviv/etnaviv_gem.c  |  7 ++-
  drivers/gpu/drm/exynos/exynos_drm_g2d.c|  3 +-
  drivers/gpu/drm/i915/i915_gem_userptr.c|  6 ++-
  drivers/gpu/drm/radeon/radeon_ttm.c|  3 +-
  drivers/gpu/drm/via/via_dmablit.c  |  4 +-
  drivers/infiniband/core/umem.c |  6 ++-
  drivers/infiniband/core/umem_odp.c |  7 ++-
  drivers/infiniband/hw/mthca/mthca_memfree.c|  2 +-
  drivers/infiniband/hw/qib/qib_user_pages.c |  3 +-
  drivers/infiniband/hw/usnic/usnic_uiom.c   |  5 ++-
  drivers/media/pci/ivtv/ivtv-udma.c |  4 +-
  drivers/media/pci/ivtv/ivtv-yuv.c  |  5 ++-
  drivers/media/platform/omap/omap_vout.c|  2 +-
  drivers/media/v4l2-core/videobuf-dma-sg.c  |  7 ++-
  drivers/media/v4l2-core/videobuf2-memops.c |  6 ++-
  drivers/misc/mic/scif/scif_rma.c   |  3 +-
  drivers/misc/sgi-gru/grufault.c|  2 +-
  drivers/platform/goldfish/goldfish_pipe.c  |  3 +-
  drivers/rapidio/devices/rio_mport_cdev.c   |  3 +-
  drivers/scsi/st.c  |  5 +--
  .../interface/vchiq_arm/vchiq_2835_arm.c   |  3 +-
  .../vc04_services/interface/vchiq_arm/vchiq_arm.c  |  3 +-
  drivers/video/fbdev/pvr2fb.c   |  4 +-
  drivers/virt/fsl_hypervisor.c  |  4 +-
  fs/exec.c  |  9 +++-
  fs/proc/base.c | 19 +---
  include/linux/mm.h  

Re: [PATCH 02/22] [media] v4l2-async: allow subdevices to add further subdevices to the notifier waiting list

2016-10-13 Thread Sakari Ailus
Hi Philipp,

On Wed, Oct 12, 2016 at 03:26:48PM +0200, Philipp Zabel wrote:
> On Fri, Oct 7, 2016 at 11:52 PM, Sakari Ailus  wrote:
> > Hi Philipp,
> >
> > On Fri, Oct 07, 2016 at 06:00:47PM +0200, Philipp Zabel wrote:
> >> Currently the v4l2_async_notifier needs to be given a list of matches
> >> for all expected subdevices on creation. When chaining subdevices that
> >> are asynchronously probed via device tree, the bridge device that sets
> >> up the notifier does not know the complete list of subdevices, as it
> >> can only parse its own device tree node to obtain information about
> >> the nearest neighbor subdevices.
> >> To support indirectly connected subdevices, we need to support amending
> >> the existing notifier waiting list with newly found neighbor subdevices
> >> with each registered subdevice.
> >
> > Could you elaborate a little what's the exact use case for this? What kind
> > of a device?
> 
> On i.MX6 there's a
> 
> DW MIPI CSI2 host -> Mux -> IPU/CSI
> 
> path and all three are asynchronous subdevices in my patchset and only
> the last one is directly known to the media device from the device
> tree, since each driver should only parse its own device tree node an
> can not follow the of_graph over multiple steps.

Ok. Are all these devices part of the SoC? Is the mux doing something else
than just sitting in between the two? :-)

> Another use case I have seen in the wild are external GPIO controlled
> multiplexers or LVDS serializer/deserializer pairs between a parallel
> camera and parallel capture interface. In each case the bridge node
> can only determine its closest neighbor from the device tree (the mux,
> the LVDS deserializer) but does not know about the indirectly
> connected device nodes further upstream.

Yeah, true.

-- 
Kind regards,

Sakari Ailus
e-mail: sakari.ai...@iki.fi XMPP: sai...@retiisi.org.uk
--
To unsubscribe from this list: send the line "unsubscribe linux-media" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


ivtv kernel panic

2016-10-13 Thread Rajil Saraswat
Hello,

I have a system with 4GB ram and two Hauppauge PVR-500 cards (each
with a daughter card). With kernel 4.0.9 both the cards were working
fine. However, after upgrading to 8GB ram, the kernel paniced with an
error, "Random memory could be DMA written".

I upgraded to kernel 4.4.21 which is latest stable release for gentoo.
The system again panicked on bootup. However, if i disable the
following module options
(https://www.mythtv.org/wiki/Hauppauge_PVR-350)  the system boots up
fine.

options ivtv enc_mpg_buffers=16 enc_yuv_buffers=20 enc_pcm_buffers=640 debug=3

Any idea how can i use these options?

Thanks
--
To unsubscribe from this list: send the line "unsubscribe linux-media" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH 02/10] mm: remove write/force parameters from __get_user_pages_unlocked()

2016-10-13 Thread Paolo Bonzini


On 13/10/2016 02:20, Lorenzo Stoakes wrote:
> This patch removes the write and force parameters from
> __get_user_pages_unlocked() to make the use of FOLL_FORCE explicit in callers 
> as
> use of this flag can result in surprising behaviour (and hence bugs) within 
> the
> mm subsystem.
> 
> Signed-off-by: Lorenzo Stoakes 
> ---
>  include/linux/mm.h |  3 +--
>  mm/gup.c   | 17 +
>  mm/nommu.c | 12 +---
>  mm/process_vm_access.c |  7 +--
>  virt/kvm/async_pf.c|  3 ++-
>  virt/kvm/kvm_main.c| 11 ---
>  6 files changed, 34 insertions(+), 19 deletions(-)
> 
> diff --git a/include/linux/mm.h b/include/linux/mm.h
> index e9caec6..2db98b6 100644
> --- a/include/linux/mm.h
> +++ b/include/linux/mm.h
> @@ -1285,8 +1285,7 @@ long get_user_pages_locked(unsigned long start, 
> unsigned long nr_pages,
>   int write, int force, struct page **pages, int *locked);
>  long __get_user_pages_unlocked(struct task_struct *tsk, struct mm_struct *mm,
>  unsigned long start, unsigned long nr_pages,
> -int write, int force, struct page **pages,
> -unsigned int gup_flags);
> +struct page **pages, unsigned int gup_flags);
>  long get_user_pages_unlocked(unsigned long start, unsigned long nr_pages,
>   int write, int force, struct page **pages);
>  int get_user_pages_fast(unsigned long start, int nr_pages, int write,
> diff --git a/mm/gup.c b/mm/gup.c
> index ba83942..3d620dd 100644
> --- a/mm/gup.c
> +++ b/mm/gup.c
> @@ -865,17 +865,11 @@ EXPORT_SYMBOL(get_user_pages_locked);
>   */
>  __always_inline long __get_user_pages_unlocked(struct task_struct *tsk, 
> struct mm_struct *mm,
>  unsigned long start, unsigned 
> long nr_pages,
> -int write, int force, struct 
> page **pages,
> -unsigned int gup_flags)
> +struct page **pages, unsigned 
> int gup_flags)
>  {
>   long ret;
>   int locked = 1;
>  
> - if (write)
> - gup_flags |= FOLL_WRITE;
> - if (force)
> - gup_flags |= FOLL_FORCE;
> -
>   down_read(>mmap_sem);
>   ret = __get_user_pages_locked(tsk, mm, start, nr_pages, pages, NULL,
> , false, gup_flags);
> @@ -905,8 +899,15 @@ EXPORT_SYMBOL(__get_user_pages_unlocked);
>  long get_user_pages_unlocked(unsigned long start, unsigned long nr_pages,
>int write, int force, struct page **pages)
>  {
> + unsigned int flags = FOLL_TOUCH;
> +
> + if (write)
> + flags |= FOLL_WRITE;
> + if (force)
> + flags |= FOLL_FORCE;
> +
>   return __get_user_pages_unlocked(current, current->mm, start, nr_pages,
> -  write, force, pages, FOLL_TOUCH);
> +  pages, flags);
>  }
>  EXPORT_SYMBOL(get_user_pages_unlocked);
>  
> diff --git a/mm/nommu.c b/mm/nommu.c
> index 95daf81..925dcc1 100644
> --- a/mm/nommu.c
> +++ b/mm/nommu.c
> @@ -185,8 +185,7 @@ EXPORT_SYMBOL(get_user_pages_locked);
>  
>  long __get_user_pages_unlocked(struct task_struct *tsk, struct mm_struct *mm,
>  unsigned long start, unsigned long nr_pages,
> -int write, int force, struct page **pages,
> -unsigned int gup_flags)
> +struct page **pages, unsigned int gup_flags)
>  {
>   long ret;
>   down_read(>mmap_sem);
> @@ -200,8 +199,15 @@ EXPORT_SYMBOL(__get_user_pages_unlocked);
>  long get_user_pages_unlocked(unsigned long start, unsigned long nr_pages,
>int write, int force, struct page **pages)
>  {
> + unsigned int flags = 0;
> +
> + if (write)
> + flags |= FOLL_WRITE;
> + if (force)
> + flags |= FOLL_FORCE;
> +
>   return __get_user_pages_unlocked(current, current->mm, start, nr_pages,
> -  write, force, pages, 0);
> +  pages, flags);
>  }
>  EXPORT_SYMBOL(get_user_pages_unlocked);
>  
> diff --git a/mm/process_vm_access.c b/mm/process_vm_access.c
> index 07514d4..be8dc8d 100644
> --- a/mm/process_vm_access.c
> +++ b/mm/process_vm_access.c
> @@ -88,12 +88,16 @@ static int process_vm_rw_single_vec(unsigned long addr,
>   ssize_t rc = 0;
>   unsigned long max_pages_per_loop = PVM_MAX_KMALLOC_PAGES
>   / sizeof(struct pages *);
> + unsigned int flags = FOLL_REMOTE;
>  
>   /* Work out address and page range required */
>   if (len == 0)
>   return 0;
>   nr_pages = (addr + len - 1) / PAGE_SIZE - addr / PAGE_SIZE + 1;
>  
> + if (vm_write)
> +

[PATCH 04/10] mm: replace get_user_pages_locked() write/force parameters with gup_flags

2016-10-13 Thread Lorenzo Stoakes
This patch removes the write and force parameters from get_user_pages_locked()
and replaces them with a gup_flags parameter to make the use of FOLL_FORCE
explicit in callers as use of this flag can result in surprising behaviour (and
hence bugs) within the mm subsystem.

Signed-off-by: Lorenzo Stoakes 
---
 include/linux/mm.h |  2 +-
 mm/frame_vector.c  |  8 +++-
 mm/gup.c   | 12 +++-
 mm/nommu.c |  5 -
 4 files changed, 15 insertions(+), 12 deletions(-)

diff --git a/include/linux/mm.h b/include/linux/mm.h
index 6adc4bc..27ab538 100644
--- a/include/linux/mm.h
+++ b/include/linux/mm.h
@@ -1282,7 +1282,7 @@ long get_user_pages(unsigned long start, unsigned long 
nr_pages,
int write, int force, struct page **pages,
struct vm_area_struct **vmas);
 long get_user_pages_locked(unsigned long start, unsigned long nr_pages,
-   int write, int force, struct page **pages, int *locked);
+   unsigned int gup_flags, struct page **pages, int *locked);
 long __get_user_pages_unlocked(struct task_struct *tsk, struct mm_struct *mm,
   unsigned long start, unsigned long nr_pages,
   struct page **pages, unsigned int gup_flags);
diff --git a/mm/frame_vector.c b/mm/frame_vector.c
index 381bb07..81b6749 100644
--- a/mm/frame_vector.c
+++ b/mm/frame_vector.c
@@ -41,10 +41,16 @@ int get_vaddr_frames(unsigned long start, unsigned int 
nr_frames,
int ret = 0;
int err;
int locked;
+   unsigned int gup_flags = 0;
 
if (nr_frames == 0)
return 0;
 
+   if (write)
+   gup_flags |= FOLL_WRITE;
+   if (force)
+   gup_flags |= FOLL_FORCE;
+
if (WARN_ON_ONCE(nr_frames > vec->nr_allocated))
nr_frames = vec->nr_allocated;
 
@@ -59,7 +65,7 @@ int get_vaddr_frames(unsigned long start, unsigned int 
nr_frames,
vec->got_ref = true;
vec->is_pfns = false;
ret = get_user_pages_locked(start, nr_frames,
-   write, force, (struct page **)(vec->ptrs), );
+   gup_flags, (struct page **)(vec->ptrs), );
goto out;
}
 
diff --git a/mm/gup.c b/mm/gup.c
index cfcb014..7a0d033 100644
--- a/mm/gup.c
+++ b/mm/gup.c
@@ -838,18 +838,12 @@ static __always_inline long 
__get_user_pages_locked(struct task_struct *tsk,
  *  up_read(>mmap_sem);
  */
 long get_user_pages_locked(unsigned long start, unsigned long nr_pages,
-  int write, int force, struct page **pages,
+  unsigned int gup_flags, struct page **pages,
   int *locked)
 {
-   unsigned int flags = FOLL_TOUCH;
-
-   if (write)
-   flags |= FOLL_WRITE;
-   if (force)
-   flags |= FOLL_FORCE;
-
return __get_user_pages_locked(current, current->mm, start, nr_pages,
-  pages, NULL, locked, true, flags);
+  pages, NULL, locked, true,
+  gup_flags | FOLL_TOUCH);
 }
 EXPORT_SYMBOL(get_user_pages_locked);
 
diff --git a/mm/nommu.c b/mm/nommu.c
index 7e27add..842cfdd 100644
--- a/mm/nommu.c
+++ b/mm/nommu.c
@@ -176,9 +176,12 @@ long get_user_pages(unsigned long start, unsigned long 
nr_pages,
 EXPORT_SYMBOL(get_user_pages);
 
 long get_user_pages_locked(unsigned long start, unsigned long nr_pages,
-   int write, int force, struct page **pages,
+   unsigned int gup_flags, struct page **pages,
int *locked)
 {
+   int write = gup_flags & FOLL_WRITE;
+   int force = gup_flags & FOLL_FORCE;
+
return get_user_pages(start, nr_pages, write, force, pages, NULL);
 }
 EXPORT_SYMBOL(get_user_pages_locked);
-- 
2.10.0

--
To unsubscribe from this list: send the line "unsubscribe linux-media" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html