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

Bluetooth: btmrvl: support sysfs initiated firmware coredump

Since commit 3c47d19ff4dc ("drivers: base: add coredump driver ops")
it is possible to initiate a device coredump from user-space. This
patch adds support for it in btmrvl_sdio adding the .coredump()
driver callback. This makes dump through debugfs obsolete so removing
it.

Signed-off-by: Arend van Spriel <arend.vanspriel@broadcom.com>
Signed-off-by: Marcel Holtmann <marcel@holtmann.org>

authored by

Arend van Spriel and committed by
Marcel Holtmann
45650499 803cdb8c

+8 -42
-31
drivers/bluetooth/btmrvl_debugfs.c
··· 167 167 .llseek = default_llseek, 168 168 }; 169 169 170 - static ssize_t btmrvl_fwdump_write(struct file *file, const char __user *ubuf, 171 - size_t count, loff_t *ppos) 172 - { 173 - struct btmrvl_private *priv = file->private_data; 174 - char buf[16]; 175 - bool result; 176 - 177 - memset(buf, 0, sizeof(buf)); 178 - 179 - if (copy_from_user(&buf, ubuf, min_t(size_t, sizeof(buf) - 1, count))) 180 - return -EFAULT; 181 - 182 - if (strtobool(buf, &result)) 183 - return -EINVAL; 184 - 185 - if (!result) 186 - return -EINVAL; 187 - 188 - btmrvl_firmware_dump(priv); 189 - 190 - return count; 191 - } 192 - 193 - static const struct file_operations btmrvl_fwdump_fops = { 194 - .write = btmrvl_fwdump_write, 195 - .open = simple_open, 196 - .llseek = default_llseek, 197 - }; 198 - 199 170 void btmrvl_debugfs_init(struct hci_dev *hdev) 200 171 { 201 172 struct btmrvl_private *priv = hci_get_drvdata(hdev); ··· 197 226 priv, &btmrvl_hscmd_fops); 198 227 debugfs_create_file("hscfgcmd", 0644, dbg->config_dir, 199 228 priv, &btmrvl_hscfgcmd_fops); 200 - debugfs_create_file("fw_dump", 0200, dbg->config_dir, 201 - priv, &btmrvl_fwdump_fops); 202 229 203 230 dbg->status_dir = debugfs_create_dir("status", hdev->debugfs); 204 231 debugfs_create_u8("curpsmode", 0444, dbg->status_dir,
-2
drivers/bluetooth/btmrvl_drv.h
··· 110 110 u8 *payload, u16 nb); 111 111 int (*hw_wakeup_firmware)(struct btmrvl_private *priv); 112 112 int (*hw_process_int_status)(struct btmrvl_private *priv); 113 - void (*firmware_dump)(struct btmrvl_private *priv); 114 113 spinlock_t driver_lock; /* spinlock used by driver */ 115 114 #ifdef CONFIG_DEBUG_FS 116 115 void *debugfs_data; ··· 182 183 int btmrvl_enable_ps(struct btmrvl_private *priv); 183 184 int btmrvl_prepare_command(struct btmrvl_private *priv); 184 185 int btmrvl_enable_hs(struct btmrvl_private *priv); 185 - void btmrvl_firmware_dump(struct btmrvl_private *priv); 186 186 187 187 #ifdef CONFIG_DEBUG_FS 188 188 void btmrvl_debugfs_init(struct hci_dev *hdev);
-6
drivers/bluetooth/btmrvl_main.c
··· 358 358 return ret; 359 359 } 360 360 361 - void btmrvl_firmware_dump(struct btmrvl_private *priv) 362 - { 363 - if (priv->firmware_dump) 364 - priv->firmware_dump(priv); 365 - } 366 - 367 361 static int btmrvl_tx_pkt(struct btmrvl_private *priv, struct sk_buff *skb) 368 362 { 369 363 int ret = 0;
+8 -3
drivers/bluetooth/btmrvl_sdio.c
··· 1311 1311 } 1312 1312 1313 1313 /* This function dump sdio register and memory data */ 1314 - static void btmrvl_sdio_dump_firmware(struct btmrvl_private *priv) 1314 + static void btmrvl_sdio_coredump(struct device *dev) 1315 1315 { 1316 - struct btmrvl_sdio_card *card = priv->btmrvl_dev.card; 1316 + struct sdio_func *func = dev_to_sdio_func(dev); 1317 + struct btmrvl_sdio_card *card; 1318 + struct btmrvl_private *priv; 1317 1319 int ret = 0; 1318 1320 unsigned int reg, reg_start, reg_end; 1319 1321 enum rdwr_status stat; 1320 1322 u8 *dbg_ptr, *end_ptr, *fw_dump_data, *fw_dump_ptr; 1321 1323 u8 dump_num = 0, idx, i, read_reg, doneflag = 0; 1322 1324 u32 memory_size, fw_dump_len = 0; 1325 + 1326 + card = sdio_get_drvdata(func); 1327 + priv = card->priv; 1323 1328 1324 1329 /* dump sdio register first */ 1325 1330 btmrvl_sdio_dump_regs(priv); ··· 1552 1547 priv->hw_host_to_card = btmrvl_sdio_host_to_card; 1553 1548 priv->hw_wakeup_firmware = btmrvl_sdio_wakeup_fw; 1554 1549 priv->hw_process_int_status = btmrvl_sdio_process_int_status; 1555 - priv->firmware_dump = btmrvl_sdio_dump_firmware; 1556 1550 1557 1551 if (btmrvl_register_hdev(priv)) { 1558 1552 BT_ERR("Register hdev failed!"); ··· 1721 1717 .remove = btmrvl_sdio_remove, 1722 1718 .drv = { 1723 1719 .owner = THIS_MODULE, 1720 + .coredump = btmrvl_sdio_coredump, 1724 1721 .pm = &btmrvl_sdio_pm_ops, 1725 1722 } 1726 1723 };