Re: [PATCH] Bluetooth: hci_uart: Support firmware download for Marvell

From: kbuild test robot
Date: Mon Feb 15 2016 - 11:27:25 EST


Hi Ganapathi,

[auto build test WARNING on bluetooth-next/master]
[also build test WARNING on v4.5-rc4 next-20160215]
[if your patch is applied to the wrong git tree, please drop us a note to help improving the system]

url: https://github.com/0day-ci/linux/commits/Amitkumar-Karwar/Bluetooth-hci_uart-Support-firmware-download-for-Marvell/20160215-234258
base: https://git.kernel.org/pub/scm/linux/kernel/git/bluetooth/bluetooth-next.git master
config: i386-allmodconfig (attached as .config)
reproduce:
# save the attached .config to linux build tree
make ARCH=i386

All warnings (new ones prefixed by >>):

In file included from drivers/bluetooth/hci_mrvl.c:41:0:
drivers/bluetooth/hci_mrvl.c: In function 'mrvl_dnld_fw':
>> drivers/bluetooth/hci_mrvl.c:301:11: warning: format '%lu' expects argument of type 'long unsigned int', but argument 2 has type 'size_t {aka const unsigned int}' [-Wformat=]
BT_INFO("Downloading FW (%lu bytes)\n", fw->size);
^
include/net/bluetooth/bluetooth.h:133:35: note: in definition of macro 'BT_INFO'
#define BT_INFO(fmt, ...) bt_info(fmt "\n", ##__VA_ARGS__)
^

coccinelle warnings: (new ones prefixed by >>)

>> drivers/bluetooth/hci_mrvl.c:411:9-10: WARNING: return of 0/1 in function 'mrvl_fw_loaded' with return type bool
--
>> drivers/bluetooth/hci_mrvl.c:536:20-27: ERROR: tty is NULL but dereferenced.

Please review and possibly fold the followup patch.

vim +301 drivers/bluetooth/hci_mrvl.c

295 if (ret < 0) {
296 BT_ERR("request_firmware() failed\n");
297 ret = -1;
298 goto done;
299 }
300 if (fw) {
> 301 BT_INFO("Downloading FW (%lu bytes)\n", fw->size);
302 } else {
303 BT_ERR("No FW image found\n");
304 ret = -1;
305 goto done;
306 }
307
308 skb = bt_skb_alloc(MRVL_MAX_FW_BLOCK_SIZE, GFP_ATOMIC);
309 if (!skb) {
310 BT_ERR("cannot allocate memory for skb\n");
311 ret = -1;
312 goto done;
313 }
314
315 skb->dev = (void *)hdev;
316 fw_data->last_ack = 0;
317
318 do {
319 if ((offset >= fw->size) || (fw_data->last_ack))
320 break;
321 tx_len = fw_data->next_len;
322 if ((fw->size - offset) < tx_len)
323 tx_len = fw->size - offset;
324
325 memcpy(skb->data, &fw->data[offset], tx_len);
326 skb_put(skb, tx_len);
327 if (mrvl_send_data(hu, skb) != 0) {
328 BT_ERR("fail to download firmware\n");
329 ret = -1;
330 goto done;
331 }
332 skb_push(skb, tx_len);
333 skb_trim(skb, 0);
334 offset += tx_len;
335 } while (1);
336
337 BT_INFO("downloaded %d byte firmware\n", offset);
338 done:
339 if (fw)
340 release_firmware(fw);
341
342 kfree(skb);
343 BT_INFO("leave dnld_fw\n");
344
345 return ret;
346 }
347
348 /* Get standard baud rate, given the speed */
349 static unsigned int get_baud_rate(unsigned int speed)
350 {
351 switch (speed) {
352 case 9600:
353 return B9600;
354 case 19200:
355 return B19200;
356 case 38400:
357 return B38400;
358 case 57600:
359 return B57600;
360 case 115200:
361 return B115200;
362 case 230400:
363 return B230400;
364 case 460800:
365 return B460800;
366 case 921600:
367 return B921600;
368 case 2000000:
369 return B2000000;
370 case 3000000:
371 return B3000000;
372 default:
373 return -1;
374 }
375 }
376
377 /* Set terminal properties */
378 static int mrvl_set_termios(struct tty_struct *tty, unsigned int speed,
379 unsigned char flow_ctl)
380 {
381 struct ktermios old_termios = tty->termios;
382 int baud;
383
384 tty->termios.c_cflag &= ~CBAUD;
385 baud = get_baud_rate(speed);
386
387 if (baud == -1) {
388 BT_ERR("Baud rate not supported\n");
389 return -1;
390 }
391
392 tty->termios.c_cflag |= baud;
393
394 if (flow_ctl)
395 tty->termios.c_cflag |= CRTSCTS;
396 else
397 tty->termios.c_cflag &= ~CRTSCTS;
398
399 tty->ops->set_termios(tty, &old_termios);
400
401 return 0;
402 }
403
404 /* Check if firmware is already loaded */
405 static bool mrvl_fw_loaded(struct hci_uart *hu)
406 {
407 struct mrvl_data *mrvl = hu->priv;
408 struct fw_data *fw_data = mrvl->fwdata;
409
410 if ((get_cts(hu->tty)) || (fw_data->fw_loaded))
> 411 return 1;
412 else
413 return 0;
414 }

---
0-DAY kernel test infrastructure Open Source Technology Center
https://lists.01.org/pipermail/kbuild-all Intel Corporation

Attachment: .config.gz
Description: Binary data