Commit dcf47f3b authored by Marcel Holtmann's avatar Marcel Holtmann

Bluetooth: Fix complicated assignment of firmware for Marvell devices

The Marvell Bluetooth SDIO driver has a really complicated concept on how
firmware names are assigned to specific device ids. Fix that by doing a
proper structure and assign it to the module device table.

And while at it fix various coding style weirdness that is still present
in this driver.
Signed-off-by: default avatarMarcel Holtman <marcel@holtmann.org>
parent 4271e08d
...@@ -31,10 +31,6 @@ ...@@ -31,10 +31,6 @@
#define VERSION "1.0" #define VERSION "1.0"
#ifndef SDIO_DEVICE_ID_MARVELL_8688BT
#define SDIO_DEVICE_ID_MARVELL_8688BT 0x9105
#endif
/* The btmrvl_sdio_remove() callback function is called /* The btmrvl_sdio_remove() callback function is called
* when user removes this module from kernel space or ejects * when user removes this module from kernel space or ejects
* the card from the slot. The driver handles these 2 cases * the card from the slot. The driver handles these 2 cases
...@@ -51,21 +47,21 @@ ...@@ -51,21 +47,21 @@
*/ */
static u8 user_rmmod; static u8 user_rmmod;
static const struct sdio_device_id btmrvl_sdio_ids[] = { static const struct btmrvl_sdio_device btmrvl_sdio_sd6888 = {
{SDIO_DEVICE(SDIO_VENDOR_ID_MARVELL, SDIO_DEVICE_ID_MARVELL_8688BT)}, .helper = "sd8688_helper.bin",
{0, 0, 0, 0} .firmware = "sd8688.bin",
}; };
MODULE_DEVICE_TABLE(sdio, btmrvl_sdio_ids); static const struct sdio_device_id btmrvl_sdio_ids[] = {
/* Marvell SD8688 Bluetooth device */
{ SDIO_DEVICE(SDIO_VENDOR_ID_MARVELL, 0x9105),
.driver_data = (unsigned long) &btmrvl_sdio_sd6888 },
static struct btmrvl_sdio_device btmrvl_sdio_devices[] = { { } /* Terminating entry */
{
.dev_id = SDIO_DEVICE_ID_MARVELL_8688BT,
.helper = "sd8688_helper.bin",
.firmware = "sd8688.bin",
},
}; };
MODULE_DEVICE_TABLE(sdio, btmrvl_sdio_ids);
static int btmrvl_sdio_get_rx_unit(struct btmrvl_sdio_card *card) static int btmrvl_sdio_get_rx_unit(struct btmrvl_sdio_card *card)
{ {
u8 reg; u8 reg;
...@@ -301,10 +297,8 @@ static int btmrvl_sdio_download_helper(struct btmrvl_sdio_card *card) ...@@ -301,10 +297,8 @@ static int btmrvl_sdio_download_helper(struct btmrvl_sdio_card *card)
tx_len); tx_len);
/* Now send the data */ /* Now send the data */
ret = sdio_writesb(card->func, card->ioport, ret = sdio_writesb(card->func, card->ioport, helperbuf,
helperbuf, FIRMWARE_TRANSFER_NBLOCK * SDIO_BLOCK_SIZE);
FIRMWARE_TRANSFER_NBLOCK *
SDIO_BLOCK_SIZE);
if (ret < 0) { if (ret < 0) {
BT_ERR("IO error during helper download @ %d", BT_ERR("IO error during helper download @ %d",
hlprblknow); hlprblknow);
...@@ -691,9 +685,9 @@ static void btmrvl_sdio_interrupt(struct sdio_func *func) ...@@ -691,9 +685,9 @@ static void btmrvl_sdio_interrupt(struct sdio_func *func)
static int btmrvl_sdio_register_dev(struct btmrvl_sdio_card *card) static int btmrvl_sdio_register_dev(struct btmrvl_sdio_card *card)
{ {
int ret = 0, i;
u8 reg;
struct sdio_func *func; struct sdio_func *func;
u8 reg;
int ret = 0;
BT_DBG("Enter"); BT_DBG("Enter");
...@@ -705,20 +699,6 @@ static int btmrvl_sdio_register_dev(struct btmrvl_sdio_card *card) ...@@ -705,20 +699,6 @@ static int btmrvl_sdio_register_dev(struct btmrvl_sdio_card *card)
func = card->func; func = card->func;
for (i = 0; i < ARRAY_SIZE(btmrvl_sdio_devices); i++) {
if (func->device == btmrvl_sdio_devices[i].dev_id)
break;
}
if (i == ARRAY_SIZE(btmrvl_sdio_devices)) {
BT_ERR("Error: unknown device id 0x%x", func->device);
ret = -EINVAL;
goto failed;
}
card->helper = btmrvl_sdio_devices[i].helper;
card->firmware = btmrvl_sdio_devices[i].firmware;
sdio_claim_host(func); sdio_claim_host(func);
ret = sdio_enable_func(func); ret = sdio_enable_func(func);
...@@ -1002,6 +982,12 @@ static int btmrvl_sdio_probe(struct sdio_func *func, ...@@ -1002,6 +982,12 @@ static int btmrvl_sdio_probe(struct sdio_func *func,
card->func = func; card->func = func;
if (id->driver_data) {
struct btmrvl_sdio_device *data = (void *) id->driver_data;
card->helper = data->helper;
card->firmware = data->firmware;
}
if (btmrvl_sdio_register_dev(card) < 0) { if (btmrvl_sdio_register_dev(card) < 0) {
BT_ERR("Failed to register BT device!"); BT_ERR("Failed to register BT device!");
ret = -ENODEV; ret = -ENODEV;
......
...@@ -90,7 +90,6 @@ struct btmrvl_sdio_card { ...@@ -90,7 +90,6 @@ struct btmrvl_sdio_card {
}; };
struct btmrvl_sdio_device { struct btmrvl_sdio_device {
unsigned short dev_id;
const char *helper; const char *helper;
const char *firmware; const char *firmware;
}; };
......
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