Skip to content

Commit afa36da

Browse files
committed
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/[email protected] Signed-off-by: Takashi Sakamoto <[email protected]>
1 parent f1e2f87 commit afa36da

File tree

1 file changed

+7
-5
lines changed

1 file changed

+7
-5
lines changed

drivers/firewire/core-device.c

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,8 @@
3131

3232
#include "core.h"
3333

34+
#define ROOT_DIR_OFFSET 5
35+
3436
void fw_csr_iterator_init(struct fw_csr_iterator *ci, const u32 *p)
3537
{
3638
ci->p = p + 1;
@@ -135,7 +137,7 @@ static void get_ids(const u32 *directory, int *id)
135137

136138
static void get_modalias_ids(const struct fw_unit *unit, int *id)
137139
{
138-
get_ids(&fw_parent_device(unit)->config_rom[5], id);
140+
get_ids(&fw_parent_device(unit)->config_rom[ROOT_DIR_OFFSET], id);
139141
get_ids(unit->directory, id);
140142
}
141143

@@ -259,7 +261,7 @@ static ssize_t show_immediate(struct device *dev,
259261
if (is_fw_unit(dev))
260262
dir = fw_unit(dev)->directory;
261263
else
262-
dir = fw_device(dev)->config_rom + 5;
264+
dir = fw_device(dev)->config_rom + ROOT_DIR_OFFSET;
263265

264266
fw_csr_iterator_init(&ci, dir);
265267
while (fw_csr_iterator_next(&ci, &key, &value))
@@ -292,7 +294,7 @@ static ssize_t show_text_leaf(struct device *dev,
292294
if (is_fw_unit(dev))
293295
dir = fw_unit(dev)->directory;
294296
else
295-
dir = fw_device(dev)->config_rom + 5;
297+
dir = fw_device(dev)->config_rom + ROOT_DIR_OFFSET;
296298

297299
if (buf) {
298300
bufsize = PAGE_SIZE - 1;
@@ -446,7 +448,7 @@ static ssize_t units_show(struct device *dev,
446448
int key, value, i = 0;
447449

448450
down_read(&fw_device_rwsem);
449-
fw_csr_iterator_init(&ci, &device->config_rom[5]);
451+
fw_csr_iterator_init(&ci, &device->config_rom[ROOT_DIR_OFFSET]);
450452
while (fw_csr_iterator_next(&ci, &key, &value)) {
451453
if (key != (CSR_UNIT | CSR_DIRECTORY))
452454
continue;
@@ -691,7 +693,7 @@ static void create_units(struct fw_device *device)
691693
int key, value, i;
692694

693695
i = 0;
694-
fw_csr_iterator_init(&ci, &device->config_rom[5]);
696+
fw_csr_iterator_init(&ci, &device->config_rom[ROOT_DIR_OFFSET]);
695697
while (fw_csr_iterator_next(&ci, &key, &value)) {
696698
if (key != (CSR_UNIT | CSR_DIRECTORY))
697699
continue;

0 commit comments

Comments
 (0)