[media_build] rc: Fix ktime erros in rc_ir_raw.c

Message ID 1503531988-15429-1-git-send-email-jasmin@anw.at (mailing list archive)
State Accepted, archived
Delegated to: Sean Young
Headers

Commit Message

Jasmin J. Aug. 23, 2017, 11:46 p.m. UTC
  From: Jasmin Jessich <jasmin@anw.at>

In Kernels prior to 4.10 ktime is a union. This fixes the compile errors
due to media_tree commits 86fe1ac0d and 48b2de197.

Signed-off-by: Jasmin Jessich <jasmin@anw.at>
---
 backports/backports.txt              |  1 +
 backports/v4.9_rc_ir_raw_ktime.patch | 36 ++++++++++++++++++++++++++++++++++++
 2 files changed, 37 insertions(+)
 create mode 100644 backports/v4.9_rc_ir_raw_ktime.patch
  

Comments

Jasmin J. Aug. 24, 2017, 12:07 a.m. UTC | #1
Hi!

Just some notes on that patch.

I have *not* tested it due to the lack of an ir remote control. So someone
needs to test this on an <= 4.9 Kernel, if the ir core is still working as
expected.

Even if I fixed that in media_build, it may be better to apply this code change
in media_tree. This because the involved variables are all of type ktime_t and
there are accessor and converter functions available for that type, which
should have been used by the original author of 86fe1ac0d and 48b2de197 in my
opinion.

BR,
   Jasmin
  
Hans Verkuil Aug. 24, 2017, 6:47 a.m. UTC | #2
On 08/24/2017 02:07 AM, Jasmin J. wrote:
> Hi!
> 
> Just some notes on that patch.
> 
> I have *not* tested it due to the lack of an ir remote control. So someone
> needs to test this on an <= 4.9 Kernel, if the ir core is still working as
> expected.
> 
> Even if I fixed that in media_build, it may be better to apply this code change
> in media_tree. This because the involved variables are all of type ktime_t and
> there are accessor and converter functions available for that type, which
> should have been used by the original author of 86fe1ac0d and 48b2de197 in my
> opinion.

Sean,

I agree with Jasmin here. I noticed the same errors in the daily build and it
is really caused by not using the correct functions. I just didn't have the
time to follow up on it.

Can you take a look at Jasmin's patch and, if OK, make a pull request for
it?

Regards,

	Hans
  
Jasmin J. Aug. 24, 2017, 7:43 a.m. UTC | #3
Hello Sean!

> I agree with Jasmin here. I noticed the same errors in the daily build and it
> is really caused by not using the correct functions. I just didn't have the
> time to follow up on it.
I started to fix also gpio-ir-tx.c, but stopped that because it was too late.
So I simply deactivated the driver:
   https://www.mail-archive.com/linux-media@vger.kernel.org/msg117607.html

Maybe you can fix gpio-ir-tx.c also by using the right functions to access
ktime_t, so that this driver would be available for older Kernels, too.
But there was another problem beside the ktime_t accessors, which I didn't
analyze (symbol missing).

BR,
   Jasmin
  
Sean Young Aug. 24, 2017, 8:53 a.m. UTC | #4
On Thu, Aug 24, 2017 at 08:47:54AM +0200, Hans Verkuil wrote:
> On 08/24/2017 02:07 AM, Jasmin J. wrote:
> > Hi!
> > 
> > Just some notes on that patch.
> > 
> > I have *not* tested it due to the lack of an ir remote control. So someone
> > needs to test this on an <= 4.9 Kernel, if the ir core is still working as
> > expected.
> > 
> > Even if I fixed that in media_build, it may be better to apply this code change
> > in media_tree. This because the involved variables are all of type ktime_t and
> > there are accessor and converter functions available for that type, which
> > should have been used by the original author of 86fe1ac0d and 48b2de197 in my
> > opinion.
> 
> Sean,
> 
> I agree with Jasmin here. I noticed the same errors in the daily build and it
> is really caused by not using the correct functions. I just didn't have the
> time to follow up on it.
> 
> Can you take a look at Jasmin's patch and, if OK, make a pull request for
> it?

I hadn't taken media_build into account when I wrote this, so yes I'll
have a look and create a pull request.


Sean
  

Patch

diff --git a/backports/backports.txt b/backports/backports.txt
index 87b9ee8..5691a3e 100644
--- a/backports/backports.txt
+++ b/backports/backports.txt
@@ -38,6 +38,7 @@  add v4.10_refcount.patch
 add v4.9_mm_address.patch
 add v4.9_dvb_net_max_mtu.patch
 add v4.9_ktime_cleanups.patch
+add v4.9_rc_ir_raw_ktime.patch
 
 [4.8.255]
 add v4.8_user_pages_flag.patch
diff --git a/backports/v4.9_rc_ir_raw_ktime.patch b/backports/v4.9_rc_ir_raw_ktime.patch
new file mode 100644
index 0000000..407128d
--- /dev/null
+++ b/backports/v4.9_rc_ir_raw_ktime.patch
@@ -0,0 +1,36 @@ 
+diff --git a/drivers/media/rc/rc-ir-raw.c b/drivers/media/rc/rc-ir-raw.c
+index f495709..f1259d1 100644
+--- a/drivers/media/rc/rc-ir-raw.c
++++ b/drivers/media/rc/rc-ir-raw.c
+@@ -106,7 +107,7 @@ int ir_raw_event_store_edge(struct rc_dev *dev, bool pulse)
+ 		return -EINVAL;
+ 
+ 	now = ktime_get();
+-	ev.duration = ktime_sub(now, dev->raw->last_event);
++	ev.duration = ktime_to_ns(ktime_sub(now, dev->raw->last_event));
+ 	ev.pulse = !pulse;
+ 
+ 	rc = ir_raw_event_store(dev, &ev);
+@@ -474,18 +479,18 @@ EXPORT_SYMBOL(ir_raw_encode_scancode);
+ static void edge_handle(unsigned long arg)
+ {
+ 	struct rc_dev *dev = (struct rc_dev *)arg;
+-	ktime_t interval = ktime_get() - dev->raw->last_event;
++	ktime_t interval = ktime_sub(ktime_get(), dev->raw->last_event);
+ 
+-	if (interval >= dev->timeout) {
++	if (ktime_to_ns(interval) >= dev->timeout) {
+ 		DEFINE_IR_RAW_EVENT(ev);
+ 
+ 		ev.timeout = true;
+-		ev.duration = interval;
++		ev.duration = ktime_to_ns(interval);
+ 
+ 		ir_raw_event_store(dev, &ev);
+ 	} else {
+ 		mod_timer(&dev->raw->edge_handle,
+-			  jiffies + nsecs_to_jiffies(dev->timeout - interval));
++			  jiffies + nsecs_to_jiffies(dev->timeout - ktime_to_ns(interval)));
+ 	}
+ 
+ 	ir_raw_event_handle(dev);