diff options
author | Stefan Richter <stefanr@s5r6.in-berlin.de> | 2009-12-25 19:44:10 -0500 |
---|---|---|
committer | Stefan Richter <stefanr@s5r6.in-berlin.de> | 2009-12-29 13:58:17 -0500 |
commit | 13b302d0a217580c0129b0641b0ca8b592e437b0 (patch) | |
tree | aa895bb410b4262d9942a0f77fe623c7d610da0c | |
parent | 3c2c58cb33b3b15a2c4871babeec8fe1456e1db6 (diff) |
firewire: qualify config ROM cache pointers as const pointers
Several config ROM related functions only peek at the ROM cache; mark
their arguments as const pointers. Ditto fw_device.config_rom and
fw_unit.directory, as the memory behind them is meant to be write-once.
Signed-off-by: Stefan Richter <stefanr@s5r6.in-berlin.de>
-rw-r--r-- | drivers/firewire/core-device.c | 21 | ||||
-rw-r--r-- | drivers/firewire/sbp2.c | 5 | ||||
-rw-r--r-- | include/linux/firewire.h | 12 |
3 files changed, 20 insertions, 18 deletions
diff --git a/drivers/firewire/core-device.c b/drivers/firewire/core-device.c index 5d5c6a689837..eecd52dc8e98 100644 --- a/drivers/firewire/core-device.c +++ b/drivers/firewire/core-device.c | |||
@@ -43,7 +43,7 @@ | |||
43 | 43 | ||
44 | #include "core.h" | 44 | #include "core.h" |
45 | 45 | ||
46 | void fw_csr_iterator_init(struct fw_csr_iterator *ci, u32 * p) | 46 | void fw_csr_iterator_init(struct fw_csr_iterator *ci, const u32 *p) |
47 | { | 47 | { |
48 | ci->p = p + 1; | 48 | ci->p = p + 1; |
49 | ci->end = ci->p + (p[0] >> 16); | 49 | ci->end = ci->p + (p[0] >> 16); |
@@ -59,7 +59,7 @@ int fw_csr_iterator_next(struct fw_csr_iterator *ci, int *key, int *value) | |||
59 | } | 59 | } |
60 | EXPORT_SYMBOL(fw_csr_iterator_next); | 60 | EXPORT_SYMBOL(fw_csr_iterator_next); |
61 | 61 | ||
62 | static u32 *search_leaf(u32 *directory, int search_key) | 62 | static const u32 *search_leaf(const u32 *directory, int search_key) |
63 | { | 63 | { |
64 | struct fw_csr_iterator ci; | 64 | struct fw_csr_iterator ci; |
65 | int last_key = 0, key, value; | 65 | int last_key = 0, key, value; |
@@ -76,7 +76,7 @@ static u32 *search_leaf(u32 *directory, int search_key) | |||
76 | return NULL; | 76 | return NULL; |
77 | } | 77 | } |
78 | 78 | ||
79 | static int textual_leaf_to_string(u32 *block, char *buf, size_t size) | 79 | static int textual_leaf_to_string(const u32 *block, char *buf, size_t size) |
80 | { | 80 | { |
81 | unsigned int quadlets, i; | 81 | unsigned int quadlets, i; |
82 | char c; | 82 | char c; |
@@ -116,9 +116,9 @@ static int textual_leaf_to_string(u32 *block, char *buf, size_t size) | |||
116 | * the immediate entry with @key. The string is zero-terminated. | 116 | * the immediate entry with @key. The string is zero-terminated. |
117 | * Returns strlen(buf) or a negative error code. | 117 | * Returns strlen(buf) or a negative error code. |
118 | */ | 118 | */ |
119 | int fw_csr_string(u32 *directory, int key, char *buf, size_t size) | 119 | int fw_csr_string(const u32 *directory, int key, char *buf, size_t size) |
120 | { | 120 | { |
121 | u32 *leaf = search_leaf(directory, key); | 121 | const u32 *leaf = search_leaf(directory, key); |
122 | if (!leaf) | 122 | if (!leaf) |
123 | return -ENOENT; | 123 | return -ENOENT; |
124 | 124 | ||
@@ -128,7 +128,7 @@ EXPORT_SYMBOL(fw_csr_string); | |||
128 | 128 | ||
129 | static bool is_fw_unit(struct device *dev); | 129 | static bool is_fw_unit(struct device *dev); |
130 | 130 | ||
131 | static int match_unit_directory(u32 *directory, u32 match_flags, | 131 | static int match_unit_directory(const u32 *directory, u32 match_flags, |
132 | const struct ieee1394_device_id *id) | 132 | const struct ieee1394_device_id *id) |
133 | { | 133 | { |
134 | struct fw_csr_iterator ci; | 134 | struct fw_csr_iterator ci; |
@@ -262,7 +262,7 @@ static ssize_t show_immediate(struct device *dev, | |||
262 | struct config_rom_attribute *attr = | 262 | struct config_rom_attribute *attr = |
263 | container_of(dattr, struct config_rom_attribute, attr); | 263 | container_of(dattr, struct config_rom_attribute, attr); |
264 | struct fw_csr_iterator ci; | 264 | struct fw_csr_iterator ci; |
265 | u32 *dir; | 265 | const u32 *dir; |
266 | int key, value, ret = -ENOENT; | 266 | int key, value, ret = -ENOENT; |
267 | 267 | ||
268 | down_read(&fw_device_rwsem); | 268 | down_read(&fw_device_rwsem); |
@@ -293,7 +293,7 @@ static ssize_t show_text_leaf(struct device *dev, | |||
293 | { | 293 | { |
294 | struct config_rom_attribute *attr = | 294 | struct config_rom_attribute *attr = |
295 | container_of(dattr, struct config_rom_attribute, attr); | 295 | container_of(dattr, struct config_rom_attribute, attr); |
296 | u32 *dir; | 296 | const u32 *dir; |
297 | size_t bufsize; | 297 | size_t bufsize; |
298 | char dummy_buf[2]; | 298 | char dummy_buf[2]; |
299 | int ret; | 299 | int ret; |
@@ -421,7 +421,7 @@ static ssize_t guid_show(struct device *dev, | |||
421 | return ret; | 421 | return ret; |
422 | } | 422 | } |
423 | 423 | ||
424 | static int units_sprintf(char *buf, u32 *directory) | 424 | static int units_sprintf(char *buf, const u32 *directory) |
425 | { | 425 | { |
426 | struct fw_csr_iterator ci; | 426 | struct fw_csr_iterator ci; |
427 | int key, value; | 427 | int key, value; |
@@ -503,7 +503,8 @@ static int read_rom(struct fw_device *device, | |||
503 | */ | 503 | */ |
504 | static int read_bus_info_block(struct fw_device *device, int generation) | 504 | static int read_bus_info_block(struct fw_device *device, int generation) |
505 | { | 505 | { |
506 | u32 *rom, *stack, *old_rom, *new_rom; | 506 | const u32 *old_rom, *new_rom; |
507 | u32 *rom, *stack; | ||
507 | u32 sp, key; | 508 | u32 sp, key; |
508 | int i, end, length, ret = -1; | 509 | int i, end, length, ret = -1; |
509 | 510 | ||
diff --git a/drivers/firewire/sbp2.c b/drivers/firewire/sbp2.c index d485cdd8cbac..7e33b0b1704c 100644 --- a/drivers/firewire/sbp2.c +++ b/drivers/firewire/sbp2.c | |||
@@ -1014,7 +1014,8 @@ static int sbp2_add_logical_unit(struct sbp2_target *tgt, int lun_entry) | |||
1014 | return 0; | 1014 | return 0; |
1015 | } | 1015 | } |
1016 | 1016 | ||
1017 | static int sbp2_scan_logical_unit_dir(struct sbp2_target *tgt, u32 *directory) | 1017 | static int sbp2_scan_logical_unit_dir(struct sbp2_target *tgt, |
1018 | const u32 *directory) | ||
1018 | { | 1019 | { |
1019 | struct fw_csr_iterator ci; | 1020 | struct fw_csr_iterator ci; |
1020 | int key, value; | 1021 | int key, value; |
@@ -1027,7 +1028,7 @@ static int sbp2_scan_logical_unit_dir(struct sbp2_target *tgt, u32 *directory) | |||
1027 | return 0; | 1028 | return 0; |
1028 | } | 1029 | } |
1029 | 1030 | ||
1030 | static int sbp2_scan_unit_dir(struct sbp2_target *tgt, u32 *directory, | 1031 | static int sbp2_scan_unit_dir(struct sbp2_target *tgt, const u32 *directory, |
1031 | u32 *model, u32 *firmware_revision) | 1032 | u32 *model, u32 *firmware_revision) |
1032 | { | 1033 | { |
1033 | struct fw_csr_iterator ci; | 1034 | struct fw_csr_iterator ci; |
diff --git a/include/linux/firewire.h b/include/linux/firewire.h index df680216e7b6..4bd94bf5e739 100644 --- a/include/linux/firewire.h +++ b/include/linux/firewire.h | |||
@@ -65,13 +65,13 @@ | |||
65 | #define CSR_DIRECTORY_ID 0x20 | 65 | #define CSR_DIRECTORY_ID 0x20 |
66 | 66 | ||
67 | struct fw_csr_iterator { | 67 | struct fw_csr_iterator { |
68 | u32 *p; | 68 | const u32 *p; |
69 | u32 *end; | 69 | const u32 *end; |
70 | }; | 70 | }; |
71 | 71 | ||
72 | void fw_csr_iterator_init(struct fw_csr_iterator *ci, u32 *p); | 72 | void fw_csr_iterator_init(struct fw_csr_iterator *ci, const u32 *p); |
73 | int fw_csr_iterator_next(struct fw_csr_iterator *ci, int *key, int *value); | 73 | int fw_csr_iterator_next(struct fw_csr_iterator *ci, int *key, int *value); |
74 | int fw_csr_string(u32 *directory, int key, char *buf, size_t size); | 74 | int fw_csr_string(const u32 *directory, int key, char *buf, size_t size); |
75 | 75 | ||
76 | extern struct bus_type fw_bus_type; | 76 | extern struct bus_type fw_bus_type; |
77 | 77 | ||
@@ -163,7 +163,7 @@ struct fw_device { | |||
163 | struct mutex client_list_mutex; | 163 | struct mutex client_list_mutex; |
164 | struct list_head client_list; | 164 | struct list_head client_list; |
165 | 165 | ||
166 | u32 *config_rom; | 166 | const u32 *config_rom; |
167 | size_t config_rom_length; | 167 | size_t config_rom_length; |
168 | int config_rom_retries; | 168 | int config_rom_retries; |
169 | unsigned is_local:1; | 169 | unsigned is_local:1; |
@@ -205,7 +205,7 @@ int fw_device_enable_phys_dma(struct fw_device *device); | |||
205 | */ | 205 | */ |
206 | struct fw_unit { | 206 | struct fw_unit { |
207 | struct device device; | 207 | struct device device; |
208 | u32 *directory; | 208 | const u32 *directory; |
209 | struct fw_attribute_group attribute_group; | 209 | struct fw_attribute_group attribute_group; |
210 | }; | 210 | }; |
211 | 211 | ||