Commit graph

443 commits

Author SHA1 Message Date
Mauro Carvalho Chehab 670d7adb09 media: dvb: point to the location of the old README.dvb-usb file
This file got renamed, but the references still point to the
old place.

Signed-off-by: Mauro Carvalho Chehab <mchehab+samsung@kernel.org>
Acked-by: Jonathan Corbet <corbet@lwn.net>
2018-06-15 18:10:01 -03:00
Mauro Carvalho Chehab fe63a1a621 media: dvb: fix location of get_dvb_firmware script
This script was moved out of Documentation/dvb, but the
links weren't updated.

Signed-off-by: Mauro Carvalho Chehab <mchehab+samsung@kernel.org>
Acked-by: Jonathan Corbet <corbet@lwn.net>
2018-06-15 18:10:01 -03:00
Mauro Carvalho Chehab 5fb94e9ca3 docs: Fix some broken references
As we move stuff around, some doc references are broken. Fix some of
them via this script:
	./scripts/documentation-file-ref-check --fix

Manually checked if the produced result is valid, removing a few
false-positives.

Acked-by: Takashi Iwai <tiwai@suse.de>
Acked-by: Masami Hiramatsu <mhiramat@kernel.org>
Acked-by: Stephen Boyd <sboyd@kernel.org>
Acked-by: Charles Keepax <ckeepax@opensource.wolfsonmicro.com>
Acked-by: Mathieu Poirier <mathieu.poirier@linaro.org>
Reviewed-by: Coly Li <colyli@suse.de>
Signed-off-by: Mauro Carvalho Chehab <mchehab+samsung@kernel.org>
Acked-by: Jonathan Corbet <corbet@lwn.net>
2018-06-15 18:10:01 -03:00
Mauro Carvalho Chehab 7d95fb746c media: dvbsky: use just one mutex for serializing device R/W ops
Right now, there are two mutexes serializing r/w ops: one "generic"
and another one specifically for stream on/off.

Clean it a little bit, getting rid of one of the mutexes.

Signed-off-by: Mauro Carvalho Chehab <mchehab+samsung@kernel.org>
2018-05-10 07:05:14 -04:00
Akihiro Tsukada 86f65c2181 media: dvb-usb-v2/gl861: ensure USB message buffers DMA'able
i2c message buf might be on stack.

Signed-off-by: Akihiro Tsukada <tskd08@gmail.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab+samsung@kernel.org>
2018-05-05 07:15:48 -04:00
Akihiro Tsukada 87360e68b3 media: dvb-usb-v2/gl861: use usleep_range() for short delay
As the kernel doc "timers-howto.txt" reads,
short delay with msleep() can take much longer.
In a case of raspbery-pi platform where CONFIG_HZ_100 was set,
it actually affected the init of Friio devices
since it issues lots of i2c transactions with short delay.

Signed-off-by: Akihiro Tsukada <tskd08@gmail.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab+samsung@kernel.org>
2018-05-05 07:15:09 -04:00
Mauro Carvalho Chehab 1a0c10ed7b media: dvb-usb-v2: stop using coherent memory for URBs
There's no need to use coherent buffers there. So, let the
DVB core do the allocation. That should give some performance
gain outside x86.

Signed-off-by: Mauro Carvalho Chehab <mchehab@s-opensource.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab+samsung@kernel.org>
2018-05-04 10:56:19 -04:00
Mauro Carvalho Chehab 14f4eaedda media: dvbsky: fix driver unregister logic
There's a user-after-free there, if the frontend is attached
via the new I2C way:

[  112.539806] usbcore: deregistering interface driver dvb_usb_dvbsky
[  112.568489] ==================================================================
[  112.568600] BUG: KASAN: use-after-free in dvb_unregister_frontend+0x18/0xb0 [dvb_core]
[  112.568610] Read of size 8 at addr ffff8803a6f61530 by task rmmod/2246

[  112.568622] CPU: 0 PID: 2246 Comm: rmmod Not tainted 4.16.0-rc4+ #103
[  112.568624] Hardware name:  /NUC5i7RYB, BIOS RYBDWi35.86A.0364.2017.0511.0949 05/11/2017
[  112.568625] Call Trace:
[  112.568631]  dump_stack+0x5c/0x7c
[  112.568636]  print_address_description+0x6a/0x270
[  112.568640]  kasan_report+0x258/0x380
[  112.568657]  ? dvb_unregister_frontend+0x18/0xb0 [dvb_core]
[  112.568673]  dvb_unregister_frontend+0x18/0xb0 [dvb_core]
[  112.568681]  dvb_usbv2_exit+0x156/0x4a0 [dvb_usb_v2]
[  112.568689]  dvb_usbv2_disconnect+0xa0/0x140 [dvb_usb_v2]
[  112.568694]  usb_unbind_interface+0xd8/0x3f0
[  112.568700]  device_release_driver_internal+0x1ce/0x2f0
[  112.568705]  driver_detach+0x66/0xc0
[  112.568709]  bus_remove_driver+0x86/0x150
[  112.568713]  usb_deregister+0x90/0x180
[  112.568718]  SyS_delete_module+0x293/0x330
[  112.568721]  ? free_module+0x330/0x330
[  112.568725]  ? _cond_resched+0x16/0x50
[  112.568729]  ? task_work_run+0x7d/0xd0
[  112.568732]  ? mem_cgroup_handle_over_high+0x1c/0xc0
[  112.568736]  ? free_module+0x330/0x330
[  112.568740]  do_syscall_64+0xe7/0x250
[  112.568744]  entry_SYSCALL_64_after_hwframe+0x3d/0xa2
[  112.568747] RIP: 0033:0x7facafa272a7
[  112.568749] RSP: 002b:00007fffdea14cc8 EFLAGS: 00000206 ORIG_RAX: 00000000000000b0
[  112.568753] RAX: ffffffffffffffda RBX: 00007fffdea14d28 RCX: 00007facafa272a7
[  112.568755] RDX: 000000000000000a RSI: 0000000000000800 RDI: 00005599557337c8
[  112.568756] RBP: 0000559955733760 R08: 000000000000000a R09: 0000000000000000
[  112.568758] R10: 00007facafaa0280 R11: 0000000000000206 R12: 00007fffdea14ef0
[  112.568761] R13: 00007fffdea16eac R14: 0000559955733260 R15: 0000559955733760

[  112.568808] Allocated by task 638:
[  112.568816]  kasan_kmalloc+0xa0/0xd0
[  112.568820]  kmem_cache_alloc_trace+0x114/0x230
[  112.568826]  m88ds3103_probe+0x9a/0x643 [m88ds3103]
[  112.568830]  i2c_device_probe+0x2e9/0x3c0
[  112.568833]  driver_probe_device+0x46e/0x6a0
[  112.568836]  bus_for_each_drv+0xd6/0x130
[  112.568838]  __device_attach+0x166/0x1f0
[  112.568841]  bus_probe_device+0xea/0x110
[  112.568844]  device_add+0x6a3/0x9f0
[  112.568847]  i2c_new_device+0x28f/0x5c0
[  112.568861]  dvb_module_probe+0x91/0x110 [dvb_core]
[  112.568867]  dvbsky_s960c_attach+0x1c4/0x460 [dvb_usb_dvbsky]
[  112.568873]  dvb_usbv2_probe+0x1191/0x1950 [dvb_usb_v2]
[  112.568877]  usb_probe_interface+0x1b3/0x430
[  112.568880]  driver_probe_device+0x46e/0x6a0
[  112.568882]  __driver_attach+0xeb/0x110
[  112.568885]  bus_for_each_dev+0xe4/0x140
[  112.568888]  bus_add_driver+0x249/0x380
[  112.568891]  driver_register+0xc6/0x170
[  112.568893]  usb_register_driver+0xec/0x200
[  112.568896]  do_one_initcall+0x8f/0x1ee
[  112.568900]  do_init_module+0xde/0x320
[  112.568902]  load_module+0x3ed0/0x4850
[  112.568905]  SYSC_finit_module+0x192/0x1c0
[  112.568908]  do_syscall_64+0xe7/0x250
[  112.568911]  entry_SYSCALL_64_after_hwframe+0x3d/0xa2

[  112.568916] Freed by task 2246:
[  112.568923]  __kasan_slab_free+0x136/0x180
[  112.568925]  kfree+0xa5/0x1e0
[  112.568931]  m88ds3103_remove+0x42/0x60 [m88ds3103]
[  112.568934]  i2c_device_remove+0x72/0xd0
[  112.568937]  device_release_driver_internal+0x1ce/0x2f0
[  112.568940]  bus_remove_device+0x197/0x270
[  112.568942]  device_del+0x239/0x550
[  112.568945]  device_unregister+0x16/0x70
[  112.568949]  dvbsky_exit+0x4c/0x70 [dvb_usb_dvbsky]
[  112.568955]  dvb_usbv2_disconnect+0x98/0x140 [dvb_usb_v2]
[  112.568958]  usb_unbind_interface+0xd8/0x3f0
[  112.568961]  device_release_driver_internal+0x1ce/0x2f0
[  112.568964]  driver_detach+0x66/0xc0
[  112.568967]  bus_remove_driver+0x86/0x150
[  112.568970]  usb_deregister+0x90/0x180
[  112.568973]  SyS_delete_module+0x293/0x330
[  112.568976]  do_syscall_64+0xe7/0x250
[  112.568979]  entry_SYSCALL_64_after_hwframe+0x3d/0xa2

[  112.568985] The buggy address belongs to the object at ffff8803a6f61100
                which belongs to the cache kmalloc-2048 of size 2048
[  112.568998] The buggy address is located 1072 bytes inside of
                2048-byte region [ffff8803a6f61100, ffff8803a6f61900)
[  112.569008] The buggy address belongs to the page:
[  112.569015] page:ffffea000e9bd800 count:1 mapcount:0 mapping:0000000000000000 index:0x0 compound_mapcount: 0
[  112.569025] flags: 0x17ffe000008100(slab|head)
[  112.569034] raw: 0017ffe000008100 0000000000000000 0000000000000000 00000001000f000f
[  112.569044] raw: ffffea000ee2d000 0000000500000005 ffff880407002a80 0000000000000000
[  112.569053] page dumped because: kasan: bad access detected

[  112.569062] Memory state around the buggy address:
[  112.569070]  ffff8803a6f61400: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb
[  112.569079]  ffff8803a6f61480: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb
[  112.569088] >ffff8803a6f61500: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb
[  112.569095]                                      ^
[  112.569103]  ffff8803a6f61580: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb
[  112.569112]  ffff8803a6f61600: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb
[  112.569119] ==================================================================
[  112.569127] Disabling lock debugging due to kernel taint
[  112.571161] dvb_usb_v2: 'DVBSky S960CI:2-2' successfully deinitialized and disconnected

Fix it by letting the dvb-usb-v2 core to know that the frontend
was already removed.

Signed-off-by: Mauro Carvalho Chehab <mchehab@s-opensource.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab+samsung@kernel.org>
2018-05-04 10:55:12 -04:00
Mauro Carvalho Chehab 2c7e3ca8fb media: dvbsky: use the new dvb_module_probe() API
Instead of repeating countless times a complex logic, use
the new dvb_module_probe()/dvb_module_release(), simplifying
the module.

That reduced about 15% at the module's size:

   text	   data	    bss	    dec	    hex	filename
   7083	   1108	     12	   8203	   200b	old/drivers/media/usb/dvb-usb-v2/dvbsky.o
   5817	   1108	     12	   6937	   1b19	new/drivers/media/usb/dvb-usb-v2/dvbsky.o

Tested with a DVBSky S960C DVB-S2 tuner (0572:960c)

Signed-off-by: Mauro Carvalho Chehab <mchehab@s-opensource.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab+samsung@kernel.org>
2018-05-04 10:54:39 -04:00
Mauro Carvalho Chehab 0d2a531d00 media: dvb-usb-v2: fix a missing dependency of I2C_MUX
Now that af9015 requires I2C_MUX, all drivers that select
it should also depend on it.

   drivers/media/dvb-frontends/af9013.o: In function `af9013_remove':
>> drivers/media/dvb-frontends/af9013.c:1560: undefined reference to `i2c_mux_del_adapters'
   drivers/media/dvb-frontends/af9013.o: In function `af9013_probe':
>> drivers/media/dvb-frontends/af9013.c:1488: undefined reference to `i2c_mux_alloc'
>> drivers/media/dvb-frontends/af9013.c:1495: undefined reference to `i2c_mux_add_adapter'
   drivers/media/dvb-frontends/af9013.c:1544: undefined reference to `i2c_mux_del_adapters'

Reported-by: kbuild test robot <fengguang.wu@intel.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@s-opensource.com>
2018-03-23 08:44:37 -04:00
Antti Palosaari b2d109f24a media: af9015: correct some coding style issues
Correct coding style issues reported mostly by checkpatch.pl.

Signed-off-by: Antti Palosaari <crope@iki.fi>
Signed-off-by: Mauro Carvalho Chehab <mchehab@s-opensource.com>
2018-03-21 14:16:32 -04:00
Antti Palosaari 8b79c7ab11 media: af9015: convert to regmap api
Use regmap for chip register access.

Signed-off-by: Antti Palosaari <crope@iki.fi>
Signed-off-by: Mauro Carvalho Chehab <mchehab@s-opensource.com>
2018-03-21 14:15:34 -04:00
Antti Palosaari 19324414c9 media: dvb-usb-v2: add probe/disconnect callbacks
Add probe and disconnect callbacks that behaves similarly than ones
used commonly on Linux driver model. We need those to get early / late
access to driver in order to use normal probe time stuff, like regmap,
extra bus adapters and so.

Signed-off-by: Antti Palosaari <crope@iki.fi>
Signed-off-by: Mauro Carvalho Chehab <mchehab@s-opensource.com>
2018-03-21 14:15:09 -04:00
Antti Palosaari 7772e380ef media: af9015: enhance streaming config
Replace static stream settings by one which enables and disables
stream interface when needed (TS streaming control).

1) Configure both TS IF and USB endpoints according to current use case

2) Disable streaming USB endpoints when streaming is stopped and
enable when streaming is started. Reduces sleep power consumption
slightly.

3) Reduce USB buffersize slightly, from 130848 to 98136 bytes

Signed-off-by: Antti Palosaari <crope@iki.fi>
Signed-off-by: Mauro Carvalho Chehab <mchehab@s-opensource.com>
2018-03-21 14:14:25 -04:00
Antti Palosaari 0092293ec7 media: af9015: refactor copy firmware to slave demod
Small improvements.

Signed-off-by: Antti Palosaari <crope@iki.fi>
Signed-off-by: Mauro Carvalho Chehab <mchehab@s-opensource.com>
2018-03-21 14:13:21 -04:00
Antti Palosaari 2ffb2fa32e media: af9015: refactor firmware download
Small revise, no functional changes.

Signed-off-by: Antti Palosaari <crope@iki.fi>
Signed-off-by: Mauro Carvalho Chehab <mchehab@s-opensource.com>
2018-03-21 14:12:55 -04:00
Antti Palosaari ba2d559b29 media: af9015: use af9013 demod pid filters
PID filters are moved to af9013 demod driver as those are property of
demod. As pid filters are now implemented correctly by demod driver,
we could enable pid filter support for possible slave demod too on
dual tuner configuration.

Signed-off-by: Antti Palosaari <crope@iki.fi>
Signed-off-by: Mauro Carvalho Chehab <mchehab@s-opensource.com>
2018-03-21 14:12:27 -04:00
Antti Palosaari 04c611e316 media: af9015: attach demod using i2c binding
af9013 demod driver has i2c binding. Use it.

Signed-off-by: Antti Palosaari <crope@iki.fi>
Signed-off-by: Mauro Carvalho Chehab <mchehab@s-opensource.com>
2018-03-21 14:10:48 -04:00
Antti Palosaari 49bade9f0e media: af9015: fix logging
Pass correct device to dev_* logging functions, which allows us to
remove redundant KBUILD_MODNAME and __func__ parameters from log format.

Signed-off-by: Antti Palosaari <crope@iki.fi>
Signed-off-by: Mauro Carvalho Chehab <mchehab@s-opensource.com>
2018-03-21 14:08:03 -04:00
Mauro Carvalho Chehab fada193559 media: move dvb kAPI headers to include/media
Except for DVB, all media kAPI headers are at include/media.

Move the headers to it.

Signed-off-by: Mauro Carvalho Chehab <mchehab@s-opensource.com>
2017-12-28 13:16:01 -05:00
Stefan Brüns 5742240577 media: dvbsky: MyGica T230C support
Mygica T230 DVB-T/T2/C USB stick support. It uses the same FX2/Si2168
bridge/demodulator combo as the other devices supported by the driver,
but uses the Si2141 tuner.
Several DVB-T (MPEG2) and DVB-T2 (H.265) channels were tested, as well as
the included remote control.

Signed-off-by: Stefan Brüns <stefan.bruens@rwth-aachen.de>
Signed-off-by: Mauro Carvalho Chehab <mchehab@s-opensource.com>
2017-12-14 06:35:18 -05:00
Mauro Carvalho Chehab ad7b57d58d media: mxl111sf: improve error handling logic
As reported by smatch:
	drivers/media/usb/dvb-usb-v2/mxl111sf-demod.c:485 mxl111sf_demod_read_signal_strength() error: uninitialized symbol 'modulation'.

The mxl111sf_demod_read_signal_strength() just ignores if something
gets wrong while reading snr or modulation.

Signed-off-by: Mauro Carvalho Chehab <mchehab@s-opensource.com>
2017-12-11 13:14:44 -05:00
Mauro Carvalho Chehab 021c01d3dc media: dvbsky: shut up a bogus warning
Smatch gives two bogus warnings on this driver:
	drivers/media/usb/dvb-usb-v2/dvbsky.c:336 dvbsky_s960_attach() error: uninitialized symbol 'i2c_adapter'.
	drivers/media/usb/dvb-usb-v2/dvbsky.c:459 dvbsky_s960c_attach() error: uninitialized symbol 'i2c_adapter'.

Shut them up.

Signed-off-by: Mauro Carvalho Chehab <mchehab@s-opensource.com>
2017-12-11 13:04:56 -05:00
Malcolm Priestley 7bf7a7116e media: dvb-usb-v2: lmedm04: move ts2020 attach to dm04_lme2510_tuner
When the tuner was split from m88rs2000 the attach function is in wrong
place.

Move to dm04_lme2510_tuner to trap errors on failure and removing
a call to lme_coldreset.

Prevents driver starting up without any tuner connected.

Fixes to trap for ts2020 fail.
LME2510(C): FE Found M88RS2000
ts2020: probe of 0-0060 failed with error -11
...
LME2510(C): TUN Found RS2000 tuner
kasan: CONFIG_KASAN_INLINE enabled
kasan: GPF could be caused by NULL-ptr deref or user memory access
general protection fault: 0000 [#1] PREEMPT SMP KASAN

Reported-by: Andrey Konovalov <andreyknvl@google.com>
Signed-off-by: Malcolm Priestley <tvboxspy@gmail.com>
Tested-by: Andrey Konovalov <andreyknvl@google.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@s-opensource.com>
2017-12-11 07:52:47 -05:00
Malcolm Priestley 3d932ee27e media: dvb-usb-v2: lmedm04: Improve logic checking of warm start
Warm start has no check as whether a genuine device has
connected and proceeds to next execution path.

Check device should read 0x47 at offset of 2 on USB descriptor read
and it is the amount requested of 6 bytes.

Fix for
kasan: CONFIG_KASAN_INLINE enabled
kasan: GPF could be caused by NULL-ptr deref or user memory access as

Reported-by: Andrey Konovalov <andreyknvl@google.com>
Signed-off-by: Malcolm Priestley <tvboxspy@gmail.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@s-opensource.com>
2017-12-11 07:51:39 -05:00
Linus Torvalds 5d352e69c6 media updates for v4.15-rc1
-----BEGIN PGP SIGNATURE-----
 
 iQIcBAABAgAGBQJaC/4EAAoJEAhfPr2O5OEVQnsP/2JNpdLuzgwNp0p2gXrvK5pl
 KOsA6Fld6RNmpuel8eHARbbDTPKF1Y1bvYXVo7lPhXb7KuM2IzG56VxoNech/5pX
 eflKwnpV/Ns/ZMLYue7Rqdw0iZnjWESBWf5lzg9MvzwhZBaPlRwqu/aOJy360AZr
 FnjKHtU/6WUIOCB8r0qLBDR/epoh7y2lKfjDTcEBrURrFEsTajdyd59npdMSIQqO
 iUeeBVEIUKyytYDQNM/VOsBnh0G+2inLuykF8Nd6pYs8O0iUEUpZYwdGuwGUG1HB
 VmCcRGU62efl5nu8zQMPnwAvjXwZAh8vbS0ha+B1vBJh1RwNVUz0kKIKEgAaOMZ3
 zZa3NLfDP4cHgYtr2Xw2vSvJvDwQecmiItJKeZ/Id4cPy03TKEV1KEaHCQJHwbDn
 RP/o9C+5gagMO/oIvZPQ+esVZXQ4prAzOdX53N7HPn4Wn+k4clkI0+hMvMGf67mo
 EYOguCqbN2D0e11BLiPP1bRbGZRSI8I9xcKuhcw4ajJHbRRkrjl8EW7V6c8CuMkd
 0Wj5oidFleJ0Vy+qQOPqXN1FwR7AbHNtI38JfWNz324AIrFCQERpfXVmKwRPZfl4
 YXgGIA9fil3a01YJCtxc0PsXlRkveKJ8hKCLpjXbjNTh1oSbgrDxx5sMx9PO6WqJ
 VOb6fL17rwTXlKV/GeU/
 =d9nT
 -----END PGP SIGNATURE-----

Merge tag 'media/v4.15-1' of ssh://gitolite.kernel.org/pub/scm/linux/kernel/git/mchehab/linux-media

Pull media updates from Mauro Carvalho Chehab:

 - Documentation for digital TV (both kAPI and uAPI) are now in sync
   with the implementation (except for legacy/deprecated ioctls). This
   is a major step, as there were always a gap there

 - New sensor driver: imx274

 - New cec driver: cec-gpio

 - New platform driver for rockship rga and tegra CEC

 - New RC driver: tango-ir

 - Several cleanups at atomisp driver

 - Core improvements for RC, CEC, V4L2 async probing support and DVB

 - Lots of drivers cleanup, fixes and improvements.

* tag 'media/v4.15-1' of ssh://gitolite.kernel.org/pub/scm/linux/kernel/git/mchehab/linux-media: (332 commits)
  dvb_frontend: don't use-after-free the frontend struct
  media: dib0700: fix invalid dvb_detach argument
  media: v4l2-ctrls: Don't validate BITMASK twice
  media: s5p-mfc: fix lockdep warning
  media: dvb-core: always call invoke_release() in fe_free()
  media: usb: dvb-usb-v2: dvb_usb_core: remove redundant code in dvb_usb_fe_sleep
  media: au0828: make const array addr_list static
  media: cx88: make const arrays default_addr_list and pvr2000_addr_list static
  media: drxd: make const array fastIncrDecLUT static
  media: usb: fix spelling mistake: "synchronuously" -> "synchronously"
  media: ddbridge: fix build warnings
  media: av7110: avoid 2038 overflow in debug print
  media: Don't do DMA on stack for firmware upload in the AS102 driver
  media: v4l: async: fix unregister for implicitly registered sub-device notifiers
  media: v4l: async: fix return of unitialized variable ret
  media: imx274: fix missing return assignment from call to imx274_mode_regs
  media: camss-vfe: always initialize reg at vfe_set_xbar_cfg()
  media: atomisp: make function calls cleaner
  media: atomisp: get rid of storage_class.h
  media: atomisp: get rid of wrong stddef.h include
  ...
2017-11-15 20:30:12 -08:00
Gustavo A. R. Silva b4b138a9d3 media: usb: dvb-usb-v2: dvb_usb_core: remove redundant code in dvb_usb_fe_sleep
Check on return value and goto instruction is redundant as the code
that follows is the goto label err.

Addresses-Coverity-ID: 1268783

Signed-off-by: Gustavo A. R. Silva <garsilva@embeddedor.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@s-opensource.com>
2017-11-07 04:42:27 -05:00
Greg Kroah-Hartman b24413180f License cleanup: add SPDX GPL-2.0 license identifier to files with no license
Many source files in the tree are missing licensing information, which
makes it harder for compliance tools to determine the correct license.

By default all files without license information are under the default
license of the kernel, which is GPL version 2.

Update the files which contain no license information with the 'GPL-2.0'
SPDX license identifier.  The SPDX identifier is a legally binding
shorthand, which can be used instead of the full boiler plate text.

This patch is based on work done by Thomas Gleixner and Kate Stewart and
Philippe Ombredanne.

How this work was done:

Patches were generated and checked against linux-4.14-rc6 for a subset of
the use cases:
 - file had no licensing information it it.
 - file was a */uapi/* one with no licensing information in it,
 - file was a */uapi/* one with existing licensing information,

Further patches will be generated in subsequent months to fix up cases
where non-standard license headers were used, and references to license
had to be inferred by heuristics based on keywords.

The analysis to determine which SPDX License Identifier to be applied to
a file was done in a spreadsheet of side by side results from of the
output of two independent scanners (ScanCode & Windriver) producing SPDX
tag:value files created by Philippe Ombredanne.  Philippe prepared the
base worksheet, and did an initial spot review of a few 1000 files.

The 4.13 kernel was the starting point of the analysis with 60,537 files
assessed.  Kate Stewart did a file by file comparison of the scanner
results in the spreadsheet to determine which SPDX license identifier(s)
to be applied to the file. She confirmed any determination that was not
immediately clear with lawyers working with the Linux Foundation.

Criteria used to select files for SPDX license identifier tagging was:
 - Files considered eligible had to be source code files.
 - Make and config files were included as candidates if they contained >5
   lines of source
 - File already had some variant of a license header in it (even if <5
   lines).

All documentation files were explicitly excluded.

The following heuristics were used to determine which SPDX license
identifiers to apply.

 - when both scanners couldn't find any license traces, file was
   considered to have no license information in it, and the top level
   COPYING file license applied.

   For non */uapi/* files that summary was:

   SPDX license identifier                            # files
   ---------------------------------------------------|-------
   GPL-2.0                                              11139

   and resulted in the first patch in this series.

   If that file was a */uapi/* path one, it was "GPL-2.0 WITH
   Linux-syscall-note" otherwise it was "GPL-2.0".  Results of that was:

   SPDX license identifier                            # files
   ---------------------------------------------------|-------
   GPL-2.0 WITH Linux-syscall-note                        930

   and resulted in the second patch in this series.

 - if a file had some form of licensing information in it, and was one
   of the */uapi/* ones, it was denoted with the Linux-syscall-note if
   any GPL family license was found in the file or had no licensing in
   it (per prior point).  Results summary:

   SPDX license identifier                            # files
   ---------------------------------------------------|------
   GPL-2.0 WITH Linux-syscall-note                       270
   GPL-2.0+ WITH Linux-syscall-note                      169
   ((GPL-2.0 WITH Linux-syscall-note) OR BSD-2-Clause)    21
   ((GPL-2.0 WITH Linux-syscall-note) OR BSD-3-Clause)    17
   LGPL-2.1+ WITH Linux-syscall-note                      15
   GPL-1.0+ WITH Linux-syscall-note                       14
   ((GPL-2.0+ WITH Linux-syscall-note) OR BSD-3-Clause)    5
   LGPL-2.0+ WITH Linux-syscall-note                       4
   LGPL-2.1 WITH Linux-syscall-note                        3
   ((GPL-2.0 WITH Linux-syscall-note) OR MIT)              3
   ((GPL-2.0 WITH Linux-syscall-note) AND MIT)             1

   and that resulted in the third patch in this series.

 - when the two scanners agreed on the detected license(s), that became
   the concluded license(s).

 - when there was disagreement between the two scanners (one detected a
   license but the other didn't, or they both detected different
   licenses) a manual inspection of the file occurred.

 - In most cases a manual inspection of the information in the file
   resulted in a clear resolution of the license that should apply (and
   which scanner probably needed to revisit its heuristics).

 - When it was not immediately clear, the license identifier was
   confirmed with lawyers working with the Linux Foundation.

 - If there was any question as to the appropriate license identifier,
   the file was flagged for further research and to be revisited later
   in time.

In total, over 70 hours of logged manual review was done on the
spreadsheet to determine the SPDX license identifiers to apply to the
source files by Kate, Philippe, Thomas and, in some cases, confirmation
by lawyers working with the Linux Foundation.

Kate also obtained a third independent scan of the 4.13 code base from
FOSSology, and compared selected files where the other two scanners
disagreed against that SPDX file, to see if there was new insights.  The
Windriver scanner is based on an older version of FOSSology in part, so
they are related.

Thomas did random spot checks in about 500 files from the spreadsheets
for the uapi headers and agreed with SPDX license identifier in the
files he inspected. For the non-uapi files Thomas did random spot checks
in about 15000 files.

In initial set of patches against 4.14-rc6, 3 files were found to have
copy/paste license identifier errors, and have been fixed to reflect the
correct identifier.

Additionally Philippe spent 10 hours this week doing a detailed manual
inspection and review of the 12,461 patched files from the initial patch
version early this week with:
 - a full scancode scan run, collecting the matched texts, detected
   license ids and scores
 - reviewing anything where there was a license detected (about 500+
   files) to ensure that the applied SPDX license was correct
 - reviewing anything where there was no detection but the patch license
   was not GPL-2.0 WITH Linux-syscall-note to ensure that the applied
   SPDX license was correct

This produced a worksheet with 20 files needing minor correction.  This
worksheet was then exported into 3 different .csv files for the
different types of files to be modified.

These .csv files were then reviewed by Greg.  Thomas wrote a script to
parse the csv files and add the proper SPDX tag to the file, in the
format that the file expected.  This script was further refined by Greg
based on the output to detect more types of files automatically and to
distinguish between header and source .c files (which need different
comment types.)  Finally Greg ran the script using the .csv files to
generate the patches.

Reviewed-by: Kate Stewart <kstewart@linuxfoundation.org>
Reviewed-by: Philippe Ombredanne <pombredanne@nexb.com>
Reviewed-by: Thomas Gleixner <tglx@linutronix.de>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2017-11-02 11:10:55 +01:00
Colin Ian King d1e2885e1e media: mxl111sf: remove redundant assignment to index
Variable index is set to zero and then set to zero again
a few lines later in a for loop initialization. Remove the
redundant setting of index to zero. Cleans up the clang
warning:

drivers/media/usb/dvb-usb-v2/mxl111sf-i2c.c:519:3: warning: Value
stored to 'index' is never read

Signed-off-by: Colin Ian King <colin.king@canonical.com>
Signed-off-by: Hans Verkuil <hans.verkuil@cisco.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@s-opensource.com>
2017-10-31 07:27:14 -04:00
Colin Ian King bab4cb30db media: rtl28xxu: make array rc_nec_tab static const
Don't populate the array rc_nec_tab on the stack, instead make it
static const. Makes the object code smaller by over 620 bytes:

Before:
   text	   data	    bss	    dec	    hex	filename
  49511	  17040	     64	  66615	  10437	rtl28xxu.o

After:
   text	   data	    bss	    dec	    hex	filename
  48825	  17104	     64	  65993	  101c9	rtl28xxu.o

Signed-off-by: Colin Ian King <colin.king@canonical.com>
Signed-off-by: Hans Verkuil <hansverk@cisco.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@s-opensource.com>
2017-09-23 08:28:28 -04:00
Eugeniu Rosca 87e9201108 media: mxl111sf: Fix potential null pointer dereference
Reviewing the delta between cppcheck output of v4.9.39 and v4.9.40
stable updates, I stumbled on the new warning:

mxl111sf.c:80: (warning) Possible null pointer dereference: rbuf

Since copying state->rcvbuf into rbuf is not needed in the 'write-only'
scenario (i.e. calling mxl111sf_ctrl_msg() from mxl111sf_i2c_send_data()
or from mxl111sf_write_reg()), bypass memcpy() in this case.

Fixes: d90b336f3f ("[media] mxl111sf: Fix driver to use heap allocate buffers for USB messages")

Signed-off-by: Eugeniu Rosca <erosca@de.adit-jv.com>
Reviewed-by: Michael Ira Krufky <mkrufky@linuxtv.org>
Signed-off-by: Mauro Carvalho Chehab <mchehab@s-opensource.com>
2017-08-27 06:58:19 -04:00
Sean Young 6d741bfed5 media: rc: rename RC_TYPE_* to RC_PROTO_* and RC_BIT_* to RC_PROTO_BIT_*
RC_TYPE is confusing and it's just the protocol. So rename it.

Suggested-by: Hans Verkuil <hans.verkuil@cisco.com>
Signed-off-by: Sean Young <sean@mess.org>
Acked-by: Hans Verkuil <hans.verkuil@cisco.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@s-opensource.com>
2017-08-20 10:02:48 -04:00
Sean Young 518f4b26be media: rc-core: rename input_name to device_name
When an ir-spi is registered, you get this message.

rc rc0: Unspecified device as /devices/platform/soc/3f215080.spi/spi_master/spi32766/spi32766.128/rc/rc0

"Unspecified device" refers to input_name, which makes no sense for IR
TX only devices. So, rename to device_name.

Also make driver_name const char* so that no casts are needed anywhere.

Now ir-spi reports:

rc rc0: IR SPI as /devices/platform/soc/3f215080.spi/spi_master/spi32766/spi32766.128/rc/rc0

Signed-off-by: Sean Young <sean@mess.org>
Signed-off-by: Mauro Carvalho Chehab <mchehab@s-opensource.com>
2017-08-20 09:43:52 -04:00
Arvind Yadav 7fb2e072d4 media: usb: constify usb_device_id
usb_device_id are not supposed to change at runtime. All functions
working with usb_device_id provided by <linux/usb.h> work with
const usb_device_id. So mark the non-const structs as const.

'drivers/media/usb/b2c2/flexcop-usb.c' Fix checkpatch.pl error:
ERROR: space prohibited before open square bracket '['.

Signed-off-by: Arvind Yadav <arvind.yadav.cs@gmail.com>
Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Signed-off-by: Hans Verkuil <hans.verkuil@cisco.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@s-opensource.com>
2017-08-20 08:04:51 -04:00
Nuno Henriques b5e0733ffc media: Added support for the TerraTec T1 DVB-T USB tuner [IT9135 chipset]
Signed-off-by: Nuno Henriques <nuno.amhenriques@gmail.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@s-opensource.com>
2017-07-20 16:46:49 -04:00
Gustavo A. R. Silva d83bc7b644 media: dvb-usb-v2: lmedm04: remove unnecessary variable in lme2510_stream_restart()
Remove unnecessary variable _ret_ and refactor the code.

Addresses-Coverity-ID: 1226934

Signed-off-by: Gustavo A. R. Silva <garsilva@embeddedor.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@s-opensource.com>
2017-06-24 18:46:05 -03:00
Antti Palosaari b5e0e1a317 [media] af9015: move 2nd demod power-up wait different location
We need to wait 2nd demod power-up before download firmware. Move
that wait to more correct location.

Signed-off-by: Antti Palosaari <crope@iki.fi>
Signed-off-by: Mauro Carvalho Chehab <mchehab@s-opensource.com>
2017-06-20 10:26:13 -03:00
Antti Palosaari e94db976b7 [media] af9015: enable 2nd TS flow control when dual mode
It needs to be enabled in order to get stream from slave af9013 demod.

Signed-off-by: Antti Palosaari <crope@iki.fi>
Signed-off-by: Mauro Carvalho Chehab <mchehab@s-opensource.com>
2017-06-20 10:24:17 -03:00
Antti Palosaari d83886ff11 [media] af9015: fix and refactor i2c adapter algo logic
* fix write+read when write has more than one byte
* remove lock, not needed on that case
* remove useless i2c msg send loop, as we support only write, read and
write+read as one go and nothing more

Signed-off-by: Antti Palosaari <crope@iki.fi>
Signed-off-by: Mauro Carvalho Chehab <mchehab@s-opensource.com>
2017-06-20 10:23:51 -03:00
Antti Palosaari 5ded0eb7f8 [media] af9015: use correct 7-bit i2c addresses
Driver was using wrong "8-bit" i2c addresses for demods and tuners.
Internal demod i2c address was not set at all. These are needed
to be fixed before proper i2c client binding is used.

Signed-off-by: Antti Palosaari <crope@iki.fi>
Signed-off-by: Mauro Carvalho Chehab <mchehab@s-opensource.com>
2017-06-20 10:12:24 -03:00
Devin Heitmueller d90b336f3f [media] mxl111sf: Fix driver to use heap allocate buffers for USB messages
The recent changes in 4.9 to mandate USB buffers be heap allocated
broke this driver, which was allocating the buffers on the stack.
This resulted in the device failing at initialization.

Introduce dedicated send/receive buffers as part of the state
structure, and add a mutex to protect access to them.

Note: we also had to tweak the API to mxl111sf_ctrl_msg to pass
the pointer to the state struct rather than the device, since
we need it inside the function to access the buffers and the
mutex.  This patch adjusts the callers to match the API change.

Signed-off-by: Devin Heitmueller <dheitmueller@kernellabs.com>
Reported-by: Doug Lung <dlung0@gmail.com>
Cc: Michael Ira Krufky <mkrufky@linuxtv.org>
Cc: <stable@vger.kernel.org>      # for v4.5 and up
Signed-off-by: Hans Verkuil <hans.verkuil@cisco.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@s-opensource.com>
2017-06-06 07:28:09 -03:00
Mauro Carvalho Chehab 06eeefe8e3 [media] media drivers: annotate fall-through
Avoid warnings like those:

drivers/media/pci/ddbridge/ddbridge-core.c: In function 'dvb_input_detach':
drivers/media/pci/ddbridge/ddbridge-core.c:787:6: warning: this statement may fall through [-Wimplicit-fallthrough=]
   if (input->fe) {
      ^
drivers/media/pci/ddbridge/ddbridge-core.c:792:2: note: here
  case 4:
  ^~~~
...

On several cases, it is just that gcc 7.1 is not capable of
understanding the comment, but on other places, we need an
annotation.

Signed-off-by: Mauro Carvalho Chehab <mchehab@s-opensource.com>
2017-05-19 07:10:03 -03:00
Mauro Carvalho Chehab 446aba663b [media] tveeprom: get rid of unused arg on tveeprom_hauppauge_analog()
tveeprom_hauppauge_analog() used to need the I2C adapter in
order to print debug messages. As it now uses pr_foo() facilities
since commit 6037b3ca28 ("[media] tveeprom: print log messages
using pr_foo()"), the first argument of the function is not
needed anymore.

So, get rid of it.

Signed-off-by: Mauro Carvalho Chehab <mchehab@s-opensource.com>
2017-03-03 07:35:02 -03:00
Arnd Bergmann 371d1143a5 [media] mxl111sf: reduce stack usage in init function
mxl111sf uses a lot of kernel stack memory as it puts an i2c_client
structure on the stack:

drivers/media/usb/dvb-usb-v2/mxl111sf.c: In function 'mxl111sf_init':
drivers/media/usb/dvb-usb-v2/mxl111sf.c:953:1: error: the frame size of 1248 bytes is larger than 1152 bytes [-Werror=frame-larger-than=]

We can avoid doing this by open-coding the call to i2c_transfer()
instead of calling tveeprom_read(), and not passing an i2c_client
pointer to tveeprom_hauppauge_analog(), which would ignore that
anyway.

Signed-off-by: Arnd Bergmann <arnd@arndb.de>
Signed-off-by: Hans Verkuil <hans.verkuil@cisco.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@s-opensource.com>
2017-03-03 07:21:48 -03:00
Arnd Bergmann 0d1270df83 [media] zd1301: fix building interface driver without demodulator
If the USB driver is enabled but the demodulator is not, we get a link error:

ERROR: "zd1301_demod_get_dvb_frontend" [drivers/media/usb/dvb-usb-v2/zd1301.ko] undefined!
ERROR: "zd1301_demod_get_i2c_adapter" [drivers/media/usb/dvb-usb-v2/zd1301.ko] undefined!

Such a configuration obviously makes no sense, but we should not fail
the build.  This tries to mimic what we have for other drivers by turning
the build failure into a runtime failure.

Alternatively we could use an unconditional 'select' or 'depends on' to enforce
a sane configuration.

Fixes: 47d65372b3 ("[media] zd1301_demod: ZyDAS ZD1301 DVB-T demodulator driver")
Fixes: 992b39872b ("[media] zd1301: ZyDAS ZD1301 DVB USB interface driver")

Signed-off-by: Arnd Bergmann <arnd@arndb.de>
Signed-off-by: Mauro Carvalho Chehab <mchehab@s-opensource.com>
2017-02-08 11:59:39 -02:00
Arnd Bergmann 005145378c [media] dvb-usb-v2: avoid use-after-free
I ran into a stack frame size warning because of the on-stack copy of
the USB device structure:

drivers/media/usb/dvb-usb-v2/dvb_usb_core.c: In function 'dvb_usbv2_disconnect':
drivers/media/usb/dvb-usb-v2/dvb_usb_core.c:1029:1: error: the frame size of 1104 bytes is larger than 1024 bytes [-Werror=frame-larger-than=]

Copying a device structure like this is wrong for a number of other reasons
too aside from the possible stack overflow. One of them is that the
dev_info() call will print the name of the device later, but AFAICT
we have only copied a pointer to the name earlier and the actual name
has been freed by the time it gets printed.

This removes the on-stack copy of the device and instead copies the
device name using kstrdup(). I'm ignoring the possible failure here
as both printk() and kfree() are able to deal with NULL pointers.

Signed-off-by: Arnd Bergmann <arnd@arndb.de>
Signed-off-by: Mauro Carvalho Chehab <mchehab@s-opensource.com>
2017-02-08 11:45:09 -02:00
Rasmus Villemoes 974eadf1fc [media] lmedm04: make lme2510_powerup a little smaller
gcc isn't smart enough to realize it can share most of the argument
buildup and the actual function call between the two branches, so help
it a little.

Signed-off-by: Rasmus Villemoes <linux@rasmusvillemoes.dk>
Signed-off-by: Mauro Carvalho Chehab <mchehab@s-opensource.com>
2017-02-03 07:39:38 -02:00
Rasmus Villemoes bfe17178a8 [media] lmedm04: make some string arrays static
It takes more .text to initialize these on the stack than they occupy
in .rodata, so just make them static const.

Signed-off-by: Rasmus Villemoes <linux@rasmusvillemoes.dk>
Signed-off-by: Mauro Carvalho Chehab <mchehab@s-opensource.com>
2017-02-03 07:39:37 -02:00
Rasmus Villemoes 75759e31e6 [media] lmedm04: change some static variables to automatic
ibuf and rbuf in lme2510_int_response are always assigned to before they
are read, and their addresses do not escape the function, so they have
no reason to be static.

Signed-off-by: Rasmus Villemoes <linux@rasmusvillemoes.dk>
Signed-off-by: Mauro Carvalho Chehab <mchehab@s-opensource.com>
2017-02-03 07:39:36 -02:00
Rasmus Villemoes 3a3402d318 [media] lmedm04: use %phN for hex dump
Using the %ph printf extension for hex dumps like this makes the
generated code quite a bit smaller.

Signed-off-by: Rasmus Villemoes <linux@rasmusvillemoes.dk>
Signed-off-by: Mauro Carvalho Chehab <mchehab@s-opensource.com>
2017-02-03 07:39:36 -02:00