Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit dcf47f3b authored by Marcel Holtmann's avatar Marcel Holtmann
Browse files

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
Loading
Loading
Loading
Loading
+38 −52
Original line number Diff line number Diff line
@@ -31,10 +31,6 @@

#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
 * when user removes this module from kernel space or ejects
 * the card from the slot. The driver handles these 2 cases
@@ -51,21 +47,21 @@
 */
static u8 user_rmmod;

static const struct sdio_device_id btmrvl_sdio_ids[] = {
	{SDIO_DEVICE(SDIO_VENDOR_ID_MARVELL, SDIO_DEVICE_ID_MARVELL_8688BT)},
	{0, 0, 0, 0}
static const struct btmrvl_sdio_device btmrvl_sdio_sd6888 = {
	.helper		= "sd8688_helper.bin",
	.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[] = {
	{
		.dev_id = SDIO_DEVICE_ID_MARVELL_8688BT,
		.helper = "sd8688_helper.bin",
		.firmware = "sd8688.bin",
	},
	{ }	/* Terminating entry */
};

MODULE_DEVICE_TABLE(sdio, btmrvl_sdio_ids);

static int btmrvl_sdio_get_rx_unit(struct btmrvl_sdio_card *card)
{
	u8 reg;
@@ -301,10 +297,8 @@ static int btmrvl_sdio_download_helper(struct btmrvl_sdio_card *card)
				tx_len);

		/* Now send the data */
		ret = sdio_writesb(card->func, card->ioport,
				   helperbuf,
				   FIRMWARE_TRANSFER_NBLOCK *
				   SDIO_BLOCK_SIZE);
		ret = sdio_writesb(card->func, card->ioport, helperbuf,
				FIRMWARE_TRANSFER_NBLOCK * SDIO_BLOCK_SIZE);
		if (ret < 0) {
			BT_ERR("IO error during helper download @ %d",
				hlprblknow);
@@ -691,9 +685,9 @@ static void btmrvl_sdio_interrupt(struct sdio_func *func)

static int btmrvl_sdio_register_dev(struct btmrvl_sdio_card *card)
{
	int ret = 0, i;
	u8 reg;
	struct sdio_func *func;
	u8 reg;
	int ret = 0;

	BT_DBG("Enter");

@@ -705,20 +699,6 @@ static int btmrvl_sdio_register_dev(struct btmrvl_sdio_card *card)

	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);

	ret = sdio_enable_func(func);
@@ -1002,6 +982,12 @@ static int btmrvl_sdio_probe(struct sdio_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) {
		BT_ERR("Failed to register BT device!");
		ret = -ENODEV;
+0 −1
Original line number Diff line number Diff line
@@ -90,7 +90,6 @@ struct btmrvl_sdio_card {
};

struct btmrvl_sdio_device {
	unsigned short dev_id;
	const char *helper;
	const char *firmware;
};