2017-11-07 01:11:51 +08:00
|
|
|
// SPDX-License-Identifier: GPL-2.0+
|
2005-04-17 06:20:36 +08:00
|
|
|
/*
|
|
|
|
* Driver for SA11x0 serial ports
|
|
|
|
*
|
|
|
|
* Based on drivers/char/serial.c, by Linus Torvalds, Theodore Ts'o.
|
|
|
|
*
|
|
|
|
* Copyright (C) 2000 Deep Blue Solutions Ltd.
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include <linux/module.h>
|
|
|
|
#include <linux/ioport.h>
|
|
|
|
#include <linux/init.h>
|
|
|
|
#include <linux/console.h>
|
|
|
|
#include <linux/sysrq.h>
|
2012-09-21 17:18:58 +08:00
|
|
|
#include <linux/platform_data/sa11x0-serial.h>
|
2005-10-30 02:07:23 +08:00
|
|
|
#include <linux/platform_device.h>
|
2005-04-17 06:20:36 +08:00
|
|
|
#include <linux/tty.h>
|
|
|
|
#include <linux/tty_flip.h>
|
|
|
|
#include <linux/serial_core.h>
|
|
|
|
#include <linux/serial.h>
|
2009-03-25 18:21:35 +08:00
|
|
|
#include <linux/io.h>
|
2005-04-17 06:20:36 +08:00
|
|
|
|
|
|
|
#include <asm/irq.h>
|
2008-08-05 23:14:15 +08:00
|
|
|
#include <mach/hardware.h>
|
2012-02-24 07:06:51 +08:00
|
|
|
#include <mach/irqs.h>
|
2005-04-17 06:20:36 +08:00
|
|
|
|
2016-08-31 15:49:52 +08:00
|
|
|
#include "serial_mctrl_gpio.h"
|
|
|
|
|
2005-04-17 06:20:36 +08:00
|
|
|
/* We've been assigned a range on the "Low-density serial ports" major */
|
|
|
|
#define SERIAL_SA1100_MAJOR 204
|
|
|
|
#define MINOR_START 5
|
|
|
|
|
|
|
|
#define NR_PORTS 3
|
|
|
|
|
|
|
|
#define SA1100_ISR_PASS_LIMIT 256
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Convert from ignore_status_mask or read_status_mask to UTSR[01]
|
|
|
|
*/
|
|
|
|
#define SM_TO_UTSR0(x) ((x) & 0xff)
|
|
|
|
#define SM_TO_UTSR1(x) ((x) >> 8)
|
|
|
|
#define UTSR0_TO_SM(x) ((x))
|
|
|
|
#define UTSR1_TO_SM(x) ((x) << 8)
|
|
|
|
|
|
|
|
#define UART_GET_UTCR0(sport) __raw_readl((sport)->port.membase + UTCR0)
|
|
|
|
#define UART_GET_UTCR1(sport) __raw_readl((sport)->port.membase + UTCR1)
|
|
|
|
#define UART_GET_UTCR2(sport) __raw_readl((sport)->port.membase + UTCR2)
|
|
|
|
#define UART_GET_UTCR3(sport) __raw_readl((sport)->port.membase + UTCR3)
|
|
|
|
#define UART_GET_UTSR0(sport) __raw_readl((sport)->port.membase + UTSR0)
|
|
|
|
#define UART_GET_UTSR1(sport) __raw_readl((sport)->port.membase + UTSR1)
|
|
|
|
#define UART_GET_CHAR(sport) __raw_readl((sport)->port.membase + UTDR)
|
|
|
|
|
|
|
|
#define UART_PUT_UTCR0(sport,v) __raw_writel((v),(sport)->port.membase + UTCR0)
|
|
|
|
#define UART_PUT_UTCR1(sport,v) __raw_writel((v),(sport)->port.membase + UTCR1)
|
|
|
|
#define UART_PUT_UTCR2(sport,v) __raw_writel((v),(sport)->port.membase + UTCR2)
|
|
|
|
#define UART_PUT_UTCR3(sport,v) __raw_writel((v),(sport)->port.membase + UTCR3)
|
|
|
|
#define UART_PUT_UTSR0(sport,v) __raw_writel((v),(sport)->port.membase + UTSR0)
|
|
|
|
#define UART_PUT_UTSR1(sport,v) __raw_writel((v),(sport)->port.membase + UTSR1)
|
|
|
|
#define UART_PUT_CHAR(sport,v) __raw_writel((v),(sport)->port.membase + UTDR)
|
|
|
|
|
|
|
|
/*
|
|
|
|
* This is the size of our serial port register set.
|
|
|
|
*/
|
|
|
|
#define UART_PORT_SIZE 0x24
|
|
|
|
|
|
|
|
/*
|
|
|
|
* This determines how often we check the modem status signals
|
|
|
|
* for any change. They generally aren't connected to an IRQ
|
|
|
|
* so we have to poll them. We also check immediately before
|
|
|
|
* filling the TX fifo incase CTS has been dropped.
|
|
|
|
*/
|
|
|
|
#define MCTRL_TIMEOUT (250*HZ/1000)
|
|
|
|
|
|
|
|
struct sa1100_port {
|
|
|
|
struct uart_port port;
|
|
|
|
struct timer_list timer;
|
|
|
|
unsigned int old_status;
|
2016-08-31 15:49:52 +08:00
|
|
|
struct mctrl_gpios *gpios;
|
2005-04-17 06:20:36 +08:00
|
|
|
};
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Handle any change of modem status signal since we were last called.
|
|
|
|
*/
|
|
|
|
static void sa1100_mctrl_check(struct sa1100_port *sport)
|
|
|
|
{
|
|
|
|
unsigned int status, changed;
|
|
|
|
|
|
|
|
status = sport->port.ops->get_mctrl(&sport->port);
|
|
|
|
changed = status ^ sport->old_status;
|
|
|
|
|
|
|
|
if (changed == 0)
|
|
|
|
return;
|
|
|
|
|
|
|
|
sport->old_status = status;
|
|
|
|
|
|
|
|
if (changed & TIOCM_RI)
|
|
|
|
sport->port.icount.rng++;
|
|
|
|
if (changed & TIOCM_DSR)
|
|
|
|
sport->port.icount.dsr++;
|
|
|
|
if (changed & TIOCM_CAR)
|
|
|
|
uart_handle_dcd_change(&sport->port, status & TIOCM_CAR);
|
|
|
|
if (changed & TIOCM_CTS)
|
|
|
|
uart_handle_cts_change(&sport->port, status & TIOCM_CTS);
|
|
|
|
|
2009-09-20 04:13:31 +08:00
|
|
|
wake_up_interruptible(&sport->port.state->port.delta_msr_wait);
|
2005-04-17 06:20:36 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* This is our per-port timeout handler, for checking the
|
|
|
|
* modem status signals.
|
|
|
|
*/
|
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 sa1100_timeout(struct timer_list *t)
|
2005-04-17 06:20:36 +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 sa1100_port *sport = from_timer(sport, t, timer);
|
2005-04-17 06:20:36 +08:00
|
|
|
unsigned long flags;
|
|
|
|
|
2009-09-20 04:13:28 +08:00
|
|
|
if (sport->port.state) {
|
2005-04-17 06:20:36 +08:00
|
|
|
spin_lock_irqsave(&sport->port.lock, flags);
|
|
|
|
sa1100_mctrl_check(sport);
|
|
|
|
spin_unlock_irqrestore(&sport->port.lock, flags);
|
|
|
|
|
|
|
|
mod_timer(&sport->timer, jiffies + MCTRL_TIMEOUT);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* interrupts disabled on entry
|
|
|
|
*/
|
2005-08-31 17:12:14 +08:00
|
|
|
static void sa1100_stop_tx(struct uart_port *port)
|
2005-04-17 06:20:36 +08:00
|
|
|
{
|
2014-10-06 01:01:03 +08:00
|
|
|
struct sa1100_port *sport =
|
|
|
|
container_of(port, struct sa1100_port, port);
|
2005-04-17 06:20:36 +08:00
|
|
|
u32 utcr3;
|
|
|
|
|
|
|
|
utcr3 = UART_GET_UTCR3(sport);
|
|
|
|
UART_PUT_UTCR3(sport, utcr3 & ~UTCR3_TIE);
|
|
|
|
sport->port.read_status_mask &= ~UTSR0_TO_SM(UTSR0_TFS);
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
2005-11-13 06:09:22 +08:00
|
|
|
* port locked and interrupts disabled
|
2005-04-17 06:20:36 +08:00
|
|
|
*/
|
2005-08-31 17:12:14 +08:00
|
|
|
static void sa1100_start_tx(struct uart_port *port)
|
2005-04-17 06:20:36 +08:00
|
|
|
{
|
2014-10-06 01:01:03 +08:00
|
|
|
struct sa1100_port *sport =
|
|
|
|
container_of(port, struct sa1100_port, port);
|
2005-04-17 06:20:36 +08:00
|
|
|
u32 utcr3;
|
|
|
|
|
|
|
|
utcr3 = UART_GET_UTCR3(sport);
|
|
|
|
sport->port.read_status_mask |= UTSR0_TO_SM(UTSR0_TFS);
|
|
|
|
UART_PUT_UTCR3(sport, utcr3 | UTCR3_TIE);
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Interrupts enabled
|
|
|
|
*/
|
|
|
|
static void sa1100_stop_rx(struct uart_port *port)
|
|
|
|
{
|
2014-10-06 01:01:03 +08:00
|
|
|
struct sa1100_port *sport =
|
|
|
|
container_of(port, struct sa1100_port, port);
|
2005-04-17 06:20:36 +08:00
|
|
|
u32 utcr3;
|
|
|
|
|
|
|
|
utcr3 = UART_GET_UTCR3(sport);
|
|
|
|
UART_PUT_UTCR3(sport, utcr3 & ~UTCR3_RIE);
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Set the modem control timer to fire immediately.
|
|
|
|
*/
|
|
|
|
static void sa1100_enable_ms(struct uart_port *port)
|
|
|
|
{
|
2014-10-06 01:01:03 +08:00
|
|
|
struct sa1100_port *sport =
|
|
|
|
container_of(port, struct sa1100_port, port);
|
2005-04-17 06:20:36 +08:00
|
|
|
|
|
|
|
mod_timer(&sport->timer, jiffies);
|
2016-08-31 15:49:52 +08:00
|
|
|
|
|
|
|
mctrl_gpio_enable_ms(sport->gpios);
|
2005-04-17 06:20:36 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
IRQ: Maintain regs pointer globally rather than passing to IRQ handlers
Maintain a per-CPU global "struct pt_regs *" variable which can be used instead
of passing regs around manually through all ~1800 interrupt handlers in the
Linux kernel.
The regs pointer is used in few places, but it potentially costs both stack
space and code to pass it around. On the FRV arch, removing the regs parameter
from all the genirq function results in a 20% speed up of the IRQ exit path
(ie: from leaving timer_interrupt() to leaving do_IRQ()).
Where appropriate, an arch may override the generic storage facility and do
something different with the variable. On FRV, for instance, the address is
maintained in GR28 at all times inside the kernel as part of general exception
handling.
Having looked over the code, it appears that the parameter may be handed down
through up to twenty or so layers of functions. Consider a USB character
device attached to a USB hub, attached to a USB controller that posts its
interrupts through a cascaded auxiliary interrupt controller. A character
device driver may want to pass regs to the sysrq handler through the input
layer which adds another few layers of parameter passing.
I've build this code with allyesconfig for x86_64 and i386. I've runtested the
main part of the code on FRV and i386, though I can't test most of the drivers.
I've also done partial conversion for powerpc and MIPS - these at least compile
with minimal configurations.
This will affect all archs. Mostly the changes should be relatively easy.
Take do_IRQ(), store the regs pointer at the beginning, saving the old one:
struct pt_regs *old_regs = set_irq_regs(regs);
And put the old one back at the end:
set_irq_regs(old_regs);
Don't pass regs through to generic_handle_irq() or __do_IRQ().
In timer_interrupt(), this sort of change will be necessary:
- update_process_times(user_mode(regs));
- profile_tick(CPU_PROFILING, regs);
+ update_process_times(user_mode(get_irq_regs()));
+ profile_tick(CPU_PROFILING);
I'd like to move update_process_times()'s use of get_irq_regs() into itself,
except that i386, alone of the archs, uses something other than user_mode().
Some notes on the interrupt handling in the drivers:
(*) input_dev() is now gone entirely. The regs pointer is no longer stored in
the input_dev struct.
(*) finish_unlinks() in drivers/usb/host/ohci-q.c needs checking. It does
something different depending on whether it's been supplied with a regs
pointer or not.
(*) Various IRQ handler function pointers have been moved to type
irq_handler_t.
Signed-Off-By: David Howells <dhowells@redhat.com>
(cherry picked from 1b16e7ac850969f38b375e511e3fa2f474a33867 commit)
2006-10-05 21:55:46 +08:00
|
|
|
sa1100_rx_chars(struct sa1100_port *sport)
|
2005-04-17 06:20:36 +08:00
|
|
|
{
|
2023-07-12 16:18:11 +08:00
|
|
|
unsigned int status;
|
|
|
|
u8 ch, flg;
|
2005-04-17 06:20:36 +08:00
|
|
|
|
|
|
|
status = UTSR1_TO_SM(UART_GET_UTSR1(sport)) |
|
|
|
|
UTSR0_TO_SM(UART_GET_UTSR0(sport));
|
|
|
|
while (status & UTSR1_TO_SM(UTSR1_RNE)) {
|
|
|
|
ch = UART_GET_CHAR(sport);
|
|
|
|
|
|
|
|
sport->port.icount.rx++;
|
|
|
|
|
|
|
|
flg = TTY_NORMAL;
|
|
|
|
|
|
|
|
/*
|
|
|
|
* note that the error handling code is
|
|
|
|
* out of the main execution path
|
|
|
|
*/
|
2005-04-26 22:32:00 +08:00
|
|
|
if (status & UTSR1_TO_SM(UTSR1_PRE | UTSR1_FRE | UTSR1_ROR)) {
|
|
|
|
if (status & UTSR1_TO_SM(UTSR1_PRE))
|
|
|
|
sport->port.icount.parity++;
|
|
|
|
else if (status & UTSR1_TO_SM(UTSR1_FRE))
|
|
|
|
sport->port.icount.frame++;
|
|
|
|
if (status & UTSR1_TO_SM(UTSR1_ROR))
|
|
|
|
sport->port.icount.overrun++;
|
|
|
|
|
|
|
|
status &= sport->port.read_status_mask;
|
|
|
|
|
|
|
|
if (status & UTSR1_TO_SM(UTSR1_PRE))
|
|
|
|
flg = TTY_PARITY;
|
|
|
|
else if (status & UTSR1_TO_SM(UTSR1_FRE))
|
|
|
|
flg = TTY_FRAME;
|
|
|
|
|
|
|
|
sport->port.sysrq = 0;
|
|
|
|
}
|
2005-04-17 06:20:36 +08:00
|
|
|
|
IRQ: Maintain regs pointer globally rather than passing to IRQ handlers
Maintain a per-CPU global "struct pt_regs *" variable which can be used instead
of passing regs around manually through all ~1800 interrupt handlers in the
Linux kernel.
The regs pointer is used in few places, but it potentially costs both stack
space and code to pass it around. On the FRV arch, removing the regs parameter
from all the genirq function results in a 20% speed up of the IRQ exit path
(ie: from leaving timer_interrupt() to leaving do_IRQ()).
Where appropriate, an arch may override the generic storage facility and do
something different with the variable. On FRV, for instance, the address is
maintained in GR28 at all times inside the kernel as part of general exception
handling.
Having looked over the code, it appears that the parameter may be handed down
through up to twenty or so layers of functions. Consider a USB character
device attached to a USB hub, attached to a USB controller that posts its
interrupts through a cascaded auxiliary interrupt controller. A character
device driver may want to pass regs to the sysrq handler through the input
layer which adds another few layers of parameter passing.
I've build this code with allyesconfig for x86_64 and i386. I've runtested the
main part of the code on FRV and i386, though I can't test most of the drivers.
I've also done partial conversion for powerpc and MIPS - these at least compile
with minimal configurations.
This will affect all archs. Mostly the changes should be relatively easy.
Take do_IRQ(), store the regs pointer at the beginning, saving the old one:
struct pt_regs *old_regs = set_irq_regs(regs);
And put the old one back at the end:
set_irq_regs(old_regs);
Don't pass regs through to generic_handle_irq() or __do_IRQ().
In timer_interrupt(), this sort of change will be necessary:
- update_process_times(user_mode(regs));
- profile_tick(CPU_PROFILING, regs);
+ update_process_times(user_mode(get_irq_regs()));
+ profile_tick(CPU_PROFILING);
I'd like to move update_process_times()'s use of get_irq_regs() into itself,
except that i386, alone of the archs, uses something other than user_mode().
Some notes on the interrupt handling in the drivers:
(*) input_dev() is now gone entirely. The regs pointer is no longer stored in
the input_dev struct.
(*) finish_unlinks() in drivers/usb/host/ohci-q.c needs checking. It does
something different depending on whether it's been supplied with a regs
pointer or not.
(*) Various IRQ handler function pointers have been moved to type
irq_handler_t.
Signed-Off-By: David Howells <dhowells@redhat.com>
(cherry picked from 1b16e7ac850969f38b375e511e3fa2f474a33867 commit)
2006-10-05 21:55:46 +08:00
|
|
|
if (uart_handle_sysrq_char(&sport->port, ch))
|
2005-04-17 06:20:36 +08:00
|
|
|
goto ignore_char;
|
|
|
|
|
2005-05-10 06:21:59 +08:00
|
|
|
uart_insert_char(&sport->port, status, UTSR1_TO_SM(UTSR1_ROR), ch, flg);
|
2005-04-26 22:32:00 +08:00
|
|
|
|
2005-04-17 06:20:36 +08:00
|
|
|
ignore_char:
|
|
|
|
status = UTSR1_TO_SM(UART_GET_UTSR1(sport)) |
|
|
|
|
UTSR0_TO_SM(UART_GET_UTSR0(sport));
|
|
|
|
}
|
2013-08-19 22:44:25 +08:00
|
|
|
|
2013-01-03 22:53:06 +08:00
|
|
|
tty_flip_buffer_push(&sport->port.state->port);
|
2005-04-17 06:20:36 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
static void sa1100_tx_chars(struct sa1100_port *sport)
|
|
|
|
{
|
2022-10-04 18:49:26 +08:00
|
|
|
u8 ch;
|
2005-04-17 06:20:36 +08:00
|
|
|
|
|
|
|
/*
|
|
|
|
* Check the modem control lines before
|
|
|
|
* transmitting anything.
|
|
|
|
*/
|
|
|
|
sa1100_mctrl_check(sport);
|
|
|
|
|
2022-10-04 18:49:26 +08:00
|
|
|
uart_port_tx(&sport->port, ch,
|
|
|
|
UART_GET_UTSR1(sport) & UTSR1_TNF,
|
|
|
|
UART_PUT_CHAR(sport, ch));
|
2005-04-17 06:20:36 +08:00
|
|
|
}
|
|
|
|
|
IRQ: Maintain regs pointer globally rather than passing to IRQ handlers
Maintain a per-CPU global "struct pt_regs *" variable which can be used instead
of passing regs around manually through all ~1800 interrupt handlers in the
Linux kernel.
The regs pointer is used in few places, but it potentially costs both stack
space and code to pass it around. On the FRV arch, removing the regs parameter
from all the genirq function results in a 20% speed up of the IRQ exit path
(ie: from leaving timer_interrupt() to leaving do_IRQ()).
Where appropriate, an arch may override the generic storage facility and do
something different with the variable. On FRV, for instance, the address is
maintained in GR28 at all times inside the kernel as part of general exception
handling.
Having looked over the code, it appears that the parameter may be handed down
through up to twenty or so layers of functions. Consider a USB character
device attached to a USB hub, attached to a USB controller that posts its
interrupts through a cascaded auxiliary interrupt controller. A character
device driver may want to pass regs to the sysrq handler through the input
layer which adds another few layers of parameter passing.
I've build this code with allyesconfig for x86_64 and i386. I've runtested the
main part of the code on FRV and i386, though I can't test most of the drivers.
I've also done partial conversion for powerpc and MIPS - these at least compile
with minimal configurations.
This will affect all archs. Mostly the changes should be relatively easy.
Take do_IRQ(), store the regs pointer at the beginning, saving the old one:
struct pt_regs *old_regs = set_irq_regs(regs);
And put the old one back at the end:
set_irq_regs(old_regs);
Don't pass regs through to generic_handle_irq() or __do_IRQ().
In timer_interrupt(), this sort of change will be necessary:
- update_process_times(user_mode(regs));
- profile_tick(CPU_PROFILING, regs);
+ update_process_times(user_mode(get_irq_regs()));
+ profile_tick(CPU_PROFILING);
I'd like to move update_process_times()'s use of get_irq_regs() into itself,
except that i386, alone of the archs, uses something other than user_mode().
Some notes on the interrupt handling in the drivers:
(*) input_dev() is now gone entirely. The regs pointer is no longer stored in
the input_dev struct.
(*) finish_unlinks() in drivers/usb/host/ohci-q.c needs checking. It does
something different depending on whether it's been supplied with a regs
pointer or not.
(*) Various IRQ handler function pointers have been moved to type
irq_handler_t.
Signed-Off-By: David Howells <dhowells@redhat.com>
(cherry picked from 1b16e7ac850969f38b375e511e3fa2f474a33867 commit)
2006-10-05 21:55:46 +08:00
|
|
|
static irqreturn_t sa1100_int(int irq, void *dev_id)
|
2005-04-17 06:20:36 +08:00
|
|
|
{
|
|
|
|
struct sa1100_port *sport = dev_id;
|
|
|
|
unsigned int status, pass_counter = 0;
|
|
|
|
|
|
|
|
spin_lock(&sport->port.lock);
|
|
|
|
status = UART_GET_UTSR0(sport);
|
|
|
|
status &= SM_TO_UTSR0(sport->port.read_status_mask) | ~UTSR0_TFS;
|
|
|
|
do {
|
|
|
|
if (status & (UTSR0_RFS | UTSR0_RID)) {
|
|
|
|
/* Clear the receiver idle bit, if set */
|
|
|
|
if (status & UTSR0_RID)
|
|
|
|
UART_PUT_UTSR0(sport, UTSR0_RID);
|
IRQ: Maintain regs pointer globally rather than passing to IRQ handlers
Maintain a per-CPU global "struct pt_regs *" variable which can be used instead
of passing regs around manually through all ~1800 interrupt handlers in the
Linux kernel.
The regs pointer is used in few places, but it potentially costs both stack
space and code to pass it around. On the FRV arch, removing the regs parameter
from all the genirq function results in a 20% speed up of the IRQ exit path
(ie: from leaving timer_interrupt() to leaving do_IRQ()).
Where appropriate, an arch may override the generic storage facility and do
something different with the variable. On FRV, for instance, the address is
maintained in GR28 at all times inside the kernel as part of general exception
handling.
Having looked over the code, it appears that the parameter may be handed down
through up to twenty or so layers of functions. Consider a USB character
device attached to a USB hub, attached to a USB controller that posts its
interrupts through a cascaded auxiliary interrupt controller. A character
device driver may want to pass regs to the sysrq handler through the input
layer which adds another few layers of parameter passing.
I've build this code with allyesconfig for x86_64 and i386. I've runtested the
main part of the code on FRV and i386, though I can't test most of the drivers.
I've also done partial conversion for powerpc and MIPS - these at least compile
with minimal configurations.
This will affect all archs. Mostly the changes should be relatively easy.
Take do_IRQ(), store the regs pointer at the beginning, saving the old one:
struct pt_regs *old_regs = set_irq_regs(regs);
And put the old one back at the end:
set_irq_regs(old_regs);
Don't pass regs through to generic_handle_irq() or __do_IRQ().
In timer_interrupt(), this sort of change will be necessary:
- update_process_times(user_mode(regs));
- profile_tick(CPU_PROFILING, regs);
+ update_process_times(user_mode(get_irq_regs()));
+ profile_tick(CPU_PROFILING);
I'd like to move update_process_times()'s use of get_irq_regs() into itself,
except that i386, alone of the archs, uses something other than user_mode().
Some notes on the interrupt handling in the drivers:
(*) input_dev() is now gone entirely. The regs pointer is no longer stored in
the input_dev struct.
(*) finish_unlinks() in drivers/usb/host/ohci-q.c needs checking. It does
something different depending on whether it's been supplied with a regs
pointer or not.
(*) Various IRQ handler function pointers have been moved to type
irq_handler_t.
Signed-Off-By: David Howells <dhowells@redhat.com>
(cherry picked from 1b16e7ac850969f38b375e511e3fa2f474a33867 commit)
2006-10-05 21:55:46 +08:00
|
|
|
sa1100_rx_chars(sport);
|
2005-04-17 06:20:36 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
/* Clear the relevant break bits */
|
|
|
|
if (status & (UTSR0_RBB | UTSR0_REB))
|
|
|
|
UART_PUT_UTSR0(sport, status & (UTSR0_RBB | UTSR0_REB));
|
|
|
|
|
|
|
|
if (status & UTSR0_RBB)
|
|
|
|
sport->port.icount.brk++;
|
|
|
|
|
|
|
|
if (status & UTSR0_REB)
|
|
|
|
uart_handle_break(&sport->port);
|
|
|
|
|
|
|
|
if (status & UTSR0_TFS)
|
|
|
|
sa1100_tx_chars(sport);
|
|
|
|
if (pass_counter++ > SA1100_ISR_PASS_LIMIT)
|
|
|
|
break;
|
|
|
|
status = UART_GET_UTSR0(sport);
|
|
|
|
status &= SM_TO_UTSR0(sport->port.read_status_mask) |
|
|
|
|
~UTSR0_TFS;
|
|
|
|
} while (status & (UTSR0_TFS | UTSR0_RFS | UTSR0_RID));
|
|
|
|
spin_unlock(&sport->port.lock);
|
|
|
|
|
|
|
|
return IRQ_HANDLED;
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Return TIOCSER_TEMT when transmitter is not busy.
|
|
|
|
*/
|
|
|
|
static unsigned int sa1100_tx_empty(struct uart_port *port)
|
|
|
|
{
|
2014-10-06 01:01:03 +08:00
|
|
|
struct sa1100_port *sport =
|
|
|
|
container_of(port, struct sa1100_port, port);
|
2005-04-17 06:20:36 +08:00
|
|
|
|
|
|
|
return UART_GET_UTSR1(sport) & UTSR1_TBY ? 0 : TIOCSER_TEMT;
|
|
|
|
}
|
|
|
|
|
|
|
|
static unsigned int sa1100_get_mctrl(struct uart_port *port)
|
|
|
|
{
|
2016-08-31 15:49:52 +08:00
|
|
|
struct sa1100_port *sport =
|
|
|
|
container_of(port, struct sa1100_port, port);
|
|
|
|
int ret = TIOCM_CTS | TIOCM_DSR | TIOCM_CAR;
|
|
|
|
|
|
|
|
mctrl_gpio_get(sport->gpios, &ret);
|
|
|
|
|
|
|
|
return ret;
|
2005-04-17 06:20:36 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
static void sa1100_set_mctrl(struct uart_port *port, unsigned int mctrl)
|
|
|
|
{
|
2016-08-31 15:49:52 +08:00
|
|
|
struct sa1100_port *sport =
|
|
|
|
container_of(port, struct sa1100_port, port);
|
|
|
|
|
|
|
|
mctrl_gpio_set(sport->gpios, mctrl);
|
2005-04-17 06:20:36 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Interrupts always disabled.
|
|
|
|
*/
|
|
|
|
static void sa1100_break_ctl(struct uart_port *port, int break_state)
|
|
|
|
{
|
2014-10-06 01:01:03 +08:00
|
|
|
struct sa1100_port *sport =
|
|
|
|
container_of(port, struct sa1100_port, port);
|
2005-04-17 06:20:36 +08:00
|
|
|
unsigned long flags;
|
|
|
|
unsigned int utcr3;
|
|
|
|
|
|
|
|
spin_lock_irqsave(&sport->port.lock, flags);
|
|
|
|
utcr3 = UART_GET_UTCR3(sport);
|
|
|
|
if (break_state == -1)
|
|
|
|
utcr3 |= UTCR3_BRK;
|
|
|
|
else
|
|
|
|
utcr3 &= ~UTCR3_BRK;
|
|
|
|
UART_PUT_UTCR3(sport, utcr3);
|
|
|
|
spin_unlock_irqrestore(&sport->port.lock, flags);
|
|
|
|
}
|
|
|
|
|
|
|
|
static int sa1100_startup(struct uart_port *port)
|
|
|
|
{
|
2014-10-06 01:01:03 +08:00
|
|
|
struct sa1100_port *sport =
|
|
|
|
container_of(port, struct sa1100_port, port);
|
2005-04-17 06:20:36 +08:00
|
|
|
int retval;
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Allocate the IRQ
|
|
|
|
*/
|
|
|
|
retval = request_irq(sport->port.irq, sa1100_int, 0,
|
|
|
|
"sa11x0-uart", sport);
|
|
|
|
if (retval)
|
|
|
|
return retval;
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Finally, clear and enable interrupts
|
|
|
|
*/
|
|
|
|
UART_PUT_UTSR0(sport, -1);
|
|
|
|
UART_PUT_UTCR3(sport, UTCR3_RXE | UTCR3_TXE | UTCR3_RIE);
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Enable modem status interrupts
|
|
|
|
*/
|
|
|
|
spin_lock_irq(&sport->port.lock);
|
|
|
|
sa1100_enable_ms(&sport->port);
|
|
|
|
spin_unlock_irq(&sport->port.lock);
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void sa1100_shutdown(struct uart_port *port)
|
|
|
|
{
|
2014-10-06 01:01:03 +08:00
|
|
|
struct sa1100_port *sport =
|
|
|
|
container_of(port, struct sa1100_port, port);
|
2005-04-17 06:20:36 +08:00
|
|
|
|
|
|
|
/*
|
|
|
|
* Stop our timer.
|
|
|
|
*/
|
|
|
|
del_timer_sync(&sport->timer);
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Free the interrupt
|
|
|
|
*/
|
|
|
|
free_irq(sport->port.irq, sport);
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Disable all interrupts, port and break condition.
|
|
|
|
*/
|
|
|
|
UART_PUT_UTCR3(sport, 0);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2006-12-08 18:38:45 +08:00
|
|
|
sa1100_set_termios(struct uart_port *port, struct ktermios *termios,
|
2022-08-16 19:57:37 +08:00
|
|
|
const struct ktermios *old)
|
2005-04-17 06:20:36 +08:00
|
|
|
{
|
2014-10-06 01:01:03 +08:00
|
|
|
struct sa1100_port *sport =
|
|
|
|
container_of(port, struct sa1100_port, port);
|
2005-04-17 06:20:36 +08:00
|
|
|
unsigned long flags;
|
|
|
|
unsigned int utcr0, old_utcr3, baud, quot;
|
|
|
|
unsigned int old_csize = old ? old->c_cflag & CSIZE : CS8;
|
|
|
|
|
|
|
|
/*
|
|
|
|
* We only support CS7 and CS8.
|
|
|
|
*/
|
|
|
|
while ((termios->c_cflag & CSIZE) != CS7 &&
|
|
|
|
(termios->c_cflag & CSIZE) != CS8) {
|
|
|
|
termios->c_cflag &= ~CSIZE;
|
|
|
|
termios->c_cflag |= old_csize;
|
|
|
|
old_csize = CS8;
|
|
|
|
}
|
|
|
|
|
|
|
|
if ((termios->c_cflag & CSIZE) == CS8)
|
|
|
|
utcr0 = UTCR0_DSS;
|
|
|
|
else
|
|
|
|
utcr0 = 0;
|
|
|
|
|
|
|
|
if (termios->c_cflag & CSTOPB)
|
|
|
|
utcr0 |= UTCR0_SBS;
|
|
|
|
if (termios->c_cflag & PARENB) {
|
|
|
|
utcr0 |= UTCR0_PE;
|
|
|
|
if (!(termios->c_cflag & PARODD))
|
|
|
|
utcr0 |= UTCR0_OES;
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Ask the core to calculate the divisor for us.
|
|
|
|
*/
|
|
|
|
baud = uart_get_baud_rate(port, termios, old, 0, port->uartclk/16);
|
|
|
|
quot = uart_get_divisor(port, baud);
|
|
|
|
|
2022-04-17 19:16:26 +08:00
|
|
|
del_timer_sync(&sport->timer);
|
|
|
|
|
2005-04-17 06:20:36 +08:00
|
|
|
spin_lock_irqsave(&sport->port.lock, flags);
|
|
|
|
|
|
|
|
sport->port.read_status_mask &= UTSR0_TO_SM(UTSR0_TFS);
|
|
|
|
sport->port.read_status_mask |= UTSR1_TO_SM(UTSR1_ROR);
|
|
|
|
if (termios->c_iflag & INPCK)
|
|
|
|
sport->port.read_status_mask |=
|
|
|
|
UTSR1_TO_SM(UTSR1_FRE | UTSR1_PRE);
|
|
|
|
if (termios->c_iflag & (BRKINT | PARMRK))
|
|
|
|
sport->port.read_status_mask |=
|
|
|
|
UTSR0_TO_SM(UTSR0_RBB | UTSR0_REB);
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Characters to ignore
|
|
|
|
*/
|
|
|
|
sport->port.ignore_status_mask = 0;
|
|
|
|
if (termios->c_iflag & IGNPAR)
|
|
|
|
sport->port.ignore_status_mask |=
|
|
|
|
UTSR1_TO_SM(UTSR1_FRE | UTSR1_PRE);
|
|
|
|
if (termios->c_iflag & IGNBRK) {
|
|
|
|
sport->port.ignore_status_mask |=
|
|
|
|
UTSR0_TO_SM(UTSR0_RBB | UTSR0_REB);
|
|
|
|
/*
|
|
|
|
* If we're ignoring parity and break indicators,
|
|
|
|
* ignore overruns too (for real raw support).
|
|
|
|
*/
|
|
|
|
if (termios->c_iflag & IGNPAR)
|
|
|
|
sport->port.ignore_status_mask |=
|
|
|
|
UTSR1_TO_SM(UTSR1_ROR);
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Update the per-port timeout.
|
|
|
|
*/
|
|
|
|
uart_update_timeout(port, termios->c_cflag, baud);
|
|
|
|
|
|
|
|
/*
|
|
|
|
* disable interrupts and drain transmitter
|
|
|
|
*/
|
|
|
|
old_utcr3 = UART_GET_UTCR3(sport);
|
|
|
|
UART_PUT_UTCR3(sport, old_utcr3 & ~(UTCR3_RIE | UTCR3_TIE));
|
|
|
|
|
|
|
|
while (UART_GET_UTSR1(sport) & UTSR1_TBY)
|
|
|
|
barrier();
|
|
|
|
|
|
|
|
/* then, disable everything */
|
|
|
|
UART_PUT_UTCR3(sport, 0);
|
|
|
|
|
|
|
|
/* set the parity, stop bits and data size */
|
|
|
|
UART_PUT_UTCR0(sport, utcr0);
|
|
|
|
|
|
|
|
/* set the baud rate */
|
|
|
|
quot -= 1;
|
|
|
|
UART_PUT_UTCR1(sport, ((quot & 0xf00) >> 8));
|
|
|
|
UART_PUT_UTCR2(sport, (quot & 0xff));
|
|
|
|
|
|
|
|
UART_PUT_UTSR0(sport, -1);
|
|
|
|
|
|
|
|
UART_PUT_UTCR3(sport, old_utcr3);
|
|
|
|
|
|
|
|
if (UART_ENABLE_MS(&sport->port, termios->c_cflag))
|
|
|
|
sa1100_enable_ms(&sport->port);
|
|
|
|
|
|
|
|
spin_unlock_irqrestore(&sport->port.lock, flags);
|
|
|
|
}
|
|
|
|
|
|
|
|
static const char *sa1100_type(struct uart_port *port)
|
|
|
|
{
|
2014-10-06 01:01:03 +08:00
|
|
|
struct sa1100_port *sport =
|
|
|
|
container_of(port, struct sa1100_port, port);
|
2005-04-17 06:20:36 +08:00
|
|
|
|
|
|
|
return sport->port.type == PORT_SA1100 ? "SA1100" : NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Release the memory region(s) being used by 'port'.
|
|
|
|
*/
|
|
|
|
static void sa1100_release_port(struct uart_port *port)
|
|
|
|
{
|
2014-10-06 01:01:03 +08:00
|
|
|
struct sa1100_port *sport =
|
|
|
|
container_of(port, struct sa1100_port, port);
|
2005-04-17 06:20:36 +08:00
|
|
|
|
|
|
|
release_mem_region(sport->port.mapbase, UART_PORT_SIZE);
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Request the memory region(s) being used by 'port'.
|
|
|
|
*/
|
|
|
|
static int sa1100_request_port(struct uart_port *port)
|
|
|
|
{
|
2014-10-06 01:01:03 +08:00
|
|
|
struct sa1100_port *sport =
|
|
|
|
container_of(port, struct sa1100_port, port);
|
2005-04-17 06:20:36 +08:00
|
|
|
|
|
|
|
return request_mem_region(sport->port.mapbase, UART_PORT_SIZE,
|
|
|
|
"sa11x0-uart") != NULL ? 0 : -EBUSY;
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Configure/autoconfigure the port.
|
|
|
|
*/
|
|
|
|
static void sa1100_config_port(struct uart_port *port, int flags)
|
|
|
|
{
|
2014-10-06 01:01:03 +08:00
|
|
|
struct sa1100_port *sport =
|
|
|
|
container_of(port, struct sa1100_port, port);
|
2005-04-17 06:20:36 +08:00
|
|
|
|
|
|
|
if (flags & UART_CONFIG_TYPE &&
|
|
|
|
sa1100_request_port(&sport->port) == 0)
|
|
|
|
sport->port.type = PORT_SA1100;
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Verify the new serial_struct (for TIOCSSERIAL).
|
|
|
|
* The only change we allow are to the flags and type, and
|
|
|
|
* even then only between PORT_SA1100 and PORT_UNKNOWN
|
|
|
|
*/
|
|
|
|
static int
|
|
|
|
sa1100_verify_port(struct uart_port *port, struct serial_struct *ser)
|
|
|
|
{
|
2014-10-06 01:01:03 +08:00
|
|
|
struct sa1100_port *sport =
|
|
|
|
container_of(port, struct sa1100_port, port);
|
2005-04-17 06:20:36 +08:00
|
|
|
int ret = 0;
|
|
|
|
|
|
|
|
if (ser->type != PORT_UNKNOWN && ser->type != PORT_SA1100)
|
|
|
|
ret = -EINVAL;
|
|
|
|
if (sport->port.irq != ser->irq)
|
|
|
|
ret = -EINVAL;
|
|
|
|
if (ser->io_type != SERIAL_IO_MEM)
|
|
|
|
ret = -EINVAL;
|
|
|
|
if (sport->port.uartclk / 16 != ser->baud_base)
|
|
|
|
ret = -EINVAL;
|
|
|
|
if ((void *)sport->port.mapbase != ser->iomem_base)
|
|
|
|
ret = -EINVAL;
|
|
|
|
if (sport->port.iobase != ser->port)
|
|
|
|
ret = -EINVAL;
|
|
|
|
if (ser->hub6 != 0)
|
|
|
|
ret = -EINVAL;
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
|
|
|
static struct uart_ops sa1100_pops = {
|
|
|
|
.tx_empty = sa1100_tx_empty,
|
|
|
|
.set_mctrl = sa1100_set_mctrl,
|
|
|
|
.get_mctrl = sa1100_get_mctrl,
|
|
|
|
.stop_tx = sa1100_stop_tx,
|
|
|
|
.start_tx = sa1100_start_tx,
|
|
|
|
.stop_rx = sa1100_stop_rx,
|
|
|
|
.enable_ms = sa1100_enable_ms,
|
|
|
|
.break_ctl = sa1100_break_ctl,
|
|
|
|
.startup = sa1100_startup,
|
|
|
|
.shutdown = sa1100_shutdown,
|
|
|
|
.set_termios = sa1100_set_termios,
|
|
|
|
.type = sa1100_type,
|
|
|
|
.release_port = sa1100_release_port,
|
|
|
|
.request_port = sa1100_request_port,
|
|
|
|
.config_port = sa1100_config_port,
|
|
|
|
.verify_port = sa1100_verify_port,
|
|
|
|
};
|
|
|
|
|
|
|
|
static struct sa1100_port sa1100_ports[NR_PORTS];
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Setup the SA1100 serial ports. Note that we don't include the IrDA
|
|
|
|
* port here since we have our own SIR/FIR driver (see drivers/net/irda)
|
|
|
|
*
|
|
|
|
* Note also that we support "console=ttySAx" where "x" is either 0 or 1.
|
|
|
|
* Which serial port this ends up being depends on the machine you're
|
|
|
|
* running this kernel on. I'm not convinced that this is a good idea,
|
|
|
|
* but that's the way it traditionally works.
|
|
|
|
*
|
|
|
|
* Note that NanoEngine UART3 becomes UART2, and UART2 is no longer
|
|
|
|
* used here.
|
|
|
|
*/
|
|
|
|
static void __init sa1100_init_ports(void)
|
|
|
|
{
|
|
|
|
static int first = 1;
|
|
|
|
int i;
|
|
|
|
|
|
|
|
if (!first)
|
|
|
|
return;
|
|
|
|
first = 0;
|
|
|
|
|
|
|
|
for (i = 0; i < NR_PORTS; i++) {
|
|
|
|
sa1100_ports[i].port.uartclk = 3686400;
|
|
|
|
sa1100_ports[i].port.ops = &sa1100_pops;
|
|
|
|
sa1100_ports[i].port.fifosize = 8;
|
|
|
|
sa1100_ports[i].port.line = i;
|
2006-02-05 18:48:10 +08:00
|
|
|
sa1100_ports[i].port.iotype = UPIO_MEM;
|
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(&sa1100_ports[i].timer, sa1100_timeout, 0);
|
2005-04-17 06:20:36 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* make transmit lines outputs, so that when the port
|
|
|
|
* is closed, the output is in the MARK state.
|
|
|
|
*/
|
|
|
|
PPDR |= PPC_TXD1 | PPC_TXD3;
|
|
|
|
PPSR |= PPC_TXD1 | PPC_TXD3;
|
|
|
|
}
|
|
|
|
|
2012-11-20 02:21:50 +08:00
|
|
|
void sa1100_register_uart_fns(struct sa1100_port_fns *fns)
|
2005-04-17 06:20:36 +08:00
|
|
|
{
|
|
|
|
if (fns->get_mctrl)
|
|
|
|
sa1100_pops.get_mctrl = fns->get_mctrl;
|
|
|
|
if (fns->set_mctrl)
|
|
|
|
sa1100_pops.set_mctrl = fns->set_mctrl;
|
|
|
|
|
|
|
|
sa1100_pops.pm = fns->pm;
|
2013-10-15 15:20:26 +08:00
|
|
|
/*
|
|
|
|
* FIXME: fns->set_wake is unused - this should be called from
|
|
|
|
* the suspend() callback if device_may_wakeup(dev)) is set.
|
|
|
|
*/
|
2005-04-17 06:20:36 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
void __init sa1100_register_uart(int idx, int port)
|
|
|
|
{
|
|
|
|
if (idx >= NR_PORTS) {
|
2008-04-30 15:55:10 +08:00
|
|
|
printk(KERN_ERR "%s: bad index number %d\n", __func__, idx);
|
2005-04-17 06:20:36 +08:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
switch (port) {
|
|
|
|
case 1:
|
|
|
|
sa1100_ports[idx].port.membase = (void __iomem *)&Ser1UTCR0;
|
|
|
|
sa1100_ports[idx].port.mapbase = _Ser1UTCR0;
|
|
|
|
sa1100_ports[idx].port.irq = IRQ_Ser1UART;
|
2006-01-22 03:28:15 +08:00
|
|
|
sa1100_ports[idx].port.flags = UPF_BOOT_AUTOCONF;
|
2005-04-17 06:20:36 +08:00
|
|
|
break;
|
|
|
|
|
|
|
|
case 2:
|
|
|
|
sa1100_ports[idx].port.membase = (void __iomem *)&Ser2UTCR0;
|
|
|
|
sa1100_ports[idx].port.mapbase = _Ser2UTCR0;
|
|
|
|
sa1100_ports[idx].port.irq = IRQ_Ser2ICP;
|
2006-01-22 03:28:15 +08:00
|
|
|
sa1100_ports[idx].port.flags = UPF_BOOT_AUTOCONF;
|
2005-04-17 06:20:36 +08:00
|
|
|
break;
|
|
|
|
|
|
|
|
case 3:
|
|
|
|
sa1100_ports[idx].port.membase = (void __iomem *)&Ser3UTCR0;
|
|
|
|
sa1100_ports[idx].port.mapbase = _Ser3UTCR0;
|
|
|
|
sa1100_ports[idx].port.irq = IRQ_Ser3UART;
|
2006-01-22 03:28:15 +08:00
|
|
|
sa1100_ports[idx].port.flags = UPF_BOOT_AUTOCONF;
|
2005-04-17 06:20:36 +08:00
|
|
|
break;
|
|
|
|
|
|
|
|
default:
|
2008-04-30 15:55:10 +08:00
|
|
|
printk(KERN_ERR "%s: bad port number %d\n", __func__, port);
|
2005-04-17 06:20:36 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
#ifdef CONFIG_SERIAL_SA1100_CONSOLE
|
2022-03-03 16:08:31 +08:00
|
|
|
static void sa1100_console_putchar(struct uart_port *port, unsigned char ch)
|
2006-03-21 04:00:09 +08:00
|
|
|
{
|
2014-10-06 01:01:03 +08:00
|
|
|
struct sa1100_port *sport =
|
|
|
|
container_of(port, struct sa1100_port, port);
|
2006-03-21 04:00:09 +08:00
|
|
|
|
|
|
|
while (!(UART_GET_UTSR1(sport) & UTSR1_TNF))
|
|
|
|
barrier();
|
|
|
|
UART_PUT_CHAR(sport, ch);
|
|
|
|
}
|
2005-04-17 06:20:36 +08:00
|
|
|
|
|
|
|
/*
|
|
|
|
* Interrupts are disabled on entering
|
|
|
|
*/
|
|
|
|
static void
|
|
|
|
sa1100_console_write(struct console *co, const char *s, unsigned int count)
|
|
|
|
{
|
|
|
|
struct sa1100_port *sport = &sa1100_ports[co->index];
|
2006-03-21 04:00:09 +08:00
|
|
|
unsigned int old_utcr3, status;
|
2005-04-17 06:20:36 +08:00
|
|
|
|
|
|
|
/*
|
|
|
|
* First, save UTCR3 and then disable interrupts
|
|
|
|
*/
|
|
|
|
old_utcr3 = UART_GET_UTCR3(sport);
|
|
|
|
UART_PUT_UTCR3(sport, (old_utcr3 & ~(UTCR3_RIE | UTCR3_TIE)) |
|
|
|
|
UTCR3_TXE);
|
|
|
|
|
2006-03-21 04:00:09 +08:00
|
|
|
uart_console_write(&sport->port, s, count, sa1100_console_putchar);
|
2005-04-17 06:20:36 +08:00
|
|
|
|
|
|
|
/*
|
|
|
|
* Finally, wait for transmitter to become empty
|
|
|
|
* and restore UTCR3
|
|
|
|
*/
|
|
|
|
do {
|
|
|
|
status = UART_GET_UTSR1(sport);
|
|
|
|
} while (status & UTSR1_TBY);
|
|
|
|
UART_PUT_UTCR3(sport, old_utcr3);
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* If the port was already initialised (eg, by a boot loader),
|
|
|
|
* try to determine the current setup.
|
|
|
|
*/
|
|
|
|
static void __init
|
|
|
|
sa1100_console_get_options(struct sa1100_port *sport, int *baud,
|
|
|
|
int *parity, int *bits)
|
|
|
|
{
|
|
|
|
unsigned int utcr3;
|
|
|
|
|
|
|
|
utcr3 = UART_GET_UTCR3(sport) & (UTCR3_RXE | UTCR3_TXE);
|
|
|
|
if (utcr3 == (UTCR3_RXE | UTCR3_TXE)) {
|
|
|
|
/* ok, the port was enabled */
|
|
|
|
unsigned int utcr0, quot;
|
|
|
|
|
|
|
|
utcr0 = UART_GET_UTCR0(sport);
|
|
|
|
|
|
|
|
*parity = 'n';
|
|
|
|
if (utcr0 & UTCR0_PE) {
|
|
|
|
if (utcr0 & UTCR0_OES)
|
|
|
|
*parity = 'e';
|
|
|
|
else
|
|
|
|
*parity = 'o';
|
|
|
|
}
|
|
|
|
|
|
|
|
if (utcr0 & UTCR0_DSS)
|
|
|
|
*bits = 8;
|
|
|
|
else
|
|
|
|
*bits = 7;
|
|
|
|
|
|
|
|
quot = UART_GET_UTCR2(sport) | UART_GET_UTCR1(sport) << 8;
|
|
|
|
quot &= 0xfff;
|
|
|
|
*baud = sport->port.uartclk / (16 * (quot + 1));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static int __init
|
|
|
|
sa1100_console_setup(struct console *co, char *options)
|
|
|
|
{
|
|
|
|
struct sa1100_port *sport;
|
|
|
|
int baud = 9600;
|
|
|
|
int bits = 8;
|
|
|
|
int parity = 'n';
|
|
|
|
int flow = 'n';
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Check whether an invalid uart number has been specified, and
|
|
|
|
* if so, search for the first available port that does have
|
|
|
|
* console support.
|
|
|
|
*/
|
|
|
|
if (co->index == -1 || co->index >= NR_PORTS)
|
|
|
|
co->index = 0;
|
|
|
|
sport = &sa1100_ports[co->index];
|
|
|
|
|
|
|
|
if (options)
|
|
|
|
uart_parse_options(options, &baud, &parity, &bits, &flow);
|
|
|
|
else
|
|
|
|
sa1100_console_get_options(sport, &baud, &parity, &bits);
|
|
|
|
|
|
|
|
return uart_set_options(&sport->port, co, baud, parity, bits, flow);
|
|
|
|
}
|
|
|
|
|
2005-09-15 05:36:03 +08:00
|
|
|
static struct uart_driver sa1100_reg;
|
2005-04-17 06:20:36 +08:00
|
|
|
static struct console sa1100_console = {
|
|
|
|
.name = "ttySA",
|
|
|
|
.write = sa1100_console_write,
|
|
|
|
.device = uart_console_device,
|
|
|
|
.setup = sa1100_console_setup,
|
|
|
|
.flags = CON_PRINTBUFFER,
|
|
|
|
.index = -1,
|
|
|
|
.data = &sa1100_reg,
|
|
|
|
};
|
|
|
|
|
|
|
|
static int __init sa1100_rs_console_init(void)
|
|
|
|
{
|
|
|
|
sa1100_init_ports();
|
|
|
|
register_console(&sa1100_console);
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
console_initcall(sa1100_rs_console_init);
|
|
|
|
|
|
|
|
#define SA1100_CONSOLE &sa1100_console
|
|
|
|
#else
|
|
|
|
#define SA1100_CONSOLE NULL
|
|
|
|
#endif
|
|
|
|
|
|
|
|
static struct uart_driver sa1100_reg = {
|
|
|
|
.owner = THIS_MODULE,
|
|
|
|
.driver_name = "ttySA",
|
|
|
|
.dev_name = "ttySA",
|
|
|
|
.major = SERIAL_SA1100_MAJOR,
|
|
|
|
.minor = MINOR_START,
|
|
|
|
.nr = NR_PORTS,
|
|
|
|
.cons = SA1100_CONSOLE,
|
|
|
|
};
|
|
|
|
|
2005-11-10 06:32:44 +08:00
|
|
|
static int sa1100_serial_suspend(struct platform_device *dev, pm_message_t state)
|
2005-04-17 06:20:36 +08:00
|
|
|
{
|
2005-11-10 06:32:44 +08:00
|
|
|
struct sa1100_port *sport = platform_get_drvdata(dev);
|
2005-04-17 06:20:36 +08:00
|
|
|
|
2005-10-29 00:52:56 +08:00
|
|
|
if (sport)
|
2005-04-17 06:20:36 +08:00
|
|
|
uart_suspend_port(&sa1100_reg, &sport->port);
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2005-11-10 06:32:44 +08:00
|
|
|
static int sa1100_serial_resume(struct platform_device *dev)
|
2005-04-17 06:20:36 +08:00
|
|
|
{
|
2005-11-10 06:32:44 +08:00
|
|
|
struct sa1100_port *sport = platform_get_drvdata(dev);
|
2005-04-17 06:20:36 +08:00
|
|
|
|
2005-10-29 00:52:56 +08:00
|
|
|
if (sport)
|
2005-04-17 06:20:36 +08:00
|
|
|
uart_resume_port(&sa1100_reg, &sport->port);
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2016-08-31 15:49:52 +08:00
|
|
|
static int sa1100_serial_add_one_port(struct sa1100_port *sport, struct platform_device *dev)
|
|
|
|
{
|
|
|
|
sport->port.dev = &dev->dev;
|
2019-12-13 08:06:35 +08:00
|
|
|
sport->port.has_sysrq = IS_ENABLED(CONFIG_SERIAL_SA1100_CONSOLE);
|
2019-05-31 23:21:28 +08:00
|
|
|
|
|
|
|
// mctrl_gpio_init() requires that the GPIO driver supports interrupts,
|
|
|
|
// but we need to support GPIO drivers for hardware that has no such
|
|
|
|
// interrupts. Use mctrl_gpio_init_noauto() instead.
|
2016-08-31 15:49:52 +08:00
|
|
|
sport->gpios = mctrl_gpio_init_noauto(sport->port.dev, 0);
|
|
|
|
if (IS_ERR(sport->gpios)) {
|
|
|
|
int err = PTR_ERR(sport->gpios);
|
|
|
|
|
|
|
|
dev_err(sport->port.dev, "failed to get mctrl gpios: %d\n",
|
|
|
|
err);
|
|
|
|
|
|
|
|
if (err == -EPROBE_DEFER)
|
|
|
|
return err;
|
|
|
|
|
|
|
|
sport->gpios = NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
platform_set_drvdata(dev, sport);
|
|
|
|
|
|
|
|
return uart_add_one_port(&sa1100_reg, &sport->port);
|
|
|
|
}
|
|
|
|
|
2005-11-10 06:32:44 +08:00
|
|
|
static int sa1100_serial_probe(struct platform_device *dev)
|
2005-04-17 06:20:36 +08:00
|
|
|
{
|
2020-08-04 21:48:07 +08:00
|
|
|
struct resource *res;
|
2005-04-17 06:20:36 +08:00
|
|
|
int i;
|
|
|
|
|
2020-08-04 21:48:07 +08:00
|
|
|
res = platform_get_resource(dev, IORESOURCE_MEM, 0);
|
|
|
|
if (!res)
|
|
|
|
return -EINVAL;
|
2005-04-17 06:20:36 +08:00
|
|
|
|
2020-08-04 21:48:07 +08:00
|
|
|
for (i = 0; i < NR_PORTS; i++)
|
|
|
|
if (sa1100_ports[i].port.mapbase == res->start)
|
2005-04-17 06:20:36 +08:00
|
|
|
break;
|
2020-08-04 21:48:07 +08:00
|
|
|
if (i == NR_PORTS)
|
|
|
|
return -ENODEV;
|
|
|
|
|
|
|
|
sa1100_serial_add_one_port(&sa1100_ports[i], dev);
|
2005-04-17 06:20:36 +08:00
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2005-11-10 06:32:44 +08:00
|
|
|
static int sa1100_serial_remove(struct platform_device *pdev)
|
2005-04-17 06:20:36 +08:00
|
|
|
{
|
2005-11-10 06:32:44 +08:00
|
|
|
struct sa1100_port *sport = platform_get_drvdata(pdev);
|
2005-04-17 06:20:36 +08:00
|
|
|
|
|
|
|
if (sport)
|
|
|
|
uart_remove_one_port(&sa1100_reg, &sport->port);
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2005-11-10 06:32:44 +08:00
|
|
|
static struct platform_driver sa11x0_serial_driver = {
|
2005-04-17 06:20:36 +08:00
|
|
|
.probe = sa1100_serial_probe,
|
|
|
|
.remove = sa1100_serial_remove,
|
|
|
|
.suspend = sa1100_serial_suspend,
|
|
|
|
.resume = sa1100_serial_resume,
|
2005-11-10 06:32:44 +08:00
|
|
|
.driver = {
|
|
|
|
.name = "sa11x0-uart",
|
|
|
|
},
|
2005-04-17 06:20:36 +08:00
|
|
|
};
|
|
|
|
|
|
|
|
static int __init sa1100_serial_init(void)
|
|
|
|
{
|
|
|
|
int ret;
|
|
|
|
|
2008-07-17 04:53:31 +08:00
|
|
|
printk(KERN_INFO "Serial: SA11x0 driver\n");
|
2005-04-17 06:20:36 +08:00
|
|
|
|
|
|
|
sa1100_init_ports();
|
|
|
|
|
|
|
|
ret = uart_register_driver(&sa1100_reg);
|
|
|
|
if (ret == 0) {
|
2005-11-10 06:32:44 +08:00
|
|
|
ret = platform_driver_register(&sa11x0_serial_driver);
|
2005-04-17 06:20:36 +08:00
|
|
|
if (ret)
|
|
|
|
uart_unregister_driver(&sa1100_reg);
|
|
|
|
}
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void __exit sa1100_serial_exit(void)
|
|
|
|
{
|
2005-11-10 06:32:44 +08:00
|
|
|
platform_driver_unregister(&sa11x0_serial_driver);
|
2005-04-17 06:20:36 +08:00
|
|
|
uart_unregister_driver(&sa1100_reg);
|
|
|
|
}
|
|
|
|
|
|
|
|
module_init(sa1100_serial_init);
|
|
|
|
module_exit(sa1100_serial_exit);
|
|
|
|
|
|
|
|
MODULE_AUTHOR("Deep Blue Solutions Ltd");
|
2008-07-17 04:53:31 +08:00
|
|
|
MODULE_DESCRIPTION("SA1100 generic serial port driver");
|
2005-04-17 06:20:36 +08:00
|
|
|
MODULE_LICENSE("GPL");
|
|
|
|
MODULE_ALIAS_CHARDEV_MAJOR(SERIAL_SA1100_MAJOR);
|
2008-04-16 05:34:35 +08:00
|
|
|
MODULE_ALIAS("platform:sa11x0-uart");
|