Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

Bluetooth: Add bt_status

This adds bt_status which can be used to convert Unix errno to
Bluetooth status.

Signed-off-by: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>

+72
+1
include/net/bluetooth/bluetooth.h
··· 521 521 } 522 522 523 523 int bt_to_errno(u16 code); 524 + __u8 bt_status(int err); 524 525 525 526 void hci_sock_set_flag(struct sock *sk, int nr); 526 527 void hci_sock_clear_flag(struct sock *sk, int nr);
+71
net/bluetooth/lib.c
··· 135 135 } 136 136 EXPORT_SYMBOL(bt_to_errno); 137 137 138 + /* Unix errno to Bluetooth error codes mapping */ 139 + __u8 bt_status(int err) 140 + { 141 + /* Don't convert if already positive value */ 142 + if (err >= 0) 143 + return err; 144 + 145 + switch (err) { 146 + case -EBADRQC: 147 + return 0x01; 148 + 149 + case -ENOTCONN: 150 + return 0x02; 151 + 152 + case -EIO: 153 + return 0x03; 154 + 155 + case -EHOSTDOWN: 156 + return 0x04; 157 + 158 + case -EACCES: 159 + return 0x05; 160 + 161 + case -EBADE: 162 + return 0x06; 163 + 164 + case -ENOMEM: 165 + return 0x07; 166 + 167 + case -ETIMEDOUT: 168 + return 0x08; 169 + 170 + case -EMLINK: 171 + return 0x09; 172 + 173 + case EALREADY: 174 + return 0x0b; 175 + 176 + case -EBUSY: 177 + return 0x0c; 178 + 179 + case -ECONNREFUSED: 180 + return 0x0d; 181 + 182 + case -EOPNOTSUPP: 183 + return 0x11; 184 + 185 + case -EINVAL: 186 + return 0x12; 187 + 188 + case -ECONNRESET: 189 + return 0x13; 190 + 191 + case -ECONNABORTED: 192 + return 0x16; 193 + 194 + case ELOOP: 195 + return 0x17; 196 + 197 + case -EPROTONOSUPPORT: 198 + return 0x1a; 199 + 200 + case -EPROTO: 201 + return 0x19; 202 + 203 + default: 204 + return 0x1f; 205 + } 206 + } 207 + EXPORT_SYMBOL(bt_status); 208 + 138 209 void bt_info(const char *format, ...) 139 210 { 140 211 struct va_format vaf;