From: Linus Torvalds Date: Fri, 26 Mar 2010 22:07:46 +0000 (-0700) Subject: Merge branch 'for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/ieee1394... X-Git-Tag: v2.6.34-rc3~28 X-Git-Url: http://ftp.safe.ca/?a=commitdiff_plain;h=50da56706b989b99edb20f9c03172df193240c78;hp=e0df9c0b42cc8cb48b801f7a0f54382f6a89ca16;p=safe%2Fjmp%2Flinux-2.6 Merge branch 'for-linus' of git://git./linux/kernel/git/ieee1394/linux1394-2.6 * 'for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/ieee1394/linux1394-2.6: firewire: core: align driver match with modalias firewire: core: fix Model_ID in modalias firewire: ohci: add cycle timer quirk for the TI TSB12LV22 firewire: core: fw_iso_resource_manage: fix error handling --- diff --git a/drivers/firewire/core-device.c b/drivers/firewire/core-device.c index 5db0518..882472d 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) } EXPORT_SYMBOL(fw_csr_string); -static bool is_fw_unit(struct device *dev); - -static int match_unit_directory(const u32 *directory, u32 match_flags, - const struct ieee1394_device_id *id) +static void get_ids(const u32 *directory, int *id) { struct fw_csr_iterator ci; - int key, value, match; + int key, value; - match = 0; fw_csr_iterator_init(&ci, directory); while (fw_csr_iterator_next(&ci, &key, &value)) { - if (key == CSR_VENDOR && value == id->vendor_id) - match |= IEEE1394_MATCH_VENDOR_ID; - if (key == CSR_MODEL && value == id->model_id) - match |= IEEE1394_MATCH_MODEL_ID; - if (key == CSR_SPECIFIER_ID && value == id->specifier_id) - match |= IEEE1394_MATCH_SPECIFIER_ID; - if (key == CSR_VERSION && value == id->version) - match |= IEEE1394_MATCH_VERSION; + switch (key) { + case CSR_VENDOR: id[0] = value; break; + case CSR_MODEL: id[1] = value; break; + case CSR_SPECIFIER_ID: id[2] = value; break; + case CSR_VERSION: id[3] = value; break; + } } +} + +static void get_modalias_ids(struct fw_unit *unit, int *id) +{ + get_ids(&fw_parent_device(unit)->config_rom[5], id); + get_ids(unit->directory, id); +} + +static bool match_ids(const struct ieee1394_device_id *id_table, int *id) +{ + int match = 0; + + if (id[0] == id_table->vendor_id) + match |= IEEE1394_MATCH_VENDOR_ID; + if (id[1] == id_table->model_id) + match |= IEEE1394_MATCH_MODEL_ID; + if (id[2] == id_table->specifier_id) + match |= IEEE1394_MATCH_SPECIFIER_ID; + if (id[3] == id_table->version) + match |= IEEE1394_MATCH_VERSION; - return (match & match_flags) == match_flags; + return (match & id_table->match_flags) == id_table->match_flags; } +static bool is_fw_unit(struct device *dev); + static int fw_unit_match(struct device *dev, struct device_driver *drv) { - struct fw_unit *unit = fw_unit(dev); - struct fw_device *device; - const struct ieee1394_device_id *id; + const struct ieee1394_device_id *id_table = + container_of(drv, struct fw_driver, driver)->id_table; + int id[] = {0, 0, 0, 0}; /* We only allow binding to fw_units. */ if (!is_fw_unit(dev)) return 0; - device = fw_parent_device(unit); - id = container_of(drv, struct fw_driver, driver)->id_table; + get_modalias_ids(fw_unit(dev), id); - for (; id->match_flags != 0; id++) { - if (match_unit_directory(unit->directory, id->match_flags, id)) + for (; id_table->match_flags != 0; id_table++) + if (match_ids(id_table, id)) return 1; - /* Also check vendor ID in the root directory. */ - if ((id->match_flags & IEEE1394_MATCH_VENDOR_ID) && - match_unit_directory(&device->config_rom[5], - IEEE1394_MATCH_VENDOR_ID, id) && - match_unit_directory(unit->directory, id->match_flags - & ~IEEE1394_MATCH_VENDOR_ID, id)) - return 1; - } - return 0; } static int get_modalias(struct fw_unit *unit, char *buffer, size_t buffer_size) { - struct fw_device *device = fw_parent_device(unit); - struct fw_csr_iterator ci; + int id[] = {0, 0, 0, 0}; - int key, value; - int vendor = 0; - int model = 0; - int specifier_id = 0; - int version = 0; - - fw_csr_iterator_init(&ci, &device->config_rom[5]); - while (fw_csr_iterator_next(&ci, &key, &value)) { - switch (key) { - case CSR_VENDOR: - vendor = value; - break; - case CSR_MODEL: - model = value; - break; - } - } - - fw_csr_iterator_init(&ci, unit->directory); - while (fw_csr_iterator_next(&ci, &key, &value)) { - switch (key) { - case CSR_SPECIFIER_ID: - specifier_id = value; - break; - case CSR_VERSION: - version = value; - break; - } - } + get_modalias_ids(unit, id); return snprintf(buffer, buffer_size, "ieee1394:ven%08Xmo%08Xsp%08Xver%08X", - vendor, model, specifier_id, version); + id[0], id[1], id[2], id[3]); } static 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 1c0b504..99c20f1 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, if (ret < 0) *bandwidth = 0; - if (allocate && ret < 0 && c >= 0) { - deallocate_channel(card, irm_id, generation, c, buffer); + if (allocate && ret < 0) { + if (c >= 0) + deallocate_channel(card, irm_id, generation, c, buffer); *channel = ret; } } diff --git a/drivers/firewire/ohci.c b/drivers/firewire/ohci.c index 75dc698..e33917b 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) static char ohci_driver_name[] = KBUILD_MODNAME; +#define PCI_DEVICE_ID_TI_TSB12LV22 0x8009 + #define QUIRK_CYCLE_TIMER 1 #define QUIRK_RESET_PACKET 2 #define QUIRK_BE_HEADERS 4 @@ -239,6 +241,8 @@ static char ohci_driver_name[] = KBUILD_MODNAME; static const struct { unsigned short vendor, device, flags; } ohci_quirks[] = { + {PCI_VENDOR_ID_TI, PCI_DEVICE_ID_TI_TSB12LV22, QUIRK_CYCLE_TIMER | + QUIRK_RESET_PACKET}, {PCI_VENDOR_ID_TI, PCI_ANY_ID, QUIRK_RESET_PACKET}, {PCI_VENDOR_ID_AL, PCI_ANY_ID, QUIRK_CYCLE_TIMER}, {PCI_VENDOR_ID_NEC, PCI_ANY_ID, QUIRK_CYCLE_TIMER},