Commit 54239903 authored by Marcel Holtmann's avatar Marcel Holtmann

Bluetooth: Remove pointless casts from Marvell debugfs support

The Marvell Bluetooth driver has debugfs support and they are casting
like there is no tomorrow. Remove all of them and magically the code
becomes more readable.
Signed-off-by: default avatarMarcel Holtmann <marcel@holtmann.org>
parent 944fe798
...@@ -51,20 +51,15 @@ static int btmrvl_open_generic(struct inode *inode, struct file *file) ...@@ -51,20 +51,15 @@ static int btmrvl_open_generic(struct inode *inode, struct file *file)
} }
static ssize_t btmrvl_hscfgcmd_write(struct file *file, static ssize_t btmrvl_hscfgcmd_write(struct file *file,
const char __user *ubuf, const char __user *ubuf, size_t count, loff_t *ppos)
size_t count,
loff_t *ppos)
{ {
struct btmrvl_private *priv = struct btmrvl_private *priv = file->private_data;
(struct btmrvl_private *) file->private_data;
long result, ret;
char buf[16]; char buf[16];
long result, ret;
memset(buf, 0, sizeof(buf)); memset(buf, 0, sizeof(buf));
if (copy_from_user(&buf, ubuf, if (copy_from_user(&buf, ubuf, min_t(size_t, sizeof(buf) - 1, count)))
min_t(size_t, sizeof(buf) - 1, count)))
return -EFAULT; return -EFAULT;
ret = strict_strtol(buf, 10, &result); ret = strict_strtol(buf, 10, &result);
...@@ -79,38 +74,35 @@ static ssize_t btmrvl_hscfgcmd_write(struct file *file, ...@@ -79,38 +74,35 @@ static ssize_t btmrvl_hscfgcmd_write(struct file *file,
return count; return count;
} }
static ssize_t btmrvl_hscfgcmd_read(struct file *file, char __user * userbuf, static ssize_t btmrvl_hscfgcmd_read(struct file *file, char __user *userbuf,
size_t count, loff_t *ppos) size_t count, loff_t *ppos)
{ {
struct btmrvl_private *priv = struct btmrvl_private *priv = file->private_data;
(struct btmrvl_private *) file->private_data;
int ret;
char buf[16]; char buf[16];
int ret;
ret = snprintf(buf, sizeof(buf) - 1, "%d\n", ret = snprintf(buf, sizeof(buf) - 1, "%d\n",
priv->btmrvl_dev.hscfgcmd); priv->btmrvl_dev.hscfgcmd);
return simple_read_from_buffer(userbuf, count, ppos, buf, ret); return simple_read_from_buffer(userbuf, count, ppos, buf, ret);
} }
static const struct file_operations btmrvl_hscfgcmd_fops = { static const struct file_operations btmrvl_hscfgcmd_fops = {
.read = btmrvl_hscfgcmd_read, .read = btmrvl_hscfgcmd_read,
.write = btmrvl_hscfgcmd_write, .write = btmrvl_hscfgcmd_write,
.open = btmrvl_open_generic, .open = btmrvl_open_generic,
}; };
static ssize_t btmrvl_psmode_write(struct file *file, const char __user *ubuf, static ssize_t btmrvl_psmode_write(struct file *file, const char __user *ubuf,
size_t count, loff_t *ppos) size_t count, loff_t *ppos)
{ {
struct btmrvl_private *priv = struct btmrvl_private *priv = file->private_data;
(struct btmrvl_private *) file->private_data;
long result, ret;
char buf[16]; char buf[16];
long result, ret;
memset(buf, 0, sizeof(buf)); memset(buf, 0, sizeof(buf));
if (copy_from_user(&buf, ubuf, if (copy_from_user(&buf, ubuf, min_t(size_t, sizeof(buf) - 1, count)))
min_t(size_t, sizeof(buf) - 1, count)))
return -EFAULT; return -EFAULT;
ret = strict_strtol(buf, 10, &result); ret = strict_strtol(buf, 10, &result);
...@@ -120,38 +112,35 @@ static ssize_t btmrvl_psmode_write(struct file *file, const char __user *ubuf, ...@@ -120,38 +112,35 @@ static ssize_t btmrvl_psmode_write(struct file *file, const char __user *ubuf,
return count; return count;
} }
static ssize_t btmrvl_psmode_read(struct file *file, char __user * userbuf, static ssize_t btmrvl_psmode_read(struct file *file, char __user *userbuf,
size_t count, loff_t *ppos) size_t count, loff_t *ppos)
{ {
struct btmrvl_private *priv = struct btmrvl_private *priv = file->private_data;
(struct btmrvl_private *) file->private_data;
int ret;
char buf[16]; char buf[16];
int ret;
ret = snprintf(buf, sizeof(buf) - 1, "%d\n", ret = snprintf(buf, sizeof(buf) - 1, "%d\n",
priv->btmrvl_dev.psmode); priv->btmrvl_dev.psmode);
return simple_read_from_buffer(userbuf, count, ppos, buf, ret); return simple_read_from_buffer(userbuf, count, ppos, buf, ret);
} }
static const struct file_operations btmrvl_psmode_fops = { static const struct file_operations btmrvl_psmode_fops = {
.read = btmrvl_psmode_read, .read = btmrvl_psmode_read,
.write = btmrvl_psmode_write, .write = btmrvl_psmode_write,
.open = btmrvl_open_generic, .open = btmrvl_open_generic,
}; };
static ssize_t btmrvl_pscmd_write(struct file *file, const char __user *ubuf, static ssize_t btmrvl_pscmd_write(struct file *file, const char __user *ubuf,
size_t count, loff_t *ppos) size_t count, loff_t *ppos)
{ {
struct btmrvl_private *priv = struct btmrvl_private *priv = file->private_data;
(struct btmrvl_private *) file->private_data;
long result, ret;
char buf[16]; char buf[16];
long result, ret;
memset(buf, 0, sizeof(buf)); memset(buf, 0, sizeof(buf));
if (copy_from_user(&buf, ubuf, if (copy_from_user(&buf, ubuf, min_t(size_t, sizeof(buf) - 1, count)))
min_t(size_t, sizeof(buf) - 1, count)))
return -EFAULT; return -EFAULT;
ret = strict_strtol(buf, 10, &result); ret = strict_strtol(buf, 10, &result);
...@@ -167,13 +156,12 @@ static ssize_t btmrvl_pscmd_write(struct file *file, const char __user *ubuf, ...@@ -167,13 +156,12 @@ static ssize_t btmrvl_pscmd_write(struct file *file, const char __user *ubuf,
} }
static ssize_t btmrvl_pscmd_read(struct file *file, char __user * userbuf, static ssize_t btmrvl_pscmd_read(struct file *file, char __user *userbuf,
size_t count, loff_t *ppos) size_t count, loff_t *ppos)
{ {
struct btmrvl_private *priv = struct btmrvl_private *priv = file->private_data;
(struct btmrvl_private *) file->private_data;
int ret;
char buf[16]; char buf[16];
int ret;
ret = snprintf(buf, sizeof(buf) - 1, "%d\n", priv->btmrvl_dev.pscmd); ret = snprintf(buf, sizeof(buf) - 1, "%d\n", priv->btmrvl_dev.pscmd);
...@@ -187,17 +175,15 @@ static const struct file_operations btmrvl_pscmd_fops = { ...@@ -187,17 +175,15 @@ static const struct file_operations btmrvl_pscmd_fops = {
}; };
static ssize_t btmrvl_gpiogap_write(struct file *file, const char __user *ubuf, static ssize_t btmrvl_gpiogap_write(struct file *file, const char __user *ubuf,
size_t count, loff_t *ppos) size_t count, loff_t *ppos)
{ {
struct btmrvl_private *priv = struct btmrvl_private *priv = file->private_data;
(struct btmrvl_private *) file->private_data;
long result, ret;
char buf[16]; char buf[16];
long result, ret;
memset(buf, 0, sizeof(buf)); memset(buf, 0, sizeof(buf));
if (copy_from_user(&buf, ubuf, if (copy_from_user(&buf, ubuf, min_t(size_t, sizeof(buf) - 1, count)))
min_t(size_t, sizeof(buf) - 1, count)))
return -EFAULT; return -EFAULT;
ret = strict_strtol(buf, 16, &result); ret = strict_strtol(buf, 16, &result);
...@@ -207,38 +193,35 @@ static ssize_t btmrvl_gpiogap_write(struct file *file, const char __user *ubuf, ...@@ -207,38 +193,35 @@ static ssize_t btmrvl_gpiogap_write(struct file *file, const char __user *ubuf,
return count; return count;
} }
static ssize_t btmrvl_gpiogap_read(struct file *file, char __user * userbuf, static ssize_t btmrvl_gpiogap_read(struct file *file, char __user *userbuf,
size_t count, loff_t *ppos) size_t count, loff_t *ppos)
{ {
struct btmrvl_private *priv = struct btmrvl_private *priv = file->private_data;
(struct btmrvl_private *) file->private_data;
int ret;
char buf[16]; char buf[16];
int ret;
ret = snprintf(buf, sizeof(buf) - 1, "0x%x\n", ret = snprintf(buf, sizeof(buf) - 1, "0x%x\n",
priv->btmrvl_dev.gpio_gap); priv->btmrvl_dev.gpio_gap);
return simple_read_from_buffer(userbuf, count, ppos, buf, ret); return simple_read_from_buffer(userbuf, count, ppos, buf, ret);
} }
static const struct file_operations btmrvl_gpiogap_fops = { static const struct file_operations btmrvl_gpiogap_fops = {
.read = btmrvl_gpiogap_read, .read = btmrvl_gpiogap_read,
.write = btmrvl_gpiogap_write, .write = btmrvl_gpiogap_write,
.open = btmrvl_open_generic, .open = btmrvl_open_generic,
}; };
static ssize_t btmrvl_hscmd_write(struct file *file, const char __user *ubuf, static ssize_t btmrvl_hscmd_write(struct file *file, const char __user *ubuf,
size_t count, loff_t *ppos) size_t count, loff_t *ppos)
{ {
struct btmrvl_private *priv = struct btmrvl_private *priv = (struct btmrvl_private *) file->private_data;
(struct btmrvl_private *) file->private_data;
long result, ret;
char buf[16]; char buf[16];
long result, ret;
memset(buf, 0, sizeof(buf)); memset(buf, 0, sizeof(buf));
if (copy_from_user(&buf, ubuf, if (copy_from_user(&buf, ubuf, min_t(size_t, sizeof(buf) - 1, count)))
min_t(size_t, sizeof(buf) - 1, count)))
return -EFAULT; return -EFAULT;
ret = strict_strtol(buf, 10, &result); ret = strict_strtol(buf, 10, &result);
...@@ -252,13 +235,12 @@ static ssize_t btmrvl_hscmd_write(struct file *file, const char __user *ubuf, ...@@ -252,13 +235,12 @@ static ssize_t btmrvl_hscmd_write(struct file *file, const char __user *ubuf,
return count; return count;
} }
static ssize_t btmrvl_hscmd_read(struct file *file, char __user * userbuf, static ssize_t btmrvl_hscmd_read(struct file *file, char __user *userbuf,
size_t count, loff_t *ppos) size_t count, loff_t *ppos)
{ {
struct btmrvl_private *priv = struct btmrvl_private *priv = file->private_data;
(struct btmrvl_private *) file->private_data;
int ret;
char buf[16]; char buf[16];
int ret;
ret = snprintf(buf, sizeof(buf) - 1, "%d\n", priv->btmrvl_dev.hscmd); ret = snprintf(buf, sizeof(buf) - 1, "%d\n", priv->btmrvl_dev.hscmd);
...@@ -266,23 +248,21 @@ static ssize_t btmrvl_hscmd_read(struct file *file, char __user * userbuf, ...@@ -266,23 +248,21 @@ static ssize_t btmrvl_hscmd_read(struct file *file, char __user * userbuf,
} }
static const struct file_operations btmrvl_hscmd_fops = { static const struct file_operations btmrvl_hscmd_fops = {
.read = btmrvl_hscmd_read, .read = btmrvl_hscmd_read,
.write = btmrvl_hscmd_write, .write = btmrvl_hscmd_write,
.open = btmrvl_open_generic, .open = btmrvl_open_generic,
}; };
static ssize_t btmrvl_hsmode_write(struct file *file, const char __user *ubuf, static ssize_t btmrvl_hsmode_write(struct file *file, const char __user *ubuf,
size_t count, loff_t *ppos) size_t count, loff_t *ppos)
{ {
struct btmrvl_private *priv = struct btmrvl_private *priv = file->private_data;
(struct btmrvl_private *) file->private_data;
long result, ret;
char buf[16]; char buf[16];
long result, ret;
memset(buf, 0, sizeof(buf)); memset(buf, 0, sizeof(buf));
if (copy_from_user(&buf, ubuf, if (copy_from_user(&buf, ubuf, min_t(size_t, sizeof(buf) - 1, count)))
min_t(size_t, sizeof(buf) - 1, count)))
return -EFAULT; return -EFAULT;
ret = strict_strtol(buf, 10, &result); ret = strict_strtol(buf, 10, &result);
...@@ -293,32 +273,29 @@ static ssize_t btmrvl_hsmode_write(struct file *file, const char __user *ubuf, ...@@ -293,32 +273,29 @@ static ssize_t btmrvl_hsmode_write(struct file *file, const char __user *ubuf,
} }
static ssize_t btmrvl_hsmode_read(struct file *file, char __user * userbuf, static ssize_t btmrvl_hsmode_read(struct file *file, char __user * userbuf,
size_t count, loff_t *ppos) size_t count, loff_t *ppos)
{ {
struct btmrvl_private *priv = struct btmrvl_private *priv = file->private_data;
(struct btmrvl_private *) file->private_data;
int ret;
char buf[16]; char buf[16];
int ret;
ret = snprintf(buf, sizeof(buf) - 1, "%d\n", ret = snprintf(buf, sizeof(buf) - 1, "%d\n", priv->btmrvl_dev.hsmode);
priv->btmrvl_dev.hsmode);
return simple_read_from_buffer(userbuf, count, ppos, buf, ret); return simple_read_from_buffer(userbuf, count, ppos, buf, ret);
} }
static const struct file_operations btmrvl_hsmode_fops = { static const struct file_operations btmrvl_hsmode_fops = {
.read = btmrvl_hsmode_read, .read = btmrvl_hsmode_read,
.write = btmrvl_hsmode_write, .write = btmrvl_hsmode_write,
.open = btmrvl_open_generic, .open = btmrvl_open_generic,
}; };
static ssize_t btmrvl_curpsmode_read(struct file *file, char __user * userbuf, static ssize_t btmrvl_curpsmode_read(struct file *file, char __user *userbuf,
size_t count, loff_t *ppos) size_t count, loff_t *ppos)
{ {
struct btmrvl_private *priv = struct btmrvl_private *priv = file->private_data;
(struct btmrvl_private *) file->private_data;
int ret;
char buf[16]; char buf[16];
int ret;
ret = snprintf(buf, sizeof(buf) - 1, "%d\n", priv->adapter->psmode); ret = snprintf(buf, sizeof(buf) - 1, "%d\n", priv->adapter->psmode);
...@@ -326,71 +303,65 @@ static ssize_t btmrvl_curpsmode_read(struct file *file, char __user * userbuf, ...@@ -326,71 +303,65 @@ static ssize_t btmrvl_curpsmode_read(struct file *file, char __user * userbuf,
} }
static const struct file_operations btmrvl_curpsmode_fops = { static const struct file_operations btmrvl_curpsmode_fops = {
.read = btmrvl_curpsmode_read, .read = btmrvl_curpsmode_read,
.open = btmrvl_open_generic, .open = btmrvl_open_generic,
}; };
static ssize_t btmrvl_psstate_read(struct file *file, char __user * userbuf, static ssize_t btmrvl_psstate_read(struct file *file, char __user * userbuf,
size_t count, loff_t *ppos) size_t count, loff_t *ppos)
{ {
struct btmrvl_private *priv = struct btmrvl_private *priv = file->private_data;
(struct btmrvl_private *) file->private_data;
int ret;
char buf[16]; char buf[16];
int ret;
ret = snprintf(buf, sizeof(buf) - 1, "%d\n", ret = snprintf(buf, sizeof(buf) - 1, "%d\n", priv->adapter->ps_state);
priv->adapter->ps_state);
return simple_read_from_buffer(userbuf, count, ppos, buf, ret); return simple_read_from_buffer(userbuf, count, ppos, buf, ret);
} }
static const struct file_operations btmrvl_psstate_fops = { static const struct file_operations btmrvl_psstate_fops = {
.read = btmrvl_psstate_read, .read = btmrvl_psstate_read,
.open = btmrvl_open_generic, .open = btmrvl_open_generic,
}; };
static ssize_t btmrvl_hsstate_read(struct file *file, char __user * userbuf, static ssize_t btmrvl_hsstate_read(struct file *file, char __user *userbuf,
size_t count, loff_t *ppos) size_t count, loff_t *ppos)
{ {
struct btmrvl_private *priv = struct btmrvl_private *priv = file->private_data;
(struct btmrvl_private *) file->private_data;
int ret;
char buf[16]; char buf[16];
int ret;
ret = snprintf(buf, sizeof(buf) - 1, "%d\n", ret = snprintf(buf, sizeof(buf) - 1, "%d\n", priv->adapter->hs_state);
priv->adapter->hs_state);
return simple_read_from_buffer(userbuf, count, ppos, buf, ret); return simple_read_from_buffer(userbuf, count, ppos, buf, ret);
} }
static const struct file_operations btmrvl_hsstate_fops = { static const struct file_operations btmrvl_hsstate_fops = {
.read = btmrvl_hsstate_read, .read = btmrvl_hsstate_read,
.open = btmrvl_open_generic, .open = btmrvl_open_generic,
}; };
static ssize_t btmrvl_txdnldready_read(struct file *file, char __user * userbuf, static ssize_t btmrvl_txdnldready_read(struct file *file, char __user *userbuf,
size_t count, loff_t *ppos) size_t count, loff_t *ppos)
{ {
struct btmrvl_private *priv = struct btmrvl_private *priv = file->private_data;
(struct btmrvl_private *) file->private_data;
int ret;
char buf[16]; char buf[16];
int ret;
ret = snprintf(buf, sizeof(buf) - 1, "%d\n", ret = snprintf(buf, sizeof(buf) - 1, "%d\n",
priv->btmrvl_dev.tx_dnld_rdy); priv->btmrvl_dev.tx_dnld_rdy);
return simple_read_from_buffer(userbuf, count, ppos, buf, ret); return simple_read_from_buffer(userbuf, count, ppos, buf, ret);
} }
static const struct file_operations btmrvl_txdnldready_fops = { static const struct file_operations btmrvl_txdnldready_fops = {
.read = btmrvl_txdnldready_read, .read = btmrvl_txdnldready_read,
.open = btmrvl_open_generic, .open = btmrvl_open_generic,
}; };
void btmrvl_debugfs_init(struct hci_dev *hdev) void btmrvl_debugfs_init(struct hci_dev *hdev)
{ {
struct btmrvl_private *priv = struct btmrvl_private *priv = hdev->driver_data;
(struct btmrvl_private *) hdev->driver_data;
struct btmrvl_debugfs_data *dbg; struct btmrvl_debugfs_data *dbg;
dbg = kzalloc(sizeof(*dbg), GFP_KERNEL); dbg = kzalloc(sizeof(*dbg), GFP_KERNEL);
...@@ -406,22 +377,16 @@ void btmrvl_debugfs_init(struct hci_dev *hdev) ...@@ -406,22 +377,16 @@ void btmrvl_debugfs_init(struct hci_dev *hdev)
dbg->config_dir = debugfs_create_dir("config", dbg->root_dir); dbg->config_dir = debugfs_create_dir("config", dbg->root_dir);
dbg->psmode = debugfs_create_file("psmode", 0644, dbg->config_dir, dbg->psmode = debugfs_create_file("psmode", 0644, dbg->config_dir,
hdev->driver_data, hdev->driver_data, &btmrvl_psmode_fops);
&btmrvl_psmode_fops); dbg->pscmd = debugfs_create_file("pscmd", 0644, dbg->config_dir,
dbg->pscmd =
debugfs_create_file("pscmd", 0644, dbg->config_dir,
hdev->driver_data, &btmrvl_pscmd_fops); hdev->driver_data, &btmrvl_pscmd_fops);
dbg->gpiogap = dbg->gpiogap = debugfs_create_file("gpiogap", 0644, dbg->config_dir,
debugfs_create_file("gpiogap", 0644, dbg->config_dir,
hdev->driver_data, &btmrvl_gpiogap_fops); hdev->driver_data, &btmrvl_gpiogap_fops);
dbg->hsmode = dbg->hsmode = debugfs_create_file("hsmode", 0644, dbg->config_dir,
debugfs_create_file("hsmode", 0644, dbg->config_dir,
hdev->driver_data, &btmrvl_hsmode_fops); hdev->driver_data, &btmrvl_hsmode_fops);
dbg->hscmd = dbg->hscmd = debugfs_create_file("hscmd", 0644, dbg->config_dir,
debugfs_create_file("hscmd", 0644, dbg->config_dir,
hdev->driver_data, &btmrvl_hscmd_fops); hdev->driver_data, &btmrvl_hscmd_fops);
dbg->hscfgcmd = dbg->hscfgcmd = debugfs_create_file("hscfgcmd", 0644, dbg->config_dir,
debugfs_create_file("hscfgcmd", 0644, dbg->config_dir,
hdev->driver_data, &btmrvl_hscfgcmd_fops); hdev->driver_data, &btmrvl_hscfgcmd_fops);
dbg->status_dir = debugfs_create_dir("status", dbg->root_dir); dbg->status_dir = debugfs_create_dir("status", dbg->root_dir);
...@@ -429,21 +394,19 @@ void btmrvl_debugfs_init(struct hci_dev *hdev) ...@@ -429,21 +394,19 @@ void btmrvl_debugfs_init(struct hci_dev *hdev)
dbg->status_dir, dbg->status_dir,
hdev->driver_data, hdev->driver_data,
&btmrvl_curpsmode_fops); &btmrvl_curpsmode_fops);
dbg->psstate = dbg->psstate = debugfs_create_file("psstate", 0444, dbg->status_dir,
debugfs_create_file("psstate", 0444, dbg->status_dir,
hdev->driver_data, &btmrvl_psstate_fops); hdev->driver_data, &btmrvl_psstate_fops);
dbg->hsstate = dbg->hsstate = debugfs_create_file("hsstate", 0444, dbg->status_dir,
debugfs_create_file("hsstate", 0444, dbg->status_dir,
hdev->driver_data, &btmrvl_hsstate_fops); hdev->driver_data, &btmrvl_hsstate_fops);
dbg->txdnldready = dbg->txdnldready = debugfs_create_file("txdnldready", 0444,
debugfs_create_file("txdnldready", 0444, dbg->status_dir, dbg->status_dir,
hdev->driver_data, &btmrvl_txdnldready_fops); hdev->driver_data,
&btmrvl_txdnldready_fops);
} }
void btmrvl_debugfs_remove(struct hci_dev *hdev) void btmrvl_debugfs_remove(struct hci_dev *hdev)
{ {
struct btmrvl_private *priv = struct btmrvl_private *priv = hdev->driver_data;
(struct btmrvl_private *) hdev->driver_data;
struct btmrvl_debugfs_data *dbg = priv->debugfs_data; struct btmrvl_debugfs_data *dbg = priv->debugfs_data;
if (!dbg) if (!dbg)
......
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