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
cfc8d68f
Commit
cfc8d68f
authored
Dec 17, 2002
by
Maksim Krasnyanskiy
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Convert Bluetooth HCI devices to new module refcounting.
parent
d7105887
Changes
10
Show whitespace changes
Inline
Side-by-side
Showing
10 changed files
with
54 additions
and
53 deletions
+54
-53
drivers/bluetooth/bluecard_cs.c
drivers/bluetooth/bluecard_cs.c
+2
-4
drivers/bluetooth/bt3c_cs.c
drivers/bluetooth/bt3c_cs.c
+2
-4
drivers/bluetooth/btuart_cs.c
drivers/bluetooth/btuart_cs.c
+2
-4
drivers/bluetooth/dtl1_cs.c
drivers/bluetooth/dtl1_cs.c
+2
-4
drivers/bluetooth/hci_ldisc.c
drivers/bluetooth/hci_ldisc.c
+4
-7
drivers/bluetooth/hci_usb.c
drivers/bluetooth/hci_usb.c
+4
-7
drivers/bluetooth/hci_vhci.c
drivers/bluetooth/hci_vhci.c
+2
-3
include/net/bluetooth/hci_core.h
include/net/bluetooth/hci_core.h
+23
-3
net/bluetooth/hci_conn.c
net/bluetooth/hci_conn.c
+2
-3
net/bluetooth/hci_core.c
net/bluetooth/hci_core.c
+11
-14
No files found.
drivers/bluetooth/bluecard_cs.c
View file @
cfc8d68f
...
...
@@ -789,6 +789,8 @@ int bluecard_open(bluecard_info_t *info)
hdev
->
destruct
=
bluecard_hci_destruct
;
hdev
->
ioctl
=
bluecard_hci_ioctl
;
hdev
->
owner
=
THIS_MODULE
;
if
(
hci_register_dev
(
hdev
)
<
0
)
{
printk
(
KERN_WARNING
"bluecard_cs: Can't register HCI device %s.
\n
"
,
hdev
->
name
);
return
-
ENODEV
;
...
...
@@ -1002,8 +1004,6 @@ void bluecard_config(dev_link_t *link)
goto
failed
;
}
MOD_INC_USE_COUNT
;
if
(
bluecard_open
(
info
)
!=
0
)
goto
failed
;
...
...
@@ -1029,8 +1029,6 @@ void bluecard_release(u_long arg)
if
(
link
->
state
&
DEV_PRESENT
)
bluecard_close
(
info
);
MOD_DEC_USE_COUNT
;
link
->
dev
=
NULL
;
CardServices
(
ReleaseConfiguration
,
link
->
handle
);
...
...
drivers/bluetooth/bt3c_cs.c
View file @
cfc8d68f
...
...
@@ -593,6 +593,8 @@ int bt3c_open(bt3c_info_t *info)
hdev
->
destruct
=
bt3c_hci_destruct
;
hdev
->
ioctl
=
bt3c_hci_ioctl
;
hdev
->
owner
=
THIS_MODULE
;
if
(
hci_register_dev
(
hdev
)
<
0
)
{
printk
(
KERN_WARNING
"bt3c_cs: Can't register HCI device %s.
\n
"
,
hdev
->
name
);
return
-
ENODEV
;
...
...
@@ -835,8 +837,6 @@ void bt3c_config(dev_link_t *link)
goto
failed
;
}
MOD_INC_USE_COUNT
;
if
(
bt3c_open
(
info
)
!=
0
)
goto
failed
;
...
...
@@ -862,8 +862,6 @@ void bt3c_release(u_long arg)
if
(
link
->
state
&
DEV_PRESENT
)
bt3c_close
(
info
);
MOD_DEC_USE_COUNT
;
link
->
dev
=
NULL
;
CardServices
(
ReleaseConfiguration
,
link
->
handle
);
...
...
drivers/bluetooth/btuart_cs.c
View file @
cfc8d68f
...
...
@@ -541,6 +541,8 @@ int btuart_open(btuart_info_t *info)
hdev
->
destruct
=
btuart_hci_destruct
;
hdev
->
ioctl
=
btuart_hci_ioctl
;
hdev
->
owner
=
THIS_MODULE
;
if
(
hci_register_dev
(
hdev
)
<
0
)
{
printk
(
KERN_WARNING
"btuart_cs: Can't register HCI device %s.
\n
"
,
hdev
->
name
);
return
-
ENODEV
;
...
...
@@ -795,8 +797,6 @@ void btuart_config(dev_link_t *link)
goto
failed
;
}
MOD_INC_USE_COUNT
;
if
(
btuart_open
(
info
)
!=
0
)
goto
failed
;
...
...
@@ -822,8 +822,6 @@ void btuart_release(u_long arg)
if
(
link
->
state
&
DEV_PRESENT
)
btuart_close
(
info
);
MOD_DEC_USE_COUNT
;
link
->
dev
=
NULL
;
CardServices
(
ReleaseConfiguration
,
link
->
handle
);
...
...
drivers/bluetooth/dtl1_cs.c
View file @
cfc8d68f
...
...
@@ -520,6 +520,8 @@ int dtl1_open(dtl1_info_t *info)
hdev
->
destruct
=
dtl1_hci_destruct
;
hdev
->
ioctl
=
dtl1_hci_ioctl
;
hdev
->
owner
=
THIS_MODULE
;
if
(
hci_register_dev
(
hdev
)
<
0
)
{
printk
(
KERN_WARNING
"dtl1_cs: Can't register HCI device %s.
\n
"
,
hdev
->
name
);
return
-
ENODEV
;
...
...
@@ -747,8 +749,6 @@ void dtl1_config(dev_link_t *link)
goto
failed
;
}
MOD_INC_USE_COUNT
;
if
(
dtl1_open
(
info
)
!=
0
)
goto
failed
;
...
...
@@ -774,8 +774,6 @@ void dtl1_release(u_long arg)
if
(
link
->
state
&
DEV_PRESENT
)
dtl1_close
(
info
);
MOD_DEC_USE_COUNT
;
link
->
dev
=
NULL
;
CardServices
(
ReleaseConfiguration
,
link
->
handle
);
...
...
drivers/bluetooth/hci_ldisc.c
View file @
cfc8d68f
...
...
@@ -250,8 +250,6 @@ static void hci_uart_destruct(struct hci_dev *hdev)
hu
=
(
struct
hci_uart
*
)
hdev
->
driver_data
;
kfree
(
hu
);
MOD_DEC_USE_COUNT
;
}
/* ------ LDISC part ------ */
...
...
@@ -291,7 +289,6 @@ static int hci_uart_tty_open(struct tty_struct *tty)
if
(
tty
->
driver
.
flush_buffer
)
tty
->
driver
.
flush_buffer
(
tty
);
MOD_INC_USE_COUNT
;
return
0
;
}
...
...
@@ -317,8 +314,6 @@ static void hci_uart_tty_close(struct tty_struct *tty)
hu
->
proto
->
close
(
hu
);
hci_unregister_dev
(
hdev
);
}
MOD_DEC_USE_COUNT
;
}
}
...
...
@@ -411,11 +406,13 @@ static int hci_uart_register_dev(struct hci_uart *hu)
hdev
->
send
=
hci_uart_send_frame
;
hdev
->
destruct
=
hci_uart_destruct
;
hdev
->
owner
=
THIS_MODULE
;
if
(
hci_register_dev
(
hdev
)
<
0
)
{
BT_ERR
(
"Can't register HCI device %s"
,
hdev
->
name
);
return
-
ENODEV
;
}
MOD_INC_USE_COUNT
;
return
0
;
}
...
...
drivers/bluetooth/hci_usb.c
View file @
cfc8d68f
...
...
@@ -207,18 +207,15 @@ static int hci_usb_open(struct hci_dev *hdev)
if
(
test_and_set_bit
(
HCI_RUNNING
,
&
hdev
->
flags
))
return
0
;
MOD_INC_USE_COUNT
;
write_lock_irqsave
(
&
husb
->
completion_lock
,
flags
);
err
=
hci_usb_enable_intr
(
husb
);
if
(
!
err
)
{
for
(
i
=
0
;
i
<
HCI_MAX_BULK_RX
;
i
++
)
hci_usb_rx_submit
(
husb
,
NULL
);
}
else
{
}
else
clear_bit
(
HCI_RUNNING
,
&
hdev
->
flags
);
MOD_DEC_USE_COUNT
;
}
write_unlock_irqrestore
(
&
husb
->
completion_lock
,
flags
);
return
err
;
...
...
@@ -271,8 +268,6 @@ static int hci_usb_close(struct hci_dev *hdev)
hci_usb_flush
(
hdev
);
write_unlock_irqrestore
(
&
husb
->
completion_lock
,
flags
);
MOD_DEC_USE_COUNT
;
return
0
;
}
...
...
@@ -758,6 +753,8 @@ int hci_usb_probe(struct usb_interface *intf, const struct usb_device_id *id)
hdev
->
send
=
hci_usb_send_frame
;
hdev
->
destruct
=
hci_usb_destruct
;
hdev
->
owner
=
THIS_MODULE
;
if
(
hci_register_dev
(
hdev
)
<
0
)
{
BT_ERR
(
"Can't register HCI device"
);
goto
probe_error
;
...
...
drivers/bluetooth/hci_vhci.c
View file @
cfc8d68f
...
...
@@ -84,8 +84,6 @@ static void hci_vhci_destruct(struct hci_dev *hdev)
vhci
=
(
struct
hci_vhci_struct
*
)
hdev
->
driver_data
;
kfree
(
vhci
);
MOD_DEC_USE_COUNT
;
}
static
int
hci_vhci_send_frame
(
struct
sk_buff
*
skb
)
...
...
@@ -288,11 +286,12 @@ static int hci_vhci_chr_open(struct inode *inode, struct file * file)
hdev
->
send
=
hci_vhci_send_frame
;
hdev
->
destruct
=
hci_vhci_destruct
;
hdev
->
owner
=
THIS_MODULE
;
if
(
hci_register_dev
(
hdev
)
<
0
)
{
kfree
(
hci_vhci
);
return
-
EBUSY
;
}
MOD_INC_USE_COUNT
;
file
->
private_data
=
hci_vhci
;
return
0
;
...
...
include/net/bluetooth/hci_core.h
View file @
cfc8d68f
...
...
@@ -118,6 +118,8 @@ struct hci_dev {
struct
proc_dir_entry
*
proc
;
#endif
struct
module
*
owner
;
int
(
*
open
)(
struct
hci_dev
*
hdev
);
int
(
*
close
)(
struct
hci_dev
*
hdev
);
int
(
*
flush
)(
struct
hci_dev
*
hdev
);
...
...
@@ -299,12 +301,30 @@ static inline void hci_sched_tx(struct hci_dev *hdev)
}
/* ----- HCI Devices ----- */
static
inline
void
hci_dev_put
(
struct
hci_dev
*
d
)
static
inline
void
__
hci_dev_put
(
struct
hci_dev
*
d
)
{
if
(
atomic_dec_and_test
(
&
d
->
refcnt
))
d
->
destruct
(
d
);
}
#define hci_dev_hold(d) atomic_inc(&d->refcnt)
static
inline
void
hci_dev_put
(
struct
hci_dev
*
d
)
{
__hci_dev_put
(
d
);
module_put
(
d
->
owner
);
}
static
inline
struct
hci_dev
*
__hci_dev_hold
(
struct
hci_dev
*
d
)
{
atomic_inc
(
&
d
->
refcnt
);
return
d
;
}
static
inline
struct
hci_dev
*
hci_dev_hold
(
struct
hci_dev
*
d
)
{
if
(
try_module_get
(
d
->
owner
))
return
__hci_dev_hold
(
d
);
return
NULL
;
}
#define hci_dev_lock(d) spin_lock(&d->lock)
#define hci_dev_unlock(d) spin_unlock(&d->lock)
...
...
net/bluetooth/hci_conn.c
View file @
cfc8d68f
...
...
@@ -218,8 +218,7 @@ struct hci_dev *hci_get_route(bdaddr_t *dst, bdaddr_t *src)
read_lock_bh
(
&
hci_dev_list_lock
);
list_for_each
(
p
,
&
hci_dev_list
)
{
struct
hci_dev
*
d
;
d
=
list_entry
(
p
,
struct
hci_dev
,
list
);
struct
hci_dev
*
d
=
list_entry
(
p
,
struct
hci_dev
,
list
);
if
(
!
test_bit
(
HCI_UP
,
&
d
->
flags
))
continue
;
...
...
@@ -241,7 +240,7 @@ struct hci_dev *hci_get_route(bdaddr_t *dst, bdaddr_t *src)
}
if
(
hdev
)
hci_dev_hold
(
hdev
);
h
dev
=
h
ci_dev_hold
(
hdev
);
read_unlock_bh
(
&
hci_dev_list_lock
);
return
hdev
;
...
...
net/bluetooth/hci_core.c
View file @
cfc8d68f
...
...
@@ -287,10 +287,10 @@ static void hci_encrypt_req(struct hci_dev *hdev, unsigned long opt)
}
/* Get HCI device by index.
* Device is
locke
d on return. */
* Device is
hel
d on return. */
struct
hci_dev
*
hci_dev_get
(
int
index
)
{
struct
hci_dev
*
hdev
;
struct
hci_dev
*
hdev
=
NULL
;
struct
list_head
*
p
;
BT_DBG
(
"%d"
,
index
);
...
...
@@ -300,14 +300,12 @@ struct hci_dev *hci_dev_get(int index)
read_lock
(
&
hci_dev_list_lock
);
list_for_each
(
p
,
&
hci_dev_list
)
{
hdev
=
list_entry
(
p
,
struct
hci_dev
,
list
);
if
(
hdev
->
id
==
index
)
{
h
ci_dev_hold
(
hdev
);
goto
done
;
struct
hci_dev
*
d
=
list_entry
(
p
,
struct
hci_dev
,
list
);
if
(
d
->
id
==
index
)
{
h
dev
=
hci_dev_hold
(
d
);
break
;
}
}
hdev
=
NULL
;
done:
read_unlock
(
&
hci_dev_list_lock
);
return
hdev
;
}
...
...
@@ -483,6 +481,7 @@ int hci_dev_open(__u16 dev)
}
if
(
!
ret
)
{
hci_dev_hold
(
hdev
);
set_bit
(
HCI_UP
,
&
hdev
->
flags
);
hci_notify
(
hdev
,
HCI_DEV_UP
);
}
else
{
...
...
@@ -567,6 +566,8 @@ static int hci_dev_do_close(struct hci_dev *hdev)
hdev
->
flags
=
0
;
hci_req_unlock
(
hdev
);
hci_dev_put
(
hdev
);
return
0
;
}
...
...
@@ -790,7 +791,7 @@ int hci_register_dev(struct hci_dev *hdev)
struct
list_head
*
head
=
&
hci_dev_list
,
*
p
;
int
id
=
0
;
BT_DBG
(
"%p name %s type %d
"
,
hdev
,
hdev
->
name
,
hdev
->
type
);
BT_DBG
(
"%p name %s type %d
owner %p"
,
hdev
,
hdev
->
name
,
hdev
->
type
,
hdev
->
owner
);
if
(
!
hdev
->
open
||
!
hdev
->
close
||
!
hdev
->
destruct
)
return
-
EINVAL
;
...
...
@@ -834,8 +835,6 @@ int hci_register_dev(struct hci_dev *hdev)
atomic_set
(
&
hdev
->
promisc
,
0
);
MOD_INC_USE_COUNT
;
write_unlock_bh
(
&
hci_dev_list_lock
);
hci_dev_proc_init
(
hdev
);
...
...
@@ -862,9 +861,7 @@ int hci_unregister_dev(struct hci_dev *hdev)
hci_notify
(
hdev
,
HCI_DEV_UNREG
);
hci_run_hotplug
(
hdev
->
name
,
"unregister"
);
hci_dev_put
(
hdev
);
MOD_DEC_USE_COUNT
;
__hci_dev_put
(
hdev
);
return
0
;
}
...
...
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