Commit edd5bdaf128e04066caac84fcb21377197ea0d64

Authored by Stefan Richter
1 parent 7cfe21aae1

firewire: core: clean up config ROM related defined constants

Clemens Ladisch pointed out that
  - BIB_IMC is not named like the field is called in the standard,
  - readers of the code may get worried about the magic 0x0c0083c0,
  - a CSR_NODE_CAPABILITIES key is there in the header but not put to
    good use.

So let's rename BIB_IMC, add a defined constant for Node_Capabilities
and a comment which reassures people that somebody thought about it and
they don't have to (or if they still do, tell them where they have to
look for confirmation), and prune our incomplete and arbitrary set of
defined constants of CSR key IDs.  And there is a nother magic number,
that of Bus_Information_Block.Bus_Name, to be defined and commented.

Signed-off-by: Stefan Richter <stefanr@s5r6.in-berlin.de>

Showing 2 changed files with 6 additions and 7 deletions Side-by-side Diff

drivers/firewire/core-card.c
... ... @@ -63,7 +63,7 @@
63 63 #define BIB_CRC(v) ((v) << 0)
64 64 #define BIB_CRC_LENGTH(v) ((v) << 16)
65 65 #define BIB_INFO_LENGTH(v) ((v) << 24)
66   -
  66 +#define BIB_BUS_NAME 0x31333934 /* "1394" */
67 67 #define BIB_LINK_SPEED(v) ((v) << 0)
68 68 #define BIB_GENERATION(v) ((v) << 4)
69 69 #define BIB_MAX_ROM(v) ((v) << 8)
... ... @@ -73,7 +73,8 @@
73 73 #define BIB_BMC ((1) << 28)
74 74 #define BIB_ISC ((1) << 29)
75 75 #define BIB_CMC ((1) << 30)
76   -#define BIB_IMC ((1) << 31)
  76 +#define BIB_IRMC ((1) << 31)
  77 +#define NODE_CAPABILITIES 0x0c0083c0 /* per IEEE 1394 clause 8.3.2.6.5.2 */
77 78  
78 79 static void generate_config_rom(struct fw_card *card, __be32 *config_rom)
79 80 {
80 81  
81 82  
... ... @@ -91,18 +92,18 @@
91 92  
92 93 config_rom[0] = cpu_to_be32(
93 94 BIB_CRC_LENGTH(4) | BIB_INFO_LENGTH(4) | BIB_CRC(0));
94   - config_rom[1] = cpu_to_be32(0x31333934);
  95 + config_rom[1] = cpu_to_be32(BIB_BUS_NAME);
95 96 config_rom[2] = cpu_to_be32(
96 97 BIB_LINK_SPEED(card->link_speed) |
97 98 BIB_GENERATION(card->config_rom_generation++ % 14 + 2) |
98 99 BIB_MAX_ROM(2) |
99 100 BIB_MAX_RECEIVE(card->max_receive) |
100   - BIB_BMC | BIB_ISC | BIB_CMC | BIB_IMC);
  101 + BIB_BMC | BIB_ISC | BIB_CMC | BIB_IRMC);
101 102 config_rom[3] = cpu_to_be32(card->guid >> 32);
102 103 config_rom[4] = cpu_to_be32(card->guid);
103 104  
104 105 /* Generate root directory. */
105   - config_rom[6] = cpu_to_be32(0x0c0083c0); /* node capabilities */
  106 + config_rom[6] = cpu_to_be32(NODE_CAPABILITIES);
106 107 i = 7;
107 108 j = 7 + descriptor_count;
108 109  
include/linux/firewire.h
... ... @@ -55,13 +55,11 @@
55 55 #define CSR_DESCRIPTOR 0x01
56 56 #define CSR_VENDOR 0x03
57 57 #define CSR_HARDWARE_VERSION 0x04
58   -#define CSR_NODE_CAPABILITIES 0x0c
59 58 #define CSR_UNIT 0x11
60 59 #define CSR_SPECIFIER_ID 0x12
61 60 #define CSR_VERSION 0x13
62 61 #define CSR_DEPENDENT_INFO 0x14
63 62 #define CSR_MODEL 0x17
64   -#define CSR_INSTANCE 0x18
65 63 #define CSR_DIRECTORY_ID 0x20
66 64  
67 65 struct fw_csr_iterator {