Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
L
linux
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Kirill Smelkov
linux
Commits
eaab542a
Commit
eaab542a
authored
Jul 01, 2003
by
Martin Diehl
Committed by
Stephen Hemminger
Jul 01, 2003
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
[PATCH] Missing IrDA stuff for 2.5.73-bk8: sir_dev
Cleanups, and kernel thread + swsuspend fix.
parent
947af82f
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
26 additions
and
71 deletions
+26
-71
drivers/net/irda/irtty-sir.c
drivers/net/irda/irtty-sir.c
+12
-18
drivers/net/irda/sir_dev.c
drivers/net/irda/sir_dev.c
+8
-14
drivers/net/irda/sir_kthread.c
drivers/net/irda/sir_kthread.c
+6
-39
No files found.
drivers/net/irda/irtty-sir.c
View file @
eaab542a
...
...
@@ -212,13 +212,6 @@ static int irtty_set_dtr_rts(struct sir_dev *dev, int dtr, int rts)
/* called from sir_dev when there is more data to send
* context is either netdev->hard_xmit or some transmit-completion bh
* i.e. we are under spinlock here and must not sleep.
*
* Note: as of 2.5.44 the usb-serial driver calls down() on a semaphore
* hence we are hitting the might_sleep bugcatcher. IMHO the whole tty-api
* would be pretty pointless if write_room/write would be allowed to sleep.
* Furthermore other tty ldiscs (like ppp) do also require the driver not
* to sleep there. Hence this is considered a current limitation of
* usb-serial.
*/
static
int
irtty_do_write
(
struct
sir_dev
*
dev
,
const
unsigned
char
*
ptr
,
size_t
len
)
...
...
@@ -269,16 +262,15 @@ static void irtty_receive_buf(struct tty_struct *tty, const unsigned char *cp,
struct
sirtty_cb
*
priv
=
tty
->
disc_data
;
int
i
;
if
(
unlikely
(
!
priv
||
priv
->
magic
!=
IRTTY_MAGIC
))
return
;
/* Please use ASSERT - Fix ASSERT as needed - Jean II */
ASSERT
(
priv
!=
NULL
,
return
;);
ASSERT
(
priv
->
magic
==
IRTTY_MAGIC
,
return
;);
if
(
unlikely
(
count
==
0
))
/* yes, this happens */
return
;
dev
=
priv
->
dev
;
if
(
!
dev
)
{
printk
(
KERN_ERR
"%s(), not ready yet!
\n
"
,
__FUNCTION__
);
WARNING
(
"%s(), not ready yet!
\n
"
,
__FUNCTION__
);
return
;
}
...
...
@@ -306,8 +298,8 @@ static int irtty_receive_room(struct tty_struct *tty)
{
struct
sirtty_cb
*
priv
=
tty
->
disc_data
;
if
(
unlikely
(
!
priv
||
priv
->
magic
!=
IRTTY_MAGIC
))
return
0
;
ASSERT
(
priv
!=
NULL
,
return
0
;);
ASSERT
(
priv
->
magic
==
IRTTY_MAGIC
,
return
0
;)
;
return
65536
;
/* We can handle an infinite amount of data. :-) */
}
...
...
@@ -323,8 +315,8 @@ static void irtty_write_wakeup(struct tty_struct *tty)
{
struct
sirtty_cb
*
priv
=
tty
->
disc_data
;
if
(
unlikely
(
!
priv
||
priv
->
magic
!=
IRTTY_MAGIC
))
return
;
ASSERT
(
priv
!=
NULL
,
return
;);
ASSERT
(
priv
->
magic
==
IRTTY_MAGIC
,
return
;)
;
tty
->
flags
&=
~
(
1
<<
TTY_DO_WRITE_WAKEUP
);
...
...
@@ -559,7 +551,7 @@ static int irtty_open(struct tty_struct *tty)
up
(
&
irtty_sem
);
printk
(
KERN_INFO
"%s - done
\n
"
,
__FUNCTION__
);
IRDA_DEBUG
(
0
,
"%s - %s: irda line discipline opened
\n
"
,
__FUNCTION__
,
tty
->
name
);
return
0
;
...
...
@@ -580,8 +572,8 @@ static void irtty_close(struct tty_struct *tty)
{
struct
sirtty_cb
*
priv
=
tty
->
disc_data
;
if
(
!
priv
||
priv
->
magic
!=
IRTTY_MAGIC
)
return
;
ASSERT
(
priv
!=
NULL
,
return
;);
ASSERT
(
priv
->
magic
==
IRTTY_MAGIC
,
return
;)
;
/* Hm, with a dongle attached the dongle driver wants
* to close the dongle - which requires the use of
...
...
@@ -610,6 +602,8 @@ static void irtty_close(struct tty_struct *tty)
tty
->
driver
->
stop
(
tty
);
kfree
(
priv
);
IRDA_DEBUG
(
0
,
"%s - %s: irda line discipline closed
\n
"
,
__FUNCTION__
,
tty
->
name
);
}
/* ------------------------------------------------------- */
...
...
drivers/net/irda/sir_dev.c
View file @
eaab542a
...
...
@@ -201,14 +201,12 @@ void sirdev_write_complete(struct sir_dev *dev)
int
sirdev_receive
(
struct
sir_dev
*
dev
,
const
unsigned
char
*
cp
,
size_t
count
)
{
if
(
!
dev
||
!
dev
->
netdev
)
{
IRDA_DEBUG
(
0
,
"%s(), not ready yet!
\n
"
,
__FUNCTION__
);
/* Use WARNING instead of IRDA_DEBUG */
WARNING
(
"%s(), not ready yet!
\n
"
,
__FUNCTION__
);
return
-
1
;
}
if
(
!
dev
->
irlap
)
{
IRDA_DEBUG
(
0
,
"%s - too early: %p / %d!
\n
"
,
__FUNCTION__
,
cp
,
count
);
/* Use WARNING instead of IRDA_DEBUG */
WARNING
(
"%s - too early: %p / %d!
\n
"
,
__FUNCTION__
,
cp
,
count
);
return
-
1
;
}
...
...
@@ -218,7 +216,7 @@ int sirdev_receive(struct sir_dev *dev, const unsigned char *cp, size_t count)
*/
irda_device_set_media_busy
(
dev
->
netdev
,
TRUE
);
dev
->
stats
.
rx_dropped
++
;
printk
(
KERN_INFO
"%s; rx-drop: %d
\n
"
,
__FUNCTION__
,
count
);
IRDA_DEBUG
(
0
,
"%s; rx-drop: %d
\n
"
,
__FUNCTION__
,
count
);
return
0
;
}
...
...
@@ -431,7 +429,6 @@ static int sirdev_alloc_buffers(struct sir_dev *dev)
return
-
ENOMEM
;
skb_reserve
(
dev
->
rx_buff
.
skb
,
1
);
dev
->
rx_buff
.
head
=
dev
->
rx_buff
.
skb
->
data
;
/* No need to memset the buffer, unless you are really pedantic */
dev
->
tx_buff
.
head
=
kmalloc
(
dev
->
tx_buff
.
truesize
,
GFP_KERNEL
);
if
(
dev
->
tx_buff
.
head
==
NULL
)
{
...
...
@@ -439,8 +436,6 @@ static int sirdev_alloc_buffers(struct sir_dev *dev)
dev
->
rx_buff
.
skb
=
NULL
;
dev
->
rx_buff
.
head
=
NULL
;
return
-
ENOMEM
;
/* Hu ??? This should not be here, Martin ? */
memset
(
dev
->
tx_buff
.
head
,
0
,
dev
->
tx_buff
.
truesize
);
}
dev
->
tx_buff
.
data
=
dev
->
tx_buff
.
head
;
...
...
@@ -492,7 +487,7 @@ static int sirdev_open(struct net_device *ndev)
netif_wake_queue
(
ndev
);
printk
(
KERN_INFO
"%s - done, speed = %d
\n
"
,
__FUNCTION__
,
dev
->
speed
);
IRDA_DEBUG
(
2
,
"%s - done, speed = %d
\n
"
,
__FUNCTION__
,
dev
->
speed
);
return
0
;
...
...
@@ -512,7 +507,7 @@ static int sirdev_close(struct net_device *ndev)
struct
sir_dev
*
dev
=
ndev
->
priv
;
const
struct
sir_driver
*
drv
;
printk
(
KERN_INFO
"%s
\n
"
,
__FUNCTION__
);
// IRDA_DEBUG(0,
"%s\n", __FUNCTION__);
netif_stop_queue
(
ndev
);
...
...
@@ -570,7 +565,7 @@ struct sir_dev * sirdev_get_instance(const struct sir_driver *drv, const char *n
struct
net_device
*
ndev
;
struct
sir_dev
*
dev
;
printk
(
KERN_INFO
"%s - %s
\n
"
,
__FUNCTION__
,
name
);
IRDA_DEBUG
(
0
,
"%s - %s
\n
"
,
__FUNCTION__
,
name
);
/* instead of adding tests to protect against drv->do_write==NULL
* at several places we refuse to create a sir_dev instance for
...
...
@@ -584,8 +579,7 @@ struct sir_dev * sirdev_get_instance(const struct sir_driver *drv, const char *n
*/
dev
=
kmalloc
(
sizeof
(
*
dev
),
GFP_KERNEL
);
if
(
dev
==
NULL
)
{
printk
(
KERN_ERR
"IrDA: Can't allocate memory for "
"IrDA control block!
\n
"
);
ERROR
(
"%s - Can't allocate memory for IrDA control block!
\n
"
,
__FUNCTION__
);
goto
out
;
}
memset
(
dev
,
0
,
sizeof
(
*
dev
));
...
...
@@ -638,7 +632,7 @@ int sirdev_put_instance(struct sir_dev *dev)
{
int
err
=
0
;
printk
(
KERN_INFO
"%s
\n
"
,
__FUNCTION__
);
IRDA_DEBUG
(
0
,
"%s
\n
"
,
__FUNCTION__
);
atomic_set
(
&
dev
->
enable_rx
,
0
);
...
...
drivers/net/irda/sir_kthread.c
View file @
eaab542a
...
...
@@ -19,6 +19,7 @@
#include <linux/smp_lock.h>
#include <linux/completion.h>
#include <linux/delay.h>
#include <linux/suspend.h>
#include <net/irda/irda.h>
...
...
@@ -107,44 +108,12 @@ static void run_irda_queue(void)
spin_unlock_irqrestore
(
&
irda_rq_queue
.
lock
,
flags
);
}
static
int
irda_rt_prio
=
0
;
/* MODULE_PARM? */
static
int
irda_thread
(
void
*
startup
)
{
DECLARE_WAITQUEUE
(
wait
,
current
);
daemonize
(
"kIrDAd"
);
set_fs
(
KERNEL_DS
);
if
(
irda_rt_prio
>
0
)
{
#if 0 /* works but requires EXPORT_SYMBOL(setscheduler) */
struct sched_param param;
param.sched_priority = irda_rt_prio;
setscheduler(0, SCHED_FIFO, ¶m);
#endif
#if 0 /* doesn't work - has some tendency to trigger instant reboot!
* looks like we would have to deactivate current on the
* runqueue - which is only possible inside of kernel/sched.h
*/
/* runqueues are per-cpu and we are current on this cpu. Hence
* The tasklist_lock with irq-off protects our runqueue too
* and we don't have to lock it (which would be impossible,
* because it is private in kernel/sched.c)
*/
read_lock_irq(&tasklist_lock);
current->rt_priority = (irda_rt_prio<MAX_RT_PRIO)
? irda_rt_prio : MAX_RT_PRIO-1;
current->policy = SCHED_FIFO;
current->prio = MAX_USER_RT_PRIO-1 - irda_rt_prio;
read_unlock_irq(&tasklist_lock);
#endif
}
irda_rq_queue
.
thread
=
current
;
complete
((
struct
completion
*
)
startup
);
...
...
@@ -166,6 +135,10 @@ static int irda_thread(void *startup)
set_task_state
(
current
,
TASK_RUNNING
);
remove_wait_queue
(
&
irda_rq_queue
.
kick
,
&
wait
);
/* make swsusp happy with our thread */
if
(
current
->
flags
&
PF_FREEZE
)
refrigerator
(
PF_IOTHREAD
);
run_irda_queue
();
}
...
...
@@ -442,7 +415,6 @@ static void irda_config_fsm(void *data)
case
SIRDEV_STATE_COMPLETE
:
/* config change finished, so we are not busy any longer */
sirdev_enable_rx
(
dev
);
printk
(
KERN_INFO
"%s - up
\n
"
,
__FUNCTION__
);
up
(
&
fsm
->
sem
);
return
;
}
...
...
@@ -462,9 +434,7 @@ int sirdev_schedule_request(struct sir_dev *dev, int initial_state, unsigned par
struct
sir_fsm
*
fsm
=
&
dev
->
fsm
;
int
xmit_was_down
;
// IRDA_DEBUG(2, "%s - state=0x%04x / param=%u\n", __FUNCTION__, initial_state, param);
printk
(
KERN_INFO
"%s - state=0x%04x / param=%u
\n
"
,
__FUNCTION__
,
initial_state
,
param
);
IRDA_DEBUG
(
2
,
"%s - state=0x%04x / param=%u
\n
"
,
__FUNCTION__
,
initial_state
,
param
);
if
(
in_interrupt
())
{
if
(
down_trylock
(
&
fsm
->
sem
))
{
...
...
@@ -474,12 +444,10 @@ int sirdev_schedule_request(struct sir_dev *dev, int initial_state, unsigned par
}
else
down
(
&
fsm
->
sem
);
printk
(
KERN_INFO
"%s - down
\n
"
,
__FUNCTION__
);
if
(
fsm
->
state
==
SIRDEV_STATE_DEAD
)
{
/* race with sirdev_close should never happen */
ERROR
(
"%s(), instance staled!
\n
"
,
__FUNCTION__
);
printk
(
KERN_INFO
"%s - up
\n
"
,
__FUNCTION__
);
up
(
&
fsm
->
sem
);
return
-
ESTALE
;
/* or better EPIPE? */
}
...
...
@@ -501,7 +469,6 @@ int sirdev_schedule_request(struct sir_dev *dev, int initial_state, unsigned par
atomic_set
(
&
dev
->
enable_rx
,
1
);
if
(
!
xmit_was_down
)
netif_wake_queue
(
dev
->
netdev
);
printk
(
KERN_INFO
"%s - up
\n
"
,
__FUNCTION__
);
up
(
&
fsm
->
sem
);
return
-
EAGAIN
;
}
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment