aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--drivers/firewire/core-device.c103
-rw-r--r--drivers/firewire/core-iso.c5
-rw-r--r--drivers/firewire/ohci.c4
3 files changed, 47 insertions, 65 deletions
diff --git a/drivers/firewire/core-device.c b/drivers/firewire/core-device.c
index 5db0518c66da..882472d1e144 100644
--- a/drivers/firewire/core-device.c
+++ b/drivers/firewire/core-device.c
@@ -126,97 +126,74 @@ int fw_csr_string(const u32 *directory, int key, char *buf, size_t size)
126} 126}
127EXPORT_SYMBOL(fw_csr_string); 127EXPORT_SYMBOL(fw_csr_string);
128 128
129static bool is_fw_unit(struct device *dev); 129static void get_ids(const u32 *directory, int *id)
130
131static int match_unit_directory(const u32 *directory, u32 match_flags,
132 const struct ieee1394_device_id *id)
133{ 130{
134 struct fw_csr_iterator ci; 131 struct fw_csr_iterator ci;
135 int key, value, match; 132 int key, value;
136 133
137 match = 0;
138 fw_csr_iterator_init(&ci, directory); 134 fw_csr_iterator_init(&ci, directory);
139 while (fw_csr_iterator_next(&ci, &key, &value)) { 135 while (fw_csr_iterator_next(&ci, &key, &value)) {
140 if (key == CSR_VENDOR && value == id->vendor_id) 136 switch (key) {
141 match |= IEEE1394_MATCH_VENDOR_ID; 137 case CSR_VENDOR: id[0] = value; break;
142 if (key == CSR_MODEL && value == id->model_id) 138 case CSR_MODEL: id[1] = value; break;
143 match |= IEEE1394_MATCH_MODEL_ID; 139 case CSR_SPECIFIER_ID: id[2] = value; break;
144 if (key == CSR_SPECIFIER_ID && value == id->specifier_id) 140 case CSR_VERSION: id[3] = value; break;
145 match |= IEEE1394_MATCH_SPECIFIER_ID; 141 }
146 if (key == CSR_VERSION && value == id->version)
147 match |= IEEE1394_MATCH_VERSION;
148 } 142 }
143}
144
145static void get_modalias_ids(struct fw_unit *unit, int *id)
146{
147 get_ids(&fw_parent_device(unit)->config_rom[5], id);
148 get_ids(unit->directory, id);
149}
150
151static bool match_ids(const struct ieee1394_device_id *id_table, int *id)
152{
153 int match = 0;
154
155 if (id[0] == id_table->vendor_id)
156 match |= IEEE1394_MATCH_VENDOR_ID;
157 if (id[1] == id_table->model_id)
158 match |= IEEE1394_MATCH_MODEL_ID;
159 if (id[2] == id_table->specifier_id)
160 match |= IEEE1394_MATCH_SPECIFIER_ID;
161 if (id[3] == id_table->version)
162 match |= IEEE1394_MATCH_VERSION;
149 163
150 return (match & match_flags) == match_flags; 164 return (match & id_table->match_flags) == id_table->match_flags;
151} 165}
152 166
167static bool is_fw_unit(struct device *dev);
168
153static int fw_unit_match(struct device *dev, struct device_driver *drv) 169static int fw_unit_match(struct device *dev, struct device_driver *drv)
154{ 170{
155 struct fw_unit *unit = fw_unit(dev); 171 const struct ieee1394_device_id *id_table =
156 struct fw_device *device; 172 container_of(drv, struct fw_driver, driver)->id_table;
157 const struct ieee1394_device_id *id; 173 int id[] = {0, 0, 0, 0};
158 174
159 /* We only allow binding to fw_units. */ 175 /* We only allow binding to fw_units. */
160 if (!is_fw_unit(dev)) 176 if (!is_fw_unit(dev))
161 return 0; 177 return 0;
162 178
163 device = fw_parent_device(unit); 179 get_modalias_ids(fw_unit(dev), id);
164 id = container_of(drv, struct fw_driver, driver)->id_table;
165 180
166 for (; id->match_flags != 0; id++) { 181 for (; id_table->match_flags != 0; id_table++)
167 if (match_unit_directory(unit->directory, id->match_flags, id)) 182 if (match_ids(id_table, id))
168 return 1; 183 return 1;
169 184
170 /* Also check vendor ID in the root directory. */
171 if ((id->match_flags & IEEE1394_MATCH_VENDOR_ID) &&
172 match_unit_directory(&device->config_rom[5],
173 IEEE1394_MATCH_VENDOR_ID, id) &&
174 match_unit_directory(unit->directory, id->match_flags
175 & ~IEEE1394_MATCH_VENDOR_ID, id))
176 return 1;
177 }
178
179 return 0; 185 return 0;
180} 186}
181 187
182static int get_modalias(struct fw_unit *unit, char *buffer, size_t buffer_size) 188static int get_modalias(struct fw_unit *unit, char *buffer, size_t buffer_size)
183{ 189{
184 struct fw_device *device = fw_parent_device(unit); 190 int id[] = {0, 0, 0, 0};
185 struct fw_csr_iterator ci;
186 191
187 int key, value; 192 get_modalias_ids(unit, id);
188 int vendor = 0;
189 int model = 0;
190 int specifier_id = 0;
191 int version = 0;
192
193 fw_csr_iterator_init(&ci, &device->config_rom[5]);
194 while (fw_csr_iterator_next(&ci, &key, &value)) {
195 switch (key) {
196 case CSR_VENDOR:
197 vendor = value;
198 break;
199 case CSR_MODEL:
200 model = value;
201 break;
202 }
203 }
204
205 fw_csr_iterator_init(&ci, unit->directory);
206 while (fw_csr_iterator_next(&ci, &key, &value)) {
207 switch (key) {
208 case CSR_SPECIFIER_ID:
209 specifier_id = value;
210 break;
211 case CSR_VERSION:
212 version = value;
213 break;
214 }
215 }
216 193
217 return snprintf(buffer, buffer_size, 194 return snprintf(buffer, buffer_size,
218 "ieee1394:ven%08Xmo%08Xsp%08Xver%08X", 195 "ieee1394:ven%08Xmo%08Xsp%08Xver%08X",
219 vendor, model, specifier_id, version); 196 id[0], id[1], id[2], id[3]);
220} 197}
221 198
222static int fw_unit_uevent(struct device *dev, struct kobj_uevent_env *env) 199static int fw_unit_uevent(struct device *dev, struct kobj_uevent_env *env)
diff --git a/drivers/firewire/core-iso.c b/drivers/firewire/core-iso.c
index 1c0b504a42f3..99c20f1b613a 100644
--- a/drivers/firewire/core-iso.c
+++ b/drivers/firewire/core-iso.c
@@ -331,8 +331,9 @@ void fw_iso_resource_manage(struct fw_card *card, int generation,
331 if (ret < 0) 331 if (ret < 0)
332 *bandwidth = 0; 332 *bandwidth = 0;
333 333
334 if (allocate && ret < 0 && c >= 0) { 334 if (allocate && ret < 0) {
335 deallocate_channel(card, irm_id, generation, c, buffer); 335 if (c >= 0)
336 deallocate_channel(card, irm_id, generation, c, buffer);
336 *channel = ret; 337 *channel = ret;
337 } 338 }
338} 339}
diff --git a/drivers/firewire/ohci.c b/drivers/firewire/ohci.c
index 75dc6988cffd..e33917bf97d2 100644
--- a/drivers/firewire/ohci.c
+++ b/drivers/firewire/ohci.c
@@ -231,6 +231,8 @@ static inline struct fw_ohci *fw_ohci(struct fw_card *card)
231 231
232static char ohci_driver_name[] = KBUILD_MODNAME; 232static char ohci_driver_name[] = KBUILD_MODNAME;
233 233
234#define PCI_DEVICE_ID_TI_TSB12LV22 0x8009
235
234#define QUIRK_CYCLE_TIMER 1 236#define QUIRK_CYCLE_TIMER 1
235#define QUIRK_RESET_PACKET 2 237#define QUIRK_RESET_PACKET 2
236#define QUIRK_BE_HEADERS 4 238#define QUIRK_BE_HEADERS 4
@@ -239,6 +241,8 @@ static char ohci_driver_name[] = KBUILD_MODNAME;
239static const struct { 241static const struct {
240 unsigned short vendor, device, flags; 242 unsigned short vendor, device, flags;
241} ohci_quirks[] = { 243} ohci_quirks[] = {
244 {PCI_VENDOR_ID_TI, PCI_DEVICE_ID_TI_TSB12LV22, QUIRK_CYCLE_TIMER |
245 QUIRK_RESET_PACKET},
242 {PCI_VENDOR_ID_TI, PCI_ANY_ID, QUIRK_RESET_PACKET}, 246 {PCI_VENDOR_ID_TI, PCI_ANY_ID, QUIRK_RESET_PACKET},
243 {PCI_VENDOR_ID_AL, PCI_ANY_ID, QUIRK_CYCLE_TIMER}, 247 {PCI_VENDOR_ID_AL, PCI_ANY_ID, QUIRK_CYCLE_TIMER},
244 {PCI_VENDOR_ID_NEC, PCI_ANY_ID, QUIRK_CYCLE_TIMER}, 248 {PCI_VENDOR_ID_NEC, PCI_ANY_ID, QUIRK_CYCLE_TIMER},