[Linux1394-cvslog] rev 537 - trunk
Brought to you by:
aeb,
bencollins
From: SVN U. <hog...@li...> - 2002-07-31 01:42:37
|
Author: hogsberg Date: 2002-07-30 17:41:12 -0400 (Tue, 30 Jul 2002) New Revision: 537 Modified: trunk/csr.c trunk/highlevel.c trunk/hosts.c trunk/hosts.h trunk/ieee1394_core.c trunk/ohci1394.c trunk/pcilynx.c Log: Remove redundant tracking of lowlevel drivers (hpsb_register_lowlevel etc.) and combine hpsb_host_driver and hpsb_host_operations structs. Modified: trunk/ieee1394_core.c ============================================================================== --- trunk/ieee1394_core.c (original) +++ trunk/ieee1394_core.c Tue Jul 30 21:43:51 2002 @@ -142,7 +142,7 @@ int hpsb_reset_bus(struct hpsb_host *host, int type) { if (!host->in_bus_reset) { - host->ops->devctl(host, RESET_BUS, type); + host->driver->devctl(host, RESET_BUS, type); return 0; } else { return 1; @@ -355,7 +355,7 @@ } host->reset_retries = 0; - if (isroot) host->ops->devctl(host, ACT_CYCLE_MASTER, 1); + if (isroot) host->driver->devctl(host, ACT_CYCLE_MASTER, 1); atomic_inc(&host->generation); host->in_bus_reset = 0; highlevel_host_reset(host); @@ -441,7 +441,7 @@ } #endif - return host->ops->transmit_packet(host, packet); + return host->driver->transmit_packet(host, packet); } static void send_packet_nocare(struct hpsb_packet *packet) @@ -737,7 +737,7 @@ struct list_head *lh; LIST_HEAD(llist); - host->ops->devctl(host, CANCEL_REQUESTS, 0); + host->driver->devctl(host, CANCEL_REQUESTS, 0); spin_lock_irqsave(&host->pending_pkt_lock, flags); list_splice(&host->pending_packets, &llist); @@ -1025,8 +1025,6 @@ module_exit(ieee1394_cleanup); /* Exported symbols */ -EXPORT_SYMBOL(hpsb_register_lowlevel); -EXPORT_SYMBOL(hpsb_unregister_lowlevel); EXPORT_SYMBOL(hpsb_alloc_host); EXPORT_SYMBOL(hpsb_add_host); EXPORT_SYMBOL(hpsb_remove_host); Modified: trunk/ohci1394.c ============================================================================== --- trunk/ohci1394.c (original) +++ trunk/ohci1394.c Tue Jul 30 21:43:52 2002 @@ -2028,15 +2028,14 @@ return reg_read(ohci, OHCI1394_CSRData); } -static struct hpsb_host_operations ohci1394_ops = { +static struct hpsb_host_driver ohci1394_driver = { + .name = OHCI1394_DRIVER_NAME, .get_rom = ohci_get_rom, .transmit_packet = ohci_transmit, .devctl = ohci_devctl, .hw_csr_reg = ohci_hw_csr_reg, }; -static struct hpsb_host_driver *ohci1394_driver; - /*********************************** @@ -2069,7 +2068,7 @@ card_id_counter++); pci_set_master(dev); - host = hpsb_alloc_host(ohci1394_driver, sizeof(struct ti_ohci)); + host = hpsb_alloc_host(&ohci1394_driver, sizeof(struct ti_ohci)); if (!host) FAIL(-ENOMEM, "Failed to allocate host structure"); ohci = host->hostdata; @@ -2427,27 +2426,11 @@ static void __exit ohci1394_cleanup (void) { pci_unregister_driver(&ohci1394_pci_driver); - hpsb_unregister_lowlevel(ohci1394_driver); } static int __init ohci1394_init(void) { - int ret; - - ohci1394_driver = hpsb_register_lowlevel(&ohci1394_ops, - OHCI1394_DRIVER_NAME); - if (!ohci1394_driver) { - PRINT_G(KERN_ERR, "hpsb_register_lowlevel failed"); - return -ENOMEM; - } - - ret = pci_module_init(&ohci1394_pci_driver); - if (ret < 0) { - PRINT_G(KERN_ERR, "pci_module_init failed"); - hpsb_unregister_lowlevel(ohci1394_driver); - return ret; - } - return ret; + return pci_module_init(&ohci1394_pci_driver); } module_init(ohci1394_init); Modified: trunk/hosts.c ============================================================================== --- trunk/hosts.c (original) +++ trunk/hosts.c Tue Jul 30 21:43:52 2002 @@ -38,7 +38,7 @@ return -1; } -static struct hpsb_host_operations dummy_ops = { +static struct hpsb_host_driver dummy_driver = { .transmit_packet = dummy_transmit_packet, .devctl = dummy_devctl }; @@ -63,7 +63,7 @@ spin_lock_irqsave(&hosts_lock, flags); list_for_each(lh, &hosts) { if (host == list_entry(lh, struct hpsb_host, host_list)) { - host->ops->devctl(host, MODIFY_USAGE, 1); + host->driver->devctl(host, MODIFY_USAGE, 1); host->refcount++; retval = 1; break; @@ -87,7 +87,7 @@ { unsigned long flags; - host->ops->devctl(host, MODIFY_USAGE, 0); + host->driver->devctl(host, MODIFY_USAGE, 0); spin_lock_irqsave(&hosts_lock, flags); host->refcount--; @@ -128,7 +128,6 @@ h->hostdata = h + 1; h->driver = drv; - h->ops = drv->ops; h->refcount = 1; INIT_LIST_HEAD(&h->pending_packets); @@ -152,62 +151,25 @@ unsigned long flags; spin_lock_irqsave(&hosts_lock, flags); - host->driver->number_of_hosts++; - list_add_tail(&host->driver_list, &host->driver->hosts); list_add_tail(&host->host_list, &hosts); spin_unlock_irqrestore(&hosts_lock, flags); highlevel_add_host(host); - host->ops->devctl(host, RESET_BUS, 0); + host->driver->devctl(host, RESET_BUS, 0); } void hpsb_remove_host(struct hpsb_host *host) { - struct hpsb_host_driver *drv = host->driver; unsigned long flags; host->is_shutdown = 1; - host->ops = &dummy_ops; + host->driver = &dummy_driver; highlevel_remove_host(host); spin_lock_irqsave(&hosts_lock, flags); - list_del(&host->driver_list); list_del(&host->host_list); - drv->number_of_hosts--; spin_unlock_irqrestore(&hosts_lock, flags); } - - -struct hpsb_host_driver *hpsb_register_lowlevel(struct hpsb_host_operations *op, - const char *name) -{ - struct hpsb_host_driver *drv; - - drv = kmalloc(sizeof(struct hpsb_host_driver), SLAB_KERNEL); - if (!drv) return NULL; - - INIT_LIST_HEAD(&drv->list); - INIT_LIST_HEAD(&drv->hosts); - drv->number_of_hosts = 0; - drv->name = name; - drv->ops = op; - - spin_lock(&host_drivers_lock); - list_add_tail(&drv->list, &host_drivers); - spin_unlock(&host_drivers_lock); - - return drv; -} - -void hpsb_unregister_lowlevel(struct hpsb_host_driver *drv) -{ - spin_lock(&host_drivers_lock); - list_del(&drv->list); - spin_unlock(&host_drivers_lock); - - kfree(drv); -} - /* * This function calls the given function for every host currently registered. Modified: trunk/hosts.h ============================================================================== --- trunk/hosts.h (original) +++ trunk/hosts.h Tue Jul 30 21:43:53 2002 @@ -15,7 +15,6 @@ struct hpsb_host { struct list_head host_list; - struct hpsb_host_operations *ops; void *hostdata; atomic_t generation; @@ -59,7 +58,6 @@ struct csr_control csr; struct hpsb_host_driver *driver; - struct list_head driver_list; struct pci_dev *pdev; }; @@ -113,7 +111,9 @@ SHORT_RESET }; -struct hpsb_host_operations { +struct hpsb_host_driver { + const char *name; + /* This function must store a pointer to the configuration ROM into the * location referenced to by pointer and return the size of the ROM. It * may not fail. If any allocation is required, it must be done @@ -149,18 +149,6 @@ quadlet_t data, quadlet_t compare); }; -struct hpsb_host_driver { - struct list_head list; - - struct list_head hosts; - - int number_of_hosts; - const char *name; - - struct hpsb_host_operations *ops; -}; - - /* core internal use */ void register_builtin_lowlevels(void); @@ -183,9 +171,5 @@ struct hpsb_host *hpsb_alloc_host(struct hpsb_host_driver *drv, size_t extra); void hpsb_add_host(struct hpsb_host *host); void hpsb_remove_host(struct hpsb_host *h); - -struct hpsb_host_driver *hpsb_register_lowlevel(struct hpsb_host_operations *op, - const char *name); -void hpsb_unregister_lowlevel(struct hpsb_host_driver *drv); #endif /* _IEEE1394_HOSTS_H */ Modified: trunk/highlevel.c ============================================================================== --- trunk/highlevel.c (original) +++ trunk/highlevel.c Tue Jul 30 21:43:53 2002 @@ -139,7 +139,7 @@ } if (host->iso_listen_count[channel]++ == 0) { - host->ops->devctl(host, ISO_LISTEN_CHANNEL, channel); + host->driver->devctl(host, ISO_LISTEN_CHANNEL, channel); } } @@ -152,7 +152,7 @@ } if (--host->iso_listen_count[channel] == 0) { - host->ops->devctl(host, ISO_UNLISTEN_CHANNEL, channel); + host->driver->devctl(host, ISO_UNLISTEN_CHANNEL, channel); } } Modified: trunk/pcilynx.c ============================================================================== --- trunk/pcilynx.c (original) +++ trunk/pcilynx.c Tue Jul 30 21:43:53 2002 @@ -65,7 +65,7 @@ static int skip_eeprom = 0; -static struct hpsb_host_driver *lynx_driver; +static struct hpsb_host_driver lynx_driver; static unsigned int card_id; @@ -1327,7 +1327,7 @@ error = -ENOMEM; - host = hpsb_alloc_host(lynx_driver, sizeof(struct ti_lynx)); + host = hpsb_alloc_host(&lynx_driver, sizeof(struct ti_lynx)); if (!host) FAIL("failed to allocate control structure memory"); lynx = host->hostdata; @@ -1697,7 +1697,8 @@ .remove = __devexit_p(remove_card), }; -static struct hpsb_host_operations lynx_ops = { +static struct hpsb_host_driver lynx_driver = { + .name = PCILYNX_DRIVER_NAME, .get_rom = get_lynx_rom, .transmit_packet = lynx_transmit, .devctl = lynx_devctl, @@ -1721,22 +1722,14 @@ } #endif - lynx_driver = hpsb_register_lowlevel(&lynx_ops, PCILYNX_DRIVER_NAME); - if (!lynx_driver) { - ret = -ENOMEM; - goto free_char_dev; - } - ret = pci_module_init(&lynx_pci_driver); if (ret < 0) { PRINT_G(KERN_ERR, "PCI module init failed"); - goto unregister_lowlevel; + goto free_char_dev; } return 0; - unregister_lowlevel: - hpsb_unregister_lowlevel(lynx_driver); free_char_dev: #ifdef CONFIG_IEEE1394_PCILYNX_PORTS unregister_chrdev(PCILYNX_MAJOR, PCILYNX_DRIVER_NAME); @@ -1748,7 +1741,6 @@ static void __exit pcilynx_cleanup(void) { pci_unregister_driver(&lynx_pci_driver); - hpsb_unregister_lowlevel(lynx_driver); #ifdef CONFIG_IEEE1394_PCILYNX_PORTS unregister_chrdev(PCILYNX_MAJOR, PCILYNX_DRIVER_NAME); Modified: trunk/csr.c ============================================================================== --- trunk/csr.c (original) +++ trunk/csr.c Tue Jul 30 21:43:54 2002 @@ -70,7 +70,7 @@ { host->csr.lock = SPIN_LOCK_UNLOCKED; - host->csr.rom_size = host->ops->get_rom(host, &host->csr.rom); + host->csr.rom_size = host->driver->get_rom(host, &host->csr.rom); host->csr.state = 0; host->csr.node_ids = 0; @@ -152,7 +152,7 @@ case CSR_CYCLE_TIME: oldcycle = host->csr.cycle_time; host->csr.cycle_time = - host->ops->devctl(host, GET_CYCLE_COUNTER, 0); + host->driver->devctl(host, GET_CYCLE_COUNTER, 0); if (oldcycle > host->csr.cycle_time) { /* cycle time wrapped around */ @@ -163,7 +163,7 @@ case CSR_BUS_TIME: oldcycle = host->csr.cycle_time; host->csr.cycle_time = - host->ops->devctl(host, GET_CYCLE_COUNTER, 0); + host->driver->devctl(host, GET_CYCLE_COUNTER, 0); if (oldcycle > host->csr.cycle_time) { /* cycle time wrapped around */ @@ -181,32 +181,32 @@ return RCODE_ADDRESS_ERROR; case CSR_BUS_MANAGER_ID: - if (host->ops->hw_csr_reg) - ret = host->ops->hw_csr_reg(host, 0, 0, 0); + if (host->driver->hw_csr_reg) + ret = host->driver->hw_csr_reg(host, 0, 0, 0); else ret = host->csr.bus_manager_id; *(buf++) = cpu_to_be32(ret); out; case CSR_BANDWIDTH_AVAILABLE: - if (host->ops->hw_csr_reg) - ret = host->ops->hw_csr_reg(host, 1, 0, 0); + if (host->driver->hw_csr_reg) + ret = host->driver->hw_csr_reg(host, 1, 0, 0); else ret = host->csr.bandwidth_available; *(buf++) = cpu_to_be32(ret); out; case CSR_CHANNELS_AVAILABLE_HI: - if (host->ops->hw_csr_reg) - ret = host->ops->hw_csr_reg(host, 2, 0, 0); + if (host->driver->hw_csr_reg) + ret = host->driver->hw_csr_reg(host, 2, 0, 0); else ret = host->csr.channels_available_hi; *(buf++) = cpu_to_be32(ret); out; case CSR_CHANNELS_AVAILABLE_LO: - if (host->ops->hw_csr_reg) - ret = host->ops->hw_csr_reg(host, 3, 0, 0); + if (host->driver->hw_csr_reg) + ret = host->driver->hw_csr_reg(host, 3, 0, 0); else ret = host->csr.channels_available_lo; @@ -244,7 +244,7 @@ host->csr.node_ids &= NODE_MASK << 16; host->csr.node_ids |= be32_to_cpu(*(data++)) & (BUS_MASK << 16); host->node_id = host->csr.node_ids >> 16; - host->ops->devctl(host, SET_BUS_ID, host->node_id >> 6); + host->driver->devctl(host, SET_BUS_ID, host->node_id >> 6); out; case CSR_RESET_START: @@ -269,7 +269,7 @@ case CSR_CYCLE_TIME: /* should only be set by cycle start packet, automatically */ host->csr.cycle_time = be32_to_cpu(*data); - host->ops->devctl(host, SET_CYCLE_COUNTER, + host->driver->devctl(host, SET_CYCLE_COUNTER, be32_to_cpu(*(data++))); out; case CSR_BUS_TIME: @@ -318,10 +318,10 @@ data = be32_to_cpu(data); arg = be32_to_cpu(arg); - if (host->ops->hw_csr_reg) { + if (host->driver->hw_csr_reg) { quadlet_t old; - old = host->ops-> + old = host->driver-> hw_csr_reg(host, (csraddr - CSR_BUS_MANAGER_ID) >> 2, data, arg); |