diff options
Diffstat (limited to 'net/bluetooth')
-rw-r--r-- | net/bluetooth/l2cap_core.c | 14 |
1 files changed, 12 insertions, 2 deletions
diff --git a/net/bluetooth/l2cap_core.c b/net/bluetooth/l2cap_core.c index 39a5149f3010..eb4f5f24cbe3 100644 --- a/net/bluetooth/l2cap_core.c +++ b/net/bluetooth/l2cap_core.c | |||
@@ -197,10 +197,20 @@ int l2cap_add_psm(struct l2cap_chan *chan, bdaddr_t *src, __le16 psm) | |||
197 | chan->sport = psm; | 197 | chan->sport = psm; |
198 | err = 0; | 198 | err = 0; |
199 | } else { | 199 | } else { |
200 | u16 p; | 200 | u16 p, start, end, incr; |
201 | |||
202 | if (chan->src_type == BDADDR_BREDR) { | ||
203 | start = L2CAP_PSM_DYN_START; | ||
204 | end = L2CAP_PSM_AUTO_END; | ||
205 | incr = 2; | ||
206 | } else { | ||
207 | start = L2CAP_PSM_LE_DYN_START; | ||
208 | end = L2CAP_PSM_LE_DYN_END; | ||
209 | incr = 1; | ||
210 | } | ||
201 | 211 | ||
202 | err = -EINVAL; | 212 | err = -EINVAL; |
203 | for (p = 0x1001; p < 0x1100; p += 2) | 213 | for (p = start; p <= end; p += incr) |
204 | if (!__l2cap_global_chan_by_addr(cpu_to_le16(p), src)) { | 214 | if (!__l2cap_global_chan_by_addr(cpu_to_le16(p), src)) { |
205 | chan->psm = cpu_to_le16(p); | 215 | chan->psm = cpu_to_le16(p); |
206 | chan->sport = cpu_to_le16(p); | 216 | chan->sport = cpu_to_le16(p); |