mirror of
https://github.com/torvalds/linux.git
synced 2024-11-25 05:32:00 +00:00
firewire: core: replace magic number with macro
In IEEE 1394 specification, the size of bus information block of configuration ROM is fixed to 5, thus the offset of root directory is 5. Current implementation to handle device structures has the hard-coded offset. This commit replaces the offset with macro. Link: https://lore.kernel.org/r/20231221134849.603857-3-o-takashi@sakamocchi.jp Signed-off-by: Takashi Sakamoto <o-takashi@sakamocchi.jp>
This commit is contained in:
parent
f1e2f87834
commit
afa36dadd3
@ -31,6 +31,8 @@
|
|||||||
|
|
||||||
#include "core.h"
|
#include "core.h"
|
||||||
|
|
||||||
|
#define ROOT_DIR_OFFSET 5
|
||||||
|
|
||||||
void fw_csr_iterator_init(struct fw_csr_iterator *ci, const u32 *p)
|
void fw_csr_iterator_init(struct fw_csr_iterator *ci, const u32 *p)
|
||||||
{
|
{
|
||||||
ci->p = p + 1;
|
ci->p = p + 1;
|
||||||
@ -135,7 +137,7 @@ static void get_ids(const u32 *directory, int *id)
|
|||||||
|
|
||||||
static void get_modalias_ids(const struct fw_unit *unit, int *id)
|
static void get_modalias_ids(const struct fw_unit *unit, int *id)
|
||||||
{
|
{
|
||||||
get_ids(&fw_parent_device(unit)->config_rom[5], id);
|
get_ids(&fw_parent_device(unit)->config_rom[ROOT_DIR_OFFSET], id);
|
||||||
get_ids(unit->directory, id);
|
get_ids(unit->directory, id);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -259,7 +261,7 @@ static ssize_t show_immediate(struct device *dev,
|
|||||||
if (is_fw_unit(dev))
|
if (is_fw_unit(dev))
|
||||||
dir = fw_unit(dev)->directory;
|
dir = fw_unit(dev)->directory;
|
||||||
else
|
else
|
||||||
dir = fw_device(dev)->config_rom + 5;
|
dir = fw_device(dev)->config_rom + ROOT_DIR_OFFSET;
|
||||||
|
|
||||||
fw_csr_iterator_init(&ci, dir);
|
fw_csr_iterator_init(&ci, dir);
|
||||||
while (fw_csr_iterator_next(&ci, &key, &value))
|
while (fw_csr_iterator_next(&ci, &key, &value))
|
||||||
@ -292,7 +294,7 @@ static ssize_t show_text_leaf(struct device *dev,
|
|||||||
if (is_fw_unit(dev))
|
if (is_fw_unit(dev))
|
||||||
dir = fw_unit(dev)->directory;
|
dir = fw_unit(dev)->directory;
|
||||||
else
|
else
|
||||||
dir = fw_device(dev)->config_rom + 5;
|
dir = fw_device(dev)->config_rom + ROOT_DIR_OFFSET;
|
||||||
|
|
||||||
if (buf) {
|
if (buf) {
|
||||||
bufsize = PAGE_SIZE - 1;
|
bufsize = PAGE_SIZE - 1;
|
||||||
@ -446,7 +448,7 @@ static ssize_t units_show(struct device *dev,
|
|||||||
int key, value, i = 0;
|
int key, value, i = 0;
|
||||||
|
|
||||||
down_read(&fw_device_rwsem);
|
down_read(&fw_device_rwsem);
|
||||||
fw_csr_iterator_init(&ci, &device->config_rom[5]);
|
fw_csr_iterator_init(&ci, &device->config_rom[ROOT_DIR_OFFSET]);
|
||||||
while (fw_csr_iterator_next(&ci, &key, &value)) {
|
while (fw_csr_iterator_next(&ci, &key, &value)) {
|
||||||
if (key != (CSR_UNIT | CSR_DIRECTORY))
|
if (key != (CSR_UNIT | CSR_DIRECTORY))
|
||||||
continue;
|
continue;
|
||||||
@ -691,7 +693,7 @@ static void create_units(struct fw_device *device)
|
|||||||
int key, value, i;
|
int key, value, i;
|
||||||
|
|
||||||
i = 0;
|
i = 0;
|
||||||
fw_csr_iterator_init(&ci, &device->config_rom[5]);
|
fw_csr_iterator_init(&ci, &device->config_rom[ROOT_DIR_OFFSET]);
|
||||||
while (fw_csr_iterator_next(&ci, &key, &value)) {
|
while (fw_csr_iterator_next(&ci, &key, &value)) {
|
||||||
if (key != (CSR_UNIT | CSR_DIRECTORY))
|
if (key != (CSR_UNIT | CSR_DIRECTORY))
|
||||||
continue;
|
continue;
|
||||||
|
Loading…
Reference in New Issue
Block a user