static int au1k_irda_init(void) { static unsigned version_printed = 0; struct net_device *dev; int err; if (version_printed++ == 0) printk(version); rtnl_lock(); dev = dev_alloc("irda%d", &err); if (dev) { dev->irq = AU1000_IRDA_RX_INT; /* TX has its own interrupt */ dev->init = au1k_irda_net_init; dev->uninit = au1k_irda_net_uninit; err = register_netdevice(dev); if (err) kfree(dev); else ir_devs[0] = dev; printk(KERN_INFO "IrDA: Registered device %s\n", dev->name); } rtnl_unlock(); return err; }
INT32 f_null_attach(struct COFDM_TUNER_CONFIG_API *ptrCOFDM_Tuner) { struct nim_device *dev; void *priv_mem; ALI_PRINTF("Enter f_null_attach()...\n"); dev = (struct nim_device *)dev_alloc(nim_null_name, HLD_DEV_TYPE_NIM, sizeof(struct nim_device)); if (dev == NULL) { NIM_PRINTF("f_null_attach(): Error, Alloc nim device error!\n"); return ERR_NO_MEM; } /* Alloc structure space of private */ priv_mem = (void *)MALLOC(sizeof(struct nim_null_private)); if (priv_mem == NULL) { dev_free(dev); NIM_PRINTF("f_null_attach(): Alloc nim device prive memory error!\n"); return ERR_NO_MEM; } MEMCPY(priv_mem, ptrCOFDM_Tuner, sizeof(struct nim_null_private)); dev->priv = priv_mem; /* Function point init */ //dev->base_addr = 0x80; dev->init = f_null_attach; dev->open = f_null_open; dev->stop = f_null_close; dev->disable = f_null_disable; dev->do_ioctl = f_null_ioctl; dev->channel_change = f_null_channel_change; dev->channel_search = f_null_channel_search; dev->get_lock = f_null_get_lock_status; dev->get_freq = f_null_get_freq; dev->get_FEC = f_null_get_code_rate; dev->get_AGC = f_null_get_AGC; dev->get_SNR = f_null_get_SNR; dev->get_BER = f_null_get_BER; //added for DVB-T additional elements dev->get_guard_interval = f_null_get_GI; dev->get_fftmode = f_null_get_fftmode; dev->get_modulation = f_null_get_modulation; dev->get_spectrum_inv = f_null_get_specinv; /* Add this device to queue */ if (dev_register(dev) != SUCCESS) { NIM_PRINTF("f_null_attach(): Error, Register nim device error!\n"); FREE(priv_mem); dev_free(dev); return ERR_NO_DEV; } NIM_PRINTF("Exit f_null_attach() normally.\n"); return SUCCESS; }
static int dsl_config_netdev(void) { int status = 0; char name[16]=""; sprintf(name, "dsl0"); g_dslNetDev = dev_alloc(name, &status); g_dslNetDev->type = ARPHRD_DSL; g_dslNetDev->mtu = 0; g_dslNetDev->get_stats = dsl_get_stats; register_netdev(g_dslNetDev); return status; }
INT32 venc_m3327_init() { struct venc_device *dev; struct venc_m3327_private *tp; void *priv_mem; dev = dev_alloc(venc_m3327_name,HLD_DEV_TYPE_VENC,sizeof(struct venc_device)); if (dev == NULL) { VENC_PRINTF("Error: Alloc video vencplay device error!\n"); return RET_FAILURE; } /* Alloc structure space of private */ priv_mem = (void *)MALLOC(sizeof(struct venc_m3327_private)); if (priv_mem == NULL) { dev_free(dev); VENC_PRINTF("Alloc vencplay device prive memory error!/n"); return RET_FAILURE; } MEMSET(priv_mem, 0, sizeof(struct venc_m3327_private)); dev->priv = tp = priv_mem; dev->next = NULL; dev->flags = 0; /* Function point init */ dev->init = venc_m3327_init; dev->open = venc_m3327_open; dev->close = venc_m3327_close; //dev->ioctl = venc_m3327_ioctl; //dev->i_frame = venc_m3327_i_frame; //dev->start = venc_m3327_start; //dev->stop = venc_m3327_stop; dev->mp2enc = venc_m3327_mp2enc; /* Add this device to queue */ if (dev_register(dev) != RET_SUCCESS) { VENC_PRINTF("Error: Register vencplay device error!\n"); FREE(priv_mem); dev_free(dev); return RET_FAILURE; } VENC_PRINTF("VENC Attached!\n"); return RET_SUCCESS; }
fs_node_t *vga_vmware_init(int width, int height, int bpp) { // Find the device and get it's BAR addresses fs_node_t *pci = 0; pci = pci_get_device(PCI_VENDOR_ID_VMWARE, PCI_DEVICE_ID_VMWARE_SVGA2); if (pci == 0) return 0; // Create new handle vgavmware_handle_t *dev; dev = (vgavmware_handle_t *)dev_alloc("vga", sizeof(vgavmware_handle_t)); // Fill universal fields dev->vga.set_mode = vga_vmware_set_mode; dev->vga.unset_mode = vga_vmware_unset_mode; dev->vga.fs.blocksize = 1; // Fill custom fields dev->vga.width = width; dev->vga.height = height; dev->vga.bpp = bpp; dev->pci = pci; //pci_enable_mem(dev->pci); dev->iobase = pci_get_bar_address(dev->pci, 0); dev->fb = pci_get_bar_address(dev->pci, 1); dev->vga.offset = (void *)dev->fb; dev->fifo = pci_get_bar_address(dev->pci, 2); // Negotiate device version dev->version = SVGA_ID_2; do { SVGA_WriteReg(dev, SVGA_REG_ID, dev->version); if (SVGA_ReadReg(dev, SVGA_REG_ID) == dev->version) break; else dev->version--; } while (dev->version >= SVGA_ID_0); assert(dev->version >= SVGA_ID_0); // Get FIFO size and FB size dev->fbsize = SVGA_ReadReg(dev, SVGA_REG_FB_SIZE); dev->fifosize = SVGA_ReadReg(dev, SVGA_REG_MEM_SIZE); assert(dev->fbsize >= 0x100000); //assert(dev->fifosize < 0x20000); kprintf(2, "found VMWare VGA device\n", 0); return (fs_node_t *)dev; }
static #endif int __init sa1100_irda_init(void) { struct net_device *dev; int err; /* * Limit power level a sensible range. */ if (power_level < 1) power_level = 1; if (power_level > 3) power_level = 3; err = request_mem_region(__PREG(Ser2UTCR0), 0x24, "IrDA") ? 0 : -EBUSY; if (err) goto err_mem_1; err = request_mem_region(__PREG(Ser2HSCR0), 0x1c, "IrDA") ? 0 : -EBUSY; if (err) goto err_mem_2; err = request_mem_region(__PREG(Ser2HSCR2), 0x04, "IrDA") ? 0 : -EBUSY; if (err) goto err_mem_3; rtnl_lock(); dev = dev_alloc("irda%d", &err); if (dev) { dev->irq = IRQ_Ser2ICP; dev->init = sa1100_irda_net_init; dev->uninit = sa1100_irda_net_uninit; err = register_netdevice(dev); if (err) kfree(dev); else netdev = dev; } rtnl_unlock(); if (err) { release_mem_region(__PREG(Ser2HSCR2), 0x04); err_mem_3: release_mem_region(__PREG(Ser2HSCR0), 0x1c); err_mem_2: release_mem_region(__PREG(Ser2UTCR0), 0x24); } err_mem_1: return err; }
static void new_index(struct timeval *tv, uint16_t index, const void *data, uint16_t size) { const struct btsnoop_opcode_new_index *ni = data; struct hci_dev *dev; dev = dev_alloc(index); if (!dev) return; dev->type = ni->type; memcpy(dev->bdaddr, ni->bdaddr, 6); queue_push_tail(dev_list, dev); }
static struct hci_dev *dev_lookup(uint16_t index) { struct hci_dev *dev; dev = queue_find(dev_list, dev_match_index, UINT_TO_PTR(index)); if (!dev) { fprintf(stderr, "Creating new device for unknown index\n"); dev = dev_alloc(index); if (!dev) return NULL; queue_push_tail(dev_list, dev); } return dev; }
static int __init pxa250_irda_init(void) { struct net_device *dev; int err; /* STUART */ err = request_mem_region(__PREG(STRBR), 0x24, "IrDA") ? 0 : -EBUSY; if (err) goto err_mem_1; /* FIR */ err = request_mem_region(__PREG(ICCR0), 0x1c, "IrDA") ? 0 : -EBUSY; if (err) goto err_mem_2; rtnl_lock(); dev = dev_alloc("irda%d", &err); if (dev) { dev->irq = IRQ_STUART; dev->init = pxa250_irda_net_init; dev->uninit = pxa250_irda_net_uninit; err = register_netdevice(dev); if (err) kfree(dev); else netdev = dev; } rtnl_unlock(); if (err) { release_mem_region(__PREG(ICCR0), 0x1c); err_mem_2: release_mem_region(__PREG(STRBR), 0x24); } err_mem_1: return err; }
/* * Function nsc_ircc_open (iobase, irq) * * Open driver instance * */ static int nsc_ircc_open(int i, chipio_t *info) { struct net_device *dev; struct nsc_ircc_cb *self; struct pm_dev *pmdev; void *ret; int err; IRDA_DEBUG(2, "%s()\n", __FUNCTION__); MESSAGE("%s, Found chip at base=0x%03x\n", driver_name, info->cfg_base); if ((nsc_ircc_setup(info)) == -1) return -1; MESSAGE("%s, driver loaded (Dag Brattli)\n", driver_name); /* Allocate new instance of the driver */ self = kmalloc(sizeof(struct nsc_ircc_cb), GFP_KERNEL); if (self == NULL) { ERROR("%s(), can't allocate memory for " "control block!\n", __FUNCTION__); return -ENOMEM; } memset(self, 0, sizeof(struct nsc_ircc_cb)); spin_lock_init(&self->lock); /* Need to store self somewhere */ dev_self[i] = self; self->index = i; /* Initialize IO */ self->io.cfg_base = info->cfg_base; self->io.fir_base = info->fir_base; self->io.irq = info->irq; self->io.fir_ext = CHIP_IO_EXTENT; self->io.dma = info->dma; self->io.fifo_size = 32; /* Reserve the ioports that we need */ ret = request_region(self->io.fir_base, self->io.fir_ext, driver_name); if (!ret) { WARNING("%s(), can't get iobase of 0x%03x\n", __FUNCTION__, self->io.fir_base); dev_self[i] = NULL; kfree(self); return -ENODEV; } /* Initialize QoS for this device */ irda_init_max_qos_capabilies(&self->qos); /* The only value we must override it the baudrate */ self->qos.baud_rate.bits = IR_9600|IR_19200|IR_38400|IR_57600| IR_115200|IR_576000|IR_1152000 |(IR_4000000 << 8); self->qos.min_turn_time.bits = qos_mtt_bits; irda_qos_bits_to_value(&self->qos); self->flags = IFF_FIR|IFF_MIR|IFF_SIR|IFF_DMA|IFF_PIO|IFF_DONGLE; /* Max DMA buffer size needed = (data_size + 6) * (window_size) + 6; */ self->rx_buff.truesize = 14384; self->tx_buff.truesize = 14384; /* Allocate memory if needed */ self->rx_buff.head = (__u8 *) kmalloc(self->rx_buff.truesize, GFP_KERNEL|GFP_DMA); if (self->rx_buff.head == NULL) { kfree(self); return -ENOMEM; } memset(self->rx_buff.head, 0, self->rx_buff.truesize); self->tx_buff.head = (__u8 *) kmalloc(self->tx_buff.truesize, GFP_KERNEL|GFP_DMA); if (self->tx_buff.head == NULL) { kfree(self->rx_buff.head); kfree(self); return -ENOMEM; } memset(self->tx_buff.head, 0, self->tx_buff.truesize); self->rx_buff.in_frame = FALSE; self->rx_buff.state = OUTSIDE_FRAME; self->tx_buff.data = self->tx_buff.head; self->rx_buff.data = self->rx_buff.head; /* Reset Tx queue info */ self->tx_fifo.len = self->tx_fifo.ptr = self->tx_fifo.free = 0; self->tx_fifo.tail = self->tx_buff.head; if (!(dev = dev_alloc("irda%d", &err))) { ERROR("%s(), dev_alloc() failed!\n", __FUNCTION__); return -ENOMEM; } dev->priv = (void *) self; self->netdev = dev; /* Override the network functions we need to use */ dev->init = nsc_ircc_net_init; dev->hard_start_xmit = nsc_ircc_hard_xmit_sir; dev->open = nsc_ircc_net_open; dev->stop = nsc_ircc_net_close; dev->do_ioctl = nsc_ircc_net_ioctl; dev->get_stats = nsc_ircc_net_get_stats; rtnl_lock(); err = register_netdevice(dev); rtnl_unlock(); if (err) { ERROR("%s(), register_netdev() failed!\n", __FUNCTION__); return -1; } MESSAGE("IrDA: Registered device %s\n", dev->name); /* Check if user has supplied the dongle id or not */ if (!dongle_id) { dongle_id = nsc_ircc_read_dongle_id(self->io.fir_base); MESSAGE("%s, Found dongle: %s\n", driver_name, dongle_types[dongle_id]); } else { MESSAGE("%s, Using dongle: %s\n", driver_name, dongle_types[dongle_id]); } self->io.dongle_id = dongle_id; nsc_ircc_init_dongle_interface(self->io.fir_base, dongle_id); pmdev = pm_register(PM_SYS_DEV, PM_SYS_IRDA, nsc_ircc_pmproc); if (pmdev) pmdev->data = self; return 0; }
void osd_dev_api_attach(struct ge_device *ge_dev, UINT32 osd_layer_id) { struct osd_device *dev; const char *name; if (ge_dev) m_osddrv_ge_dev = ge_dev; if (osd_layer_id >= 3) return; if (osd_layer_id == 0) name = "OSD_DEV_0"; else if (osd_layer_id == 1) name = "OSD_DEV_1"; else name = "OSD_DEV_2"; dev = (struct osd_device *)dev_alloc((INT8 *)name,HLD_DEV_TYPE_OSD,sizeof(struct osd_device)); if (dev == NULL) { return ; } dev->priv = (void *)osd_layer_id; dev->next = NULL; dev->flags = 0; dev->sema_opert_osd = osal_mutex_create(); if(OSAL_INVALID_ID == dev->sema_opert_osd) { PRINTF("OSD Can not create mutex!!!\n"); ASSERT(0); } /* Function point init */ #if 0 dev->open = OSDDrv_Open; dev->close = OSDDrv_Close; dev->ioctl = OSDDrv_IoCtl; dev->get_para = OSDDrv_GetPara; dev->show_onoff = OSDDrv_ShowOnOff; dev->region_show = OSDDrv_RegionShow; dev->set_pallette = OSDDrv_SetPallette; dev->get_pallette = OSDDrv_GetPallette; dev->modify_pallette = OSDDrv_ModifyPallette; dev->create_region = OSDDrv_CreateRegion; dev->delete_region = OSDDrv_DeleteRegion; dev->set_region_pos = OSDDrv_SetRegionPos; dev->get_region_pos = OSDDrv_GetRegionPos; dev->region_write = OSDDrv_RegionWrite; dev->region_read = OSDDrv_RegionRead; dev->region_fill = OSDDrv_RegionFill; dev->region_write2 = OSDDrv_RegionWrite2; dev->draw_hor_line = OSDDrv_DrawHorLine; dev->scale = OSDDrv_Scale; dev->set_clip = OSDDrv_SetClip; dev->clear_clip = OSDDrv_ClearClip; dev->get_region_addr = OSDDrv_GetRegionAddr; #endif /* Add this device to queue */ if (dev_register(dev) != RET_SUCCESS) { dev_free(dev); return ; } return ; }
/* * Function w83977af_open (iobase, irq) * * Open driver instance * */ int w83977af_open(int i, unsigned int iobase, unsigned int irq, unsigned int dma) { struct net_device *dev; struct w83977af_ir *self; int ret; int err; IRDA_DEBUG(0, __FUNCTION__ "()\n"); if (w83977af_probe(iobase, irq, dma) == -1) return -1; /* * Allocate new instance of the driver */ self = kmalloc(sizeof(struct w83977af_ir), GFP_KERNEL); if (self == NULL) { printk( KERN_ERR "IrDA: Can't allocate memory for " "IrDA control block!\n"); return -ENOMEM; } memset(self, 0, sizeof(struct w83977af_ir)); /* Need to store self somewhere */ dev_self[i] = self; /* Initialize IO */ self->io.fir_base = iobase; self->io.irq = irq; self->io.fir_ext = CHIP_IO_EXTENT; self->io.dma = dma; self->io.fifo_size = 32; /* Lock the port that we need */ ret = check_region(self->io.fir_base, self->io.fir_ext); if (ret < 0) { IRDA_DEBUG(0, __FUNCTION__ "(), can't get iobase of 0x%03x\n", self->io.fir_base); /* w83977af_cleanup( self); */ return -ENODEV; } request_region(self->io.fir_base, self->io.fir_ext, driver_name); /* Initialize QoS for this device */ irda_init_max_qos_capabilies(&self->qos); /* The only value we must override it the baudrate */ /* FIXME: The HP HDLS-1100 does not support 1152000! */ self->qos.baud_rate.bits = IR_9600|IR_19200|IR_38400|IR_57600| IR_115200/*|IR_576000|IR_1152000|(IR_4000000 << 8)*/; /* The HP HDLS-1100 needs 1 ms according to the specs */ self->qos.min_turn_time.bits = qos_mtt_bits; irda_qos_bits_to_value(&self->qos); self->flags = IFF_FIR|IFF_MIR|IFF_SIR|IFF_DMA|IFF_PIO; /* Max DMA buffer size needed = (data_size + 6) * (window_size) + 6; */ self->rx_buff.truesize = 14384; self->tx_buff.truesize = 4000; /* Allocate memory if needed */ self->rx_buff.head = (__u8 *) kmalloc(self->rx_buff.truesize, GFP_KERNEL|GFP_DMA); if (self->rx_buff.head == NULL) return -ENOMEM; memset(self->rx_buff.head, 0, self->rx_buff.truesize); self->tx_buff.head = (__u8 *) kmalloc(self->tx_buff.truesize, GFP_KERNEL|GFP_DMA); if (self->tx_buff.head == NULL) { kfree(self->rx_buff.head); return -ENOMEM; } memset(self->tx_buff.head, 0, self->tx_buff.truesize); self->rx_buff.in_frame = FALSE; self->rx_buff.state = OUTSIDE_FRAME; self->tx_buff.data = self->tx_buff.head; self->rx_buff.data = self->rx_buff.head; if (!(dev = dev_alloc("irda%d", &err))) { ERROR(__FUNCTION__ "(), dev_alloc() failed!\n"); return -ENOMEM; } dev->priv = (void *) self; self->netdev = dev; /* Override the network functions we need to use */ dev->init = w83977af_net_init; dev->hard_start_xmit = w83977af_hard_xmit; dev->open = w83977af_net_open; dev->stop = w83977af_net_close; dev->do_ioctl = w83977af_net_ioctl; dev->get_stats = w83977af_net_get_stats; rtnl_lock(); err = register_netdevice(dev); rtnl_unlock(); if (err) { ERROR(__FUNCTION__ "(), register_netdevice() failed!\n"); return -1; } MESSAGE("IrDA: Registered device %s\n", dev->name); return 0; }
static dev_link_t *com20020_attach(void) { client_reg_t client_reg; dev_link_t *link; com20020_dev_t *info; struct net_device *dev; int i, ret; struct arcnet_local *lp; DEBUG(0, "com20020_attach()\n"); flush_stale_links(); /* Create new network device */ link = kmalloc(sizeof(struct dev_link_t), GFP_KERNEL); if (!link) return NULL; info = kmalloc(sizeof(struct com20020_dev_t), GFP_KERNEL); if (!info) goto fail_alloc_info; lp = kmalloc(sizeof(struct arcnet_local), GFP_KERNEL); if (!lp) goto fail_alloc_lp; dev = dev_alloc("arc%d", &ret); if (!dev) goto fail_alloc_dev; memset(info, 0, sizeof(struct com20020_dev_t)); memset(lp, 0, sizeof(struct arcnet_local)); memset(link, 0, sizeof(struct dev_link_t)); dev->priv = lp; link->release.function = &com20020_release; link->release.data = (u_long)link; link->io.Attributes1 = IO_DATA_PATH_WIDTH_8; link->io.NumPorts1 = 16; link->io.IOAddrLines = 16; link->irq.Attributes = IRQ_TYPE_EXCLUSIVE; link->irq.IRQInfo1 = IRQ_INFO2_VALID|IRQ_LEVEL_ID; if (irq_list[0] == -1) link->irq.IRQInfo2 = irq_mask; else for (i = 0; i < 4; i++) link->irq.IRQInfo2 |= 1 << irq_list[i]; link->conf.Attributes = CONF_ENABLE_IRQ; link->conf.Vcc = 50; link->conf.IntType = INT_MEMORY_AND_IO; link->conf.Present = PRESENT_OPTION; /* fill in our module parameters as defaults */ dev->dev_addr[0] = node; lp->timeout = timeout; lp->backplane = backplane; lp->clockp = clockp; lp->clockm = clockm & 3; lp->hw.open_close_ll = com20020cs_open_close; link->irq.Instance = info->dev = dev; link->priv = info; /* Register with Card Services */ link->next = dev_list; dev_list = link; client_reg.dev_info = &dev_info; client_reg.Attributes = INFO_IO_CLIENT | INFO_CARD_SHARE; client_reg.EventMask = CS_EVENT_CARD_INSERTION | CS_EVENT_CARD_REMOVAL | CS_EVENT_RESET_PHYSICAL | CS_EVENT_CARD_RESET | CS_EVENT_PM_SUSPEND | CS_EVENT_PM_RESUME; client_reg.event_handler = &com20020_event; client_reg.Version = 0x0210; client_reg.event_callback_args.client_data = link; ret = CardServices(RegisterClient, &link->handle, &client_reg); if (ret != 0) { cs_error(link->handle, RegisterClient, ret); com20020_detach(link); return NULL; } return link; fail_alloc_dev: kfree(lp); fail_alloc_lp: kfree(info); fail_alloc_info: kfree(link); return NULL; } /* com20020_attach */
/********************************************************** * Name : hcdi_s3602_attach * Description : usb host controller s3602 device attach * Parameter : notify: HC event notify callback to USBD * Return : RET_SUCCESS: success * RET_FAILURE: error ***********************************************************/ RET_CODE hcdi_s3602_attach_ex(HC_NOTIFY_CB notify) { struct usb_hc_device* dev; struct hc_s3602_private* priv ; void* priv_mem_ctrl; void* priv_mem_bulk; void* priv_mem_bulk_out; void* priv_mem_opt_bulk; void* priv_mem_int_c; void* priv_mem_int_d; UINT32 base_address; UINT16 i = 0; dev = (struct usb_hc_device *) dev_alloc(hc_s3602_name_ex, HLD_DEV_TYPE_USB_HOST, sizeof(struct usb_hc_device)); if (dev == NULL) { HCDI_CMD_PRINTF("Error: Alloc usb host controller device error!\n"); HCDI_CMD_ASSERT(0); return RET_FAILURE; } /* Alloc structure space of private ctrl*/ priv_mem_ctrl = (void *) MALLOC(sizeof(struct hc_s3602_private) + 0x0f); if (priv_mem_ctrl == NULL) { dev_free(dev); HCDI_CMD_PRINTF("Alloc usb host controller device prive memory error!\n"); HCDI_CMD_ASSERT(0); return RET_FAILURE; } /* Private date struct 16 bytes aligen */ dev->priv_ctrl= priv = (void *) (((UINT32) priv_mem_ctrl+ 0x0f) & (~0x0f)); /* Init priv element */ MEMSET((UINT8 *) priv, 0, sizeof(struct hc_s3602_private)); priv->priv_addr = priv_mem_ctrl; /* Unaligned address of struct real located */ priv->priv_type = USB_CONTROL_TRANSFER_MODE ; /* Alloc structure space of private bulk */ priv_mem_bulk = (void *) MALLOC(sizeof(struct hc_s3602_private) + 0x0f); if (priv_mem_bulk== NULL) { FREE(priv_mem_ctrl); dev_free(dev); HCDI_CMD_PRINTF("Alloc usb host controller device prive memory error!\n"); HCDI_CMD_ASSERT(0); return RET_FAILURE; } /* Private date struct 16 bytes aligen */ dev->priv_bulk= priv = (void *) (((UINT32) priv_mem_bulk+ 0x0f) & (~0x0f)); /* Init priv element */ MEMSET((UINT8 *) priv, 0, sizeof(struct hc_s3602_private)); priv->priv_addr = priv_mem_bulk; /* Unaligned address of struct real located */ priv->priv_type = USB_BULK_IN_TRANSFER_MODE ; /* Alloc structure space of private bulk_out */ priv_mem_bulk_out = (void *) MALLOC(sizeof(struct hc_s3602_private) + 0x0f); if (priv_mem_bulk_out== NULL) { FREE(priv_mem_ctrl); FREE(priv_mem_bulk); dev_free(dev); HCDI_CMD_PRINTF("Alloc usb host controller device prive memory error!\n"); HCDI_CMD_ASSERT(0); return RET_FAILURE; } /* Private date struct 16 bytes aligen */ dev->priv_bulk_out= priv = (void *) (((UINT32) priv_mem_bulk_out+ 0x0f) & (~0x0f)); /* Init priv element */ MEMSET((UINT8 *) priv, 0, sizeof(struct hc_s3602_private)); priv->priv_addr = priv_mem_bulk_out; /* Unaligned address of struct real located */ priv->priv_type = USB_BULK_OUT_TRANSFER_MODE ; /* Alloc structure space of private opt_bulk */ priv_mem_opt_bulk = (void *) MALLOC(sizeof(struct hc_s3602_private) + 0x0f); if (priv_mem_opt_bulk== NULL) { FREE(priv_mem_ctrl); FREE(priv_mem_bulk); FREE(priv_mem_bulk_out); dev_free(dev); HCDI_CMD_PRINTF("Alloc usb host controller device prive memory error!\n"); HCDI_CMD_ASSERT(0); return RET_FAILURE; } /* Private date struct 16 bytes aligen */ dev->priv_opt_bulk = priv = (void *) (((UINT32) priv_mem_opt_bulk+ 0x0f) & (~0x0f)); /* Init priv element */ MEMSET((UINT8 *) priv, 0, sizeof(struct hc_s3602_private)); priv->priv_addr = priv_mem_opt_bulk; /* Unaligned address of struct real located */ priv->priv_type = USB_OPT_BULK_TRANSFER_MODE ; /* Alloc structure space of private int_c*/ priv_mem_int_c= (void *) MALLOC(sizeof(struct hc_s3602_private) + 0x0f); if (priv_mem_int_c == NULL) { FREE(priv_mem_bulk); FREE(priv_mem_ctrl); dev_free(dev); HCDI_CMD_PRINTF("Alloc usb host controller device prive memory error!\n"); HCDI_CMD_ASSERT(0); return RET_FAILURE; } /* Private date struct 16 bytes aligen */ dev->priv_int_c= priv = (void *) (((UINT32) priv_mem_int_c+ 0x0f) & (~0x0f)); /* Init priv element */ MEMSET((UINT8 *) priv, 0, sizeof(struct hc_s3602_private)); priv->priv_addr = priv_mem_int_c; /* Unaligned address of struct real located */ priv->priv_type = USB_INTERRUPT_TRANSFER_MODE ; /* Alloc structure space of private int d*/ priv_mem_int_d= (void *) MALLOC(sizeof(struct hc_s3602_private) + 0x0f); if (priv_mem_int_d == NULL) { FREE(priv_mem_int_c); FREE(priv_mem_bulk); FREE(priv_mem_ctrl); dev_free(dev); HCDI_CMD_PRINTF("Alloc usb host controller device prive memory error!\n"); HCDI_CMD_ASSERT(0); return RET_FAILURE; } /* Private date struct 16 bytes aligen */ dev->priv_int_d= priv = (void *) (((UINT32) priv_mem_int_d+ 0x0f) & (~0x0f)); /* Init priv element */ MEMSET((UINT8 *) priv, 0, sizeof(struct hc_s3602_private)); priv->priv_addr = priv_mem_int_d; /* Unaligned address of struct real located */ priv->priv_type = USB_HUB_TRANSFER_MODE ; /* Function point init */ if( (sys_ic_get_chip_id() == ALI_M3329E)&&(sys_ic_get_rev_id() >=IC_REV_5)) dev->base_addr = HC_S3329E5_BASE_ADDR; else if (sys_ic_get_chip_id() == ALI_S3602) dev->base_addr = HC_S3602_BASE_ADDR; else return !RET_SUCCESS; // usb invalid chip id //dev->base_addr = base_address; dev->init = hcdi_s3602_attach_ex; dev->open = hcdi_s3602_open_ex; dev->close = hcdi_s3602_close_ex; dev->submit_upt = hcdi_s3602_submit_upt_ex; dev->cancel_upt = hcdi_s3602_cancel_upt_ex; dev->suspend = hcdi_s3602_suspend_ex; dev->resume = hcdi_s3602_resume_ex; dev->reset = hcdi_s3602_reset_ex; dev->io_control = hcdi_s3602_ioctl_ex; dev->hc_notify_uplayer = notify; dev->rh_port_num = 1; //dev->curr_upt = NULL; dev->curr_upt_bulk= NULL; dev->curr_upt_ctl= NULL; dev->curr_upt_int_c= NULL; dev->curr_upt_int_d= NULL; for (i = 0; i < USB_MAX_DEVICES; i++) dev->adrsVec[i] = 0; dev->pRoot = NULL ; dev->nanSeconds = 0; /* Add this device to queue */ if (dev_register(dev) != SUCCESS) { HCDI_CMD_PRINTF("Error: Register usb host controller device error!\n"); FREE(priv_mem_int_d); FREE(priv_mem_int_c); FREE(priv_mem_bulk); FREE(priv_mem_ctrl); dev_free(dev); HCDI_CMD_ASSERT(0); return RET_FAILURE; } return RET_SUCCESS; }
/******************************************** * NAME: vbi_cc_init * init cc parameters and set callback fucn of vpo_isr to excute push user data for cc using * * Returns : BOOL * 1 : RET_FAILURE * 0 : RET_SUCCESS * Parameter Flow Description * ------------------------------------------------------------------------------ * None * ------------------------------------------------------------------------------ * Additional information: ******************************************/ __ATTRIBUTE_REUSE_ INT32 vbi_cc_init() { struct vbi_device *dev; struct vbi_m3327_private *tp; void *priv_mem; g_vbi_m3327_name = (char *)ccvbi_m3327_name; dev = dev_alloc(g_vbi_m3327_name,HLD_DEV_TYPE_VBI,sizeof(struct vbi_device)); if (dev == NULL) { VBI_PRINTF("Error: Alloc video vbiplay device error!\n"); return RET_FAILURE; } /* Alloc structure space of private */ priv_mem = (void *)MALLOC(sizeof(struct vbi_m3327_private)); if (priv_mem == NULL) { dev_free(dev); VBI_PRINTF("Alloc vbiplay device prive memory error!/n"); return RET_FAILURE; } MEMSET(priv_mem, 0, sizeof(struct vbi_m3327_private)); g_vbi_priv = dev->priv = tp = (struct vbi_m3327_private *)priv_mem; ccg_vbi27_pconfig_par = &(g_vbi_priv->config_par); ccg_vbi27_ttx_by_osd = &(g_vbi_priv->ttx_by_osd); ccg_vbi27_cc_by_osd = &(g_vbi_priv->cc_by_osd); //====================================== #ifdef CC_BY_OSD ccg_vbi27_dtvcc_by_osd=&(g_vbi_priv->dtvcc_by_osd);//hbchen #endif //====================================== /*according the macro , config the VBI driver*/ //vbi_data_array = (struct vbi_data_array_t *)MALLOC((VBI_QUEUE_DEPTH)*sizeof(struct vbi_data_array_t)); //MEMSET(vbi_data_array, 0, (VBI_QUEUE_DEPTH)*sizeof(struct vbi_m3327_private)); *ccg_vbi27_ttx_by_osd = FALSE; g_vbi_priv->init_ttx_decoder = NULL; #ifdef CC_BY_OSD *ccg_vbi27_cc_by_osd = TRUE; g_vbi_priv->init_cc_decoder = vbi_m3327_init_cc_decoder; g_vbi_priv->vbi_line21_push_by_cc = vbi_line21_push; g_vbi_priv->vbi_line21_push_by_dtvcc = vbi_line21_push_dtvcc;//xing for DTVCC #else *ccg_vbi27_cc_by_osd = FALSE; #endif #ifdef CC_BY_VBI ccg_vbi27_pconfig_par->cc_by_vbi = TRUE; #else ccg_vbi27_pconfig_par->cc_by_vbi = FALSE; #endif //dev->setoutput = vbi_m3327_setoutput; dev->next = NULL; dev->flags = 0; /* Function point init */ dev->init = vbi_cc_init; dev->open = vbi_cc_open; dev->close = NULL; dev->request_write = NULL; dev->update_write = NULL; dev->setoutput = ccvbi_m3327_setoutput; dev->start = NULL; dev->stop = NULL; /* Add this device to queue */ if(dev_register(dev) != RET_SUCCESS) { VBI_PRINTF("Error: Register vbiplay device error!\n"); FREE(priv_mem); dev_free(dev); return RET_FAILURE; } return RET_SUCCESS; }
__ATTRIBUTE_REUSE_ INT32 pan_direct_gpio_attach(struct pan_configuration *config) { struct pan_device *dev; struct pan_hw_info *tp; if (config == NULL || config->hw_info == NULL) { return ERR_FAILUE; } dev = dev_alloc(pan_direct_gpio_name, HLD_DEV_TYPE_PAN, sizeof(struct pan_device)); if (dev == NULL) { PRINTF("Error: Alloc front panel device error!\n"); return ERR_NO_MEM; } dev->priv = config->hw_info; tp = (struct pan_hw_info*)dev->priv; #ifdef SUPPORT_FIRMWARE_CONFIG POS_GPIO_POWER_LED = tp->lbd[0].position; POS_GPIO_POWER_LED_POLAR = tp->lbd[0].polar; POS_GPIO_STANDBY_LED = tp->lbd[2].position; POS_GPIO_STANDBY_LED_POLAR = tp->lbd[2].polar; POS_GPIO_LOCK_LED = tp->lbd[1].position; POS_GPIO_STANDBY_KEY = tp->flatch.position; //POS_GPIO_STANDBY_KEY_POLAR = tp->flatch.polar; POS_GPIO_CHANNEL_UP_KEY = tp->fclock.position; //POS_GPIO_CHANNEL_UP_KEY_POLAR = tp->fclock.polar; POS_GPIO_CHANNEL_DOWN_KEY = tp->fdata.position; //POS_GPIO_CHANNEL_DOWN_KEY_POLAR = tp->fdata.polar; //keypress_repeat = tp->intv_repeat; #endif /* Function point init */ dev->init = pan_direct_gpio_attach; dev->open = pan_direct_gpio_open; dev->stop = pan_direct_gpio_close; dev->do_ioctl = pan_direct_gpio_ioctl; dev->display = pan_direct_gpio_display; /* Add this device to queue */ if (dev_register(dev) != SUCCESS) { PRINTF("Error: Register panel device error!\n"); dev_free(dev); return ERR_NO_DEV; } return SUCCESS; }
struct irport_cb * irport_open(int i, unsigned int iobase, unsigned int irq) { struct net_device *dev; struct irport_cb *self; void *ret; int err; IRDA_DEBUG(0, "%s()\n", __FUNCTION__); /* * Allocate new instance of the driver */ self = kmalloc(sizeof(struct irport_cb), GFP_KERNEL); if (!self) { ERROR("%s(), can't allocate memory for " "control block!\n", __FUNCTION__); return NULL; } memset(self, 0, sizeof(struct irport_cb)); spin_lock_init(&self->lock); /* Need to store self somewhere */ dev_self[i] = self; self->priv = self; self->index = i; /* Initialize IO */ self->io.sir_base = iobase; self->io.sir_ext = IO_EXTENT; self->io.irq = irq; self->io.fifo_size = 16; /* Lock the port that we need */ ret = request_region(self->io.sir_base, self->io.sir_ext, driver_name); if (!ret) { IRDA_DEBUG(0, "%s(), can't get iobase of 0x%03x\n", __FUNCTION__, self->io.sir_base); return NULL; } /* Initialize QoS for this device */ irda_init_max_qos_capabilies(&self->qos); self->qos.baud_rate.bits = IR_9600|IR_19200|IR_38400|IR_57600| IR_115200; self->qos.min_turn_time.bits = qos_mtt_bits; irda_qos_bits_to_value(&self->qos); self->flags = IFF_SIR|IFF_PIO; /* Specify how much memory we want */ self->rx_buff.truesize = 4000; self->tx_buff.truesize = 4000; /* Allocate memory if needed */ if (self->rx_buff.truesize > 0) { self->rx_buff.head = (__u8 *) kmalloc(self->rx_buff.truesize, GFP_KERNEL); if (self->rx_buff.head == NULL) return NULL; memset(self->rx_buff.head, 0, self->rx_buff.truesize); } if (self->tx_buff.truesize > 0) { self->tx_buff.head = (__u8 *) kmalloc(self->tx_buff.truesize, GFP_KERNEL); if (self->tx_buff.head == NULL) { kfree(self->rx_buff.head); return NULL; } memset(self->tx_buff.head, 0, self->tx_buff.truesize); } self->rx_buff.in_frame = FALSE; self->rx_buff.state = OUTSIDE_FRAME; self->tx_buff.data = self->tx_buff.head; self->rx_buff.data = self->rx_buff.head; self->mode = IRDA_IRLAP; if (!(dev = dev_alloc("irda%d", &err))) { ERROR("%s(), dev_alloc() failed!\n", __FUNCTION__); return NULL; } self->netdev = dev; /* May be overridden by piggyback drivers */ dev->priv = (void *) self; self->interrupt = irport_interrupt; self->change_speed = irport_change_speed; /* Override the network functions we need to use */ dev->init = irport_net_init; dev->hard_start_xmit = irport_hard_xmit; dev->tx_timeout = irport_timeout; dev->watchdog_timeo = HZ; /* Allow time enough for speed change */ dev->open = irport_net_open; dev->stop = irport_net_close; dev->get_stats = irport_net_get_stats; dev->do_ioctl = irport_net_ioctl; /* Make ifconfig display some details */ dev->base_addr = iobase; dev->irq = irq; rtnl_lock(); err = register_netdevice(dev); rtnl_unlock(); if (err) { ERROR("%s(), register_netdev() failed!\n", __FUNCTION__); return NULL; } MESSAGE("IrDA: Registered device %s\n", dev->name); return self; }
*****************************************************************************/ INT32 f_TC90512_attach(struct COFDM_TUNER_CONFIG_API *ptrCOFDM_Tuner) //51117-01Angus { struct nim_device *dev; struct nim_TC90512_private * priv_mem; UINT32 tuner_id=0; if ((ptrCOFDM_Tuner == NULL)) { NIM_PRINTF("Tuner Configuration API structure is NULL!/n"); return ERR_NO_DEV; } dev = (struct nim_device *)dev_alloc(nim_TC90512_name, HLD_DEV_TYPE_NIM, sizeof(struct nim_device)); if (dev == NULL) { NIM_PRINTF("Error: Alloc nim device error!\n"); return ERR_NO_MEM; } /* Alloc structure space of private */ priv_mem = (struct nim_TC90512_private *)MALLOC(sizeof(struct nim_TC90512_private)); if ((void*)priv_mem == NULL) { dev_free(dev); NIM_TC90512_PRINTF("Alloc nim device prive memory error!/n"); return ERR_NO_MEM; } MEMCPY((void*)&(priv_mem->Tuner_Control), (void*)ptrCOFDM_Tuner, sizeof(struct COFDM_TUNER_CONFIG_API)); dev->priv = (void*)priv_mem; /* Function point init */ dev->base_addr = SYS_COFDM_TC90512_CHIP_ADRRESS; //please check here dev->init = f_TC90512_attach; dev->open = f_TC90512_open; dev->stop = f_TC90512_close; dev->do_ioctl = NULL; dev->channel_change = f_TC90512_channel_change; dev->channel_search = f_TC90512_channel_search; dev->get_lock = f_TC90512_get_lock; dev->get_freq = f_TC90512_get_freq; dev->get_FEC = f_TC90512_get_code_rate; dev->get_AGC = f_TC90512_get_AGC; dev->get_SNR = f_TC90512_get_SNR; //dev->get_BER = f_TC90512_get_BER; dev->get_guard_interval = f_TC90512_get_GI; dev->get_fftmode = f_TC90512_get_fftmode; dev->get_modulation = f_TC90512_get_modulation; dev->get_spectrum_inv = NULL; //dev->get_HIER= f_TC90512_get_hier_mode; //dev->get_priority=f_TC90512_priority; dev->get_freq_offset = NULL; f_IIC_Sema_ID=osal_semaphore_create(1); /*if((((struct nim_TC90512_private*)dev->priv)->Tuner_Control.tuner_config.cChip)!=Tuner_Chip_QUANTEK ) { ptrCOFDM_Tuner->tuner_config.Tuner_Write=NULL; ptrCOFDM_Tuner->tuner_config.Tuner_Read=NULL; }*/ /* Add this device to queue */ if (dev_register(dev) != SUCCESS) { NIM_PRINTF("Error: Register nim device error!\n"); FREE(priv_mem); dev_free(dev); return ERR_NO_DEV; } if (((struct nim_TC90512_private*)dev->priv)->Tuner_Control.nim_Tuner_Init != NULL) { if((((struct nim_TC90512_private*)dev->priv)->Tuner_Control.tuner_config.cChip)==Tuner_Chip_QUANTEK || (((struct nim_TC90512_private*)dev->priv)->Tuner_Control.tuner_config.cChip)==Tuner_Chip_MAXLINEAR) { f_TC90512_PassThrough(dev,TRUE); //if (((struct nim_TC90512_private*)dev->priv)->Tuner_Control.nim_Tuner_Init(&((struct nim_TC90512_private*)dev->priv)->tuner_id, &(ptrCOFDM_Tuner->tuner_config)) != SUCCESS) if (((struct nim_TC90512_private*)dev->priv)->Tuner_Control.nim_Tuner_Init(&tuner_id, &(ptrCOFDM_Tuner->tuner_config)) != SUCCESS) { NIM_PRINTF("Error: Init Tuner Failure!\n"); f_TC90512_PassThrough(dev,FALSE); return ERR_NO_DEV; } f_TC90512_PassThrough(dev,FALSE); } else { if (((struct nim_TC90512_private*)dev->priv)->Tuner_Control.nim_Tuner_Init(&tuner_id, &(ptrCOFDM_Tuner->tuner_config)) != SUCCESS) { NIM_PRINTF("Error: Init Tuner Failure!\n"); return ERR_NO_DEV; } } } return SUCCESS;
/* Set up the struct net_device associated with this card. Called after * probing succeeds. */ static int __init com90xx_found(struct net_device *dev0, int ioaddr, int airq, u_long shmem) { struct net_device *dev = dev0; struct arcnet_local *lp; u_long first_mirror, last_mirror; int mirror_size, err; /* allocate struct net_device if we don't have one yet */ if (!dev && !(dev = dev_alloc("arc%d", &err))) { BUGMSG2(D_NORMAL, "com90xx: Can't allocate device!\n"); return err; } lp = dev->priv = kmalloc(sizeof(struct arcnet_local), GFP_KERNEL); if (!lp) { BUGMSG(D_NORMAL, "Can't allocate device data!\n"); goto err_free_dev; } /* find the real shared memory start/end points, including mirrors */ /* guess the actual size of one "memory mirror" - the number of * bytes between copies of the shared memory. On most cards, it's * 2k (or there are no mirrors at all) but on some, it's 4k. */ mirror_size = MIRROR_SIZE; if (isa_readb(shmem) == TESTvalue && isa_readb(shmem - mirror_size) != TESTvalue && isa_readb(shmem - 2 * mirror_size) == TESTvalue) mirror_size *= 2; first_mirror = last_mirror = shmem; while (isa_readb(first_mirror) == TESTvalue) first_mirror -= mirror_size; first_mirror += mirror_size; while (isa_readb(last_mirror) == TESTvalue) last_mirror += mirror_size; last_mirror -= mirror_size; dev->mem_start = first_mirror; dev->mem_end = last_mirror + MIRROR_SIZE - 1; dev->rmem_start = dev->mem_start + BUFFER_SIZE * 0; dev->rmem_end = dev->mem_start + BUFFER_SIZE * 2 - 1; /* Initialize the rest of the device structure. */ memset(lp, 0, sizeof(struct arcnet_local)); lp->card_name = "COM90xx"; lp->hw.command = com90xx_command; lp->hw.status = com90xx_status; lp->hw.intmask = com90xx_setmask; lp->hw.reset = com90xx_reset; lp->hw.open_close = com90xx_openclose; lp->hw.copy_to_card = com90xx_copy_to_card; lp->hw.copy_from_card = com90xx_copy_from_card; lp->mem_start = ioremap(dev->mem_start, dev->mem_end - dev->mem_start + 1); if (!lp->mem_start) { BUGMSG(D_NORMAL, "Can't remap device memory!\n"); goto err_free_dev_priv; } /* Fill in the fields of the device structure with generic values. */ arcdev_setup(dev); /* get and check the station ID from offset 1 in shmem */ dev->dev_addr[0] = readb(lp->mem_start + 1); /* reserve the irq */ if (request_irq(airq, &arcnet_interrupt, 0, "arcnet (90xx)", dev)) { BUGMSG(D_NORMAL, "Can't get IRQ %d!\n", airq); goto err_unmap; } dev->irq = airq; /* reserve the I/O and memory regions - guaranteed to work by check_region */ request_region(ioaddr, ARCNET_TOTAL_SIZE, "arcnet (90xx)"); request_mem_region(dev->mem_start, dev->mem_end - dev->mem_start + 1, "arcnet (90xx)"); dev->base_addr = ioaddr; BUGMSG(D_NORMAL, "COM90xx station %02Xh found at %03lXh, IRQ %d, " "ShMem %lXh (%ld*%xh).\n", dev->dev_addr[0], dev->base_addr, dev->irq, dev->mem_start, (dev->mem_end - dev->mem_start + 1) / mirror_size, mirror_size); if (!dev0 && register_netdev(dev)) goto err_release; cards[numcards++] = dev; return 0; err_release: free_irq(dev->irq, dev); release_region(dev->base_addr, ARCNET_TOTAL_SIZE); release_mem_region(dev->mem_start, dev->mem_end - dev->mem_start + 1); err_unmap: iounmap(lp->mem_start); err_free_dev_priv: kfree(dev->priv); err_free_dev: if (!dev0) kfree(dev); return -EIO; }