Commit 63d902f7 authored by Maksim Krasnyanskiy's avatar Maksim Krasnyanskiy

Get rid of the MIN() thing in Bluetooth code and use min_t() instead.

parent ba4d1613
...@@ -160,7 +160,7 @@ static int h4_recv(struct hci_uart *hu, void *data, int count) ...@@ -160,7 +160,7 @@ static int h4_recv(struct hci_uart *hu, void *data, int count)
ptr = data; ptr = data;
while (count) { while (count) {
if (h4->rx_count) { if (h4->rx_count) {
len = MIN(h4->rx_count, count); len = min_t(unsigned int, h4->rx_count, count);
memcpy(skb_put(h4->rx_skb, len), ptr, len); memcpy(skb_put(h4->rx_skb, len), ptr, len);
h4->rx_count -= len; count -= len; ptr += len; h4->rx_count -= len; count -= len; ptr += len;
......
...@@ -639,7 +639,7 @@ int hci_usb_probe(struct usb_interface *intf, const struct usb_device_id *id) ...@@ -639,7 +639,7 @@ int hci_usb_probe(struct usb_interface *intf, const struct usb_device_id *id)
/* Find endpoints that we need */ /* Find endpoints that we need */
ifn = MIN(udev->actconfig->bNumInterfaces, HCI_MAX_IFACE_NUM); ifn = min_t(unsigned int, udev->actconfig->bNumInterfaces, HCI_MAX_IFACE_NUM);
for (i = 0; i < ifn; i++) { for (i = 0; i < ifn; i++) {
iface = &udev->actconfig->interface[i]; iface = &udev->actconfig->interface[i];
for (a = 0; a < iface->num_altsetting; a++) { for (a = 0; a < iface->num_altsetting; a++) {
......
...@@ -172,7 +172,7 @@ static inline ssize_t hci_vhci_put_user(struct hci_vhci_struct *hci_vhci, ...@@ -172,7 +172,7 @@ static inline ssize_t hci_vhci_put_user(struct hci_vhci_struct *hci_vhci,
int len = count, total = 0; int len = count, total = 0;
char *ptr = buf; char *ptr = buf;
len = MIN(skb->len, len); len = min_t(unsigned int, skb->len, len);
if (copy_to_user(ptr, skb->data, len)) if (copy_to_user(ptr, skb->data, len))
return -EFAULT; return -EFAULT;
total += len; total += len;
......
...@@ -42,10 +42,6 @@ ...@@ -42,10 +42,6 @@
/* Reserv for core and drivers use */ /* Reserv for core and drivers use */
#define BT_SKB_RESERVE 8 #define BT_SKB_RESERVE 8
#ifndef MIN
#define MIN(a,b) ((a) < (b) ? (a) : (b))
#endif
#define BTPROTO_L2CAP 0 #define BTPROTO_L2CAP 0
#define BTPROTO_HCI 1 #define BTPROTO_HCI 1
#define BTPROTO_SCO 2 #define BTPROTO_SCO 2
......
...@@ -454,7 +454,7 @@ int hci_sock_setsockopt(struct socket *sock, int level, int optname, char *optva ...@@ -454,7 +454,7 @@ int hci_sock_setsockopt(struct socket *sock, int level, int optname, char *optva
break; break;
case HCI_FILTER: case HCI_FILTER:
len = MIN(len, sizeof(uf)); len = min_t(unsigned int, len, sizeof(uf));
if (copy_from_user(&uf, optval, len)) { if (copy_from_user(&uf, optval, len)) {
err = -EFAULT; err = -EFAULT;
break; break;
...@@ -525,7 +525,7 @@ int hci_sock_getsockopt(struct socket *sock, int level, int optname, char *optva ...@@ -525,7 +525,7 @@ int hci_sock_getsockopt(struct socket *sock, int level, int optname, char *optva
uf.event_mask[1] = *((u32 *) f->event_mask + 1); uf.event_mask[1] = *((u32 *) f->event_mask + 1);
} }
len = MIN(len, sizeof(uf)); len = min_t(unsigned int, len, sizeof(uf));
if (copy_to_user(optval, &uf, len)) if (copy_to_user(optval, &uf, len))
return -EFAULT; return -EFAULT;
break; break;
......
...@@ -682,7 +682,7 @@ static int l2cap_sock_setsockopt(struct socket *sock, int level, int optname, ch ...@@ -682,7 +682,7 @@ static int l2cap_sock_setsockopt(struct socket *sock, int level, int optname, ch
switch (optname) { switch (optname) {
case L2CAP_OPTIONS: case L2CAP_OPTIONS:
len = MIN(sizeof(opts), optlen); len = min_t(unsigned int, sizeof(opts), optlen);
if (copy_from_user((char *)&opts, optval, len)) { if (copy_from_user((char *)&opts, optval, len)) {
err = -EFAULT; err = -EFAULT;
break; break;
...@@ -727,7 +727,7 @@ static int l2cap_sock_getsockopt(struct socket *sock, int level, int optname, ch ...@@ -727,7 +727,7 @@ static int l2cap_sock_getsockopt(struct socket *sock, int level, int optname, ch
opts.omtu = l2cap_pi(sk)->omtu; opts.omtu = l2cap_pi(sk)->omtu;
opts.flush_to = l2cap_pi(sk)->flush_to; opts.flush_to = l2cap_pi(sk)->flush_to;
len = MIN(len, sizeof(opts)); len = min_t(unsigned int, len, sizeof(opts));
if (copy_to_user(optval, (char *)&opts, len)) if (copy_to_user(optval, (char *)&opts, len))
err = -EFAULT; err = -EFAULT;
...@@ -746,7 +746,7 @@ static int l2cap_sock_getsockopt(struct socket *sock, int level, int optname, ch ...@@ -746,7 +746,7 @@ static int l2cap_sock_getsockopt(struct socket *sock, int level, int optname, ch
cinfo.hci_handle = l2cap_pi(sk)->conn->hcon->handle; cinfo.hci_handle = l2cap_pi(sk)->conn->hcon->handle;
len = MIN(len, sizeof(cinfo)); len = min_t(unsigned int, len, sizeof(cinfo));
if (copy_to_user(optval, (char *)&cinfo, len)) if (copy_to_user(optval, (char *)&cinfo, len))
err = -EFAULT; err = -EFAULT;
...@@ -1017,7 +1017,7 @@ static int l2cap_chan_send(struct sock *sk, struct msghdr *msg, int len) ...@@ -1017,7 +1017,7 @@ static int l2cap_chan_send(struct sock *sk, struct msghdr *msg, int len)
else else
hlen = L2CAP_HDR_SIZE; hlen = L2CAP_HDR_SIZE;
count = MIN(conn->mtu - hlen, len); count = min_t(unsigned int, (conn->mtu - hlen), len);
skb = bt_skb_send_alloc(sk, hlen + count, skb = bt_skb_send_alloc(sk, hlen + count,
msg->msg_flags & MSG_DONTWAIT, &err); msg->msg_flags & MSG_DONTWAIT, &err);
...@@ -1043,7 +1043,7 @@ static int l2cap_chan_send(struct sock *sk, struct msghdr *msg, int len) ...@@ -1043,7 +1043,7 @@ static int l2cap_chan_send(struct sock *sk, struct msghdr *msg, int len)
/* Continuation fragments (no L2CAP header) */ /* Continuation fragments (no L2CAP header) */
frag = &skb_shinfo(skb)->frag_list; frag = &skb_shinfo(skb)->frag_list;
while (len) { while (len) {
count = MIN(conn->mtu, len); count = min_t(unsigned int, conn->mtu, len);
*frag = bt_skb_send_alloc(sk, count, msg->msg_flags & MSG_DONTWAIT, &err); *frag = bt_skb_send_alloc(sk, count, msg->msg_flags & MSG_DONTWAIT, &err);
if (!*frag) if (!*frag)
...@@ -1103,7 +1103,7 @@ static struct sk_buff *l2cap_build_cmd(struct l2cap_conn *conn, ...@@ -1103,7 +1103,7 @@ static struct sk_buff *l2cap_build_cmd(struct l2cap_conn *conn,
BT_DBG("conn %p, code 0x%2.2x, ident 0x%2.2x, len %d", conn, code, ident, dlen); BT_DBG("conn %p, code 0x%2.2x, ident 0x%2.2x, len %d", conn, code, ident, dlen);
len = L2CAP_HDR_SIZE + L2CAP_CMD_HDR_SIZE + dlen; len = L2CAP_HDR_SIZE + L2CAP_CMD_HDR_SIZE + dlen;
count = MIN(conn->mtu, len); count = min_t(unsigned int, conn->mtu, len);
skb = bt_skb_alloc(count, GFP_ATOMIC); skb = bt_skb_alloc(count, GFP_ATOMIC);
if (!skb) if (!skb)
...@@ -1129,7 +1129,7 @@ static struct sk_buff *l2cap_build_cmd(struct l2cap_conn *conn, ...@@ -1129,7 +1129,7 @@ static struct sk_buff *l2cap_build_cmd(struct l2cap_conn *conn,
/* Continuation fragments (no L2CAP header) */ /* Continuation fragments (no L2CAP header) */
frag = &skb_shinfo(skb)->frag_list; frag = &skb_shinfo(skb)->frag_list;
while (len) { while (len) {
count = MIN(conn->mtu, len); count = min_t(unsigned int, conn->mtu, len);
*frag = bt_skb_alloc(count, GFP_ATOMIC); *frag = bt_skb_alloc(count, GFP_ATOMIC);
if (!*frag) if (!*frag)
......
...@@ -258,7 +258,7 @@ static inline int sco_send_frame(struct sock *sk, struct msghdr *msg, int len) ...@@ -258,7 +258,7 @@ static inline int sco_send_frame(struct sock *sk, struct msghdr *msg, int len)
BT_DBG("sk %p len %d", sk, len); BT_DBG("sk %p len %d", sk, len);
count = MIN(conn->mtu, len); count = min_t(unsigned int, conn->mtu, len);
if (!(skb = bt_skb_send_alloc(sk, count, msg->msg_flags & MSG_DONTWAIT, &err))) if (!(skb = bt_skb_send_alloc(sk, count, msg->msg_flags & MSG_DONTWAIT, &err)))
return err; return err;
...@@ -699,7 +699,7 @@ int sco_sock_getsockopt(struct socket *sock, int level, int optname, char *optva ...@@ -699,7 +699,7 @@ int sco_sock_getsockopt(struct socket *sock, int level, int optname, char *optva
BT_INFO("mtu %d", opts.mtu); BT_INFO("mtu %d", opts.mtu);
len = MIN(len, sizeof(opts)); len = min_t(unsigned int, len, sizeof(opts));
if (copy_to_user(optval, (char *)&opts, len)) if (copy_to_user(optval, (char *)&opts, len))
err = -EFAULT; err = -EFAULT;
...@@ -713,7 +713,7 @@ int sco_sock_getsockopt(struct socket *sock, int level, int optname, char *optva ...@@ -713,7 +713,7 @@ int sco_sock_getsockopt(struct socket *sock, int level, int optname, char *optva
cinfo.hci_handle = sco_pi(sk)->conn->hcon->handle; cinfo.hci_handle = sco_pi(sk)->conn->hcon->handle;
len = MIN(len, sizeof(cinfo)); len = min_t(unsigned int, len, sizeof(cinfo));
if (copy_to_user(optval, (char *)&cinfo, len)) if (copy_to_user(optval, (char *)&cinfo, len))
err = -EFAULT; err = -EFAULT;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment