2019-05-26 23:55:05 -07:00
|
|
|
// SPDX-License-Identifier: GPL-2.0-or-later
|
2010-01-06 06:34:15 -07:00
|
|
|
/*
|
|
|
|
* Copyright (c) 2008-2009 Atheros Communications Inc.
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include <linux/module.h>
|
|
|
|
#include <linux/kernel.h>
|
|
|
|
#include <linux/init.h>
|
|
|
|
#include <linux/slab.h>
|
|
|
|
#include <linux/types.h>
|
|
|
|
#include <linux/errno.h>
|
|
|
|
#include <linux/firmware.h>
|
|
|
|
#include <linux/usb.h>
|
2024-10-01 12:35:57 -07:00
|
|
|
#include <linux/unaligned.h>
|
2010-01-06 06:34:15 -07:00
|
|
|
#include <net/bluetooth/bluetooth.h>
|
|
|
|
|
|
|
|
#define VERSION "1.0"
|
2011-10-29 10:52:49 -07:00
|
|
|
#define ATH3K_FIRMWARE "ath3k-1.fw"
|
2010-01-06 06:34:15 -07:00
|
|
|
|
2011-02-11 03:08:53 -07:00
|
|
|
#define ATH3K_DNLOAD 0x01
|
|
|
|
#define ATH3K_GETSTATE 0x05
|
|
|
|
#define ATH3K_SET_NORMAL_MODE 0x07
|
|
|
|
#define ATH3K_GETVERSION 0x09
|
|
|
|
#define USB_REG_SWITCH_VID_PID 0x0a
|
|
|
|
|
|
|
|
#define ATH3K_MODE_MASK 0x3F
|
|
|
|
#define ATH3K_NORMAL_MODE 0x0E
|
|
|
|
|
|
|
|
#define ATH3K_PATCH_UPDATE 0x80
|
|
|
|
#define ATH3K_SYSCFG_UPDATE 0x40
|
|
|
|
|
|
|
|
#define ATH3K_XTAL_FREQ_26M 0x00
|
|
|
|
#define ATH3K_XTAL_FREQ_40M 0x01
|
|
|
|
#define ATH3K_XTAL_FREQ_19P2 0x02
|
|
|
|
#define ATH3K_NAME_LEN 0xFF
|
|
|
|
|
|
|
|
struct ath3k_version {
|
2014-07-20 08:29:59 -07:00
|
|
|
__le32 rom_version;
|
|
|
|
__le32 build_version;
|
|
|
|
__le32 ram_version;
|
|
|
|
__u8 ref_clock;
|
|
|
|
__u8 reserved[7];
|
|
|
|
} __packed;
|
2010-01-06 06:34:15 -07:00
|
|
|
|
2013-10-11 07:46:21 -07:00
|
|
|
static const struct usb_device_id ath3k_table[] = {
|
2010-01-06 06:34:15 -07:00
|
|
|
/* Atheros AR3011 */
|
|
|
|
{ USB_DEVICE(0x0CF3, 0x3000) },
|
2010-11-26 05:05:46 -07:00
|
|
|
|
|
|
|
/* Atheros AR3011 with sflash firmware*/
|
2014-02-18 09:26:19 -07:00
|
|
|
{ USB_DEVICE(0x0489, 0xE027) },
|
|
|
|
{ USB_DEVICE(0x0489, 0xE03D) },
|
2015-02-13 12:05:11 -07:00
|
|
|
{ USB_DEVICE(0x04F2, 0xAFF1) },
|
2014-02-18 09:26:19 -07:00
|
|
|
{ USB_DEVICE(0x0930, 0x0215) },
|
2010-11-26 05:05:46 -07:00
|
|
|
{ USB_DEVICE(0x0CF3, 0x3002) },
|
2012-06-08 05:32:50 -07:00
|
|
|
{ USB_DEVICE(0x0CF3, 0xE019) },
|
2011-05-09 16:11:16 -07:00
|
|
|
{ USB_DEVICE(0x13d3, 0x3304) },
|
2010-11-26 05:05:46 -07:00
|
|
|
|
2011-01-26 02:10:59 -07:00
|
|
|
/* Atheros AR9285 Malbec with sflash firmware */
|
|
|
|
{ USB_DEVICE(0x03F0, 0x311D) },
|
2011-02-11 03:08:53 -07:00
|
|
|
|
|
|
|
/* Atheros AR3012 with sflash firmware*/
|
2014-02-18 09:26:19 -07:00
|
|
|
{ USB_DEVICE(0x0489, 0xe04d) },
|
|
|
|
{ USB_DEVICE(0x0489, 0xe04e) },
|
|
|
|
{ USB_DEVICE(0x0489, 0xe057) },
|
|
|
|
{ USB_DEVICE(0x0489, 0xe056) },
|
|
|
|
{ USB_DEVICE(0x0489, 0xe05f) },
|
2015-06-06 10:25:40 -07:00
|
|
|
{ USB_DEVICE(0x0489, 0xe076) },
|
2014-10-06 04:01:49 -07:00
|
|
|
{ USB_DEVICE(0x0489, 0xe078) },
|
2016-02-09 14:49:11 -07:00
|
|
|
{ USB_DEVICE(0x0489, 0xe095) },
|
2014-02-18 09:26:19 -07:00
|
|
|
{ USB_DEVICE(0x04c5, 0x1330) },
|
|
|
|
{ USB_DEVICE(0x04CA, 0x3004) },
|
|
|
|
{ USB_DEVICE(0x04CA, 0x3005) },
|
|
|
|
{ USB_DEVICE(0x04CA, 0x3006) },
|
2014-04-17 11:37:13 -07:00
|
|
|
{ USB_DEVICE(0x04CA, 0x3007) },
|
2014-02-18 09:26:19 -07:00
|
|
|
{ USB_DEVICE(0x04CA, 0x3008) },
|
|
|
|
{ USB_DEVICE(0x04CA, 0x300b) },
|
2015-06-18 10:41:51 -07:00
|
|
|
{ USB_DEVICE(0x04CA, 0x300d) },
|
2015-05-02 03:36:58 -07:00
|
|
|
{ USB_DEVICE(0x04CA, 0x300f) },
|
2014-12-08 22:44:51 -07:00
|
|
|
{ USB_DEVICE(0x04CA, 0x3010) },
|
2016-02-28 01:04:06 -07:00
|
|
|
{ USB_DEVICE(0x04CA, 0x3014) },
|
2017-01-05 03:19:53 -07:00
|
|
|
{ USB_DEVICE(0x04CA, 0x3018) },
|
2014-02-18 09:26:19 -07:00
|
|
|
{ USB_DEVICE(0x0930, 0x0219) },
|
2015-10-05 09:29:33 -07:00
|
|
|
{ USB_DEVICE(0x0930, 0x021c) },
|
2014-02-18 09:26:19 -07:00
|
|
|
{ USB_DEVICE(0x0930, 0x0220) },
|
2014-08-08 04:33:56 -07:00
|
|
|
{ USB_DEVICE(0x0930, 0x0227) },
|
2014-02-18 09:26:20 -07:00
|
|
|
{ USB_DEVICE(0x0b05, 0x17d0) },
|
2013-03-14 20:00:39 -07:00
|
|
|
{ USB_DEVICE(0x0CF3, 0x0036) },
|
2011-02-11 03:08:53 -07:00
|
|
|
{ USB_DEVICE(0x0CF3, 0x3004) },
|
2013-03-11 12:41:58 -07:00
|
|
|
{ USB_DEVICE(0x0CF3, 0x3008) },
|
2012-03-14 13:01:21 -07:00
|
|
|
{ USB_DEVICE(0x0CF3, 0x311D) },
|
2014-01-16 07:37:11 -07:00
|
|
|
{ USB_DEVICE(0x0CF3, 0x311E) },
|
2014-01-16 08:02:58 -07:00
|
|
|
{ USB_DEVICE(0x0CF3, 0x311F) },
|
2014-02-18 09:26:19 -07:00
|
|
|
{ USB_DEVICE(0x0cf3, 0x3121) },
|
2013-03-18 08:45:11 -07:00
|
|
|
{ USB_DEVICE(0x0CF3, 0x817a) },
|
2015-10-16 01:45:26 -07:00
|
|
|
{ USB_DEVICE(0x0CF3, 0x817b) },
|
2014-02-18 09:26:19 -07:00
|
|
|
{ USB_DEVICE(0x0cf3, 0xe003) },
|
2012-04-18 23:53:45 -07:00
|
|
|
{ USB_DEVICE(0x0CF3, 0xE004) },
|
2013-08-30 02:41:40 -07:00
|
|
|
{ USB_DEVICE(0x0CF3, 0xE005) },
|
2015-05-12 20:39:24 -07:00
|
|
|
{ USB_DEVICE(0x0CF3, 0xE006) },
|
2014-02-18 09:26:19 -07:00
|
|
|
{ USB_DEVICE(0x13d3, 0x3362) },
|
|
|
|
{ USB_DEVICE(0x13d3, 0x3375) },
|
2012-12-10 20:41:20 -07:00
|
|
|
{ USB_DEVICE(0x13d3, 0x3393) },
|
2016-02-10 05:33:17 -07:00
|
|
|
{ USB_DEVICE(0x13d3, 0x3395) },
|
2013-07-14 20:59:03 -07:00
|
|
|
{ USB_DEVICE(0x13d3, 0x3402) },
|
2014-11-25 10:19:52 -07:00
|
|
|
{ USB_DEVICE(0x13d3, 0x3408) },
|
2015-01-17 14:16:51 -07:00
|
|
|
{ USB_DEVICE(0x13d3, 0x3423) },
|
2014-07-08 06:55:08 -07:00
|
|
|
{ USB_DEVICE(0x13d3, 0x3432) },
|
2016-03-03 15:32:19 -07:00
|
|
|
{ USB_DEVICE(0x13d3, 0x3472) },
|
2015-06-06 10:29:25 -07:00
|
|
|
{ USB_DEVICE(0x13d3, 0x3474) },
|
2016-05-09 13:36:11 -07:00
|
|
|
{ USB_DEVICE(0x13d3, 0x3487) },
|
2016-07-11 15:35:18 -07:00
|
|
|
{ USB_DEVICE(0x13d3, 0x3490) },
|
2011-02-11 03:08:53 -07:00
|
|
|
|
2011-02-14 19:20:07 -07:00
|
|
|
/* Atheros AR5BBU12 with sflash firmware */
|
|
|
|
{ USB_DEVICE(0x0489, 0xE02C) },
|
2011-02-18 15:03:41 -07:00
|
|
|
|
2012-05-02 13:33:40 -07:00
|
|
|
/* Atheros AR5BBU22 with sflash firmware */
|
2012-08-07 07:18:10 -07:00
|
|
|
{ USB_DEVICE(0x0489, 0xE036) },
|
2014-02-18 09:26:19 -07:00
|
|
|
{ USB_DEVICE(0x0489, 0xE03C) },
|
2012-05-02 13:33:40 -07:00
|
|
|
|
2010-01-06 06:34:15 -07:00
|
|
|
{ } /* Terminating entry */
|
|
|
|
};
|
|
|
|
|
|
|
|
MODULE_DEVICE_TABLE(usb, ath3k_table);
|
|
|
|
|
2011-02-11 03:08:53 -07:00
|
|
|
#define BTUSB_ATH3012 0x80
|
|
|
|
/* This table is to load patch and sysconfig files
|
2017-07-21 18:47:07 -07:00
|
|
|
* for AR3012
|
|
|
|
*/
|
2013-10-11 07:46:21 -07:00
|
|
|
static const struct usb_device_id ath3k_blist_tbl[] = {
|
2011-02-11 03:08:53 -07:00
|
|
|
/* Atheros AR3012 with sflash firmware*/
|
2014-02-18 09:26:19 -07:00
|
|
|
{ USB_DEVICE(0x0489, 0xe04e), .driver_info = BTUSB_ATH3012 },
|
|
|
|
{ USB_DEVICE(0x0489, 0xe04d), .driver_info = BTUSB_ATH3012 },
|
|
|
|
{ USB_DEVICE(0x0489, 0xe056), .driver_info = BTUSB_ATH3012 },
|
|
|
|
{ USB_DEVICE(0x0489, 0xe057), .driver_info = BTUSB_ATH3012 },
|
|
|
|
{ USB_DEVICE(0x0489, 0xe05f), .driver_info = BTUSB_ATH3012 },
|
2015-06-06 10:25:40 -07:00
|
|
|
{ USB_DEVICE(0x0489, 0xe076), .driver_info = BTUSB_ATH3012 },
|
2014-10-06 04:01:49 -07:00
|
|
|
{ USB_DEVICE(0x0489, 0xe078), .driver_info = BTUSB_ATH3012 },
|
2016-02-09 14:49:11 -07:00
|
|
|
{ USB_DEVICE(0x0489, 0xe095), .driver_info = BTUSB_ATH3012 },
|
2014-02-18 09:26:19 -07:00
|
|
|
{ USB_DEVICE(0x04c5, 0x1330), .driver_info = BTUSB_ATH3012 },
|
|
|
|
{ USB_DEVICE(0x04ca, 0x3004), .driver_info = BTUSB_ATH3012 },
|
|
|
|
{ USB_DEVICE(0x04ca, 0x3005), .driver_info = BTUSB_ATH3012 },
|
|
|
|
{ USB_DEVICE(0x04ca, 0x3006), .driver_info = BTUSB_ATH3012 },
|
2014-04-17 11:37:13 -07:00
|
|
|
{ USB_DEVICE(0x04ca, 0x3007), .driver_info = BTUSB_ATH3012 },
|
2014-02-18 09:26:19 -07:00
|
|
|
{ USB_DEVICE(0x04ca, 0x3008), .driver_info = BTUSB_ATH3012 },
|
|
|
|
{ USB_DEVICE(0x04ca, 0x300b), .driver_info = BTUSB_ATH3012 },
|
2015-06-18 10:41:51 -07:00
|
|
|
{ USB_DEVICE(0x04ca, 0x300d), .driver_info = BTUSB_ATH3012 },
|
2015-05-02 03:36:58 -07:00
|
|
|
{ USB_DEVICE(0x04ca, 0x300f), .driver_info = BTUSB_ATH3012 },
|
2014-12-08 22:44:51 -07:00
|
|
|
{ USB_DEVICE(0x04ca, 0x3010), .driver_info = BTUSB_ATH3012 },
|
2016-02-28 01:04:06 -07:00
|
|
|
{ USB_DEVICE(0x04ca, 0x3014), .driver_info = BTUSB_ATH3012 },
|
2017-01-05 03:19:53 -07:00
|
|
|
{ USB_DEVICE(0x04ca, 0x3018), .driver_info = BTUSB_ATH3012 },
|
2014-02-18 09:26:19 -07:00
|
|
|
{ USB_DEVICE(0x0930, 0x0219), .driver_info = BTUSB_ATH3012 },
|
2015-10-05 09:29:33 -07:00
|
|
|
{ USB_DEVICE(0x0930, 0x021c), .driver_info = BTUSB_ATH3012 },
|
2014-02-18 09:26:19 -07:00
|
|
|
{ USB_DEVICE(0x0930, 0x0220), .driver_info = BTUSB_ATH3012 },
|
2014-08-08 04:33:56 -07:00
|
|
|
{ USB_DEVICE(0x0930, 0x0227), .driver_info = BTUSB_ATH3012 },
|
2014-02-18 09:26:20 -07:00
|
|
|
{ USB_DEVICE(0x0b05, 0x17d0), .driver_info = BTUSB_ATH3012 },
|
2013-03-14 20:00:39 -07:00
|
|
|
{ USB_DEVICE(0x0CF3, 0x0036), .driver_info = BTUSB_ATH3012 },
|
2011-02-11 03:08:53 -07:00
|
|
|
{ USB_DEVICE(0x0cf3, 0x3004), .driver_info = BTUSB_ATH3012 },
|
2013-03-11 12:41:58 -07:00
|
|
|
{ USB_DEVICE(0x0cf3, 0x3008), .driver_info = BTUSB_ATH3012 },
|
2012-03-14 13:01:21 -07:00
|
|
|
{ USB_DEVICE(0x0cf3, 0x311D), .driver_info = BTUSB_ATH3012 },
|
2014-01-16 07:37:11 -07:00
|
|
|
{ USB_DEVICE(0x0cf3, 0x311E), .driver_info = BTUSB_ATH3012 },
|
2014-01-16 08:02:58 -07:00
|
|
|
{ USB_DEVICE(0x0cf3, 0x311F), .driver_info = BTUSB_ATH3012 },
|
2014-02-18 09:26:19 -07:00
|
|
|
{ USB_DEVICE(0x0cf3, 0x3121), .driver_info = BTUSB_ATH3012 },
|
2013-03-18 08:45:11 -07:00
|
|
|
{ USB_DEVICE(0x0CF3, 0x817a), .driver_info = BTUSB_ATH3012 },
|
2015-10-16 01:45:26 -07:00
|
|
|
{ USB_DEVICE(0x0CF3, 0x817b), .driver_info = BTUSB_ATH3012 },
|
2012-04-18 23:53:45 -07:00
|
|
|
{ USB_DEVICE(0x0cf3, 0xe004), .driver_info = BTUSB_ATH3012 },
|
2013-08-30 02:41:40 -07:00
|
|
|
{ USB_DEVICE(0x0cf3, 0xe005), .driver_info = BTUSB_ATH3012 },
|
2015-05-12 20:39:24 -07:00
|
|
|
{ USB_DEVICE(0x0cf3, 0xe006), .driver_info = BTUSB_ATH3012 },
|
2014-02-18 09:26:19 -07:00
|
|
|
{ USB_DEVICE(0x0cf3, 0xe003), .driver_info = BTUSB_ATH3012 },
|
|
|
|
{ USB_DEVICE(0x13d3, 0x3362), .driver_info = BTUSB_ATH3012 },
|
|
|
|
{ USB_DEVICE(0x13d3, 0x3375), .driver_info = BTUSB_ATH3012 },
|
2012-12-10 20:41:20 -07:00
|
|
|
{ USB_DEVICE(0x13d3, 0x3393), .driver_info = BTUSB_ATH3012 },
|
2016-02-10 05:33:17 -07:00
|
|
|
{ USB_DEVICE(0x13d3, 0x3395), .driver_info = BTUSB_ATH3012 },
|
2013-07-14 20:59:03 -07:00
|
|
|
{ USB_DEVICE(0x13d3, 0x3402), .driver_info = BTUSB_ATH3012 },
|
2014-11-25 10:19:52 -07:00
|
|
|
{ USB_DEVICE(0x13d3, 0x3408), .driver_info = BTUSB_ATH3012 },
|
2015-01-17 14:16:51 -07:00
|
|
|
{ USB_DEVICE(0x13d3, 0x3423), .driver_info = BTUSB_ATH3012 },
|
2014-07-08 06:55:08 -07:00
|
|
|
{ USB_DEVICE(0x13d3, 0x3432), .driver_info = BTUSB_ATH3012 },
|
2016-03-03 15:32:19 -07:00
|
|
|
{ USB_DEVICE(0x13d3, 0x3472), .driver_info = BTUSB_ATH3012 },
|
2015-06-06 10:29:25 -07:00
|
|
|
{ USB_DEVICE(0x13d3, 0x3474), .driver_info = BTUSB_ATH3012 },
|
2016-05-09 13:36:11 -07:00
|
|
|
{ USB_DEVICE(0x13d3, 0x3487), .driver_info = BTUSB_ATH3012 },
|
2016-07-11 15:35:18 -07:00
|
|
|
{ USB_DEVICE(0x13d3, 0x3490), .driver_info = BTUSB_ATH3012 },
|
2011-02-11 03:08:53 -07:00
|
|
|
|
2012-05-02 13:33:40 -07:00
|
|
|
/* Atheros AR5BBU22 with sflash firmware */
|
2012-08-07 07:18:10 -07:00
|
|
|
{ USB_DEVICE(0x0489, 0xE036), .driver_info = BTUSB_ATH3012 },
|
2014-02-18 09:26:19 -07:00
|
|
|
{ USB_DEVICE(0x0489, 0xE03C), .driver_info = BTUSB_ATH3012 },
|
2012-05-02 13:33:40 -07:00
|
|
|
|
2011-02-11 03:08:53 -07:00
|
|
|
{ } /* Terminating entry */
|
|
|
|
};
|
|
|
|
|
2018-09-27 13:19:26 -07:00
|
|
|
static inline void ath3k_log_failed_loading(int err, int len, int size,
|
|
|
|
int count)
|
2018-02-04 14:09:46 -07:00
|
|
|
{
|
2018-09-27 13:19:26 -07:00
|
|
|
BT_ERR("Firmware loading err = %d, len = %d, size = %d, count = %d",
|
|
|
|
err, len, size, count);
|
2018-02-04 14:09:46 -07:00
|
|
|
}
|
|
|
|
|
2010-01-06 06:34:15 -07:00
|
|
|
#define USB_REQ_DFU_DNLOAD 1
|
|
|
|
#define BULK_SIZE 4096
|
2011-02-11 03:08:53 -07:00
|
|
|
#define FW_HDR_SIZE 20
|
2015-01-28 13:30:27 -07:00
|
|
|
#define TIMEGAP_USEC_MIN 50
|
|
|
|
#define TIMEGAP_USEC_MAX 100
|
2010-01-06 06:34:15 -07:00
|
|
|
|
2010-11-22 13:09:01 -07:00
|
|
|
static int ath3k_load_firmware(struct usb_device *udev,
|
Bluetooth: ath3k: Fix multiple issues reported by checkpatch.pl
This fixes some CHECKs reported by the checkpatch script.
Issues reported in ath3k.c:
-------
ath3k.c
-------
CHECK: Please don't use multiple blank lines
+
+
CHECK: Blank lines aren't necessary after an open brace '{'
+static const struct usb_device_id ath3k_blist_tbl[] = {
+
CHECK: Alignment should match open parenthesis
+static int ath3k_load_firmware(struct usb_device *udev,
+ const struct firmware *firmware)
CHECK: Alignment should match open parenthesis
+ err = usb_bulk_msg(udev, pipe, send_buf, size,
+ &len, 3000);
CHECK: Unnecessary parentheses around 'len != size'
+ if (err || (len != size)) {
CHECK: Alignment should match open parenthesis
+static int ath3k_get_version(struct usb_device *udev,
+ struct ath3k_version *version)
CHECK: Alignment should match open parenthesis
+static int ath3k_load_fwfile(struct usb_device *udev,
+ const struct firmware *firmware)
CHECK: Alignment should match open parenthesis
+ err = usb_bulk_msg(udev, pipe, send_buf, size,
+ &len, 3000);
CHECK: Unnecessary parentheses around 'len != size'
+ if (err || (len != size)) {
CHECK: Blank lines aren't necessary after an open brace '{'
+ switch (fw_version.ref_clock) {
+
CHECK: Alignment should match open parenthesis
+ snprintf(filename, ATH3K_NAME_LEN, "ar3k/ramps_0x%08x_%d%s",
+ le32_to_cpu(fw_version.rom_version), clk_value, ".dfu");
CHECK: Alignment should match open parenthesis
+static int ath3k_probe(struct usb_interface *intf,
+ const struct usb_device_id *id)
CHECK: Alignment should match open parenthesis
+ BT_ERR("Firmware file \"%s\" not found",
+ ATH3K_FIRMWARE);
CHECK: Alignment should match open parenthesis
+ BT_ERR("Firmware file \"%s\" request failed (err=%d)",
+ ATH3K_FIRMWARE, ret);
total: 0 errors, 0 warnings, 14 checks, 540 lines checked
Signed-off-by: Uri Arev <me@wantyapps.xyz>
Signed-off-by: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>
2024-04-05 14:42:24 -07:00
|
|
|
const struct firmware *firmware)
|
2010-01-06 06:34:15 -07:00
|
|
|
{
|
|
|
|
u8 *send_buf;
|
2016-04-22 03:02:55 -07:00
|
|
|
int len = 0;
|
|
|
|
int err, pipe, size, sent = 0;
|
2010-11-22 13:09:01 -07:00
|
|
|
int count = firmware->size;
|
2010-01-06 06:34:15 -07:00
|
|
|
|
2010-11-22 13:09:01 -07:00
|
|
|
BT_DBG("udev %p", udev);
|
2010-01-06 06:34:15 -07:00
|
|
|
|
2011-10-25 03:09:52 -07:00
|
|
|
send_buf = kmalloc(BULK_SIZE, GFP_KERNEL);
|
2010-11-22 13:09:01 -07:00
|
|
|
if (!send_buf) {
|
|
|
|
BT_ERR("Can't allocate memory chunk for firmware");
|
|
|
|
return -ENOMEM;
|
|
|
|
}
|
|
|
|
|
2020-09-23 06:43:48 -07:00
|
|
|
err = usb_control_msg_send(udev, 0, USB_REQ_DFU_DNLOAD, USB_TYPE_VENDOR,
|
|
|
|
0, 0, firmware->data, FW_HDR_SIZE,
|
|
|
|
USB_CTRL_SET_TIMEOUT, GFP_KERNEL);
|
|
|
|
if (err) {
|
2010-01-06 06:34:15 -07:00
|
|
|
BT_ERR("Can't change to loading configuration err");
|
2010-11-22 13:09:01 -07:00
|
|
|
goto error;
|
2010-01-06 06:34:15 -07:00
|
|
|
}
|
2018-02-04 14:09:43 -07:00
|
|
|
sent += FW_HDR_SIZE;
|
|
|
|
count -= FW_HDR_SIZE;
|
2010-01-06 06:34:15 -07:00
|
|
|
|
2014-05-26 22:49:07 -07:00
|
|
|
pipe = usb_sndbulkpipe(udev, 0x02);
|
|
|
|
|
2010-01-06 06:34:15 -07:00
|
|
|
while (count) {
|
2015-01-28 13:30:27 -07:00
|
|
|
/* workaround the compatibility issue with xHCI controller*/
|
|
|
|
usleep_range(TIMEGAP_USEC_MIN, TIMEGAP_USEC_MAX);
|
|
|
|
|
2010-01-06 06:34:15 -07:00
|
|
|
size = min_t(uint, count, BULK_SIZE);
|
2010-11-22 13:09:01 -07:00
|
|
|
memcpy(send_buf, firmware->data + sent, size);
|
2010-01-06 06:34:15 -07:00
|
|
|
|
2010-11-22 13:09:01 -07:00
|
|
|
err = usb_bulk_msg(udev, pipe, send_buf, size,
|
Bluetooth: ath3k: Fix multiple issues reported by checkpatch.pl
This fixes some CHECKs reported by the checkpatch script.
Issues reported in ath3k.c:
-------
ath3k.c
-------
CHECK: Please don't use multiple blank lines
+
+
CHECK: Blank lines aren't necessary after an open brace '{'
+static const struct usb_device_id ath3k_blist_tbl[] = {
+
CHECK: Alignment should match open parenthesis
+static int ath3k_load_firmware(struct usb_device *udev,
+ const struct firmware *firmware)
CHECK: Alignment should match open parenthesis
+ err = usb_bulk_msg(udev, pipe, send_buf, size,
+ &len, 3000);
CHECK: Unnecessary parentheses around 'len != size'
+ if (err || (len != size)) {
CHECK: Alignment should match open parenthesis
+static int ath3k_get_version(struct usb_device *udev,
+ struct ath3k_version *version)
CHECK: Alignment should match open parenthesis
+static int ath3k_load_fwfile(struct usb_device *udev,
+ const struct firmware *firmware)
CHECK: Alignment should match open parenthesis
+ err = usb_bulk_msg(udev, pipe, send_buf, size,
+ &len, 3000);
CHECK: Unnecessary parentheses around 'len != size'
+ if (err || (len != size)) {
CHECK: Blank lines aren't necessary after an open brace '{'
+ switch (fw_version.ref_clock) {
+
CHECK: Alignment should match open parenthesis
+ snprintf(filename, ATH3K_NAME_LEN, "ar3k/ramps_0x%08x_%d%s",
+ le32_to_cpu(fw_version.rom_version), clk_value, ".dfu");
CHECK: Alignment should match open parenthesis
+static int ath3k_probe(struct usb_interface *intf,
+ const struct usb_device_id *id)
CHECK: Alignment should match open parenthesis
+ BT_ERR("Firmware file \"%s\" not found",
+ ATH3K_FIRMWARE);
CHECK: Alignment should match open parenthesis
+ BT_ERR("Firmware file \"%s\" request failed (err=%d)",
+ ATH3K_FIRMWARE, ret);
total: 0 errors, 0 warnings, 14 checks, 540 lines checked
Signed-off-by: Uri Arev <me@wantyapps.xyz>
Signed-off-by: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>
2024-04-05 14:42:24 -07:00
|
|
|
&len, 3000);
|
2010-01-06 06:34:15 -07:00
|
|
|
|
Bluetooth: ath3k: Fix multiple issues reported by checkpatch.pl
This fixes some CHECKs reported by the checkpatch script.
Issues reported in ath3k.c:
-------
ath3k.c
-------
CHECK: Please don't use multiple blank lines
+
+
CHECK: Blank lines aren't necessary after an open brace '{'
+static const struct usb_device_id ath3k_blist_tbl[] = {
+
CHECK: Alignment should match open parenthesis
+static int ath3k_load_firmware(struct usb_device *udev,
+ const struct firmware *firmware)
CHECK: Alignment should match open parenthesis
+ err = usb_bulk_msg(udev, pipe, send_buf, size,
+ &len, 3000);
CHECK: Unnecessary parentheses around 'len != size'
+ if (err || (len != size)) {
CHECK: Alignment should match open parenthesis
+static int ath3k_get_version(struct usb_device *udev,
+ struct ath3k_version *version)
CHECK: Alignment should match open parenthesis
+static int ath3k_load_fwfile(struct usb_device *udev,
+ const struct firmware *firmware)
CHECK: Alignment should match open parenthesis
+ err = usb_bulk_msg(udev, pipe, send_buf, size,
+ &len, 3000);
CHECK: Unnecessary parentheses around 'len != size'
+ if (err || (len != size)) {
CHECK: Blank lines aren't necessary after an open brace '{'
+ switch (fw_version.ref_clock) {
+
CHECK: Alignment should match open parenthesis
+ snprintf(filename, ATH3K_NAME_LEN, "ar3k/ramps_0x%08x_%d%s",
+ le32_to_cpu(fw_version.rom_version), clk_value, ".dfu");
CHECK: Alignment should match open parenthesis
+static int ath3k_probe(struct usb_interface *intf,
+ const struct usb_device_id *id)
CHECK: Alignment should match open parenthesis
+ BT_ERR("Firmware file \"%s\" not found",
+ ATH3K_FIRMWARE);
CHECK: Alignment should match open parenthesis
+ BT_ERR("Firmware file \"%s\" request failed (err=%d)",
+ ATH3K_FIRMWARE, ret);
total: 0 errors, 0 warnings, 14 checks, 540 lines checked
Signed-off-by: Uri Arev <me@wantyapps.xyz>
Signed-off-by: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>
2024-04-05 14:42:24 -07:00
|
|
|
if (err || len != size) {
|
2018-09-27 13:19:26 -07:00
|
|
|
ath3k_log_failed_loading(err, len, size, count);
|
2010-01-06 06:34:15 -07:00
|
|
|
goto error;
|
|
|
|
}
|
|
|
|
|
|
|
|
sent += size;
|
|
|
|
count -= size;
|
|
|
|
}
|
|
|
|
|
|
|
|
error:
|
|
|
|
kfree(send_buf);
|
|
|
|
return err;
|
|
|
|
}
|
|
|
|
|
2011-02-11 03:08:53 -07:00
|
|
|
static int ath3k_get_state(struct usb_device *udev, unsigned char *state)
|
|
|
|
{
|
2020-09-23 06:43:48 -07:00
|
|
|
return usb_control_msg_recv(udev, 0, ATH3K_GETSTATE,
|
|
|
|
USB_TYPE_VENDOR | USB_DIR_IN, 0, 0,
|
|
|
|
state, 1, USB_CTRL_SET_TIMEOUT,
|
|
|
|
GFP_KERNEL);
|
2011-02-11 03:08:53 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
static int ath3k_get_version(struct usb_device *udev,
|
Bluetooth: ath3k: Fix multiple issues reported by checkpatch.pl
This fixes some CHECKs reported by the checkpatch script.
Issues reported in ath3k.c:
-------
ath3k.c
-------
CHECK: Please don't use multiple blank lines
+
+
CHECK: Blank lines aren't necessary after an open brace '{'
+static const struct usb_device_id ath3k_blist_tbl[] = {
+
CHECK: Alignment should match open parenthesis
+static int ath3k_load_firmware(struct usb_device *udev,
+ const struct firmware *firmware)
CHECK: Alignment should match open parenthesis
+ err = usb_bulk_msg(udev, pipe, send_buf, size,
+ &len, 3000);
CHECK: Unnecessary parentheses around 'len != size'
+ if (err || (len != size)) {
CHECK: Alignment should match open parenthesis
+static int ath3k_get_version(struct usb_device *udev,
+ struct ath3k_version *version)
CHECK: Alignment should match open parenthesis
+static int ath3k_load_fwfile(struct usb_device *udev,
+ const struct firmware *firmware)
CHECK: Alignment should match open parenthesis
+ err = usb_bulk_msg(udev, pipe, send_buf, size,
+ &len, 3000);
CHECK: Unnecessary parentheses around 'len != size'
+ if (err || (len != size)) {
CHECK: Blank lines aren't necessary after an open brace '{'
+ switch (fw_version.ref_clock) {
+
CHECK: Alignment should match open parenthesis
+ snprintf(filename, ATH3K_NAME_LEN, "ar3k/ramps_0x%08x_%d%s",
+ le32_to_cpu(fw_version.rom_version), clk_value, ".dfu");
CHECK: Alignment should match open parenthesis
+static int ath3k_probe(struct usb_interface *intf,
+ const struct usb_device_id *id)
CHECK: Alignment should match open parenthesis
+ BT_ERR("Firmware file \"%s\" not found",
+ ATH3K_FIRMWARE);
CHECK: Alignment should match open parenthesis
+ BT_ERR("Firmware file \"%s\" request failed (err=%d)",
+ ATH3K_FIRMWARE, ret);
total: 0 errors, 0 warnings, 14 checks, 540 lines checked
Signed-off-by: Uri Arev <me@wantyapps.xyz>
Signed-off-by: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>
2024-04-05 14:42:24 -07:00
|
|
|
struct ath3k_version *version)
|
2011-02-11 03:08:53 -07:00
|
|
|
{
|
2020-09-23 06:43:48 -07:00
|
|
|
return usb_control_msg_recv(udev, 0, ATH3K_GETVERSION,
|
|
|
|
USB_TYPE_VENDOR | USB_DIR_IN, 0, 0,
|
|
|
|
version, sizeof(*version), USB_CTRL_SET_TIMEOUT,
|
|
|
|
GFP_KERNEL);
|
2011-02-11 03:08:53 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
static int ath3k_load_fwfile(struct usb_device *udev,
|
Bluetooth: ath3k: Fix multiple issues reported by checkpatch.pl
This fixes some CHECKs reported by the checkpatch script.
Issues reported in ath3k.c:
-------
ath3k.c
-------
CHECK: Please don't use multiple blank lines
+
+
CHECK: Blank lines aren't necessary after an open brace '{'
+static const struct usb_device_id ath3k_blist_tbl[] = {
+
CHECK: Alignment should match open parenthesis
+static int ath3k_load_firmware(struct usb_device *udev,
+ const struct firmware *firmware)
CHECK: Alignment should match open parenthesis
+ err = usb_bulk_msg(udev, pipe, send_buf, size,
+ &len, 3000);
CHECK: Unnecessary parentheses around 'len != size'
+ if (err || (len != size)) {
CHECK: Alignment should match open parenthesis
+static int ath3k_get_version(struct usb_device *udev,
+ struct ath3k_version *version)
CHECK: Alignment should match open parenthesis
+static int ath3k_load_fwfile(struct usb_device *udev,
+ const struct firmware *firmware)
CHECK: Alignment should match open parenthesis
+ err = usb_bulk_msg(udev, pipe, send_buf, size,
+ &len, 3000);
CHECK: Unnecessary parentheses around 'len != size'
+ if (err || (len != size)) {
CHECK: Blank lines aren't necessary after an open brace '{'
+ switch (fw_version.ref_clock) {
+
CHECK: Alignment should match open parenthesis
+ snprintf(filename, ATH3K_NAME_LEN, "ar3k/ramps_0x%08x_%d%s",
+ le32_to_cpu(fw_version.rom_version), clk_value, ".dfu");
CHECK: Alignment should match open parenthesis
+static int ath3k_probe(struct usb_interface *intf,
+ const struct usb_device_id *id)
CHECK: Alignment should match open parenthesis
+ BT_ERR("Firmware file \"%s\" not found",
+ ATH3K_FIRMWARE);
CHECK: Alignment should match open parenthesis
+ BT_ERR("Firmware file \"%s\" request failed (err=%d)",
+ ATH3K_FIRMWARE, ret);
total: 0 errors, 0 warnings, 14 checks, 540 lines checked
Signed-off-by: Uri Arev <me@wantyapps.xyz>
Signed-off-by: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>
2024-04-05 14:42:24 -07:00
|
|
|
const struct firmware *firmware)
|
2011-02-11 03:08:53 -07:00
|
|
|
{
|
|
|
|
u8 *send_buf;
|
2016-04-22 03:02:55 -07:00
|
|
|
int len = 0;
|
|
|
|
int err, pipe, size, count, sent = 0;
|
2011-02-11 03:08:53 -07:00
|
|
|
int ret;
|
|
|
|
|
|
|
|
count = firmware->size;
|
|
|
|
|
2011-10-25 03:09:52 -07:00
|
|
|
send_buf = kmalloc(BULK_SIZE, GFP_KERNEL);
|
2011-02-11 03:08:53 -07:00
|
|
|
if (!send_buf) {
|
|
|
|
BT_ERR("Can't allocate memory chunk for firmware");
|
|
|
|
return -ENOMEM;
|
|
|
|
}
|
|
|
|
|
|
|
|
size = min_t(uint, count, FW_HDR_SIZE);
|
|
|
|
|
2020-09-23 06:43:48 -07:00
|
|
|
ret = usb_control_msg_send(udev, 0, ATH3K_DNLOAD, USB_TYPE_VENDOR, 0, 0,
|
|
|
|
firmware->data, size, USB_CTRL_SET_TIMEOUT,
|
|
|
|
GFP_KERNEL);
|
|
|
|
if (ret) {
|
2011-02-11 03:08:53 -07:00
|
|
|
BT_ERR("Can't change to loading configuration err");
|
|
|
|
kfree(send_buf);
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
|
|
|
sent += size;
|
|
|
|
count -= size;
|
|
|
|
|
2014-06-05 06:47:44 -07:00
|
|
|
pipe = usb_sndbulkpipe(udev, 0x02);
|
|
|
|
|
2011-02-11 03:08:53 -07:00
|
|
|
while (count) {
|
2015-01-28 13:30:27 -07:00
|
|
|
/* workaround the compatibility issue with xHCI controller*/
|
|
|
|
usleep_range(TIMEGAP_USEC_MIN, TIMEGAP_USEC_MAX);
|
|
|
|
|
2011-02-11 03:08:53 -07:00
|
|
|
size = min_t(uint, count, BULK_SIZE);
|
|
|
|
memcpy(send_buf, firmware->data + sent, size);
|
|
|
|
|
|
|
|
err = usb_bulk_msg(udev, pipe, send_buf, size,
|
Bluetooth: ath3k: Fix multiple issues reported by checkpatch.pl
This fixes some CHECKs reported by the checkpatch script.
Issues reported in ath3k.c:
-------
ath3k.c
-------
CHECK: Please don't use multiple blank lines
+
+
CHECK: Blank lines aren't necessary after an open brace '{'
+static const struct usb_device_id ath3k_blist_tbl[] = {
+
CHECK: Alignment should match open parenthesis
+static int ath3k_load_firmware(struct usb_device *udev,
+ const struct firmware *firmware)
CHECK: Alignment should match open parenthesis
+ err = usb_bulk_msg(udev, pipe, send_buf, size,
+ &len, 3000);
CHECK: Unnecessary parentheses around 'len != size'
+ if (err || (len != size)) {
CHECK: Alignment should match open parenthesis
+static int ath3k_get_version(struct usb_device *udev,
+ struct ath3k_version *version)
CHECK: Alignment should match open parenthesis
+static int ath3k_load_fwfile(struct usb_device *udev,
+ const struct firmware *firmware)
CHECK: Alignment should match open parenthesis
+ err = usb_bulk_msg(udev, pipe, send_buf, size,
+ &len, 3000);
CHECK: Unnecessary parentheses around 'len != size'
+ if (err || (len != size)) {
CHECK: Blank lines aren't necessary after an open brace '{'
+ switch (fw_version.ref_clock) {
+
CHECK: Alignment should match open parenthesis
+ snprintf(filename, ATH3K_NAME_LEN, "ar3k/ramps_0x%08x_%d%s",
+ le32_to_cpu(fw_version.rom_version), clk_value, ".dfu");
CHECK: Alignment should match open parenthesis
+static int ath3k_probe(struct usb_interface *intf,
+ const struct usb_device_id *id)
CHECK: Alignment should match open parenthesis
+ BT_ERR("Firmware file \"%s\" not found",
+ ATH3K_FIRMWARE);
CHECK: Alignment should match open parenthesis
+ BT_ERR("Firmware file \"%s\" request failed (err=%d)",
+ ATH3K_FIRMWARE, ret);
total: 0 errors, 0 warnings, 14 checks, 540 lines checked
Signed-off-by: Uri Arev <me@wantyapps.xyz>
Signed-off-by: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>
2024-04-05 14:42:24 -07:00
|
|
|
&len, 3000);
|
|
|
|
if (err || len != size) {
|
2018-09-27 13:19:26 -07:00
|
|
|
ath3k_log_failed_loading(err, len, size, count);
|
2011-02-11 03:08:53 -07:00
|
|
|
kfree(send_buf);
|
|
|
|
return err;
|
|
|
|
}
|
|
|
|
sent += size;
|
|
|
|
count -= size;
|
|
|
|
}
|
|
|
|
|
|
|
|
kfree(send_buf);
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2020-09-23 06:43:48 -07:00
|
|
|
static void ath3k_switch_pid(struct usb_device *udev)
|
2011-02-11 03:08:53 -07:00
|
|
|
{
|
2020-09-23 06:43:48 -07:00
|
|
|
usb_control_msg_send(udev, 0, USB_REG_SWITCH_VID_PID, USB_TYPE_VENDOR,
|
|
|
|
0, 0, NULL, 0, USB_CTRL_SET_TIMEOUT, GFP_KERNEL);
|
2011-02-11 03:08:53 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
static int ath3k_set_normal_mode(struct usb_device *udev)
|
|
|
|
{
|
|
|
|
unsigned char fw_state;
|
2020-09-23 06:43:48 -07:00
|
|
|
int ret;
|
2011-02-11 03:08:53 -07:00
|
|
|
|
|
|
|
ret = ath3k_get_state(udev, &fw_state);
|
2020-09-23 06:43:48 -07:00
|
|
|
if (ret) {
|
2011-02-11 03:08:53 -07:00
|
|
|
BT_ERR("Can't get state to change to normal mode err");
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
|
|
|
if ((fw_state & ATH3K_MODE_MASK) == ATH3K_NORMAL_MODE) {
|
|
|
|
BT_DBG("firmware was already in normal mode");
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2020-09-23 06:43:48 -07:00
|
|
|
return usb_control_msg_send(udev, 0, ATH3K_SET_NORMAL_MODE,
|
|
|
|
USB_TYPE_VENDOR, 0, 0, NULL, 0,
|
|
|
|
USB_CTRL_SET_TIMEOUT, GFP_KERNEL);
|
2011-02-11 03:08:53 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
static int ath3k_load_patch(struct usb_device *udev)
|
|
|
|
{
|
|
|
|
unsigned char fw_state;
|
2018-02-04 14:09:44 -07:00
|
|
|
char filename[ATH3K_NAME_LEN];
|
2011-02-11 03:08:53 -07:00
|
|
|
const struct firmware *firmware;
|
2014-07-20 08:29:59 -07:00
|
|
|
struct ath3k_version fw_version;
|
|
|
|
__u32 pt_rom_version, pt_build_version;
|
2011-02-11 03:08:53 -07:00
|
|
|
int ret;
|
|
|
|
|
|
|
|
ret = ath3k_get_state(udev, &fw_state);
|
2020-09-23 06:43:48 -07:00
|
|
|
if (ret) {
|
2011-02-11 03:08:53 -07:00
|
|
|
BT_ERR("Can't get state to change to load ram patch err");
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (fw_state & ATH3K_PATCH_UPDATE) {
|
|
|
|
BT_DBG("Patch was already downloaded");
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
ret = ath3k_get_version(udev, &fw_version);
|
2020-09-23 06:43:48 -07:00
|
|
|
if (ret) {
|
2011-02-11 03:08:53 -07:00
|
|
|
BT_ERR("Can't get version to change to load ram patch err");
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
|
|
|
snprintf(filename, ATH3K_NAME_LEN, "ar3k/AthrBT_0x%08x.dfu",
|
2014-07-20 08:29:59 -07:00
|
|
|
le32_to_cpu(fw_version.rom_version));
|
2011-02-11 03:08:53 -07:00
|
|
|
|
|
|
|
ret = request_firmware(&firmware, filename, &udev->dev);
|
|
|
|
if (ret < 0) {
|
|
|
|
BT_ERR("Patch file not found %s", filename);
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
2014-07-20 08:29:59 -07:00
|
|
|
pt_rom_version = get_unaligned_le32(firmware->data +
|
|
|
|
firmware->size - 8);
|
|
|
|
pt_build_version = get_unaligned_le32(firmware->data +
|
|
|
|
firmware->size - 4);
|
2011-02-11 03:08:53 -07:00
|
|
|
|
2014-07-20 08:29:59 -07:00
|
|
|
if (pt_rom_version != le32_to_cpu(fw_version.rom_version) ||
|
|
|
|
pt_build_version <= le32_to_cpu(fw_version.build_version)) {
|
2011-02-11 03:08:53 -07:00
|
|
|
BT_ERR("Patch file version did not match with firmware");
|
|
|
|
release_firmware(firmware);
|
|
|
|
return -EINVAL;
|
|
|
|
}
|
|
|
|
|
|
|
|
ret = ath3k_load_fwfile(udev, firmware);
|
|
|
|
release_firmware(firmware);
|
|
|
|
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
|
|
|
static int ath3k_load_syscfg(struct usb_device *udev)
|
|
|
|
{
|
|
|
|
unsigned char fw_state;
|
2018-02-04 14:09:44 -07:00
|
|
|
char filename[ATH3K_NAME_LEN];
|
2011-02-11 03:08:53 -07:00
|
|
|
const struct firmware *firmware;
|
|
|
|
struct ath3k_version fw_version;
|
|
|
|
int clk_value, ret;
|
|
|
|
|
|
|
|
ret = ath3k_get_state(udev, &fw_state);
|
2020-09-23 06:43:48 -07:00
|
|
|
if (ret) {
|
2012-12-28 10:00:09 -07:00
|
|
|
BT_ERR("Can't get state to change to load configuration err");
|
2011-02-11 03:08:53 -07:00
|
|
|
return -EBUSY;
|
|
|
|
}
|
|
|
|
|
|
|
|
ret = ath3k_get_version(udev, &fw_version);
|
2020-09-23 06:43:48 -07:00
|
|
|
if (ret) {
|
2011-02-11 03:08:53 -07:00
|
|
|
BT_ERR("Can't get version to change to load ram patch err");
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
|
|
|
switch (fw_version.ref_clock) {
|
|
|
|
case ATH3K_XTAL_FREQ_26M:
|
|
|
|
clk_value = 26;
|
|
|
|
break;
|
|
|
|
case ATH3K_XTAL_FREQ_40M:
|
|
|
|
clk_value = 40;
|
|
|
|
break;
|
|
|
|
case ATH3K_XTAL_FREQ_19P2:
|
|
|
|
clk_value = 19;
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
clk_value = 0;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
snprintf(filename, ATH3K_NAME_LEN, "ar3k/ramps_0x%08x_%d%s",
|
Bluetooth: ath3k: Fix multiple issues reported by checkpatch.pl
This fixes some CHECKs reported by the checkpatch script.
Issues reported in ath3k.c:
-------
ath3k.c
-------
CHECK: Please don't use multiple blank lines
+
+
CHECK: Blank lines aren't necessary after an open brace '{'
+static const struct usb_device_id ath3k_blist_tbl[] = {
+
CHECK: Alignment should match open parenthesis
+static int ath3k_load_firmware(struct usb_device *udev,
+ const struct firmware *firmware)
CHECK: Alignment should match open parenthesis
+ err = usb_bulk_msg(udev, pipe, send_buf, size,
+ &len, 3000);
CHECK: Unnecessary parentheses around 'len != size'
+ if (err || (len != size)) {
CHECK: Alignment should match open parenthesis
+static int ath3k_get_version(struct usb_device *udev,
+ struct ath3k_version *version)
CHECK: Alignment should match open parenthesis
+static int ath3k_load_fwfile(struct usb_device *udev,
+ const struct firmware *firmware)
CHECK: Alignment should match open parenthesis
+ err = usb_bulk_msg(udev, pipe, send_buf, size,
+ &len, 3000);
CHECK: Unnecessary parentheses around 'len != size'
+ if (err || (len != size)) {
CHECK: Blank lines aren't necessary after an open brace '{'
+ switch (fw_version.ref_clock) {
+
CHECK: Alignment should match open parenthesis
+ snprintf(filename, ATH3K_NAME_LEN, "ar3k/ramps_0x%08x_%d%s",
+ le32_to_cpu(fw_version.rom_version), clk_value, ".dfu");
CHECK: Alignment should match open parenthesis
+static int ath3k_probe(struct usb_interface *intf,
+ const struct usb_device_id *id)
CHECK: Alignment should match open parenthesis
+ BT_ERR("Firmware file \"%s\" not found",
+ ATH3K_FIRMWARE);
CHECK: Alignment should match open parenthesis
+ BT_ERR("Firmware file \"%s\" request failed (err=%d)",
+ ATH3K_FIRMWARE, ret);
total: 0 errors, 0 warnings, 14 checks, 540 lines checked
Signed-off-by: Uri Arev <me@wantyapps.xyz>
Signed-off-by: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>
2024-04-05 14:42:24 -07:00
|
|
|
le32_to_cpu(fw_version.rom_version), clk_value, ".dfu");
|
2011-02-11 03:08:53 -07:00
|
|
|
|
|
|
|
ret = request_firmware(&firmware, filename, &udev->dev);
|
|
|
|
if (ret < 0) {
|
|
|
|
BT_ERR("Configuration file not found %s", filename);
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
|
|
|
ret = ath3k_load_fwfile(udev, firmware);
|
|
|
|
release_firmware(firmware);
|
|
|
|
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
2010-01-06 06:34:15 -07:00
|
|
|
static int ath3k_probe(struct usb_interface *intf,
|
Bluetooth: ath3k: Fix multiple issues reported by checkpatch.pl
This fixes some CHECKs reported by the checkpatch script.
Issues reported in ath3k.c:
-------
ath3k.c
-------
CHECK: Please don't use multiple blank lines
+
+
CHECK: Blank lines aren't necessary after an open brace '{'
+static const struct usb_device_id ath3k_blist_tbl[] = {
+
CHECK: Alignment should match open parenthesis
+static int ath3k_load_firmware(struct usb_device *udev,
+ const struct firmware *firmware)
CHECK: Alignment should match open parenthesis
+ err = usb_bulk_msg(udev, pipe, send_buf, size,
+ &len, 3000);
CHECK: Unnecessary parentheses around 'len != size'
+ if (err || (len != size)) {
CHECK: Alignment should match open parenthesis
+static int ath3k_get_version(struct usb_device *udev,
+ struct ath3k_version *version)
CHECK: Alignment should match open parenthesis
+static int ath3k_load_fwfile(struct usb_device *udev,
+ const struct firmware *firmware)
CHECK: Alignment should match open parenthesis
+ err = usb_bulk_msg(udev, pipe, send_buf, size,
+ &len, 3000);
CHECK: Unnecessary parentheses around 'len != size'
+ if (err || (len != size)) {
CHECK: Blank lines aren't necessary after an open brace '{'
+ switch (fw_version.ref_clock) {
+
CHECK: Alignment should match open parenthesis
+ snprintf(filename, ATH3K_NAME_LEN, "ar3k/ramps_0x%08x_%d%s",
+ le32_to_cpu(fw_version.rom_version), clk_value, ".dfu");
CHECK: Alignment should match open parenthesis
+static int ath3k_probe(struct usb_interface *intf,
+ const struct usb_device_id *id)
CHECK: Alignment should match open parenthesis
+ BT_ERR("Firmware file \"%s\" not found",
+ ATH3K_FIRMWARE);
CHECK: Alignment should match open parenthesis
+ BT_ERR("Firmware file \"%s\" request failed (err=%d)",
+ ATH3K_FIRMWARE, ret);
total: 0 errors, 0 warnings, 14 checks, 540 lines checked
Signed-off-by: Uri Arev <me@wantyapps.xyz>
Signed-off-by: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>
2024-04-05 14:42:24 -07:00
|
|
|
const struct usb_device_id *id)
|
2010-01-06 06:34:15 -07:00
|
|
|
{
|
|
|
|
const struct firmware *firmware;
|
|
|
|
struct usb_device *udev = interface_to_usbdev(intf);
|
2011-02-02 20:42:05 -07:00
|
|
|
int ret;
|
2010-01-06 06:34:15 -07:00
|
|
|
|
|
|
|
BT_DBG("intf %p id %p", intf, id);
|
|
|
|
|
|
|
|
if (intf->cur_altsetting->desc.bInterfaceNumber != 0)
|
|
|
|
return -ENODEV;
|
|
|
|
|
2011-02-11 03:08:53 -07:00
|
|
|
/* match device ID in ath3k blacklist table */
|
|
|
|
if (!id->driver_info) {
|
|
|
|
const struct usb_device_id *match;
|
2016-01-12 09:40:15 -07:00
|
|
|
|
2011-02-11 03:08:53 -07:00
|
|
|
match = usb_match_id(intf, ath3k_blist_tbl);
|
|
|
|
if (match)
|
|
|
|
id = match;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* load patch and sysconfig files for AR3012 */
|
|
|
|
if (id->driver_info & BTUSB_ATH3012) {
|
2011-06-30 23:02:36 -07:00
|
|
|
/* New firmware with patch and sysconfig files already loaded */
|
|
|
|
if (le16_to_cpu(udev->descriptor.bcdDevice) > 0x0001)
|
|
|
|
return -ENODEV;
|
|
|
|
|
2011-02-11 03:08:53 -07:00
|
|
|
ret = ath3k_load_patch(udev);
|
|
|
|
if (ret < 0) {
|
|
|
|
BT_ERR("Loading patch file failed");
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
ret = ath3k_load_syscfg(udev);
|
|
|
|
if (ret < 0) {
|
|
|
|
BT_ERR("Loading sysconfig file failed");
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
ret = ath3k_set_normal_mode(udev);
|
2020-09-23 06:43:48 -07:00
|
|
|
if (ret) {
|
2011-02-11 03:08:53 -07:00
|
|
|
BT_ERR("Set normal mode failed");
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
ath3k_switch_pid(udev);
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2011-10-29 10:52:49 -07:00
|
|
|
ret = request_firmware(&firmware, ATH3K_FIRMWARE, &udev->dev);
|
|
|
|
if (ret < 0) {
|
|
|
|
if (ret == -ENOENT)
|
|
|
|
BT_ERR("Firmware file \"%s\" not found",
|
Bluetooth: ath3k: Fix multiple issues reported by checkpatch.pl
This fixes some CHECKs reported by the checkpatch script.
Issues reported in ath3k.c:
-------
ath3k.c
-------
CHECK: Please don't use multiple blank lines
+
+
CHECK: Blank lines aren't necessary after an open brace '{'
+static const struct usb_device_id ath3k_blist_tbl[] = {
+
CHECK: Alignment should match open parenthesis
+static int ath3k_load_firmware(struct usb_device *udev,
+ const struct firmware *firmware)
CHECK: Alignment should match open parenthesis
+ err = usb_bulk_msg(udev, pipe, send_buf, size,
+ &len, 3000);
CHECK: Unnecessary parentheses around 'len != size'
+ if (err || (len != size)) {
CHECK: Alignment should match open parenthesis
+static int ath3k_get_version(struct usb_device *udev,
+ struct ath3k_version *version)
CHECK: Alignment should match open parenthesis
+static int ath3k_load_fwfile(struct usb_device *udev,
+ const struct firmware *firmware)
CHECK: Alignment should match open parenthesis
+ err = usb_bulk_msg(udev, pipe, send_buf, size,
+ &len, 3000);
CHECK: Unnecessary parentheses around 'len != size'
+ if (err || (len != size)) {
CHECK: Blank lines aren't necessary after an open brace '{'
+ switch (fw_version.ref_clock) {
+
CHECK: Alignment should match open parenthesis
+ snprintf(filename, ATH3K_NAME_LEN, "ar3k/ramps_0x%08x_%d%s",
+ le32_to_cpu(fw_version.rom_version), clk_value, ".dfu");
CHECK: Alignment should match open parenthesis
+static int ath3k_probe(struct usb_interface *intf,
+ const struct usb_device_id *id)
CHECK: Alignment should match open parenthesis
+ BT_ERR("Firmware file \"%s\" not found",
+ ATH3K_FIRMWARE);
CHECK: Alignment should match open parenthesis
+ BT_ERR("Firmware file \"%s\" request failed (err=%d)",
+ ATH3K_FIRMWARE, ret);
total: 0 errors, 0 warnings, 14 checks, 540 lines checked
Signed-off-by: Uri Arev <me@wantyapps.xyz>
Signed-off-by: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>
2024-04-05 14:42:24 -07:00
|
|
|
ATH3K_FIRMWARE);
|
2011-10-29 10:52:49 -07:00
|
|
|
else
|
|
|
|
BT_ERR("Firmware file \"%s\" request failed (err=%d)",
|
Bluetooth: ath3k: Fix multiple issues reported by checkpatch.pl
This fixes some CHECKs reported by the checkpatch script.
Issues reported in ath3k.c:
-------
ath3k.c
-------
CHECK: Please don't use multiple blank lines
+
+
CHECK: Blank lines aren't necessary after an open brace '{'
+static const struct usb_device_id ath3k_blist_tbl[] = {
+
CHECK: Alignment should match open parenthesis
+static int ath3k_load_firmware(struct usb_device *udev,
+ const struct firmware *firmware)
CHECK: Alignment should match open parenthesis
+ err = usb_bulk_msg(udev, pipe, send_buf, size,
+ &len, 3000);
CHECK: Unnecessary parentheses around 'len != size'
+ if (err || (len != size)) {
CHECK: Alignment should match open parenthesis
+static int ath3k_get_version(struct usb_device *udev,
+ struct ath3k_version *version)
CHECK: Alignment should match open parenthesis
+static int ath3k_load_fwfile(struct usb_device *udev,
+ const struct firmware *firmware)
CHECK: Alignment should match open parenthesis
+ err = usb_bulk_msg(udev, pipe, send_buf, size,
+ &len, 3000);
CHECK: Unnecessary parentheses around 'len != size'
+ if (err || (len != size)) {
CHECK: Blank lines aren't necessary after an open brace '{'
+ switch (fw_version.ref_clock) {
+
CHECK: Alignment should match open parenthesis
+ snprintf(filename, ATH3K_NAME_LEN, "ar3k/ramps_0x%08x_%d%s",
+ le32_to_cpu(fw_version.rom_version), clk_value, ".dfu");
CHECK: Alignment should match open parenthesis
+static int ath3k_probe(struct usb_interface *intf,
+ const struct usb_device_id *id)
CHECK: Alignment should match open parenthesis
+ BT_ERR("Firmware file \"%s\" not found",
+ ATH3K_FIRMWARE);
CHECK: Alignment should match open parenthesis
+ BT_ERR("Firmware file \"%s\" request failed (err=%d)",
+ ATH3K_FIRMWARE, ret);
total: 0 errors, 0 warnings, 14 checks, 540 lines checked
Signed-off-by: Uri Arev <me@wantyapps.xyz>
Signed-off-by: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>
2024-04-05 14:42:24 -07:00
|
|
|
ATH3K_FIRMWARE, ret);
|
2011-10-29 10:52:49 -07:00
|
|
|
return ret;
|
2010-01-06 06:34:15 -07:00
|
|
|
}
|
|
|
|
|
2011-02-02 20:42:05 -07:00
|
|
|
ret = ath3k_load_firmware(udev, firmware);
|
2010-11-22 13:09:01 -07:00
|
|
|
release_firmware(firmware);
|
2010-01-06 06:34:15 -07:00
|
|
|
|
2011-02-02 20:42:05 -07:00
|
|
|
return ret;
|
2010-01-06 06:34:15 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
static void ath3k_disconnect(struct usb_interface *intf)
|
|
|
|
{
|
2018-02-04 14:09:47 -07:00
|
|
|
BT_DBG("%s intf %p", __func__, intf);
|
2010-01-06 06:34:15 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
static struct usb_driver ath3k_driver = {
|
|
|
|
.name = "ath3k",
|
|
|
|
.probe = ath3k_probe,
|
|
|
|
.disconnect = ath3k_disconnect,
|
|
|
|
.id_table = ath3k_table,
|
2012-04-23 10:08:51 -07:00
|
|
|
.disable_hub_initiated_lpm = 1,
|
2010-01-06 06:34:15 -07:00
|
|
|
};
|
|
|
|
|
2011-11-18 10:47:34 -07:00
|
|
|
module_usb_driver(ath3k_driver);
|
2010-01-06 06:34:15 -07:00
|
|
|
|
|
|
|
MODULE_AUTHOR("Atheros Communications");
|
|
|
|
MODULE_DESCRIPTION("Atheros AR30xx firmware driver");
|
|
|
|
MODULE_VERSION(VERSION);
|
|
|
|
MODULE_LICENSE("GPL");
|
2011-10-29 10:52:49 -07:00
|
|
|
MODULE_FIRMWARE(ATH3K_FIRMWARE);
|