mirror of
https://github.com/Fishwaldo/Star64_linux.git
synced 2025-07-23 07:12:09 +00:00
rt2x00: Split rt2x00dev->flags
The number of flags defined for the rt2x00dev->flags field, has been growing over the years. Currently we are approaching the maximum number of bits which are available in the field. A secondary problem, is that one part of the field are initialized only during boot, because the driver requirements are initialized or device requirements are loaded from the EEPROM. In both cases, the flags are fixed and will not change during device operation. The other flags are the device state, and will change frequently. So far this resulted in the fact that for some flags, the atomic bit accessors are used, while for the others the non-atomic variants are used. By splitting the flags up into a "flags" and "cap_flags" we can put all flags which are fixed inside "cap_flags". This field can then be read non-atomically. In the "flags" field we keep the device state, which is going to be read atomically. This adds more room for more flags in the future, and sanitizes the field access methods. Signed-off-by: Ivo van Doorn <IvDoorn@gmail.com> Acked-by: Helmut Schaa <helmut.schaa@googlemail.com> Signed-off-by: John W. Linville <linville@tuxdriver.com>
This commit is contained in:
parent
62fe778412
commit
7dab73b37f
19 changed files with 203 additions and 153 deletions
|
@ -63,7 +63,8 @@ struct rt2x00debug_intf {
|
|||
* - driver folder
|
||||
* - driver file
|
||||
* - chipset file
|
||||
* - device flags file
|
||||
* - device state flags file
|
||||
* - device capability flags file
|
||||
* - register folder
|
||||
* - csr offset/value files
|
||||
* - eeprom offset/value files
|
||||
|
@ -78,6 +79,7 @@ struct rt2x00debug_intf {
|
|||
struct dentry *driver_entry;
|
||||
struct dentry *chipset_entry;
|
||||
struct dentry *dev_flags;
|
||||
struct dentry *cap_flags;
|
||||
struct dentry *register_folder;
|
||||
struct dentry *csr_off_entry;
|
||||
struct dentry *csr_val_entry;
|
||||
|
@ -553,6 +555,35 @@ static const struct file_operations rt2x00debug_fop_dev_flags = {
|
|||
.llseek = default_llseek,
|
||||
};
|
||||
|
||||
static ssize_t rt2x00debug_read_cap_flags(struct file *file,
|
||||
char __user *buf,
|
||||
size_t length,
|
||||
loff_t *offset)
|
||||
{
|
||||
struct rt2x00debug_intf *intf = file->private_data;
|
||||
char line[16];
|
||||
size_t size;
|
||||
|
||||
if (*offset)
|
||||
return 0;
|
||||
|
||||
size = sprintf(line, "0x%.8x\n", (unsigned int)intf->rt2x00dev->cap_flags);
|
||||
|
||||
if (copy_to_user(buf, line, size))
|
||||
return -EFAULT;
|
||||
|
||||
*offset += size;
|
||||
return size;
|
||||
}
|
||||
|
||||
static const struct file_operations rt2x00debug_fop_cap_flags = {
|
||||
.owner = THIS_MODULE,
|
||||
.read = rt2x00debug_read_cap_flags,
|
||||
.open = rt2x00debug_file_open,
|
||||
.release = rt2x00debug_file_release,
|
||||
.llseek = default_llseek,
|
||||
};
|
||||
|
||||
static struct dentry *rt2x00debug_create_file_driver(const char *name,
|
||||
struct rt2x00debug_intf
|
||||
*intf,
|
||||
|
@ -652,6 +683,12 @@ void rt2x00debug_register(struct rt2x00_dev *rt2x00dev)
|
|||
if (IS_ERR(intf->dev_flags) || !intf->dev_flags)
|
||||
goto exit;
|
||||
|
||||
intf->cap_flags = debugfs_create_file("cap_flags", S_IRUSR,
|
||||
intf->driver_folder, intf,
|
||||
&rt2x00debug_fop_cap_flags);
|
||||
if (IS_ERR(intf->cap_flags) || !intf->cap_flags)
|
||||
goto exit;
|
||||
|
||||
intf->register_folder =
|
||||
debugfs_create_dir("register", intf->driver_folder);
|
||||
if (IS_ERR(intf->register_folder) || !intf->register_folder)
|
||||
|
@ -705,7 +742,7 @@ void rt2x00debug_register(struct rt2x00_dev *rt2x00dev)
|
|||
intf, &rt2x00debug_fop_queue_stats);
|
||||
|
||||
#ifdef CONFIG_RT2X00_LIB_CRYPTO
|
||||
if (test_bit(CONFIG_SUPPORT_HW_CRYPTO, &rt2x00dev->flags))
|
||||
if (test_bit(CAPABILITY_HW_CRYPTO, &rt2x00dev->cap_flags))
|
||||
intf->crypto_stats_entry =
|
||||
debugfs_create_file("crypto", S_IRUGO, intf->queue_folder,
|
||||
intf, &rt2x00debug_fop_crypto_stats);
|
||||
|
@ -743,6 +780,7 @@ void rt2x00debug_deregister(struct rt2x00_dev *rt2x00dev)
|
|||
debugfs_remove(intf->csr_off_entry);
|
||||
debugfs_remove(intf->register_folder);
|
||||
debugfs_remove(intf->dev_flags);
|
||||
debugfs_remove(intf->cap_flags);
|
||||
debugfs_remove(intf->chipset_entry);
|
||||
debugfs_remove(intf->driver_entry);
|
||||
debugfs_remove(intf->driver_folder);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue