2008-04-19 08:34:00 +08:00
|
|
|
/*
|
|
|
|
* Driver for the Auvitek USB bridge
|
|
|
|
*
|
2008-09-04 04:12:12 +08:00
|
|
|
* Copyright (c) 2008 Steven Toth <stoth@linuxtv.org>
|
2008-04-19 08:34:00 +08:00
|
|
|
*
|
|
|
|
* This program is free software; you can redistribute it and/or modify
|
|
|
|
* it under the terms of the GNU General Public License as published by
|
|
|
|
* the Free Software Foundation; either version 2 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 General Public License for more details.
|
|
|
|
*/
|
|
|
|
|
2014-08-10 08:47:17 +08:00
|
|
|
#include "au0828.h"
|
|
|
|
|
2008-04-19 08:34:00 +08:00
|
|
|
#include <linux/module.h>
|
include cleanup: Update gfp.h and slab.h includes to prepare for breaking implicit slab.h inclusion from percpu.h
percpu.h is included by sched.h and module.h and thus ends up being
included when building most .c files. percpu.h includes slab.h which
in turn includes gfp.h making everything defined by the two files
universally available and complicating inclusion dependencies.
percpu.h -> slab.h dependency is about to be removed. Prepare for
this change by updating users of gfp and slab facilities include those
headers directly instead of assuming availability. As this conversion
needs to touch large number of source files, the following script is
used as the basis of conversion.
http://userweb.kernel.org/~tj/misc/slabh-sweep.py
The script does the followings.
* Scan files for gfp and slab usages and update includes such that
only the necessary includes are there. ie. if only gfp is used,
gfp.h, if slab is used, slab.h.
* When the script inserts a new include, it looks at the include
blocks and try to put the new include such that its order conforms
to its surrounding. It's put in the include block which contains
core kernel includes, in the same order that the rest are ordered -
alphabetical, Christmas tree, rev-Xmas-tree or at the end if there
doesn't seem to be any matching order.
* If the script can't find a place to put a new include (mostly
because the file doesn't have fitting include block), it prints out
an error message indicating which .h file needs to be added to the
file.
The conversion was done in the following steps.
1. The initial automatic conversion of all .c files updated slightly
over 4000 files, deleting around 700 includes and adding ~480 gfp.h
and ~3000 slab.h inclusions. The script emitted errors for ~400
files.
2. Each error was manually checked. Some didn't need the inclusion,
some needed manual addition while adding it to implementation .h or
embedding .c file was more appropriate for others. This step added
inclusions to around 150 files.
3. The script was run again and the output was compared to the edits
from #2 to make sure no file was left behind.
4. Several build tests were done and a couple of problems were fixed.
e.g. lib/decompress_*.c used malloc/free() wrappers around slab
APIs requiring slab.h to be added manually.
5. The script was run on all .h files but without automatically
editing them as sprinkling gfp.h and slab.h inclusions around .h
files could easily lead to inclusion dependency hell. Most gfp.h
inclusion directives were ignored as stuff from gfp.h was usually
wildly available and often used in preprocessor macros. Each
slab.h inclusion directive was examined and added manually as
necessary.
6. percpu.h was updated not to include slab.h.
7. Build test were done on the following configurations and failures
were fixed. CONFIG_GCOV_KERNEL was turned off for all tests (as my
distributed build env didn't work with gcov compiles) and a few
more options had to be turned off depending on archs to make things
build (like ipr on powerpc/64 which failed due to missing writeq).
* x86 and x86_64 UP and SMP allmodconfig and a custom test config.
* powerpc and powerpc64 SMP allmodconfig
* sparc and sparc64 SMP allmodconfig
* ia64 SMP allmodconfig
* s390 SMP allmodconfig
* alpha SMP allmodconfig
* um on x86_64 SMP allmodconfig
8. percpu.h modifications were reverted so that it could be applied as
a separate patch and serve as bisection point.
Given the fact that I had only a couple of failures from tests on step
6, I'm fairly confident about the coverage of this conversion patch.
If there is a breakage, it's likely to be something in one of the arch
headers which should be easily discoverable easily on most builds of
the specific arch.
Signed-off-by: Tejun Heo <tj@kernel.org>
Guess-its-ok-by: Christoph Lameter <cl@linux-foundation.org>
Cc: Ingo Molnar <mingo@redhat.com>
Cc: Lee Schermerhorn <Lee.Schermerhorn@hp.com>
2010-03-24 16:04:11 +08:00
|
|
|
#include <linux/slab.h>
|
2008-04-19 08:34:00 +08:00
|
|
|
#include <linux/init.h>
|
|
|
|
#include <linux/device.h>
|
|
|
|
#include <media/v4l2-common.h>
|
2012-04-09 08:39:56 +08:00
|
|
|
#include <media/tuner.h>
|
2008-04-19 08:34:00 +08:00
|
|
|
|
|
|
|
#include "au8522.h"
|
|
|
|
#include "xc5000.h"
|
2008-07-09 11:23:08 +08:00
|
|
|
#include "mxl5007t.h"
|
2008-09-04 03:46:36 +08:00
|
|
|
#include "tda18271.h"
|
2008-04-19 08:34:00 +08:00
|
|
|
|
2014-01-15 10:49:23 +08:00
|
|
|
static int preallocate_big_buffers;
|
2014-01-07 12:29:25 +08:00
|
|
|
module_param_named(preallocate_big_buffers, preallocate_big_buffers, int, 0644);
|
|
|
|
MODULE_PARM_DESC(preallocate_big_buffers, "Preallocate the larger transfer buffers at module load time");
|
|
|
|
|
2008-04-19 08:34:00 +08:00
|
|
|
DVB_DEFINE_MOD_OPT_ADAPTER_NR(adapter_nr);
|
|
|
|
|
2008-04-18 08:41:28 +08:00
|
|
|
#define _AU0828_BULKPIPE 0x83
|
|
|
|
#define _BULKPIPESIZE 0xe522
|
|
|
|
|
2008-04-06 07:55:14 +08:00
|
|
|
static u8 hauppauge_hvr950q_led_states[] = {
|
|
|
|
0x00, /* off */
|
|
|
|
0x02, /* yellow */
|
|
|
|
0x04, /* green */
|
|
|
|
};
|
|
|
|
|
|
|
|
static struct au8522_led_config hauppauge_hvr950q_led_cfg = {
|
|
|
|
.gpio_output = 0x00e0,
|
|
|
|
.gpio_output_enable = 0x6006,
|
|
|
|
.gpio_output_disable = 0x0660,
|
|
|
|
|
|
|
|
.gpio_leds = 0x00e2,
|
|
|
|
.led_states = hauppauge_hvr950q_led_states,
|
|
|
|
.num_led_states = sizeof(hauppauge_hvr950q_led_states),
|
|
|
|
|
|
|
|
.vsb8_strong = 20 /* dB */ * 10,
|
|
|
|
.qam64_strong = 25 /* dB */ * 10,
|
|
|
|
.qam256_strong = 32 /* dB */ * 10,
|
|
|
|
};
|
|
|
|
|
2008-04-19 08:34:00 +08:00
|
|
|
static struct au8522_config hauppauge_hvr950q_config = {
|
|
|
|
.demod_address = 0x8e >> 1,
|
|
|
|
.status_mode = AU8522_DEMODLOCKING,
|
2008-09-04 03:46:43 +08:00
|
|
|
.qam_if = AU8522_IF_6MHZ,
|
|
|
|
.vsb_if = AU8522_IF_6MHZ,
|
2008-04-06 07:55:14 +08:00
|
|
|
.led_cfg = &hauppauge_hvr950q_led_cfg,
|
|
|
|
};
|
|
|
|
|
|
|
|
static struct au8522_config fusionhdtv7usb_config = {
|
|
|
|
.demod_address = 0x8e >> 1,
|
|
|
|
.status_mode = AU8522_DEMODLOCKING,
|
|
|
|
.qam_if = AU8522_IF_6MHZ,
|
|
|
|
.vsb_if = AU8522_IF_6MHZ,
|
2008-04-19 08:34:00 +08:00
|
|
|
};
|
|
|
|
|
2008-09-04 03:46:36 +08:00
|
|
|
static struct au8522_config hauppauge_woodbury_config = {
|
|
|
|
.demod_address = 0x8e >> 1,
|
|
|
|
.status_mode = AU8522_DEMODLOCKING,
|
|
|
|
.qam_if = AU8522_IF_4MHZ,
|
|
|
|
.vsb_if = AU8522_IF_3_25MHZ,
|
|
|
|
};
|
|
|
|
|
2012-04-09 08:39:56 +08:00
|
|
|
static struct xc5000_config hauppauge_xc5000a_config = {
|
2008-04-19 08:34:00 +08:00
|
|
|
.i2c_address = 0x61,
|
|
|
|
.if_khz = 6000,
|
2012-04-09 08:39:56 +08:00
|
|
|
.chip_id = XC5000A,
|
2014-10-26 04:17:22 +08:00
|
|
|
.output_amp = 0x8f,
|
2012-04-09 08:39:56 +08:00
|
|
|
};
|
|
|
|
|
|
|
|
static struct xc5000_config hauppauge_xc5000c_config = {
|
|
|
|
.i2c_address = 0x61,
|
|
|
|
.if_khz = 6000,
|
|
|
|
.chip_id = XC5000C,
|
2014-10-26 04:17:22 +08:00
|
|
|
.output_amp = 0x8f,
|
2008-04-19 08:34:00 +08:00
|
|
|
};
|
|
|
|
|
2008-07-09 11:23:08 +08:00
|
|
|
static struct mxl5007t_config mxl5007t_hvr950q_config = {
|
|
|
|
.xtal_freq_hz = MxL_XTAL_24_MHZ,
|
|
|
|
.if_freq_hz = MxL_IF_6_MHZ,
|
|
|
|
};
|
|
|
|
|
2008-09-04 03:46:36 +08:00
|
|
|
static struct tda18271_config hauppauge_woodbury_tunerconfig = {
|
|
|
|
.gate = TDA18271_GATE_DIGITAL,
|
|
|
|
};
|
|
|
|
|
2012-08-07 09:46:53 +08:00
|
|
|
static void au0828_restart_dvb_streaming(struct work_struct *work);
|
|
|
|
|
treewide: setup_timer() -> timer_setup()
This converts all remaining cases of the old setup_timer() API into using
timer_setup(), where the callback argument is the structure already
holding the struct timer_list. These should have no behavioral changes,
since they just change which pointer is passed into the callback with
the same available pointers after conversion. It handles the following
examples, in addition to some other variations.
Casting from unsigned long:
void my_callback(unsigned long data)
{
struct something *ptr = (struct something *)data;
...
}
...
setup_timer(&ptr->my_timer, my_callback, ptr);
and forced object casts:
void my_callback(struct something *ptr)
{
...
}
...
setup_timer(&ptr->my_timer, my_callback, (unsigned long)ptr);
become:
void my_callback(struct timer_list *t)
{
struct something *ptr = from_timer(ptr, t, my_timer);
...
}
...
timer_setup(&ptr->my_timer, my_callback, 0);
Direct function assignments:
void my_callback(unsigned long data)
{
struct something *ptr = (struct something *)data;
...
}
...
ptr->my_timer.function = my_callback;
have a temporary cast added, along with converting the args:
void my_callback(struct timer_list *t)
{
struct something *ptr = from_timer(ptr, t, my_timer);
...
}
...
ptr->my_timer.function = (TIMER_FUNC_TYPE)my_callback;
And finally, callbacks without a data assignment:
void my_callback(unsigned long data)
{
...
}
...
setup_timer(&ptr->my_timer, my_callback, 0);
have their argument renamed to verify they're unused during conversion:
void my_callback(struct timer_list *unused)
{
...
}
...
timer_setup(&ptr->my_timer, my_callback, 0);
The conversion is done with the following Coccinelle script:
spatch --very-quiet --all-includes --include-headers \
-I ./arch/x86/include -I ./arch/x86/include/generated \
-I ./include -I ./arch/x86/include/uapi \
-I ./arch/x86/include/generated/uapi -I ./include/uapi \
-I ./include/generated/uapi --include ./include/linux/kconfig.h \
--dir . \
--cocci-file ~/src/data/timer_setup.cocci
@fix_address_of@
expression e;
@@
setup_timer(
-&(e)
+&e
, ...)
// Update any raw setup_timer() usages that have a NULL callback, but
// would otherwise match change_timer_function_usage, since the latter
// will update all function assignments done in the face of a NULL
// function initialization in setup_timer().
@change_timer_function_usage_NULL@
expression _E;
identifier _timer;
type _cast_data;
@@
(
-setup_timer(&_E->_timer, NULL, _E);
+timer_setup(&_E->_timer, NULL, 0);
|
-setup_timer(&_E->_timer, NULL, (_cast_data)_E);
+timer_setup(&_E->_timer, NULL, 0);
|
-setup_timer(&_E._timer, NULL, &_E);
+timer_setup(&_E._timer, NULL, 0);
|
-setup_timer(&_E._timer, NULL, (_cast_data)&_E);
+timer_setup(&_E._timer, NULL, 0);
)
@change_timer_function_usage@
expression _E;
identifier _timer;
struct timer_list _stl;
identifier _callback;
type _cast_func, _cast_data;
@@
(
-setup_timer(&_E->_timer, _callback, _E);
+timer_setup(&_E->_timer, _callback, 0);
|
-setup_timer(&_E->_timer, &_callback, _E);
+timer_setup(&_E->_timer, _callback, 0);
|
-setup_timer(&_E->_timer, _callback, (_cast_data)_E);
+timer_setup(&_E->_timer, _callback, 0);
|
-setup_timer(&_E->_timer, &_callback, (_cast_data)_E);
+timer_setup(&_E->_timer, _callback, 0);
|
-setup_timer(&_E->_timer, (_cast_func)_callback, _E);
+timer_setup(&_E->_timer, _callback, 0);
|
-setup_timer(&_E->_timer, (_cast_func)&_callback, _E);
+timer_setup(&_E->_timer, _callback, 0);
|
-setup_timer(&_E->_timer, (_cast_func)_callback, (_cast_data)_E);
+timer_setup(&_E->_timer, _callback, 0);
|
-setup_timer(&_E->_timer, (_cast_func)&_callback, (_cast_data)_E);
+timer_setup(&_E->_timer, _callback, 0);
|
-setup_timer(&_E._timer, _callback, (_cast_data)_E);
+timer_setup(&_E._timer, _callback, 0);
|
-setup_timer(&_E._timer, _callback, (_cast_data)&_E);
+timer_setup(&_E._timer, _callback, 0);
|
-setup_timer(&_E._timer, &_callback, (_cast_data)_E);
+timer_setup(&_E._timer, _callback, 0);
|
-setup_timer(&_E._timer, &_callback, (_cast_data)&_E);
+timer_setup(&_E._timer, _callback, 0);
|
-setup_timer(&_E._timer, (_cast_func)_callback, (_cast_data)_E);
+timer_setup(&_E._timer, _callback, 0);
|
-setup_timer(&_E._timer, (_cast_func)_callback, (_cast_data)&_E);
+timer_setup(&_E._timer, _callback, 0);
|
-setup_timer(&_E._timer, (_cast_func)&_callback, (_cast_data)_E);
+timer_setup(&_E._timer, _callback, 0);
|
-setup_timer(&_E._timer, (_cast_func)&_callback, (_cast_data)&_E);
+timer_setup(&_E._timer, _callback, 0);
|
_E->_timer@_stl.function = _callback;
|
_E->_timer@_stl.function = &_callback;
|
_E->_timer@_stl.function = (_cast_func)_callback;
|
_E->_timer@_stl.function = (_cast_func)&_callback;
|
_E._timer@_stl.function = _callback;
|
_E._timer@_stl.function = &_callback;
|
_E._timer@_stl.function = (_cast_func)_callback;
|
_E._timer@_stl.function = (_cast_func)&_callback;
)
// callback(unsigned long arg)
@change_callback_handle_cast
depends on change_timer_function_usage@
identifier change_timer_function_usage._callback;
identifier change_timer_function_usage._timer;
type _origtype;
identifier _origarg;
type _handletype;
identifier _handle;
@@
void _callback(
-_origtype _origarg
+struct timer_list *t
)
{
(
... when != _origarg
_handletype *_handle =
-(_handletype *)_origarg;
+from_timer(_handle, t, _timer);
... when != _origarg
|
... when != _origarg
_handletype *_handle =
-(void *)_origarg;
+from_timer(_handle, t, _timer);
... when != _origarg
|
... when != _origarg
_handletype *_handle;
... when != _handle
_handle =
-(_handletype *)_origarg;
+from_timer(_handle, t, _timer);
... when != _origarg
|
... when != _origarg
_handletype *_handle;
... when != _handle
_handle =
-(void *)_origarg;
+from_timer(_handle, t, _timer);
... when != _origarg
)
}
// callback(unsigned long arg) without existing variable
@change_callback_handle_cast_no_arg
depends on change_timer_function_usage &&
!change_callback_handle_cast@
identifier change_timer_function_usage._callback;
identifier change_timer_function_usage._timer;
type _origtype;
identifier _origarg;
type _handletype;
@@
void _callback(
-_origtype _origarg
+struct timer_list *t
)
{
+ _handletype *_origarg = from_timer(_origarg, t, _timer);
+
... when != _origarg
- (_handletype *)_origarg
+ _origarg
... when != _origarg
}
// Avoid already converted callbacks.
@match_callback_converted
depends on change_timer_function_usage &&
!change_callback_handle_cast &&
!change_callback_handle_cast_no_arg@
identifier change_timer_function_usage._callback;
identifier t;
@@
void _callback(struct timer_list *t)
{ ... }
// callback(struct something *handle)
@change_callback_handle_arg
depends on change_timer_function_usage &&
!match_callback_converted &&
!change_callback_handle_cast &&
!change_callback_handle_cast_no_arg@
identifier change_timer_function_usage._callback;
identifier change_timer_function_usage._timer;
type _handletype;
identifier _handle;
@@
void _callback(
-_handletype *_handle
+struct timer_list *t
)
{
+ _handletype *_handle = from_timer(_handle, t, _timer);
...
}
// If change_callback_handle_arg ran on an empty function, remove
// the added handler.
@unchange_callback_handle_arg
depends on change_timer_function_usage &&
change_callback_handle_arg@
identifier change_timer_function_usage._callback;
identifier change_timer_function_usage._timer;
type _handletype;
identifier _handle;
identifier t;
@@
void _callback(struct timer_list *t)
{
- _handletype *_handle = from_timer(_handle, t, _timer);
}
// We only want to refactor the setup_timer() data argument if we've found
// the matching callback. This undoes changes in change_timer_function_usage.
@unchange_timer_function_usage
depends on change_timer_function_usage &&
!change_callback_handle_cast &&
!change_callback_handle_cast_no_arg &&
!change_callback_handle_arg@
expression change_timer_function_usage._E;
identifier change_timer_function_usage._timer;
identifier change_timer_function_usage._callback;
type change_timer_function_usage._cast_data;
@@
(
-timer_setup(&_E->_timer, _callback, 0);
+setup_timer(&_E->_timer, _callback, (_cast_data)_E);
|
-timer_setup(&_E._timer, _callback, 0);
+setup_timer(&_E._timer, _callback, (_cast_data)&_E);
)
// If we fixed a callback from a .function assignment, fix the
// assignment cast now.
@change_timer_function_assignment
depends on change_timer_function_usage &&
(change_callback_handle_cast ||
change_callback_handle_cast_no_arg ||
change_callback_handle_arg)@
expression change_timer_function_usage._E;
identifier change_timer_function_usage._timer;
identifier change_timer_function_usage._callback;
type _cast_func;
typedef TIMER_FUNC_TYPE;
@@
(
_E->_timer.function =
-_callback
+(TIMER_FUNC_TYPE)_callback
;
|
_E->_timer.function =
-&_callback
+(TIMER_FUNC_TYPE)_callback
;
|
_E->_timer.function =
-(_cast_func)_callback;
+(TIMER_FUNC_TYPE)_callback
;
|
_E->_timer.function =
-(_cast_func)&_callback
+(TIMER_FUNC_TYPE)_callback
;
|
_E._timer.function =
-_callback
+(TIMER_FUNC_TYPE)_callback
;
|
_E._timer.function =
-&_callback;
+(TIMER_FUNC_TYPE)_callback
;
|
_E._timer.function =
-(_cast_func)_callback
+(TIMER_FUNC_TYPE)_callback
;
|
_E._timer.function =
-(_cast_func)&_callback
+(TIMER_FUNC_TYPE)_callback
;
)
// Sometimes timer functions are called directly. Replace matched args.
@change_timer_function_calls
depends on change_timer_function_usage &&
(change_callback_handle_cast ||
change_callback_handle_cast_no_arg ||
change_callback_handle_arg)@
expression _E;
identifier change_timer_function_usage._timer;
identifier change_timer_function_usage._callback;
type _cast_data;
@@
_callback(
(
-(_cast_data)_E
+&_E->_timer
|
-(_cast_data)&_E
+&_E._timer
|
-_E
+&_E->_timer
)
)
// If a timer has been configured without a data argument, it can be
// converted without regard to the callback argument, since it is unused.
@match_timer_function_unused_data@
expression _E;
identifier _timer;
identifier _callback;
@@
(
-setup_timer(&_E->_timer, _callback, 0);
+timer_setup(&_E->_timer, _callback, 0);
|
-setup_timer(&_E->_timer, _callback, 0L);
+timer_setup(&_E->_timer, _callback, 0);
|
-setup_timer(&_E->_timer, _callback, 0UL);
+timer_setup(&_E->_timer, _callback, 0);
|
-setup_timer(&_E._timer, _callback, 0);
+timer_setup(&_E._timer, _callback, 0);
|
-setup_timer(&_E._timer, _callback, 0L);
+timer_setup(&_E._timer, _callback, 0);
|
-setup_timer(&_E._timer, _callback, 0UL);
+timer_setup(&_E._timer, _callback, 0);
|
-setup_timer(&_timer, _callback, 0);
+timer_setup(&_timer, _callback, 0);
|
-setup_timer(&_timer, _callback, 0L);
+timer_setup(&_timer, _callback, 0);
|
-setup_timer(&_timer, _callback, 0UL);
+timer_setup(&_timer, _callback, 0);
|
-setup_timer(_timer, _callback, 0);
+timer_setup(_timer, _callback, 0);
|
-setup_timer(_timer, _callback, 0L);
+timer_setup(_timer, _callback, 0);
|
-setup_timer(_timer, _callback, 0UL);
+timer_setup(_timer, _callback, 0);
)
@change_callback_unused_data
depends on match_timer_function_unused_data@
identifier match_timer_function_unused_data._callback;
type _origtype;
identifier _origarg;
@@
void _callback(
-_origtype _origarg
+struct timer_list *unused
)
{
... when != _origarg
}
Signed-off-by: Kees Cook <keescook@chromium.org>
2017-10-17 05:43:17 +08:00
|
|
|
static void au0828_bulk_timeout(struct timer_list *t)
|
2017-04-20 07:13:55 +08:00
|
|
|
{
|
treewide: setup_timer() -> timer_setup()
This converts all remaining cases of the old setup_timer() API into using
timer_setup(), where the callback argument is the structure already
holding the struct timer_list. These should have no behavioral changes,
since they just change which pointer is passed into the callback with
the same available pointers after conversion. It handles the following
examples, in addition to some other variations.
Casting from unsigned long:
void my_callback(unsigned long data)
{
struct something *ptr = (struct something *)data;
...
}
...
setup_timer(&ptr->my_timer, my_callback, ptr);
and forced object casts:
void my_callback(struct something *ptr)
{
...
}
...
setup_timer(&ptr->my_timer, my_callback, (unsigned long)ptr);
become:
void my_callback(struct timer_list *t)
{
struct something *ptr = from_timer(ptr, t, my_timer);
...
}
...
timer_setup(&ptr->my_timer, my_callback, 0);
Direct function assignments:
void my_callback(unsigned long data)
{
struct something *ptr = (struct something *)data;
...
}
...
ptr->my_timer.function = my_callback;
have a temporary cast added, along with converting the args:
void my_callback(struct timer_list *t)
{
struct something *ptr = from_timer(ptr, t, my_timer);
...
}
...
ptr->my_timer.function = (TIMER_FUNC_TYPE)my_callback;
And finally, callbacks without a data assignment:
void my_callback(unsigned long data)
{
...
}
...
setup_timer(&ptr->my_timer, my_callback, 0);
have their argument renamed to verify they're unused during conversion:
void my_callback(struct timer_list *unused)
{
...
}
...
timer_setup(&ptr->my_timer, my_callback, 0);
The conversion is done with the following Coccinelle script:
spatch --very-quiet --all-includes --include-headers \
-I ./arch/x86/include -I ./arch/x86/include/generated \
-I ./include -I ./arch/x86/include/uapi \
-I ./arch/x86/include/generated/uapi -I ./include/uapi \
-I ./include/generated/uapi --include ./include/linux/kconfig.h \
--dir . \
--cocci-file ~/src/data/timer_setup.cocci
@fix_address_of@
expression e;
@@
setup_timer(
-&(e)
+&e
, ...)
// Update any raw setup_timer() usages that have a NULL callback, but
// would otherwise match change_timer_function_usage, since the latter
// will update all function assignments done in the face of a NULL
// function initialization in setup_timer().
@change_timer_function_usage_NULL@
expression _E;
identifier _timer;
type _cast_data;
@@
(
-setup_timer(&_E->_timer, NULL, _E);
+timer_setup(&_E->_timer, NULL, 0);
|
-setup_timer(&_E->_timer, NULL, (_cast_data)_E);
+timer_setup(&_E->_timer, NULL, 0);
|
-setup_timer(&_E._timer, NULL, &_E);
+timer_setup(&_E._timer, NULL, 0);
|
-setup_timer(&_E._timer, NULL, (_cast_data)&_E);
+timer_setup(&_E._timer, NULL, 0);
)
@change_timer_function_usage@
expression _E;
identifier _timer;
struct timer_list _stl;
identifier _callback;
type _cast_func, _cast_data;
@@
(
-setup_timer(&_E->_timer, _callback, _E);
+timer_setup(&_E->_timer, _callback, 0);
|
-setup_timer(&_E->_timer, &_callback, _E);
+timer_setup(&_E->_timer, _callback, 0);
|
-setup_timer(&_E->_timer, _callback, (_cast_data)_E);
+timer_setup(&_E->_timer, _callback, 0);
|
-setup_timer(&_E->_timer, &_callback, (_cast_data)_E);
+timer_setup(&_E->_timer, _callback, 0);
|
-setup_timer(&_E->_timer, (_cast_func)_callback, _E);
+timer_setup(&_E->_timer, _callback, 0);
|
-setup_timer(&_E->_timer, (_cast_func)&_callback, _E);
+timer_setup(&_E->_timer, _callback, 0);
|
-setup_timer(&_E->_timer, (_cast_func)_callback, (_cast_data)_E);
+timer_setup(&_E->_timer, _callback, 0);
|
-setup_timer(&_E->_timer, (_cast_func)&_callback, (_cast_data)_E);
+timer_setup(&_E->_timer, _callback, 0);
|
-setup_timer(&_E._timer, _callback, (_cast_data)_E);
+timer_setup(&_E._timer, _callback, 0);
|
-setup_timer(&_E._timer, _callback, (_cast_data)&_E);
+timer_setup(&_E._timer, _callback, 0);
|
-setup_timer(&_E._timer, &_callback, (_cast_data)_E);
+timer_setup(&_E._timer, _callback, 0);
|
-setup_timer(&_E._timer, &_callback, (_cast_data)&_E);
+timer_setup(&_E._timer, _callback, 0);
|
-setup_timer(&_E._timer, (_cast_func)_callback, (_cast_data)_E);
+timer_setup(&_E._timer, _callback, 0);
|
-setup_timer(&_E._timer, (_cast_func)_callback, (_cast_data)&_E);
+timer_setup(&_E._timer, _callback, 0);
|
-setup_timer(&_E._timer, (_cast_func)&_callback, (_cast_data)_E);
+timer_setup(&_E._timer, _callback, 0);
|
-setup_timer(&_E._timer, (_cast_func)&_callback, (_cast_data)&_E);
+timer_setup(&_E._timer, _callback, 0);
|
_E->_timer@_stl.function = _callback;
|
_E->_timer@_stl.function = &_callback;
|
_E->_timer@_stl.function = (_cast_func)_callback;
|
_E->_timer@_stl.function = (_cast_func)&_callback;
|
_E._timer@_stl.function = _callback;
|
_E._timer@_stl.function = &_callback;
|
_E._timer@_stl.function = (_cast_func)_callback;
|
_E._timer@_stl.function = (_cast_func)&_callback;
)
// callback(unsigned long arg)
@change_callback_handle_cast
depends on change_timer_function_usage@
identifier change_timer_function_usage._callback;
identifier change_timer_function_usage._timer;
type _origtype;
identifier _origarg;
type _handletype;
identifier _handle;
@@
void _callback(
-_origtype _origarg
+struct timer_list *t
)
{
(
... when != _origarg
_handletype *_handle =
-(_handletype *)_origarg;
+from_timer(_handle, t, _timer);
... when != _origarg
|
... when != _origarg
_handletype *_handle =
-(void *)_origarg;
+from_timer(_handle, t, _timer);
... when != _origarg
|
... when != _origarg
_handletype *_handle;
... when != _handle
_handle =
-(_handletype *)_origarg;
+from_timer(_handle, t, _timer);
... when != _origarg
|
... when != _origarg
_handletype *_handle;
... when != _handle
_handle =
-(void *)_origarg;
+from_timer(_handle, t, _timer);
... when != _origarg
)
}
// callback(unsigned long arg) without existing variable
@change_callback_handle_cast_no_arg
depends on change_timer_function_usage &&
!change_callback_handle_cast@
identifier change_timer_function_usage._callback;
identifier change_timer_function_usage._timer;
type _origtype;
identifier _origarg;
type _handletype;
@@
void _callback(
-_origtype _origarg
+struct timer_list *t
)
{
+ _handletype *_origarg = from_timer(_origarg, t, _timer);
+
... when != _origarg
- (_handletype *)_origarg
+ _origarg
... when != _origarg
}
// Avoid already converted callbacks.
@match_callback_converted
depends on change_timer_function_usage &&
!change_callback_handle_cast &&
!change_callback_handle_cast_no_arg@
identifier change_timer_function_usage._callback;
identifier t;
@@
void _callback(struct timer_list *t)
{ ... }
// callback(struct something *handle)
@change_callback_handle_arg
depends on change_timer_function_usage &&
!match_callback_converted &&
!change_callback_handle_cast &&
!change_callback_handle_cast_no_arg@
identifier change_timer_function_usage._callback;
identifier change_timer_function_usage._timer;
type _handletype;
identifier _handle;
@@
void _callback(
-_handletype *_handle
+struct timer_list *t
)
{
+ _handletype *_handle = from_timer(_handle, t, _timer);
...
}
// If change_callback_handle_arg ran on an empty function, remove
// the added handler.
@unchange_callback_handle_arg
depends on change_timer_function_usage &&
change_callback_handle_arg@
identifier change_timer_function_usage._callback;
identifier change_timer_function_usage._timer;
type _handletype;
identifier _handle;
identifier t;
@@
void _callback(struct timer_list *t)
{
- _handletype *_handle = from_timer(_handle, t, _timer);
}
// We only want to refactor the setup_timer() data argument if we've found
// the matching callback. This undoes changes in change_timer_function_usage.
@unchange_timer_function_usage
depends on change_timer_function_usage &&
!change_callback_handle_cast &&
!change_callback_handle_cast_no_arg &&
!change_callback_handle_arg@
expression change_timer_function_usage._E;
identifier change_timer_function_usage._timer;
identifier change_timer_function_usage._callback;
type change_timer_function_usage._cast_data;
@@
(
-timer_setup(&_E->_timer, _callback, 0);
+setup_timer(&_E->_timer, _callback, (_cast_data)_E);
|
-timer_setup(&_E._timer, _callback, 0);
+setup_timer(&_E._timer, _callback, (_cast_data)&_E);
)
// If we fixed a callback from a .function assignment, fix the
// assignment cast now.
@change_timer_function_assignment
depends on change_timer_function_usage &&
(change_callback_handle_cast ||
change_callback_handle_cast_no_arg ||
change_callback_handle_arg)@
expression change_timer_function_usage._E;
identifier change_timer_function_usage._timer;
identifier change_timer_function_usage._callback;
type _cast_func;
typedef TIMER_FUNC_TYPE;
@@
(
_E->_timer.function =
-_callback
+(TIMER_FUNC_TYPE)_callback
;
|
_E->_timer.function =
-&_callback
+(TIMER_FUNC_TYPE)_callback
;
|
_E->_timer.function =
-(_cast_func)_callback;
+(TIMER_FUNC_TYPE)_callback
;
|
_E->_timer.function =
-(_cast_func)&_callback
+(TIMER_FUNC_TYPE)_callback
;
|
_E._timer.function =
-_callback
+(TIMER_FUNC_TYPE)_callback
;
|
_E._timer.function =
-&_callback;
+(TIMER_FUNC_TYPE)_callback
;
|
_E._timer.function =
-(_cast_func)_callback
+(TIMER_FUNC_TYPE)_callback
;
|
_E._timer.function =
-(_cast_func)&_callback
+(TIMER_FUNC_TYPE)_callback
;
)
// Sometimes timer functions are called directly. Replace matched args.
@change_timer_function_calls
depends on change_timer_function_usage &&
(change_callback_handle_cast ||
change_callback_handle_cast_no_arg ||
change_callback_handle_arg)@
expression _E;
identifier change_timer_function_usage._timer;
identifier change_timer_function_usage._callback;
type _cast_data;
@@
_callback(
(
-(_cast_data)_E
+&_E->_timer
|
-(_cast_data)&_E
+&_E._timer
|
-_E
+&_E->_timer
)
)
// If a timer has been configured without a data argument, it can be
// converted without regard to the callback argument, since it is unused.
@match_timer_function_unused_data@
expression _E;
identifier _timer;
identifier _callback;
@@
(
-setup_timer(&_E->_timer, _callback, 0);
+timer_setup(&_E->_timer, _callback, 0);
|
-setup_timer(&_E->_timer, _callback, 0L);
+timer_setup(&_E->_timer, _callback, 0);
|
-setup_timer(&_E->_timer, _callback, 0UL);
+timer_setup(&_E->_timer, _callback, 0);
|
-setup_timer(&_E._timer, _callback, 0);
+timer_setup(&_E._timer, _callback, 0);
|
-setup_timer(&_E._timer, _callback, 0L);
+timer_setup(&_E._timer, _callback, 0);
|
-setup_timer(&_E._timer, _callback, 0UL);
+timer_setup(&_E._timer, _callback, 0);
|
-setup_timer(&_timer, _callback, 0);
+timer_setup(&_timer, _callback, 0);
|
-setup_timer(&_timer, _callback, 0L);
+timer_setup(&_timer, _callback, 0);
|
-setup_timer(&_timer, _callback, 0UL);
+timer_setup(&_timer, _callback, 0);
|
-setup_timer(_timer, _callback, 0);
+timer_setup(_timer, _callback, 0);
|
-setup_timer(_timer, _callback, 0L);
+timer_setup(_timer, _callback, 0);
|
-setup_timer(_timer, _callback, 0UL);
+timer_setup(_timer, _callback, 0);
)
@change_callback_unused_data
depends on match_timer_function_unused_data@
identifier match_timer_function_unused_data._callback;
type _origtype;
identifier _origarg;
@@
void _callback(
-_origtype _origarg
+struct timer_list *unused
)
{
... when != _origarg
}
Signed-off-by: Kees Cook <keescook@chromium.org>
2017-10-17 05:43:17 +08:00
|
|
|
struct au0828_dev *dev = from_timer(dev, t, bulk_timeout);
|
2017-04-20 07:13:55 +08:00
|
|
|
|
|
|
|
dprintk(1, "%s called\n", __func__);
|
|
|
|
dev->bulk_timeout_running = 0;
|
|
|
|
schedule_work(&dev->restart_streaming);
|
|
|
|
}
|
|
|
|
|
2008-04-19 08:34:00 +08:00
|
|
|
/*-------------------------------------------------------------------*/
|
|
|
|
static void urb_completion(struct urb *purb)
|
|
|
|
{
|
|
|
|
struct au0828_dev *dev = purb->context;
|
|
|
|
int ptype = usb_pipetype(purb->pipe);
|
2012-08-07 09:46:53 +08:00
|
|
|
unsigned char *ptr;
|
2008-04-19 08:34:00 +08:00
|
|
|
|
2014-05-21 20:35:06 +08:00
|
|
|
dprintk(2, "%s: %d\n", __func__, purb->actual_length);
|
2008-04-19 08:39:11 +08:00
|
|
|
|
2014-05-21 20:35:06 +08:00
|
|
|
if (!dev) {
|
|
|
|
dprintk(2, "%s: no dev!\n", __func__);
|
2008-04-02 12:10:40 +08:00
|
|
|
return;
|
2014-05-21 20:35:06 +08:00
|
|
|
}
|
2008-04-02 12:10:40 +08:00
|
|
|
|
2014-08-10 10:14:21 +08:00
|
|
|
if (!dev->urb_streaming) {
|
2014-05-21 20:35:06 +08:00
|
|
|
dprintk(2, "%s: not streaming!\n", __func__);
|
2008-04-19 08:34:00 +08:00
|
|
|
return;
|
2014-05-21 20:35:06 +08:00
|
|
|
}
|
2008-04-19 08:34:00 +08:00
|
|
|
|
|
|
|
if (ptype != PIPE_BULK) {
|
2014-08-10 08:47:17 +08:00
|
|
|
pr_err("%s: Unsupported URB type %d\n",
|
2008-04-19 08:42:30 +08:00
|
|
|
__func__, ptype);
|
2008-04-19 08:34:00 +08:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2012-08-07 09:46:53 +08:00
|
|
|
/* See if the stream is corrupted (to work around a hardware
|
|
|
|
bug where the stream gets misaligned */
|
|
|
|
ptr = purb->transfer_buffer;
|
|
|
|
if (purb->actual_length > 0 && ptr[0] != 0x47) {
|
|
|
|
dprintk(1, "Need to restart streaming %02x len=%d!\n",
|
|
|
|
ptr[0], purb->actual_length);
|
|
|
|
schedule_work(&dev->restart_streaming);
|
|
|
|
return;
|
2017-04-20 07:13:55 +08:00
|
|
|
} else if (dev->bulk_timeout_running == 1) {
|
|
|
|
/* The URB handler has fired, so cancel timer which would
|
|
|
|
* restart endpoint if we hadn't
|
|
|
|
*/
|
|
|
|
dprintk(1, "%s cancelling bulk timeout\n", __func__);
|
|
|
|
dev->bulk_timeout_running = 0;
|
|
|
|
del_timer(&dev->bulk_timeout);
|
2012-08-07 09:46:53 +08:00
|
|
|
}
|
|
|
|
|
2008-04-19 08:34:00 +08:00
|
|
|
/* Feed the transport payload into the kernel demux */
|
2008-04-18 08:41:28 +08:00
|
|
|
dvb_dmx_swfilter_packets(&dev->dvb.demux,
|
|
|
|
purb->transfer_buffer, purb->actual_length / 188);
|
2008-04-19 08:34:00 +08:00
|
|
|
|
|
|
|
/* Clean the buffer before we requeue */
|
|
|
|
memset(purb->transfer_buffer, 0, URB_BUFSIZE);
|
|
|
|
|
|
|
|
/* Requeue URB */
|
|
|
|
usb_submit_urb(purb, GFP_ATOMIC);
|
|
|
|
}
|
|
|
|
|
|
|
|
static int stop_urb_transfer(struct au0828_dev *dev)
|
|
|
|
{
|
|
|
|
int i;
|
|
|
|
|
2008-04-19 08:42:30 +08:00
|
|
|
dprintk(2, "%s()\n", __func__);
|
2008-04-19 08:34:00 +08:00
|
|
|
|
2014-08-10 10:14:21 +08:00
|
|
|
if (!dev->urb_streaming)
|
|
|
|
return 0;
|
|
|
|
|
2017-04-20 07:13:55 +08:00
|
|
|
if (dev->bulk_timeout_running == 1) {
|
|
|
|
dev->bulk_timeout_running = 0;
|
|
|
|
del_timer(&dev->bulk_timeout);
|
|
|
|
}
|
|
|
|
|
2014-08-10 10:14:21 +08:00
|
|
|
dev->urb_streaming = false;
|
2008-04-19 08:34:00 +08:00
|
|
|
for (i = 0; i < URB_COUNT; i++) {
|
2014-01-07 12:29:24 +08:00
|
|
|
if (dev->urbs[i]) {
|
|
|
|
usb_kill_urb(dev->urbs[i]);
|
2014-01-07 12:29:25 +08:00
|
|
|
if (!preallocate_big_buffers)
|
|
|
|
kfree(dev->urbs[i]->transfer_buffer);
|
|
|
|
|
2014-01-07 12:29:24 +08:00
|
|
|
usb_free_urb(dev->urbs[i]);
|
|
|
|
}
|
2008-04-19 08:34:00 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
static int start_urb_transfer(struct au0828_dev *dev)
|
|
|
|
{
|
|
|
|
struct urb *purb;
|
2015-12-29 05:52:48 +08:00
|
|
|
int i, ret;
|
2008-04-19 08:34:00 +08:00
|
|
|
|
2008-04-19 08:42:30 +08:00
|
|
|
dprintk(2, "%s()\n", __func__);
|
2008-04-19 08:34:00 +08:00
|
|
|
|
|
|
|
if (dev->urb_streaming) {
|
2009-07-28 04:35:59 +08:00
|
|
|
dprintk(2, "%s: bulk xfer already running!\n", __func__);
|
2008-04-19 08:34:00 +08:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
for (i = 0; i < URB_COUNT; i++) {
|
|
|
|
|
|
|
|
dev->urbs[i] = usb_alloc_urb(0, GFP_KERNEL);
|
2008-04-19 09:12:52 +08:00
|
|
|
if (!dev->urbs[i])
|
2015-12-29 05:52:48 +08:00
|
|
|
return -ENOMEM;
|
2008-04-19 08:34:00 +08:00
|
|
|
|
|
|
|
purb = dev->urbs[i];
|
|
|
|
|
2014-01-07 12:29:25 +08:00
|
|
|
if (preallocate_big_buffers)
|
|
|
|
purb->transfer_buffer = dev->dig_transfer_buffer[i];
|
|
|
|
else
|
|
|
|
purb->transfer_buffer = kzalloc(URB_BUFSIZE,
|
|
|
|
GFP_KERNEL);
|
|
|
|
|
2008-04-19 08:34:00 +08:00
|
|
|
if (!purb->transfer_buffer) {
|
|
|
|
usb_free_urb(purb);
|
2008-04-29 07:50:03 +08:00
|
|
|
dev->urbs[i] = NULL;
|
2015-12-29 05:52:48 +08:00
|
|
|
ret = -ENOMEM;
|
2014-08-10 08:47:17 +08:00
|
|
|
pr_err("%s: failed big buffer allocation, err = %d\n",
|
2014-01-07 12:29:24 +08:00
|
|
|
__func__, ret);
|
2015-12-29 05:52:48 +08:00
|
|
|
return ret;
|
2008-04-19 08:34:00 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
purb->status = -EINPROGRESS;
|
|
|
|
usb_fill_bulk_urb(purb,
|
|
|
|
dev->usbdev,
|
2008-10-17 07:19:41 +08:00
|
|
|
usb_rcvbulkpipe(dev->usbdev,
|
|
|
|
_AU0828_BULKPIPE),
|
2008-04-19 08:34:00 +08:00
|
|
|
purb->transfer_buffer,
|
|
|
|
URB_BUFSIZE,
|
|
|
|
urb_completion,
|
|
|
|
dev);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
for (i = 0; i < URB_COUNT; i++) {
|
|
|
|
ret = usb_submit_urb(dev->urbs[i], GFP_ATOMIC);
|
|
|
|
if (ret != 0) {
|
|
|
|
stop_urb_transfer(dev);
|
2014-08-10 08:47:17 +08:00
|
|
|
pr_err("%s: failed urb submission, err = %d\n",
|
|
|
|
__func__, ret);
|
2008-04-19 08:34:00 +08:00
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2014-08-10 10:14:21 +08:00
|
|
|
dev->urb_streaming = true;
|
2017-04-20 07:13:55 +08:00
|
|
|
|
|
|
|
/* If we don't valid data within 1 second, restart stream */
|
|
|
|
mod_timer(&dev->bulk_timeout, jiffies + (HZ));
|
|
|
|
dev->bulk_timeout_running = 1;
|
|
|
|
|
2015-12-29 05:52:48 +08:00
|
|
|
return 0;
|
2008-04-19 08:34:00 +08:00
|
|
|
}
|
|
|
|
|
2014-01-07 12:29:24 +08:00
|
|
|
static void au0828_start_transport(struct au0828_dev *dev)
|
|
|
|
{
|
|
|
|
au0828_write(dev, 0x608, 0x90);
|
|
|
|
au0828_write(dev, 0x609, 0x72);
|
|
|
|
au0828_write(dev, 0x60a, 0x71);
|
|
|
|
au0828_write(dev, 0x60b, 0x01);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
static void au0828_stop_transport(struct au0828_dev *dev, int full_stop)
|
|
|
|
{
|
|
|
|
if (full_stop) {
|
|
|
|
au0828_write(dev, 0x608, 0x00);
|
|
|
|
au0828_write(dev, 0x609, 0x00);
|
|
|
|
au0828_write(dev, 0x60a, 0x00);
|
|
|
|
}
|
|
|
|
au0828_write(dev, 0x60b, 0x00);
|
|
|
|
}
|
|
|
|
|
2008-04-19 08:34:00 +08:00
|
|
|
static int au0828_dvb_start_feed(struct dvb_demux_feed *feed)
|
|
|
|
{
|
|
|
|
struct dvb_demux *demux = feed->demux;
|
|
|
|
struct au0828_dev *dev = (struct au0828_dev *) demux->priv;
|
|
|
|
struct au0828_dvb *dvb = &dev->dvb;
|
|
|
|
int ret = 0;
|
|
|
|
|
2008-04-19 08:42:30 +08:00
|
|
|
dprintk(1, "%s()\n", __func__);
|
2008-04-19 08:34:00 +08:00
|
|
|
|
|
|
|
if (!demux->dmx.frontend)
|
|
|
|
return -EINVAL;
|
|
|
|
|
2014-08-10 10:14:20 +08:00
|
|
|
if (dvb->frontend) {
|
2008-04-19 08:34:00 +08:00
|
|
|
mutex_lock(&dvb->lock);
|
2014-01-07 12:29:24 +08:00
|
|
|
dvb->start_count++;
|
|
|
|
dprintk(1, "%s(), start_count: %d, stop_count: %d\n", __func__,
|
|
|
|
dvb->start_count, dvb->stop_count);
|
2008-04-19 08:34:00 +08:00
|
|
|
if (dvb->feeding++ == 0) {
|
2008-04-19 08:39:11 +08:00
|
|
|
/* Start transport */
|
2014-01-07 12:29:24 +08:00
|
|
|
au0828_start_transport(dev);
|
2008-04-19 08:34:00 +08:00
|
|
|
ret = start_urb_transfer(dev);
|
2014-01-07 12:29:24 +08:00
|
|
|
if (ret < 0) {
|
|
|
|
au0828_stop_transport(dev, 0);
|
|
|
|
dvb->feeding--; /* We ran out of memory... */
|
|
|
|
}
|
2008-04-19 08:34:00 +08:00
|
|
|
}
|
|
|
|
mutex_unlock(&dvb->lock);
|
|
|
|
}
|
|
|
|
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
|
|
|
static int au0828_dvb_stop_feed(struct dvb_demux_feed *feed)
|
|
|
|
{
|
|
|
|
struct dvb_demux *demux = feed->demux;
|
|
|
|
struct au0828_dev *dev = (struct au0828_dev *) demux->priv;
|
|
|
|
struct au0828_dvb *dvb = &dev->dvb;
|
|
|
|
int ret = 0;
|
|
|
|
|
2008-04-19 08:42:30 +08:00
|
|
|
dprintk(1, "%s()\n", __func__);
|
2008-04-19 08:34:00 +08:00
|
|
|
|
2014-08-10 10:14:20 +08:00
|
|
|
if (dvb->frontend) {
|
[media] au0828: reset streaming when a new frequency is set
As reported by Trevor, doing several opening/streaming/closing
operations to the demux causes it to fail.
I was able to simulate this bug too. I also noticed that,
sometimes, changing channels with au0828, the same thing
happens.
Most of the issues seem to be due to some hardware bug, that
causes the device to not fill all the URBs allocated. When
the bug happens, the only known fix is to either replug the
device, or to send an USB reset to it.
There's also a hack a the au0828 driver that starts a thread
that tries to reset the device when a package doesn't start
with a sync.
One of the culpits for this bad hardware behavior seem to be
caused by the lack of stopping and restarting the stream every
time a new channel is set.
This patch warrants that the stream will be properly reset
every time the set_frontend callback is called, partially
solving the problem.
A complete fix, however, would also need to check the PM
conditions for the tuner and demux.
Reported-by: Trevor Graffa <tlgraffa@gmail.com>
Signed-off-by: Mauro Carvalho Chehab <m.chehab@samsung.com>
2014-05-09 17:17:55 +08:00
|
|
|
cancel_work_sync(&dev->restart_streaming);
|
|
|
|
|
2008-04-19 08:34:00 +08:00
|
|
|
mutex_lock(&dvb->lock);
|
2014-01-07 12:29:24 +08:00
|
|
|
dvb->stop_count++;
|
|
|
|
dprintk(1, "%s(), start_count: %d, stop_count: %d\n", __func__,
|
|
|
|
dvb->start_count, dvb->stop_count);
|
|
|
|
if (dvb->feeding > 0) {
|
|
|
|
dvb->feeding--;
|
|
|
|
if (dvb->feeding == 0) {
|
|
|
|
/* Stop transport */
|
|
|
|
ret = stop_urb_transfer(dev);
|
|
|
|
au0828_stop_transport(dev, 0);
|
|
|
|
}
|
2008-04-19 08:34:00 +08:00
|
|
|
}
|
|
|
|
mutex_unlock(&dvb->lock);
|
|
|
|
}
|
|
|
|
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
2012-08-07 09:46:53 +08:00
|
|
|
static void au0828_restart_dvb_streaming(struct work_struct *work)
|
|
|
|
{
|
|
|
|
struct au0828_dev *dev = container_of(work, struct au0828_dev,
|
|
|
|
restart_streaming);
|
|
|
|
struct au0828_dvb *dvb = &dev->dvb;
|
|
|
|
|
2014-08-10 10:14:21 +08:00
|
|
|
if (!dev->urb_streaming)
|
2012-08-07 09:46:53 +08:00
|
|
|
return;
|
|
|
|
|
|
|
|
dprintk(1, "Restarting streaming...!\n");
|
|
|
|
|
|
|
|
mutex_lock(&dvb->lock);
|
|
|
|
|
|
|
|
/* Stop transport */
|
2012-10-28 03:36:34 +08:00
|
|
|
stop_urb_transfer(dev);
|
2014-01-07 12:29:24 +08:00
|
|
|
au0828_stop_transport(dev, 1);
|
2012-08-07 09:46:53 +08:00
|
|
|
|
|
|
|
/* Start transport */
|
2014-01-07 12:29:24 +08:00
|
|
|
au0828_start_transport(dev);
|
2012-10-28 03:36:34 +08:00
|
|
|
start_urb_transfer(dev);
|
2012-08-07 09:46:53 +08:00
|
|
|
|
|
|
|
mutex_unlock(&dvb->lock);
|
|
|
|
}
|
|
|
|
|
[media] au0828: reset streaming when a new frequency is set
As reported by Trevor, doing several opening/streaming/closing
operations to the demux causes it to fail.
I was able to simulate this bug too. I also noticed that,
sometimes, changing channels with au0828, the same thing
happens.
Most of the issues seem to be due to some hardware bug, that
causes the device to not fill all the URBs allocated. When
the bug happens, the only known fix is to either replug the
device, or to send an USB reset to it.
There's also a hack a the au0828 driver that starts a thread
that tries to reset the device when a package doesn't start
with a sync.
One of the culpits for this bad hardware behavior seem to be
caused by the lack of stopping and restarting the stream every
time a new channel is set.
This patch warrants that the stream will be properly reset
every time the set_frontend callback is called, partially
solving the problem.
A complete fix, however, would also need to check the PM
conditions for the tuner and demux.
Reported-by: Trevor Graffa <tlgraffa@gmail.com>
Signed-off-by: Mauro Carvalho Chehab <m.chehab@samsung.com>
2014-05-09 17:17:55 +08:00
|
|
|
static int au0828_set_frontend(struct dvb_frontend *fe)
|
|
|
|
{
|
|
|
|
struct au0828_dev *dev = fe->dvb->priv;
|
|
|
|
struct au0828_dvb *dvb = &dev->dvb;
|
|
|
|
int ret, was_streaming;
|
|
|
|
|
|
|
|
mutex_lock(&dvb->lock);
|
|
|
|
was_streaming = dev->urb_streaming;
|
|
|
|
if (was_streaming) {
|
|
|
|
au0828_stop_transport(dev, 1);
|
|
|
|
|
|
|
|
/*
|
|
|
|
* We can't hold a mutex here, as the restart_streaming
|
|
|
|
* kthread may also hold it.
|
|
|
|
*/
|
|
|
|
mutex_unlock(&dvb->lock);
|
|
|
|
cancel_work_sync(&dev->restart_streaming);
|
|
|
|
mutex_lock(&dvb->lock);
|
|
|
|
|
|
|
|
stop_urb_transfer(dev);
|
|
|
|
}
|
|
|
|
mutex_unlock(&dvb->lock);
|
|
|
|
|
|
|
|
ret = dvb->set_frontend(fe);
|
|
|
|
|
|
|
|
if (was_streaming) {
|
|
|
|
mutex_lock(&dvb->lock);
|
|
|
|
au0828_start_transport(dev);
|
|
|
|
start_urb_transfer(dev);
|
|
|
|
mutex_unlock(&dvb->lock);
|
|
|
|
}
|
|
|
|
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
2008-04-26 06:06:03 +08:00
|
|
|
static int dvb_register(struct au0828_dev *dev)
|
2008-04-19 08:34:00 +08:00
|
|
|
{
|
|
|
|
struct au0828_dvb *dvb = &dev->dvb;
|
|
|
|
int result;
|
|
|
|
|
2008-04-19 08:42:30 +08:00
|
|
|
dprintk(1, "%s()\n", __func__);
|
2008-04-19 08:39:11 +08:00
|
|
|
|
2014-01-07 12:29:25 +08:00
|
|
|
if (preallocate_big_buffers) {
|
|
|
|
int i;
|
|
|
|
for (i = 0; i < URB_COUNT; i++) {
|
|
|
|
dev->dig_transfer_buffer[i] = kzalloc(URB_BUFSIZE,
|
|
|
|
GFP_KERNEL);
|
|
|
|
|
|
|
|
if (!dev->dig_transfer_buffer[i]) {
|
|
|
|
result = -ENOMEM;
|
|
|
|
|
2014-08-10 08:47:17 +08:00
|
|
|
pr_err("failed buffer allocation (errno = %d)\n",
|
|
|
|
result);
|
2014-01-07 12:29:25 +08:00
|
|
|
goto fail_adapter;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2012-08-07 09:46:53 +08:00
|
|
|
INIT_WORK(&dev->restart_streaming, au0828_restart_dvb_streaming);
|
|
|
|
|
2008-04-19 08:34:00 +08:00
|
|
|
/* register adapter */
|
2014-08-10 08:47:17 +08:00
|
|
|
result = dvb_register_adapter(&dvb->adapter,
|
|
|
|
KBUILD_MODNAME, THIS_MODULE,
|
2008-04-19 08:34:00 +08:00
|
|
|
&dev->usbdev->dev, adapter_nr);
|
|
|
|
if (result < 0) {
|
2014-08-10 08:47:17 +08:00
|
|
|
pr_err("dvb_register_adapter failed (errno = %d)\n",
|
|
|
|
result);
|
2008-04-19 08:34:00 +08:00
|
|
|
goto fail_adapter;
|
|
|
|
}
|
2015-06-09 09:20:46 +08:00
|
|
|
|
|
|
|
#ifdef CONFIG_MEDIA_CONTROLLER_DVB
|
|
|
|
dvb->adapter.mdev = dev->media_dev;
|
|
|
|
#endif
|
|
|
|
|
2008-04-19 08:34:00 +08:00
|
|
|
dvb->adapter.priv = dev;
|
|
|
|
|
|
|
|
/* register frontend */
|
|
|
|
result = dvb_register_frontend(&dvb->adapter, dvb->frontend);
|
|
|
|
if (result < 0) {
|
2014-08-10 08:47:17 +08:00
|
|
|
pr_err("dvb_register_frontend failed (errno = %d)\n",
|
|
|
|
result);
|
2008-04-19 08:34:00 +08:00
|
|
|
goto fail_frontend;
|
|
|
|
}
|
|
|
|
|
[media] au0828: reset streaming when a new frequency is set
As reported by Trevor, doing several opening/streaming/closing
operations to the demux causes it to fail.
I was able to simulate this bug too. I also noticed that,
sometimes, changing channels with au0828, the same thing
happens.
Most of the issues seem to be due to some hardware bug, that
causes the device to not fill all the URBs allocated. When
the bug happens, the only known fix is to either replug the
device, or to send an USB reset to it.
There's also a hack a the au0828 driver that starts a thread
that tries to reset the device when a package doesn't start
with a sync.
One of the culpits for this bad hardware behavior seem to be
caused by the lack of stopping and restarting the stream every
time a new channel is set.
This patch warrants that the stream will be properly reset
every time the set_frontend callback is called, partially
solving the problem.
A complete fix, however, would also need to check the PM
conditions for the tuner and demux.
Reported-by: Trevor Graffa <tlgraffa@gmail.com>
Signed-off-by: Mauro Carvalho Chehab <m.chehab@samsung.com>
2014-05-09 17:17:55 +08:00
|
|
|
/* Hook dvb frontend */
|
|
|
|
dvb->set_frontend = dvb->frontend->ops.set_frontend;
|
|
|
|
dvb->frontend->ops.set_frontend = au0828_set_frontend;
|
|
|
|
|
2008-04-19 08:34:00 +08:00
|
|
|
/* register demux stuff */
|
|
|
|
dvb->demux.dmx.capabilities =
|
|
|
|
DMX_TS_FILTERING | DMX_SECTION_FILTERING |
|
|
|
|
DMX_MEMORY_BASED_FILTERING;
|
|
|
|
dvb->demux.priv = dev;
|
|
|
|
dvb->demux.filternum = 256;
|
|
|
|
dvb->demux.feednum = 256;
|
|
|
|
dvb->demux.start_feed = au0828_dvb_start_feed;
|
|
|
|
dvb->demux.stop_feed = au0828_dvb_stop_feed;
|
|
|
|
result = dvb_dmx_init(&dvb->demux);
|
|
|
|
if (result < 0) {
|
2014-08-10 08:47:17 +08:00
|
|
|
pr_err("dvb_dmx_init failed (errno = %d)\n", result);
|
2008-04-19 08:34:00 +08:00
|
|
|
goto fail_dmx;
|
|
|
|
}
|
|
|
|
|
|
|
|
dvb->dmxdev.filternum = 256;
|
|
|
|
dvb->dmxdev.demux = &dvb->demux.dmx;
|
|
|
|
dvb->dmxdev.capabilities = 0;
|
|
|
|
result = dvb_dmxdev_init(&dvb->dmxdev, &dvb->adapter);
|
|
|
|
if (result < 0) {
|
2014-08-10 08:47:17 +08:00
|
|
|
pr_err("dvb_dmxdev_init failed (errno = %d)\n", result);
|
2008-04-19 08:34:00 +08:00
|
|
|
goto fail_dmxdev;
|
|
|
|
}
|
|
|
|
|
|
|
|
dvb->fe_hw.source = DMX_FRONTEND_0;
|
|
|
|
result = dvb->demux.dmx.add_frontend(&dvb->demux.dmx, &dvb->fe_hw);
|
|
|
|
if (result < 0) {
|
2014-08-10 08:47:17 +08:00
|
|
|
pr_err("add_frontend failed (DMX_FRONTEND_0, errno = %d)\n",
|
|
|
|
result);
|
2008-04-19 08:34:00 +08:00
|
|
|
goto fail_fe_hw;
|
|
|
|
}
|
|
|
|
|
|
|
|
dvb->fe_mem.source = DMX_MEMORY_FE;
|
|
|
|
result = dvb->demux.dmx.add_frontend(&dvb->demux.dmx, &dvb->fe_mem);
|
|
|
|
if (result < 0) {
|
2014-08-10 08:47:17 +08:00
|
|
|
pr_err("add_frontend failed (DMX_MEMORY_FE, errno = %d)\n",
|
|
|
|
result);
|
2008-04-19 08:34:00 +08:00
|
|
|
goto fail_fe_mem;
|
|
|
|
}
|
|
|
|
|
|
|
|
result = dvb->demux.dmx.connect_frontend(&dvb->demux.dmx, &dvb->fe_hw);
|
|
|
|
if (result < 0) {
|
2014-08-10 08:47:17 +08:00
|
|
|
pr_err("connect_frontend failed (errno = %d)\n", result);
|
2008-04-19 08:34:00 +08:00
|
|
|
goto fail_fe_conn;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* register network adapter */
|
|
|
|
dvb_net_init(&dvb->adapter, &dvb->net, &dvb->demux.dmx);
|
2014-01-07 12:29:24 +08:00
|
|
|
|
|
|
|
dvb->start_count = 0;
|
|
|
|
dvb->stop_count = 0;
|
2015-06-09 09:20:46 +08:00
|
|
|
|
2015-12-29 21:52:23 +08:00
|
|
|
result = dvb_create_media_graph(&dvb->adapter, false);
|
2015-09-05 02:33:46 +08:00
|
|
|
if (result < 0)
|
|
|
|
goto fail_create_graph;
|
2015-06-09 09:20:46 +08:00
|
|
|
|
2008-04-19 08:34:00 +08:00
|
|
|
return 0;
|
|
|
|
|
2015-09-05 02:33:46 +08:00
|
|
|
fail_create_graph:
|
|
|
|
dvb_net_release(&dvb->net);
|
2008-04-19 08:34:00 +08:00
|
|
|
fail_fe_conn:
|
|
|
|
dvb->demux.dmx.remove_frontend(&dvb->demux.dmx, &dvb->fe_mem);
|
|
|
|
fail_fe_mem:
|
|
|
|
dvb->demux.dmx.remove_frontend(&dvb->demux.dmx, &dvb->fe_hw);
|
|
|
|
fail_fe_hw:
|
|
|
|
dvb_dmxdev_release(&dvb->dmxdev);
|
|
|
|
fail_dmxdev:
|
|
|
|
dvb_dmx_release(&dvb->demux);
|
|
|
|
fail_dmx:
|
|
|
|
dvb_unregister_frontend(dvb->frontend);
|
|
|
|
fail_frontend:
|
|
|
|
dvb_frontend_detach(dvb->frontend);
|
|
|
|
dvb_unregister_adapter(&dvb->adapter);
|
|
|
|
fail_adapter:
|
2014-01-07 12:29:25 +08:00
|
|
|
|
|
|
|
if (preallocate_big_buffers) {
|
|
|
|
int i;
|
|
|
|
for (i = 0; i < URB_COUNT; i++)
|
|
|
|
kfree(dev->dig_transfer_buffer[i]);
|
|
|
|
}
|
|
|
|
|
2008-04-19 08:34:00 +08:00
|
|
|
return result;
|
|
|
|
}
|
|
|
|
|
|
|
|
void au0828_dvb_unregister(struct au0828_dev *dev)
|
|
|
|
{
|
|
|
|
struct au0828_dvb *dvb = &dev->dvb;
|
|
|
|
|
2008-04-19 08:42:30 +08:00
|
|
|
dprintk(1, "%s()\n", __func__);
|
2008-04-19 08:39:11 +08:00
|
|
|
|
2008-04-18 08:41:28 +08:00
|
|
|
if (dvb->frontend == NULL)
|
2008-04-02 12:10:40 +08:00
|
|
|
return;
|
|
|
|
|
2014-05-09 12:54:11 +08:00
|
|
|
cancel_work_sync(&dev->restart_streaming);
|
|
|
|
|
2008-04-19 08:34:00 +08:00
|
|
|
dvb_net_release(&dvb->net);
|
|
|
|
dvb->demux.dmx.remove_frontend(&dvb->demux.dmx, &dvb->fe_mem);
|
|
|
|
dvb->demux.dmx.remove_frontend(&dvb->demux.dmx, &dvb->fe_hw);
|
|
|
|
dvb_dmxdev_release(&dvb->dmxdev);
|
|
|
|
dvb_dmx_release(&dvb->demux);
|
|
|
|
dvb_unregister_frontend(dvb->frontend);
|
|
|
|
dvb_frontend_detach(dvb->frontend);
|
|
|
|
dvb_unregister_adapter(&dvb->adapter);
|
2014-01-07 12:29:25 +08:00
|
|
|
|
|
|
|
if (preallocate_big_buffers) {
|
|
|
|
int i;
|
|
|
|
for (i = 0; i < URB_COUNT; i++)
|
|
|
|
kfree(dev->dig_transfer_buffer[i]);
|
|
|
|
}
|
2014-08-10 10:14:20 +08:00
|
|
|
dvb->frontend = NULL;
|
2008-04-19 08:34:00 +08:00
|
|
|
}
|
|
|
|
|
2019-03-01 23:01:58 +08:00
|
|
|
/* All the DVB attach calls go here, this function gets modified
|
2008-04-19 08:34:00 +08:00
|
|
|
* for each new card. No other function in this file needs
|
|
|
|
* to change.
|
|
|
|
*/
|
|
|
|
int au0828_dvb_register(struct au0828_dev *dev)
|
|
|
|
{
|
|
|
|
struct au0828_dvb *dvb = &dev->dvb;
|
|
|
|
int ret;
|
|
|
|
|
2008-04-19 08:42:30 +08:00
|
|
|
dprintk(1, "%s()\n", __func__);
|
2008-04-19 08:39:11 +08:00
|
|
|
|
2008-04-19 08:34:00 +08:00
|
|
|
/* init frontend */
|
2009-03-11 14:00:47 +08:00
|
|
|
switch (dev->boardnr) {
|
2008-04-19 08:34:00 +08:00
|
|
|
case AU0828_BOARD_HAUPPAUGE_HVR850:
|
|
|
|
case AU0828_BOARD_HAUPPAUGE_HVR950Q:
|
|
|
|
dvb->frontend = dvb_attach(au8522_attach,
|
|
|
|
&hauppauge_hvr950q_config,
|
|
|
|
&dev->i2c_adap);
|
2008-05-11 01:34:09 +08:00
|
|
|
if (dvb->frontend != NULL)
|
2012-04-09 08:39:56 +08:00
|
|
|
switch (dev->board.tuner_type) {
|
|
|
|
default:
|
|
|
|
case TUNER_XC5000:
|
|
|
|
dvb_attach(xc5000_attach, dvb->frontend,
|
|
|
|
&dev->i2c_adap,
|
|
|
|
&hauppauge_xc5000a_config);
|
|
|
|
break;
|
|
|
|
case TUNER_XC5000C:
|
|
|
|
dvb_attach(xc5000_attach, dvb->frontend,
|
|
|
|
&dev->i2c_adap,
|
|
|
|
&hauppauge_xc5000c_config);
|
|
|
|
break;
|
|
|
|
}
|
2008-04-19 08:34:00 +08:00
|
|
|
break;
|
2008-07-09 11:23:08 +08:00
|
|
|
case AU0828_BOARD_HAUPPAUGE_HVR950Q_MXL:
|
|
|
|
dvb->frontend = dvb_attach(au8522_attach,
|
|
|
|
&hauppauge_hvr950q_config,
|
|
|
|
&dev->i2c_adap);
|
|
|
|
if (dvb->frontend != NULL)
|
|
|
|
dvb_attach(mxl5007t_attach, dvb->frontend,
|
|
|
|
&dev->i2c_adap, 0x60,
|
|
|
|
&mxl5007t_hvr950q_config);
|
|
|
|
break;
|
2008-09-04 03:46:36 +08:00
|
|
|
case AU0828_BOARD_HAUPPAUGE_WOODBURY:
|
|
|
|
dvb->frontend = dvb_attach(au8522_attach,
|
|
|
|
&hauppauge_woodbury_config,
|
|
|
|
&dev->i2c_adap);
|
|
|
|
if (dvb->frontend != NULL)
|
|
|
|
dvb_attach(tda18271_attach, dvb->frontend,
|
|
|
|
0x60, &dev->i2c_adap,
|
|
|
|
&hauppauge_woodbury_tunerconfig);
|
|
|
|
break;
|
2008-04-06 07:55:14 +08:00
|
|
|
case AU0828_BOARD_DVICO_FUSIONHDTV7:
|
|
|
|
dvb->frontend = dvb_attach(au8522_attach,
|
|
|
|
&fusionhdtv7usb_config,
|
|
|
|
&dev->i2c_adap);
|
|
|
|
if (dvb->frontend != NULL) {
|
|
|
|
dvb_attach(xc5000_attach, dvb->frontend,
|
|
|
|
&dev->i2c_adap,
|
2012-04-09 08:39:56 +08:00
|
|
|
&hauppauge_xc5000a_config);
|
2008-04-06 07:55:14 +08:00
|
|
|
}
|
|
|
|
break;
|
2008-04-19 08:34:00 +08:00
|
|
|
default:
|
2014-08-10 08:47:17 +08:00
|
|
|
pr_warn("The frontend of your DVB/ATSC card isn't supported yet\n");
|
2008-04-19 08:34:00 +08:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
if (NULL == dvb->frontend) {
|
2014-08-10 08:47:17 +08:00
|
|
|
pr_err("%s() Frontend initialization failed\n",
|
2008-04-19 08:42:30 +08:00
|
|
|
__func__);
|
2008-04-19 08:34:00 +08:00
|
|
|
return -1;
|
|
|
|
}
|
2008-09-13 00:31:45 +08:00
|
|
|
/* define general-purpose callback pointer */
|
|
|
|
dvb->frontend->callback = au0828_tuner_callback;
|
2008-04-19 08:34:00 +08:00
|
|
|
|
|
|
|
/* register everything */
|
|
|
|
ret = dvb_register(dev);
|
|
|
|
if (ret < 0) {
|
|
|
|
if (dvb->frontend->ops.release)
|
|
|
|
dvb->frontend->ops.release(dvb->frontend);
|
2014-08-10 10:14:20 +08:00
|
|
|
dvb->frontend = NULL;
|
2008-04-19 08:34:00 +08:00
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
treewide: setup_timer() -> timer_setup()
This converts all remaining cases of the old setup_timer() API into using
timer_setup(), where the callback argument is the structure already
holding the struct timer_list. These should have no behavioral changes,
since they just change which pointer is passed into the callback with
the same available pointers after conversion. It handles the following
examples, in addition to some other variations.
Casting from unsigned long:
void my_callback(unsigned long data)
{
struct something *ptr = (struct something *)data;
...
}
...
setup_timer(&ptr->my_timer, my_callback, ptr);
and forced object casts:
void my_callback(struct something *ptr)
{
...
}
...
setup_timer(&ptr->my_timer, my_callback, (unsigned long)ptr);
become:
void my_callback(struct timer_list *t)
{
struct something *ptr = from_timer(ptr, t, my_timer);
...
}
...
timer_setup(&ptr->my_timer, my_callback, 0);
Direct function assignments:
void my_callback(unsigned long data)
{
struct something *ptr = (struct something *)data;
...
}
...
ptr->my_timer.function = my_callback;
have a temporary cast added, along with converting the args:
void my_callback(struct timer_list *t)
{
struct something *ptr = from_timer(ptr, t, my_timer);
...
}
...
ptr->my_timer.function = (TIMER_FUNC_TYPE)my_callback;
And finally, callbacks without a data assignment:
void my_callback(unsigned long data)
{
...
}
...
setup_timer(&ptr->my_timer, my_callback, 0);
have their argument renamed to verify they're unused during conversion:
void my_callback(struct timer_list *unused)
{
...
}
...
timer_setup(&ptr->my_timer, my_callback, 0);
The conversion is done with the following Coccinelle script:
spatch --very-quiet --all-includes --include-headers \
-I ./arch/x86/include -I ./arch/x86/include/generated \
-I ./include -I ./arch/x86/include/uapi \
-I ./arch/x86/include/generated/uapi -I ./include/uapi \
-I ./include/generated/uapi --include ./include/linux/kconfig.h \
--dir . \
--cocci-file ~/src/data/timer_setup.cocci
@fix_address_of@
expression e;
@@
setup_timer(
-&(e)
+&e
, ...)
// Update any raw setup_timer() usages that have a NULL callback, but
// would otherwise match change_timer_function_usage, since the latter
// will update all function assignments done in the face of a NULL
// function initialization in setup_timer().
@change_timer_function_usage_NULL@
expression _E;
identifier _timer;
type _cast_data;
@@
(
-setup_timer(&_E->_timer, NULL, _E);
+timer_setup(&_E->_timer, NULL, 0);
|
-setup_timer(&_E->_timer, NULL, (_cast_data)_E);
+timer_setup(&_E->_timer, NULL, 0);
|
-setup_timer(&_E._timer, NULL, &_E);
+timer_setup(&_E._timer, NULL, 0);
|
-setup_timer(&_E._timer, NULL, (_cast_data)&_E);
+timer_setup(&_E._timer, NULL, 0);
)
@change_timer_function_usage@
expression _E;
identifier _timer;
struct timer_list _stl;
identifier _callback;
type _cast_func, _cast_data;
@@
(
-setup_timer(&_E->_timer, _callback, _E);
+timer_setup(&_E->_timer, _callback, 0);
|
-setup_timer(&_E->_timer, &_callback, _E);
+timer_setup(&_E->_timer, _callback, 0);
|
-setup_timer(&_E->_timer, _callback, (_cast_data)_E);
+timer_setup(&_E->_timer, _callback, 0);
|
-setup_timer(&_E->_timer, &_callback, (_cast_data)_E);
+timer_setup(&_E->_timer, _callback, 0);
|
-setup_timer(&_E->_timer, (_cast_func)_callback, _E);
+timer_setup(&_E->_timer, _callback, 0);
|
-setup_timer(&_E->_timer, (_cast_func)&_callback, _E);
+timer_setup(&_E->_timer, _callback, 0);
|
-setup_timer(&_E->_timer, (_cast_func)_callback, (_cast_data)_E);
+timer_setup(&_E->_timer, _callback, 0);
|
-setup_timer(&_E->_timer, (_cast_func)&_callback, (_cast_data)_E);
+timer_setup(&_E->_timer, _callback, 0);
|
-setup_timer(&_E._timer, _callback, (_cast_data)_E);
+timer_setup(&_E._timer, _callback, 0);
|
-setup_timer(&_E._timer, _callback, (_cast_data)&_E);
+timer_setup(&_E._timer, _callback, 0);
|
-setup_timer(&_E._timer, &_callback, (_cast_data)_E);
+timer_setup(&_E._timer, _callback, 0);
|
-setup_timer(&_E._timer, &_callback, (_cast_data)&_E);
+timer_setup(&_E._timer, _callback, 0);
|
-setup_timer(&_E._timer, (_cast_func)_callback, (_cast_data)_E);
+timer_setup(&_E._timer, _callback, 0);
|
-setup_timer(&_E._timer, (_cast_func)_callback, (_cast_data)&_E);
+timer_setup(&_E._timer, _callback, 0);
|
-setup_timer(&_E._timer, (_cast_func)&_callback, (_cast_data)_E);
+timer_setup(&_E._timer, _callback, 0);
|
-setup_timer(&_E._timer, (_cast_func)&_callback, (_cast_data)&_E);
+timer_setup(&_E._timer, _callback, 0);
|
_E->_timer@_stl.function = _callback;
|
_E->_timer@_stl.function = &_callback;
|
_E->_timer@_stl.function = (_cast_func)_callback;
|
_E->_timer@_stl.function = (_cast_func)&_callback;
|
_E._timer@_stl.function = _callback;
|
_E._timer@_stl.function = &_callback;
|
_E._timer@_stl.function = (_cast_func)_callback;
|
_E._timer@_stl.function = (_cast_func)&_callback;
)
// callback(unsigned long arg)
@change_callback_handle_cast
depends on change_timer_function_usage@
identifier change_timer_function_usage._callback;
identifier change_timer_function_usage._timer;
type _origtype;
identifier _origarg;
type _handletype;
identifier _handle;
@@
void _callback(
-_origtype _origarg
+struct timer_list *t
)
{
(
... when != _origarg
_handletype *_handle =
-(_handletype *)_origarg;
+from_timer(_handle, t, _timer);
... when != _origarg
|
... when != _origarg
_handletype *_handle =
-(void *)_origarg;
+from_timer(_handle, t, _timer);
... when != _origarg
|
... when != _origarg
_handletype *_handle;
... when != _handle
_handle =
-(_handletype *)_origarg;
+from_timer(_handle, t, _timer);
... when != _origarg
|
... when != _origarg
_handletype *_handle;
... when != _handle
_handle =
-(void *)_origarg;
+from_timer(_handle, t, _timer);
... when != _origarg
)
}
// callback(unsigned long arg) without existing variable
@change_callback_handle_cast_no_arg
depends on change_timer_function_usage &&
!change_callback_handle_cast@
identifier change_timer_function_usage._callback;
identifier change_timer_function_usage._timer;
type _origtype;
identifier _origarg;
type _handletype;
@@
void _callback(
-_origtype _origarg
+struct timer_list *t
)
{
+ _handletype *_origarg = from_timer(_origarg, t, _timer);
+
... when != _origarg
- (_handletype *)_origarg
+ _origarg
... when != _origarg
}
// Avoid already converted callbacks.
@match_callback_converted
depends on change_timer_function_usage &&
!change_callback_handle_cast &&
!change_callback_handle_cast_no_arg@
identifier change_timer_function_usage._callback;
identifier t;
@@
void _callback(struct timer_list *t)
{ ... }
// callback(struct something *handle)
@change_callback_handle_arg
depends on change_timer_function_usage &&
!match_callback_converted &&
!change_callback_handle_cast &&
!change_callback_handle_cast_no_arg@
identifier change_timer_function_usage._callback;
identifier change_timer_function_usage._timer;
type _handletype;
identifier _handle;
@@
void _callback(
-_handletype *_handle
+struct timer_list *t
)
{
+ _handletype *_handle = from_timer(_handle, t, _timer);
...
}
// If change_callback_handle_arg ran on an empty function, remove
// the added handler.
@unchange_callback_handle_arg
depends on change_timer_function_usage &&
change_callback_handle_arg@
identifier change_timer_function_usage._callback;
identifier change_timer_function_usage._timer;
type _handletype;
identifier _handle;
identifier t;
@@
void _callback(struct timer_list *t)
{
- _handletype *_handle = from_timer(_handle, t, _timer);
}
// We only want to refactor the setup_timer() data argument if we've found
// the matching callback. This undoes changes in change_timer_function_usage.
@unchange_timer_function_usage
depends on change_timer_function_usage &&
!change_callback_handle_cast &&
!change_callback_handle_cast_no_arg &&
!change_callback_handle_arg@
expression change_timer_function_usage._E;
identifier change_timer_function_usage._timer;
identifier change_timer_function_usage._callback;
type change_timer_function_usage._cast_data;
@@
(
-timer_setup(&_E->_timer, _callback, 0);
+setup_timer(&_E->_timer, _callback, (_cast_data)_E);
|
-timer_setup(&_E._timer, _callback, 0);
+setup_timer(&_E._timer, _callback, (_cast_data)&_E);
)
// If we fixed a callback from a .function assignment, fix the
// assignment cast now.
@change_timer_function_assignment
depends on change_timer_function_usage &&
(change_callback_handle_cast ||
change_callback_handle_cast_no_arg ||
change_callback_handle_arg)@
expression change_timer_function_usage._E;
identifier change_timer_function_usage._timer;
identifier change_timer_function_usage._callback;
type _cast_func;
typedef TIMER_FUNC_TYPE;
@@
(
_E->_timer.function =
-_callback
+(TIMER_FUNC_TYPE)_callback
;
|
_E->_timer.function =
-&_callback
+(TIMER_FUNC_TYPE)_callback
;
|
_E->_timer.function =
-(_cast_func)_callback;
+(TIMER_FUNC_TYPE)_callback
;
|
_E->_timer.function =
-(_cast_func)&_callback
+(TIMER_FUNC_TYPE)_callback
;
|
_E._timer.function =
-_callback
+(TIMER_FUNC_TYPE)_callback
;
|
_E._timer.function =
-&_callback;
+(TIMER_FUNC_TYPE)_callback
;
|
_E._timer.function =
-(_cast_func)_callback
+(TIMER_FUNC_TYPE)_callback
;
|
_E._timer.function =
-(_cast_func)&_callback
+(TIMER_FUNC_TYPE)_callback
;
)
// Sometimes timer functions are called directly. Replace matched args.
@change_timer_function_calls
depends on change_timer_function_usage &&
(change_callback_handle_cast ||
change_callback_handle_cast_no_arg ||
change_callback_handle_arg)@
expression _E;
identifier change_timer_function_usage._timer;
identifier change_timer_function_usage._callback;
type _cast_data;
@@
_callback(
(
-(_cast_data)_E
+&_E->_timer
|
-(_cast_data)&_E
+&_E._timer
|
-_E
+&_E->_timer
)
)
// If a timer has been configured without a data argument, it can be
// converted without regard to the callback argument, since it is unused.
@match_timer_function_unused_data@
expression _E;
identifier _timer;
identifier _callback;
@@
(
-setup_timer(&_E->_timer, _callback, 0);
+timer_setup(&_E->_timer, _callback, 0);
|
-setup_timer(&_E->_timer, _callback, 0L);
+timer_setup(&_E->_timer, _callback, 0);
|
-setup_timer(&_E->_timer, _callback, 0UL);
+timer_setup(&_E->_timer, _callback, 0);
|
-setup_timer(&_E._timer, _callback, 0);
+timer_setup(&_E._timer, _callback, 0);
|
-setup_timer(&_E._timer, _callback, 0L);
+timer_setup(&_E._timer, _callback, 0);
|
-setup_timer(&_E._timer, _callback, 0UL);
+timer_setup(&_E._timer, _callback, 0);
|
-setup_timer(&_timer, _callback, 0);
+timer_setup(&_timer, _callback, 0);
|
-setup_timer(&_timer, _callback, 0L);
+timer_setup(&_timer, _callback, 0);
|
-setup_timer(&_timer, _callback, 0UL);
+timer_setup(&_timer, _callback, 0);
|
-setup_timer(_timer, _callback, 0);
+timer_setup(_timer, _callback, 0);
|
-setup_timer(_timer, _callback, 0L);
+timer_setup(_timer, _callback, 0);
|
-setup_timer(_timer, _callback, 0UL);
+timer_setup(_timer, _callback, 0);
)
@change_callback_unused_data
depends on match_timer_function_unused_data@
identifier match_timer_function_unused_data._callback;
type _origtype;
identifier _origarg;
@@
void _callback(
-_origtype _origarg
+struct timer_list *unused
)
{
... when != _origarg
}
Signed-off-by: Kees Cook <keescook@chromium.org>
2017-10-17 05:43:17 +08:00
|
|
|
timer_setup(&dev->bulk_timeout, au0828_bulk_timeout, 0);
|
2017-04-20 07:13:55 +08:00
|
|
|
|
2008-04-19 08:34:00 +08:00
|
|
|
return 0;
|
|
|
|
}
|
2014-08-10 08:47:13 +08:00
|
|
|
|
|
|
|
void au0828_dvb_suspend(struct au0828_dev *dev)
|
|
|
|
{
|
|
|
|
struct au0828_dvb *dvb = &dev->dvb;
|
2014-08-14 02:52:39 +08:00
|
|
|
int rc;
|
2014-08-10 08:47:13 +08:00
|
|
|
|
2014-08-14 02:52:39 +08:00
|
|
|
if (dvb->frontend) {
|
|
|
|
if (dev->urb_streaming) {
|
|
|
|
cancel_work_sync(&dev->restart_streaming);
|
|
|
|
/* Stop transport */
|
|
|
|
mutex_lock(&dvb->lock);
|
|
|
|
stop_urb_transfer(dev);
|
|
|
|
au0828_stop_transport(dev, 1);
|
|
|
|
mutex_unlock(&dvb->lock);
|
2014-09-04 03:17:56 +08:00
|
|
|
dev->need_urb_start = true;
|
2014-08-14 02:52:39 +08:00
|
|
|
}
|
|
|
|
/* suspend frontend - does tuner and fe to sleep */
|
|
|
|
rc = dvb_frontend_suspend(dvb->frontend);
|
|
|
|
pr_info("au0828_dvb_suspend(): Suspending DVB fe %d\n", rc);
|
2014-08-10 08:47:13 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void au0828_dvb_resume(struct au0828_dev *dev)
|
|
|
|
{
|
|
|
|
struct au0828_dvb *dvb = &dev->dvb;
|
2014-08-14 02:52:39 +08:00
|
|
|
int rc;
|
2014-08-10 08:47:13 +08:00
|
|
|
|
2014-08-14 02:52:39 +08:00
|
|
|
if (dvb->frontend) {
|
|
|
|
/* resume frontend - does fe and tuner init */
|
|
|
|
rc = dvb_frontend_resume(dvb->frontend);
|
|
|
|
pr_info("au0828_dvb_resume(): Resuming DVB fe %d\n", rc);
|
|
|
|
if (dev->need_urb_start) {
|
|
|
|
/* Start transport */
|
|
|
|
mutex_lock(&dvb->lock);
|
|
|
|
au0828_start_transport(dev);
|
|
|
|
start_urb_transfer(dev);
|
|
|
|
mutex_unlock(&dvb->lock);
|
|
|
|
}
|
2014-08-10 08:47:13 +08:00
|
|
|
}
|
|
|
|
}
|