这篇教程C++ spin_lock_init函数代码示例写得很实用,希望能帮到您。
本文整理汇总了C++中spin_lock_init函数的典型用法代码示例。如果您正苦于以下问题:C++ spin_lock_init函数的具体用法?C++ spin_lock_init怎么用?C++ spin_lock_init使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。 在下文中一共展示了spin_lock_init函数的25个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。 示例1: n_hdlc_buf_list_init/** * n_hdlc_buf_list_init - initialize specified HDLC buffer list * @list - pointer to buffer list */static void n_hdlc_buf_list_init(struct n_hdlc_buf_list *list){ memset(list, 0, sizeof(*list)); spin_lock_init(&list->spinlock);} /* end of n_hdlc_buf_list_init() */
开发者ID:33d,项目名称:linux-2.6.21-hh20,代码行数:9,
示例2: GobiUSBNetProbe//.........这里部分代码省略.........#if (LINUX_VERSION_CODE >= KERNEL_VERSION( 2,6,19 )) pIntf->needs_remote_wakeup = 1;#endif#if (LINUX_VERSION_CODE > KERNEL_VERSION( 2,6,23 )) pDev = usb_get_intfdata( pIntf );#else pDev = (struct usbnet *)pIntf->dev.platform_data;#endif if (pDev == NULL || pDev->net == NULL) { DBG( "failed to get netdevice/n" ); usbnet_disconnect( pIntf ); kfree( pEndpoints ); return -ENXIO; } pGobiDev = kmalloc( sizeof( sGobiUSBNet ), GFP_KERNEL ); if (pGobiDev == NULL) { DBG( "falied to allocate device buffers" ); usbnet_disconnect( pIntf ); kfree( pEndpoints ); return -ENOMEM; } pDev->data[0] = (unsigned long)pGobiDev; pGobiDev->mpNetDev = pDev; pGobiDev->mpEndpoints = pEndpoints; // Overload PM related network functions#if (LINUX_VERSION_CODE < KERNEL_VERSION( 2,6,29 )) pGobiDev->mpUSBNetOpen = pDev->net->open; pDev->net->open = GobiUSBNetOpen; pGobiDev->mpUSBNetStop = pDev->net->stop; pDev->net->stop = GobiUSBNetStop; pDev->net->hard_start_xmit = GobiUSBNetStartXmit; pDev->net->tx_timeout = GobiUSBNetTXTimeout;#else pNetDevOps = kmalloc( sizeof( struct net_device_ops ), GFP_KERNEL ); if (pNetDevOps == NULL) { DBG( "falied to allocate net device ops" ); usbnet_disconnect( pIntf ); return -ENOMEM; } memcpy( pNetDevOps, pDev->net->netdev_ops, sizeof( struct net_device_ops ) ); pGobiDev->mpUSBNetOpen = pNetDevOps->ndo_open; pNetDevOps->ndo_open = GobiUSBNetOpen; pGobiDev->mpUSBNetStop = pNetDevOps->ndo_stop; pNetDevOps->ndo_stop = GobiUSBNetStop; pNetDevOps->ndo_start_xmit = GobiUSBNetStartXmit; pNetDevOps->ndo_tx_timeout = GobiUSBNetTXTimeout; pDev->net->netdev_ops = pNetDevOps;#endif#if (LINUX_VERSION_CODE < KERNEL_VERSION( 2,6,31 )) memset( &(pGobiDev->mpNetDev->stats), 0, sizeof( struct net_device_stats ) );#else memset( &(pGobiDev->mpNetDev->net->stats), 0, sizeof( struct net_device_stats ) );#endif pGobiDev->mpIntf = pIntf; memset( &(pGobiDev->mMEID), '0', 14 ); DBG( "Mac Address:/n" ); PrintHex( &pGobiDev->mpNetDev->net->dev_addr[0], 6 ); pGobiDev->mbQMIValid = false; memset( &pGobiDev->mQMIDev, 0, sizeof( sQMIDev ) ); pGobiDev->mQMIDev.mbCdevIsInitialized = false; pGobiDev->mQMIDev.mpDevClass = gpClass; init_completion( &pGobiDev->mAutoPM.mThreadDoWork ); spin_lock_init( &pGobiDev->mQMIDev.mClientMemLock ); // Default to device down pGobiDev->mDownReason = 0; GobiSetDownReason( pGobiDev, NO_NDIS_CONNECTION ); GobiSetDownReason( pGobiDev, NET_IFACE_STOPPED ); // Register QMI status = RegisterQMIDevice( pGobiDev ); if (status != 0) { // usbnet_disconnect() will call GobiNetDriverUnbind() which will call // DeregisterQMIDevice() to clean up any partially created QMI device usbnet_disconnect( pIntf ); return status; } // Success return 0;}
开发者ID:ckkeo,项目名称:gobi-drivers,代码行数:101,
示例3: kingsun_probestatic int kingsun_probe(struct usb_interface *intf, const struct usb_device_id *id){ struct usb_host_interface *interface; struct usb_endpoint_descriptor *endpoint; struct usb_device *dev = interface_to_usbdev(intf); struct kingsun_cb *kingsun = NULL; struct net_device *net = NULL; int ret = -ENOMEM; int pipe, maxp_in, maxp_out; __u8 ep_in; __u8 ep_out; interface = intf->cur_altsetting; if (interface->desc.bNumEndpoints != 2) { err("kingsun-sir: expected 2 endpoints, found %d", interface->desc.bNumEndpoints); return -ENODEV; } endpoint = &interface->endpoint[KINGSUN_EP_IN].desc; if (!usb_endpoint_is_int_in(endpoint)) { err("kingsun-sir: endpoint 0 is not interrupt IN"); return -ENODEV; } ep_in = endpoint->bEndpointAddress; pipe = usb_rcvintpipe(dev, ep_in); maxp_in = usb_maxpacket(dev, pipe, usb_pipeout(pipe)); if (maxp_in > 255 || maxp_in <= 1) { err("%s: endpoint 0 has max packet size %d not in range", __FILE__, maxp_in); return -ENODEV; } endpoint = &interface->endpoint[KINGSUN_EP_OUT].desc; if (!usb_endpoint_is_int_out(endpoint)) { err("kingsun-sir: endpoint 1 is not interrupt OUT"); return -ENODEV; } ep_out = endpoint->bEndpointAddress; pipe = usb_sndintpipe(dev, ep_out); maxp_out = usb_maxpacket(dev, pipe, usb_pipeout(pipe)); net = alloc_irdadev(sizeof(*kingsun)); if(!net) goto err_out1; SET_NETDEV_DEV(net, &intf->dev); kingsun = netdev_priv(net); kingsun->irlap = NULL; kingsun->tx_urb = NULL; kingsun->rx_urb = NULL; kingsun->ep_in = ep_in; kingsun->ep_out = ep_out; kingsun->in_buf = NULL; kingsun->out_buf = NULL; kingsun->max_rx = (__u8)maxp_in; kingsun->max_tx = (__u8)maxp_out; kingsun->netdev = net; kingsun->usbdev = dev; kingsun->rx_buff.in_frame = FALSE; kingsun->rx_buff.state = OUTSIDE_FRAME; kingsun->rx_buff.skb = NULL; kingsun->receiving = 0; spin_lock_init(&kingsun->lock); kingsun->in_buf = kmalloc(kingsun->max_rx, GFP_KERNEL); if (!kingsun->in_buf) goto free_mem; kingsun->out_buf = kmalloc(KINGSUN_FIFO_SIZE, GFP_KERNEL); if (!kingsun->out_buf) goto free_mem; printk(KERN_INFO "KingSun/DonShine IRDA/USB found at address %d, " "Vendor: %x, Product: %x/n", dev->devnum, le16_to_cpu(dev->descriptor.idVendor), le16_to_cpu(dev->descriptor.idProduct)); irda_init_max_qos_capabilies(&kingsun->qos); kingsun->qos.baud_rate.bits &= IR_9600; kingsun->qos.min_turn_time.bits &= KINGSUN_MTT; irda_qos_bits_to_value(&kingsun->qos); net->netdev_ops = &kingsun_ops; ret = register_netdev(net); if (ret != 0) goto free_mem; dev_info(&net->dev, "IrDA: Registered KingSun/DonShine device %s/n",//.........这里部分代码省略.........
开发者ID:DirtyDroidX,项目名称:android_kernel_htc_m8ul,代码行数:101,
示例4: drm_gem_open/** * Called at device open time, sets up the structure for handling refcounting * of mm objects. */voiddrm_gem_open(struct drm_device *dev, struct drm_file *file_private){ idr_init(&file_private->object_idr); spin_lock_init(&file_private->table_lock);}
开发者ID:alessandroste,项目名称:testBSP,代码行数:10,
示例5: advdrv_init_one/** * advdrv_init_one - Pnp to initialize the device, and allocate resource for the device. * * @dev: Points to the pci_dev device * @ent: Points to pci_device_id including the device info. */static INT32S __devinit advdrv_init_one(struct pci_dev *dev, const struct pci_device_id *ent){ private_data *privdata = NULL; struct semaphore *dio_sema = NULL; adv_device *device = NULL; INT32S ret; if ((ret = pci_enable_device(dev)) != 0) { KdPrint("pci_enable_device failed/n"); return ret; } /* allocate urb sema */ dio_sema = kmalloc(sizeof(struct semaphore), GFP_KERNEL); if (dio_sema == NULL) { return -ENOMEM; } init_MUTEX(dio_sema); /* initialize & zero the device structure */ device = (adv_device *) kmalloc(sizeof(adv_device), GFP_KERNEL); if (device == NULL) { KdPrint("Could not kmalloc space for device!"); kfree(dio_sema); return -ENOMEM; } memset(device, 0, sizeof(adv_device)); /* alloc & initialize the private data structure */ privdata = kmalloc(sizeof(private_data), GFP_KERNEL); if (!privdata) { kfree(device); kfree(dio_sema); return -ENOMEM; } memset(privdata, 0, sizeof(private_data)); privdata->pci_slot = PCI_SLOT(dev->devfn); privdata->pci_bus = dev->bus->number; privdata->device_type = dev->device; /* multi-card support for new driver */ privdata->irq = dev->irq; privdata->dio_sema = dio_sema; printk(KERN_ERR "privdata->device = 0x%x/n", dev->device); switch (privdata->device_type) { case PCI1761: case PCI1762: case MIC3761: privdata->iobase = dev->resource[2].start & ~1UL; privdata->iolength = dev->resource[2].end - dev->resource[2].start; break; case PCI1763: privdata->iobase = dev->resource[0].start & ~1UL; privdata->iolength = dev->resource[0].end - dev->resource[0].start; break; } adv_process_info_header_init(&privdata->ptr_process_info); init_waitqueue_head(&privdata->event_wait); spin_lock_init(&privdata->spinlock); /* request I/O regions */ if (request_region(privdata->iobase, privdata->iolength, "PCI-1761") == NULL) { kfree(device); kfree(privdata); kfree(dio_sema); KdPrint("Request region failed/n"); return -ENXIO; } /* request irq */ switch (privdata->device_type) { case PCI1761: case PCI1763: case MIC3761: ret = request_irq(privdata->irq, pci1761_interrupt_handler, SA_SHIRQ, "adv1761", privdata); if (ret != 0) { release_region(privdata->iobase, privdata->iolength); kfree(device); kfree(privdata); kfree(dio_sema); KdPrint("Request IRQ failed/n"); return ret; } break; case PCI1762: ret = request_irq(privdata->irq, pci1762_interrupt_handler,//.........这里部分代码省略.........
开发者ID:rct225,项目名称:scanside,代码行数:101,
示例6: pm8xxx_vib_probestatic int __devinit pm8xxx_vib_probe(struct platform_device *pdev){ const struct pm8xxx_vibrator_platform_data *pdata = pdev->dev.platform_data; struct pm8xxx_vib *vib; u8 val; int rc; if (!pdata) return -EINVAL; if (pdata->level_mV < VIB_MIN_LEVEL_mV || pdata->level_mV > VIB_MAX_LEVEL_mV) return -EINVAL; vib = kzalloc(sizeof(*vib), GFP_KERNEL); if (!vib) return -ENOMEM; vib->pdata = pdata; vib->level = pdata->level_mV / 100; vib->dev = &pdev->dev;#ifdef CONFIG_LGE_PMIC8XXX_VIBRATOR_VOL vib->default_level = vib->level; vib->request_level = vib->level;#endif#ifdef CONFIG_LGE_PMIC8XXX_VIBRATOR_MIN_TIMEOUT vib->min_timeout_ms = pdata->min_timeout_ms; vib->pre_value = 0;#endif#ifdef CONFIG_LGE_PMIC8XXX_VIBRATOR_OVERDRIVE vib->overdrive_ms = pdata->overdrive_ms; vib->overdrive_range_ms = pdata->overdrive_range_ms;#endif#ifdef CONFIG_LGE_PMIC8XXX_VIBRATOR_REST_POWER vib->min_stop_ms = pdata->min_stop_ms; vib->start_tv.tv_sec = 0; vib->start_tv.tv_usec = 0; vib->stop_tv.tv_sec = 0; vib->stop_tv.tv_usec = 0;#endif vib->max_level_mv = VIB_MAX_LEVEL_mV; vib->min_level_mv = VIB_MIN_LEVEL_mV; spin_lock_init(&vib->lock); INIT_WORK(&vib->work, pm8xxx_vib_update); hrtimer_init(&vib->vib_timer, CLOCK_MONOTONIC, HRTIMER_MODE_REL); vib->vib_timer.function = pm8xxx_vib_timer_func;#ifdef CONFIG_LGE_PMIC8XXX_VIBRATOR_OVERDRIVE hrtimer_init(&vib->vib_overdrive_timer, CLOCK_MONOTONIC, HRTIMER_MODE_REL); vib->vib_overdrive_timer.function = pm8xxx_vib_overdrive_timer_func;#endif vib->timed_dev.name = "vibrator"; vib->timed_dev.get_time = pm8xxx_vib_get_time; vib->timed_dev.enable = pm8xxx_vib_enable; __dump_vib_regs(vib, "boot_vib_default"); /* * Configure the vibrator, it operates in manual mode * for timed_output framework. */ rc = pm8xxx_vib_read_u8(vib, &val, VIB_DRV); if (rc < 0) goto err_read_vib; val &= ~VIB_DRV_EN_MANUAL_MASK; rc = pm8xxx_vib_write_u8(vib, val, VIB_DRV); if (rc < 0) goto err_read_vib; vib->reg_vib_drv = val; rc = timed_output_dev_register(&vib->timed_dev); if (rc < 0) goto err_read_vib; rc = sysfs_create_group(&vib->timed_dev.dev->kobj, &pm8xxx_vib_attr_group);#if 0#ifdef CONFIG_LGE_PMIC8XXX_VIBRATOR_VOL rc = device_create_file(vib->timed_dev.dev, &dev_attr_amp); if (rc < 0) goto err_read_vib; rc = device_create_file(vib->timed_dev.dev, &dev_attr_default_level); if (rc < 0) goto err_read_vib;#endif// //.........这里部分代码省略.........
开发者ID:Rondeau7,项目名称:android_kernel_lge_msm8960,代码行数:101,
示例7: gmc_v9_0_sw_initstatic int gmc_v9_0_sw_init(void *handle){ int r; int dma_bits; struct amdgpu_device *adev = (struct amdgpu_device *)handle; gfxhub_v1_0_init(adev); mmhub_v1_0_init(adev); spin_lock_init(&adev->gmc.invalidate_lock); adev->gmc.vram_type = amdgpu_atomfirmware_get_vram_type(adev); switch (adev->asic_type) { case CHIP_RAVEN: if (adev->rev_id == 0x0 || adev->rev_id == 0x1) { amdgpu_vm_adjust_size(adev, 256 * 1024, 9, 3, 48); } else { /* vm_size is 128TB + 512GB for legacy 3-level page support */ amdgpu_vm_adjust_size(adev, 128 * 1024 + 512, 9, 2, 48); adev->gmc.translate_further = adev->vm_manager.num_level > 1; } break; case CHIP_VEGA10: case CHIP_VEGA12: case CHIP_VEGA20: /* * To fulfill 4-level page support, * vm size is 256TB (48bit), maximum size of Vega10, * block size 512 (9bit) */ amdgpu_vm_adjust_size(adev, 256 * 1024, 9, 3, 48); break; default: break; } /* This interrupt is VMC page fault.*/ r = amdgpu_irq_add_id(adev, SOC15_IH_CLIENTID_VMC, VMC_1_0__SRCID__VM_FAULT, &adev->gmc.vm_fault); r = amdgpu_irq_add_id(adev, SOC15_IH_CLIENTID_UTCL2, UTCL2_1_0__SRCID__FAULT, &adev->gmc.vm_fault); if (r) return r; /* Set the internal MC address mask * This is the max address of the GPU's * internal address space. */ adev->gmc.mc_mask = 0xffffffffffffULL; /* 48 bit MC */ /* set DMA mask + need_dma32 flags. * PCIE - can handle 44-bits. * IGP - can handle 44-bits * PCI - dma32 for legacy pci gart, 44 bits on vega10 */ adev->need_dma32 = false; dma_bits = adev->need_dma32 ? 32 : 44; r = pci_set_dma_mask(adev->pdev, DMA_BIT_MASK(dma_bits)); if (r) { adev->need_dma32 = true; dma_bits = 32; printk(KERN_WARNING "amdgpu: No suitable DMA available./n"); } r = pci_set_consistent_dma_mask(adev->pdev, DMA_BIT_MASK(dma_bits)); if (r) { pci_set_consistent_dma_mask(adev->pdev, DMA_BIT_MASK(32)); printk(KERN_WARNING "amdgpu: No coherent DMA available./n"); } adev->need_swiotlb = drm_get_max_iomem() > ((u64)1 << dma_bits); r = gmc_v9_0_mc_init(adev); if (r) return r; adev->gmc.stolen_size = gmc_v9_0_get_vbios_fb_size(adev); /* Memory manager */ r = amdgpu_bo_init(adev); if (r) return r; r = gmc_v9_0_gart_init(adev); if (r) return r; /* * number of VMs * VMID 0 is reserved for System * amdgpu graphics/compute will use VMIDs 1-7 * amdkfd will use VMIDs 8-15 */ adev->vm_manager.id_mgr[AMDGPU_GFXHUB].num_ids = AMDGPU_NUM_OF_VMIDS; adev->vm_manager.id_mgr[AMDGPU_MMHUB].num_ids = AMDGPU_NUM_OF_VMIDS; amdgpu_vm_manager_init(adev); return 0;}
开发者ID:Lyude,项目名称:linux,代码行数:100,
示例8: msm_gemini_core_initvoid msm_gemini_core_init(void){ init_waitqueue_head(&reset_wait); spin_lock_init(&reset_lock);}
开发者ID:Hadramos,项目名称:android_sony_xperiaz_kernel_sources,代码行数:5,
示例9: twl6030_usb_probestatic int twl6030_usb_probe(struct platform_device *pdev){ u32 ret; struct twl6030_usb *twl; int status, err; struct device_node *np = pdev->dev.of_node; struct device *dev = &pdev->dev; struct twl4030_usb_data *pdata = dev_get_platdata(dev); twl = devm_kzalloc(dev, sizeof(*twl), GFP_KERNEL); if (!twl) return -ENOMEM; twl->dev = &pdev->dev; twl->irq1 = platform_get_irq(pdev, 0); twl->irq2 = platform_get_irq(pdev, 1); twl->linkstat = MUSB_UNKNOWN; twl->comparator.set_vbus = twl6030_set_vbus; twl->comparator.start_srp = twl6030_start_srp; ret = omap_usb2_set_comparator(&twl->comparator); if (ret == -ENODEV) { dev_info(&pdev->dev, "phy not ready, deferring probe"); return -EPROBE_DEFER; } if (np) { twl->regulator = "usb"; } else if (pdata) { if (pdata->features & TWL6032_SUBCLASS) twl->regulator = "ldousb"; else twl->regulator = "vusb"; } else { dev_err(&pdev->dev, "twl6030 initialized without pdata/n"); return -EINVAL; } /* init spinlock for workqueue */ spin_lock_init(&twl->lock); err = twl6030_usb_ldo_init(twl); if (err) { dev_err(&pdev->dev, "ldo init failed/n"); return err; } platform_set_drvdata(pdev, twl); if (device_create_file(&pdev->dev, &dev_attr_vbus)) dev_warn(&pdev->dev, "could not create sysfs file/n"); INIT_WORK(&twl->set_vbus_work, otg_set_vbus_work); status = request_threaded_irq(twl->irq1, NULL, twl6030_usbotg_irq, IRQF_TRIGGER_FALLING | IRQF_TRIGGER_RISING | IRQF_ONESHOT, "twl6030_usb", twl); if (status < 0) { dev_err(&pdev->dev, "can't get IRQ %d, err %d/n", twl->irq1, status); device_remove_file(twl->dev, &dev_attr_vbus); return status; } status = request_threaded_irq(twl->irq2, NULL, twl6030_usb_irq, IRQF_TRIGGER_FALLING | IRQF_TRIGGER_RISING | IRQF_ONESHOT, "twl6030_usb", twl); if (status < 0) { dev_err(&pdev->dev, "can't get IRQ %d, err %d/n", twl->irq2, status); free_irq(twl->irq1, twl); device_remove_file(twl->dev, &dev_attr_vbus); return status; } twl->asleep = 0; twl6030_enable_irq(twl); dev_info(&pdev->dev, "Initialized TWL6030 USB module/n"); return 0;}
开发者ID:020gzh,项目名称:linux,代码行数:81,
示例10: ubifs_fill_superstatic int ubifs_fill_super(struct super_block *sb, void *data, int silent){ struct ubi_volume_desc *ubi = sb->s_fs_info; struct ubifs_info *c; struct inode *root; int err; c = kzalloc(sizeof(struct ubifs_info), GFP_KERNEL); if (!c) return -ENOMEM; spin_lock_init(&c->cnt_lock); spin_lock_init(&c->cs_lock); spin_lock_init(&c->buds_lock); spin_lock_init(&c->space_lock); spin_lock_init(&c->orphan_lock); init_rwsem(&c->commit_sem); mutex_init(&c->lp_mutex); mutex_init(&c->tnc_mutex); mutex_init(&c->log_mutex); mutex_init(&c->mst_mutex); mutex_init(&c->umount_mutex); init_waitqueue_head(&c->cmt_wq); c->buds = RB_ROOT; c->old_idx = RB_ROOT; c->size_tree = RB_ROOT; c->orph_tree = RB_ROOT; INIT_LIST_HEAD(&c->infos_list); INIT_LIST_HEAD(&c->idx_gc); INIT_LIST_HEAD(&c->replay_list); INIT_LIST_HEAD(&c->replay_buds); INIT_LIST_HEAD(&c->uncat_list); INIT_LIST_HEAD(&c->empty_list); INIT_LIST_HEAD(&c->freeable_list); INIT_LIST_HEAD(&c->frdi_idx_list); INIT_LIST_HEAD(&c->unclean_leb_list); INIT_LIST_HEAD(&c->old_buds); INIT_LIST_HEAD(&c->orph_list); INIT_LIST_HEAD(&c->orph_new); c->highest_inum = UBIFS_FIRST_INO; c->lhead_lnum = c->ltail_lnum = UBIFS_LOG_LNUM; ubi_get_volume_info(ubi, &c->vi); ubi_get_device_info(c->vi.ubi_num, &c->di); /* Re-open the UBI device in read-write mode */ c->ubi = ubi_open_volume(c->vi.ubi_num, c->vi.vol_id, UBI_READONLY); if (IS_ERR(c->ubi)) { err = PTR_ERR(c->ubi); goto out_free; } c->vfs_sb = sb; sb->s_fs_info = c; sb->s_magic = UBIFS_SUPER_MAGIC; sb->s_blocksize = UBIFS_BLOCK_SIZE; sb->s_blocksize_bits = UBIFS_BLOCK_SHIFT; sb->s_dev = c->vi.cdev; sb->s_maxbytes = c->max_inode_sz = key_max_inode_size(c); if (c->max_inode_sz > MAX_LFS_FILESIZE) sb->s_maxbytes = c->max_inode_sz = MAX_LFS_FILESIZE; if (c->rw_incompat) { ubifs_err("the file-system is not R/W-compatible"); ubifs_msg("on-flash format version is w%d/r%d, but software " "only supports up to version w%d/r%d", c->fmt_version, c->ro_compat_version, UBIFS_FORMAT_VERSION, UBIFS_RO_COMPAT_VERSION); return -EROFS; } mutex_lock(&c->umount_mutex); err = mount_ubifs(c); if (err) { ubifs_assert(err < 0); goto out_unlock; } /* Read the root inode */ root = ubifs_iget(sb, UBIFS_ROOT_INO); if (IS_ERR(root)) { err = PTR_ERR(root); goto out_umount; } sb->s_root = NULL; mutex_unlock(&c->umount_mutex); return 0;out_umount: ubifs_umount(c);out_unlock: mutex_unlock(&c->umount_mutex); ubi_close_volume(c->ubi);out_free: kfree(c); return err;//.........这里部分代码省略.........
开发者ID:kizukukoto,项目名称:WDN900_GPL,代码行数:101,
示例11: msm_i2c_probestatic intmsm_i2c_probe(struct platform_device *pdev){ struct msm_i2c_dev *dev; struct resource *mem, *irq, *ioarea; struct msm_i2c_device_platform_data *pdata = pdev->dev.platform_data; int ret; int fs_div; int hs_div; int i2c_clk, i2c_clock; int clk_ctl; struct clk *clk; printk(KERN_INFO "msm_i2c_probe/n"); /* NOTE: driver uses the static register mapping */ mem = platform_get_resource(pdev, IORESOURCE_MEM, 0); if (!mem) { dev_err(&pdev->dev, "no mem resource?/n"); return -ENODEV; } irq = platform_get_resource(pdev, IORESOURCE_IRQ, 0); if (!irq) { dev_err(&pdev->dev, "no irq resource?/n"); return -ENODEV; } ioarea = request_mem_region(mem->start, (mem->end - mem->start) + 1, pdev->name); if (!ioarea) { dev_err(&pdev->dev, "I2C region already claimed/n"); return -EBUSY; } clk = clk_get(&pdev->dev, "i2c_clk"); if (IS_ERR(clk)) { dev_err(&pdev->dev, "Could not get clock/n"); ret = PTR_ERR(clk); goto err_clk_get_failed; } dev = kzalloc(sizeof(struct msm_i2c_dev), GFP_KERNEL); if (!dev) { ret = -ENOMEM; goto err_alloc_dev_failed; } dev->dev = &pdev->dev; dev->irq = irq->start; dev->clk = clk; dev->base = ioremap(mem->start, (mem->end - mem->start) + 1); if (!dev->base) { ret = -ENOMEM; goto err_ioremap_failed; } spin_lock_init(&dev->lock); wake_lock_init(&dev->wakelock, WAKE_LOCK_SUSPEND, "i2c"); platform_set_drvdata(pdev, dev); if (pdata) { dev->clk_drv_str = pdata->clock_strength; dev->dat_drv_str = pdata->data_strength; if (pdata->i2c_clock < 100000 || pdata->i2c_clock > 400000) i2c_clock = 100000; else i2c_clock = pdata->i2c_clock; if(pdata->reset_slave) dev->reset_slave = pdata->reset_slave; } else { dev->clk_drv_str = 0; dev->dat_drv_str = 0; i2c_clock = 100000; dev->skip_recover = 1; } if (!dev->skip_recover) msm_set_i2c_mux(false, NULL, NULL, dev->clk_drv_str, dev->dat_drv_str); clk_enable(clk); /* I2C_HS_CLK = I2C_CLK/(3*(HS_DIVIDER_VALUE+1) */ /* I2C_FS_CLK = I2C_CLK/(2*(FS_DIVIDER_VALUE+3) */ /* FS_DIVIDER_VALUE = ((I2C_CLK / I2C_FS_CLK) / 2) - 3 */ i2c_clk = 19200000; /* input clock */ fs_div = ((i2c_clk / i2c_clock) / 2) - 3; hs_div = 3; clk_ctl = ((hs_div & 0x7) << 8) | (fs_div & 0xff); writel(clk_ctl, dev->base + I2C_CLK_CTL); printk(KERN_INFO "msm_i2c_probe: clk_ctl %x, %d Hz/n", clk_ctl, i2c_clk / (2 * ((clk_ctl & 0xff) + 3))); clk_disable(clk); i2c_set_adapdata(&dev->adapter, dev); dev->adapter.algo = &msm_i2c_algo; strncpy(dev->adapter.name, "MSM I2C adapter", sizeof(dev->adapter.name));//.........这里部分代码省略.........
开发者ID:vpaull,项目名称:2.6.35-photonic-kernel,代码行数:101,
示例12: s3c_pcm_dev_probestatic __devinit int s3c_pcm_dev_probe(struct platform_device *pdev){ struct s3c_pcm_info *pcm; struct resource *mem_res, *dmatx_res, *dmarx_res; struct s3c_audio_pdata *pcm_pdata; int ret; /* Check for valid device index */ if ((pdev->id < 0) || pdev->id >= ARRAY_SIZE(s3c_pcm)) { dev_err(&pdev->dev, "id %d out of range/n", pdev->id); return -EINVAL; } pcm_pdata = pdev->dev.platform_data; /* Check for availability of necessary resource */ dmatx_res = platform_get_resource(pdev, IORESOURCE_DMA, 0); if (!dmatx_res) { dev_err(&pdev->dev, "Unable to get PCM-TX dma resource/n"); return -ENXIO; } dmarx_res = platform_get_resource(pdev, IORESOURCE_DMA, 1); if (!dmarx_res) { dev_err(&pdev->dev, "Unable to get PCM-RX dma resource/n"); return -ENXIO; } mem_res = platform_get_resource(pdev, IORESOURCE_MEM, 0); if (!mem_res) { dev_err(&pdev->dev, "Unable to get register resource/n"); return -ENXIO; } if (pcm_pdata && pcm_pdata->cfg_gpio && pcm_pdata->cfg_gpio(pdev)) { dev_err(&pdev->dev, "Unable to configure gpio/n"); return -EINVAL; } pcm = &s3c_pcm[pdev->id]; pcm->dev = &pdev->dev; spin_lock_init(&pcm->lock); /* Default is 128fs */ pcm->sclk_per_fs = 128; pcm->cclk = clk_get(&pdev->dev, "audio-bus"); if (IS_ERR(pcm->cclk)) { dev_err(&pdev->dev, "failed to get audio-bus/n"); ret = PTR_ERR(pcm->cclk); goto err1; } clk_enable(pcm->cclk); /* record our pcm structure for later use in the callbacks */ dev_set_drvdata(&pdev->dev, pcm); if (!request_mem_region(mem_res->start, resource_size(mem_res), "samsung-pcm")) { dev_err(&pdev->dev, "Unable to request register region/n"); ret = -EBUSY; goto err2; } pcm->regs = ioremap(mem_res->start, 0x100); if (pcm->regs == NULL) { dev_err(&pdev->dev, "cannot ioremap registers/n"); ret = -ENXIO; goto err3; } pcm->pclk = clk_get(&pdev->dev, "pcm"); if (IS_ERR(pcm->pclk)) { dev_err(&pdev->dev, "failed to get pcm_clock/n"); ret = -ENOENT; goto err4; } clk_enable(pcm->pclk); ret = snd_soc_register_dai(&pdev->dev, &s3c_pcm_dai[pdev->id]); if (ret != 0) { dev_err(&pdev->dev, "failed to get pcm_clock/n"); goto err5; } s3c_pcm_stereo_in[pdev->id].dma_addr = mem_res->start + S3C_PCM_RXFIFO; s3c_pcm_stereo_out[pdev->id].dma_addr = mem_res->start + S3C_PCM_TXFIFO; s3c_pcm_stereo_in[pdev->id].channel = dmarx_res->start; s3c_pcm_stereo_out[pdev->id].channel = dmatx_res->start; pcm->dma_capture = &s3c_pcm_stereo_in[pdev->id]; pcm->dma_playback = &s3c_pcm_stereo_out[pdev->id]; return 0;err5://.........这里部分代码省略.........
开发者ID:Adjustxx,项目名称:Savaged-Zen,代码行数:101,
示例13: sys_timer_createasmlinkage longsys_timer_create(const clockid_t which_clock, struct sigevent __user *timer_event_spec, timer_t __user * created_timer_id){ int error = 0; struct k_itimer *new_timer = NULL; int new_timer_id; struct task_struct *process = NULL; unsigned long flags; sigevent_t event; int it_id_set = IT_ID_NOT_SET; if (invalid_clockid(which_clock)) return -EINVAL; new_timer = alloc_posix_timer(); if (unlikely(!new_timer)) return -EAGAIN; spin_lock_init(&new_timer->it_lock); retry: if (unlikely(!idr_pre_get(&posix_timers_id, GFP_KERNEL))) { error = -EAGAIN; goto out; } spin_lock_irq(&idr_lock); error = idr_get_new(&posix_timers_id, (void *) new_timer, &new_timer_id); spin_unlock_irq(&idr_lock); if (error == -EAGAIN) goto retry; else if (error) { /* * Wierd looking, but we return EAGAIN if the IDR is * full (proper POSIX return value for this) */ error = -EAGAIN; goto out; } it_id_set = IT_ID_SET; new_timer->it_id = (timer_t) new_timer_id; new_timer->it_clock = which_clock; new_timer->it_overrun = -1; error = CLOCK_DISPATCH(which_clock, timer_create, (new_timer)); if (error) goto out; /* * return the timer_id now. The next step is hard to * back out if there is an error. */ if (copy_to_user(created_timer_id, &new_timer_id, sizeof (new_timer_id))) { error = -EFAULT; goto out; } if (timer_event_spec) { if (copy_from_user(&event, timer_event_spec, sizeof (event))) { error = -EFAULT; goto out; } new_timer->it_sigev_notify = event.sigev_notify; new_timer->it_sigev_signo = event.sigev_signo; new_timer->it_sigev_value = event.sigev_value; read_lock(&tasklist_lock); if ((process = good_sigevent(&event))) { /* * We may be setting up this process for another * thread. It may be exiting. To catch this * case the we check the PF_EXITING flag. If * the flag is not set, the siglock will catch * him before it is too late (in exit_itimers). * * The exec case is a bit more invloved but easy * to code. If the process is in our thread * group (and it must be or we would not allow * it here) and is doing an exec, it will cause * us to be killed. In this case it will wait * for us to die which means we can finish this * linkage with our last gasp. I.e. no code :) */ spin_lock_irqsave(&process->sighand->siglock, flags); if (!(process->flags & PF_EXITING)) { new_timer->it_process = process; list_add(&new_timer->list, &process->signal->posix_timers); if (new_timer->it_sigev_notify == (SIGEV_SIGNAL|SIGEV_THREAD_ID)) get_task_struct(process); spin_unlock_irqrestore(&process->sighand->siglock, flags); } else { spin_unlock_irqrestore(&process->sighand->siglock, flags); process = NULL; } } read_unlock(&tasklist_lock); if (!process) { error = -EINVAL;//.........这里部分代码省略.........
开发者ID:acassis,项目名称:emlinux-ssd1935,代码行数:101,
示例14: nozomi_card_init/* Allocate memory for one device */static int nozomi_card_init(struct pci_dev *pdev, const struct pci_device_id *ent){ resource_size_t start; int ret; struct nozomi *dc = NULL; int ndev_idx; int i; dev_dbg(&pdev->dev, "Init, new card found/n"); for (ndev_idx = 0; ndev_idx < ARRAY_SIZE(ndevs); ndev_idx++) if (!ndevs[ndev_idx]) break; if (ndev_idx >= ARRAY_SIZE(ndevs)) { dev_err(&pdev->dev, "no free tty range for this card left/n"); ret = -EIO; goto err; } dc = kzalloc(sizeof(struct nozomi), GFP_KERNEL); if (unlikely(!dc)) { dev_err(&pdev->dev, "Could not allocate memory/n"); ret = -ENOMEM; goto err_free; } dc->pdev = pdev; ret = pci_enable_device(dc->pdev); if (ret) { dev_err(&pdev->dev, "Failed to enable PCI Device/n"); goto err_free; } ret = pci_request_regions(dc->pdev, NOZOMI_NAME); if (ret) { dev_err(&pdev->dev, "I/O address 0x%04x already in use/n", (int) /* nozomi_private.io_addr */ 0); goto err_disable_device; } start = pci_resource_start(dc->pdev, 0); if (start == 0) { dev_err(&pdev->dev, "No I/O address for card detected/n"); ret = -ENODEV; goto err_rel_regs; } /* Find out what card type it is */ nozomi_get_card_type(dc); dc->base_addr = ioremap_nocache(start, dc->card_type); if (!dc->base_addr) { dev_err(&pdev->dev, "Unable to map card MMIO/n"); ret = -ENODEV; goto err_rel_regs; } dc->send_buf = kmalloc(SEND_BUF_MAX, GFP_KERNEL); if (!dc->send_buf) { dev_err(&pdev->dev, "Could not allocate send buffer?/n"); ret = -ENOMEM; goto err_free_sbuf; } for (i = PORT_MDM; i < MAX_PORT; i++) { if (kfifo_alloc(&dc->port[i].fifo_ul, FIFO_BUFFER_SIZE_UL, GFP_KERNEL)) { dev_err(&pdev->dev, "Could not allocate kfifo buffer/n"); ret = -ENOMEM; goto err_free_kfifo; } } spin_lock_init(&dc->spin_mutex); nozomi_setup_private_data(dc); /* Disable all interrupts */ dc->last_ier = 0; writew(dc->last_ier, dc->reg_ier); ret = request_irq(pdev->irq, &interrupt_handler, IRQF_SHARED, NOZOMI_NAME, dc); if (unlikely(ret)) { dev_err(&pdev->dev, "can't request irq %d/n", pdev->irq); goto err_free_kfifo; } DBG1("base_addr: %p", dc->base_addr); make_sysfs_files(dc); dc->index_start = ndev_idx * MAX_PORT; ndevs[ndev_idx] = dc;//.........这里部分代码省略.........
开发者ID:AlexShiLucky,项目名称:linux,代码行数:101,
示例15: gtm_probestatic int __devinit gtm_probe(struct of_device *dev, const struct of_device_id *match){ struct device_node *np = dev->node; struct resource res; int ret = 0; u32 busfreq = fsl_get_sys_freq(); struct gtm_priv *priv; if (busfreq == 0) { dev_err(&dev->dev, "gtm: No bus frequency in device tree./n"); return -ENODEV; } priv = kmalloc(sizeof(struct gtm_priv), GFP_KERNEL); if (!priv) return -ENOMEM; spin_lock_init(&priv->lock); dev_set_drvdata(&dev->dev, priv); ret = of_address_to_resource(np, 0, &res); if (ret) goto out; priv->irq = irq_of_parse_and_map(np, 0); if (priv->irq == NO_IRQ) { dev_err(&dev->dev, "mpc83xx-gtm exists in device tree " "without an IRQ./n"); ret = -ENODEV; goto out; } ret = request_irq(priv->irq, fsl_gtm_isr, 0, "gtm timer", priv); if (ret) goto out; priv->regs = ioremap(res.start, sizeof(struct gtm_regs)); if (!priv->regs) { ret = -ENOMEM; goto out; } /* Disable the unused clocks to save power. */ out_8(&priv->regs->cfr1, CFR1_STP1 | CFR1_STP2); out_8(&priv->regs->cfr2, CFR2_STP3 | CFR2_STP4); /* * Maximum prescaling is used (input clock/16, 256 primary prescaler, * 256 secondary prescaler) to maximize the timer's range. With a * bus clock of 133MHz, this yields a maximum interval of 516 * seconds while retaining subsecond precision. Since only * timer 4 is supported for wakeup on the 8313, and timer 4 * is the LSB when chained, we can't use chaining to increase * the range. */ priv->ticks_per_sec = busfreq / (16*256*256); ret = device_create_file(&dev->dev, &dev_attr_timeout); if (ret) goto out; return 0;out: kfree(priv); return ret;}
开发者ID:kierank,项目名称:p2-kernel,代码行数:68,
示例16: rio_probe1static intrio_probe1 (struct pci_dev *pdev, const struct pci_device_id *ent){ struct net_device *dev; struct netdev_private *np; static int card_idx; int chip_idx = ent->driver_data; int err, irq; void __iomem *ioaddr; static int version_printed; void *ring_space; dma_addr_t ring_dma; if (!version_printed++) printk ("%s", version); err = pci_enable_device (pdev); if (err) return err; irq = pdev->irq; err = pci_request_regions (pdev, "dl2k"); if (err) goto err_out_disable; pci_set_master (pdev); err = -ENOMEM; dev = alloc_etherdev (sizeof (*np)); if (!dev) goto err_out_res; SET_NETDEV_DEV(dev, &pdev->dev); np = netdev_priv(dev); /* IO registers range. */ ioaddr = pci_iomap(pdev, 0, 0); if (!ioaddr) goto err_out_dev; np->eeprom_addr = ioaddr;#ifdef MEM_MAPPING /* MM registers range. */ ioaddr = pci_iomap(pdev, 1, 0); if (!ioaddr) goto err_out_iounmap;#endif np->ioaddr = ioaddr; np->chip_id = chip_idx; np->pdev = pdev; spin_lock_init (&np->tx_lock); spin_lock_init (&np->rx_lock); /* Parse manual configuration */ np->an_enable = 1; np->tx_coalesce = 1; if (card_idx < MAX_UNITS) { if (media[card_idx] != NULL) { np->an_enable = 0; if (strcmp (media[card_idx], "auto") == 0 || strcmp (media[card_idx], "autosense") == 0 || strcmp (media[card_idx], "0") == 0 ) { np->an_enable = 2; } else if (strcmp (media[card_idx], "100mbps_fd") == 0 || strcmp (media[card_idx], "4") == 0) { np->speed = 100; np->full_duplex = 1; } else if (strcmp (media[card_idx], "100mbps_hd") == 0 || strcmp (media[card_idx], "3") == 0) { np->speed = 100; np->full_duplex = 0; } else if (strcmp (media[card_idx], "10mbps_fd") == 0 || strcmp (media[card_idx], "2") == 0) { np->speed = 10; np->full_duplex = 1; } else if (strcmp (media[card_idx], "10mbps_hd") == 0 || strcmp (media[card_idx], "1") == 0) { np->speed = 10; np->full_duplex = 0; } else if (strcmp (media[card_idx], "1000mbps_fd") == 0 || strcmp (media[card_idx], "6") == 0) { np->speed=1000; np->full_duplex=1; } else if (strcmp (media[card_idx], "1000mbps_hd") == 0 || strcmp (media[card_idx], "5") == 0) { np->speed = 1000; np->full_duplex = 0; } else { np->an_enable = 1; } } if (jumbo[card_idx] != 0) { np->jumbo = 1; dev->mtu = MAX_JUMBO; } else { np->jumbo = 0; if (mtu[card_idx] > 0 && mtu[card_idx] < PACKET_SIZE) dev->mtu = mtu[card_idx]; }//.........这里部分代码省略.........
开发者ID:AshishNamdev,项目名称:linux,代码行数:101,
示例17: rt2x00lib_probe_dev/* * driver allocation handlers. */int rt2x00lib_probe_dev(struct rt2x00_dev *rt2x00dev){ int retval = -ENOMEM; /* * Allocate the driver data memory, if necessary. */ if (rt2x00dev->ops->drv_data_size > 0) { rt2x00dev->drv_data = kzalloc(rt2x00dev->ops->drv_data_size, GFP_KERNEL); if (!rt2x00dev->drv_data) { retval = -ENOMEM; goto exit; } } spin_lock_init(&rt2x00dev->irqmask_lock); mutex_init(&rt2x00dev->csr_mutex); set_bit(DEVICE_STATE_PRESENT, &rt2x00dev->flags); /* * Make room for rt2x00_intf inside the per-interface * structure ieee80211_vif. */ rt2x00dev->hw->vif_data_size = sizeof(struct rt2x00_intf); /* * Determine which operating modes are supported, all modes * which require beaconing, depend on the availability of * beacon entries. */ rt2x00dev->hw->wiphy->interface_modes = BIT(NL80211_IFTYPE_STATION); if (rt2x00dev->ops->bcn->entry_num > 0) rt2x00dev->hw->wiphy->interface_modes |= BIT(NL80211_IFTYPE_ADHOC) | BIT(NL80211_IFTYPE_AP) | BIT(NL80211_IFTYPE_MESH_POINT) | BIT(NL80211_IFTYPE_WDS); rt2x00dev->hw->wiphy->flags |= WIPHY_FLAG_IBSS_RSN; /* * Initialize work. */ rt2x00dev->workqueue = alloc_ordered_workqueue(wiphy_name(rt2x00dev->hw->wiphy), 0); if (!rt2x00dev->workqueue) { retval = -ENOMEM; goto exit; } INIT_WORK(&rt2x00dev->intf_work, rt2x00lib_intf_scheduled); INIT_DELAYED_WORK(&rt2x00dev->autowakeup_work, rt2x00lib_autowakeup); INIT_WORK(&rt2x00dev->sleep_work, rt2x00lib_sleep); /* * Let the driver probe the device to detect the capabilities. */ retval = rt2x00dev->ops->lib->probe_hw(rt2x00dev); if (retval) { ERROR(rt2x00dev, "Failed to allocate device./n"); goto exit; } /* * Allocate queue array. */ retval = rt2x00queue_allocate(rt2x00dev); if (retval) goto exit; /* * Initialize ieee80211 structure. */ retval = rt2x00lib_probe_hw(rt2x00dev); if (retval) { ERROR(rt2x00dev, "Failed to initialize hw./n"); goto exit; } /* * Register extra components. */ rt2x00link_register(rt2x00dev); rt2x00leds_register(rt2x00dev); rt2x00debug_register(rt2x00dev); rt2x00rfkill_register(rt2x00dev); return 0;exit: rt2x00lib_remove_dev(rt2x00dev); return retval;}
开发者ID:Componentality,项目名称:openwrt-compat-wireless,代码行数:99,
示例18: max14688_probestatic __devinit int max14688_probe (struct i2c_client *client, const struct i2c_device_id *id){ struct max14688_platform_data *pdata = client->dev.platform_data; struct max14688 *me; u8 chip_id, chip_rev; int i, rc; u8 pincontrol2 = 0; log_dbg(MAX14688_NAME" attached/n"); log_dbg("wake_lock_init/n"); wake_lock_init(&ear_key_wake_lock, WAKE_LOCK_SUSPEND, "ear_key"); me = kzalloc(sizeof(struct max14688), GFP_KERNEL); if (me == NULL) { log_err("Failed to allloate headset per device info/n"); return -ENOMEM; } if (client->dev.of_node) { pdata = devm_kzalloc(&client->dev, sizeof(struct max14688_platform_data), GFP_KERNEL); if (unlikely(!pdata)) { log_err("out of memory (%uB requested)/n", sizeof(struct max14688_platform_data)); return -ENOMEM; } client->dev.platform_data = pdata; max14688_parse_dt(&client->dev, pdata); } else { pdata = devm_kzalloc(&client->dev, sizeof(struct max14688_platform_data), GFP_KERNEL); if (unlikely(!pdata)) { log_err("out of memory (%uB requested)/n", sizeof(struct max14688_platform_data)); return -ENOMEM; } else { pdata = client->dev.platform_data; } } i2c_set_clientdata(client, me); spin_lock_init(&me->irq_lock); mutex_init(&me->lock); me->dev = &client->dev; me->kobj = &client->dev.kobj; me->irq = -1; me->gpio_int = pdata->gpio_int; me->gpio_detect = pdata->gpio_detect; INIT_DELAYED_WORK(&me->irq_work, max14688_irq_work); INIT_DELAYED_WORK(&me->det_work, max14688_det_work);#ifdef I2C_SUSPEND_WORKAROUND INIT_DELAYED_WORK(&me->check_suspended_work, max14688_check_suspended_worker);#endif rc = gpio_request(me->gpio_detect, MAX14688_NAME"-detect"); if (unlikely(rc)) { return rc; } rc = gpio_direction_input(me->gpio_detect); if (rc < 0) { log_err("Failed to configure gpio%d (me->gpio_detect) gpio_direction_input/n", me->gpio_detect); gpio_free(me->gpio_detect); return rc; } rc = gpio_request(me->gpio_int, MAX14688_NAME"-irq"); if (unlikely(rc)) { return rc; } rc = gpio_direction_input(me->gpio_int); if (rc < 0) { log_err("Failed to configure gpio%d (me->gpio_int) gpio_direction_input/n", me->gpio_int); gpio_free(me->gpio_int); return rc; } me->irq = gpio_to_irq(me->gpio_int); /* Save jack lookup table given via platform data */ me->jack_matches = pdata->jack_matches; me->num_of_jack_matches = pdata->num_of_jack_matches; /* Save button lookup table given via platform data */ me->button_matches = pdata->button_matches; me->num_of_button_matches = pdata->num_of_button_matches; me->matched_jack = -1; me->matched_button = -1; /* Platform-specific Calls */ me->detect_jack = pdata->detect_jack; me->read_mic_impedence = pdata->read_mic_impedence; me->read_left_impedence = pdata->read_left_impedence; me->report_jack = pdata->report_jack; me->report_button = pdata->report_button;//.........这里部分代码省略.........
开发者ID:adyjl,项目名称:DORIMANX_LG_STOCK_LP_KERNEL,代码行数:101,
示例19: gpio_keys_setup_keystatic int __devinit gpio_keys_setup_key(struct platform_device *pdev, struct input_dev *input, struct gpio_button_data *bdata, struct gpio_keys_button *button){ const char *desc = button->desc ? button->desc : "gpio_keys"; struct device *dev = &pdev->dev; irq_handler_t isr; unsigned long irqflags; int irq, error; bdata->input = input; bdata->button = button; spin_lock_init(&bdata->lock); if (gpio_is_valid(button->gpio)) { error = gpio_request(button->gpio, desc); if (error < 0) { dev_err(dev, "Failed to request GPIO %d, error %d/n", button->gpio, error); return error; } error = gpio_direction_input(button->gpio); if (error < 0) { dev_err(dev, "Failed to configure direction for GPIO %d, error %d/n", button->gpio, error); goto fail; } if (button->debounce_interval) { error = gpio_set_debounce(button->gpio, button->debounce_interval * 1000); /* use timer if gpiolib doesn't provide debounce */ if (error < 0) bdata->timer_debounce = button->debounce_interval; } irq = gpio_to_irq(button->gpio); if (irq < 0) { error = irq; dev_err(dev, "Unable to get irq number for GPIO %d, error %d/n", button->gpio, error); goto fail; } bdata->irq = irq; INIT_WORK(&bdata->work, gpio_keys_gpio_work_func); setup_timer(&bdata->timer, gpio_keys_gpio_timer, (unsigned long)bdata); isr = gpio_keys_gpio_isr; irqflags = IRQF_TRIGGER_RISING | IRQF_TRIGGER_FALLING; } else { if (!button->irq) { dev_err(dev, "No IRQ specified/n"); return -EINVAL; } bdata->irq = button->irq; if (button->type && button->type != EV_KEY) { dev_err(dev, "Only EV_KEY allowed for IRQ buttons./n"); return -EINVAL; } bdata->timer_debounce = button->debounce_interval; setup_timer(&bdata->timer, gpio_keys_irq_timer, (unsigned long)bdata); isr = gpio_keys_irq_isr; irqflags = 0; } input_set_capability(input, button->type ?: EV_KEY, button->code); /* * If platform has specified that the button can be disabled, * we don't want it to share the interrupt line. */ if (!button->can_disable) irqflags |= IRQF_SHARED; if (button->wakeup) irqflags |= IRQF_NO_SUSPEND; error = request_any_context_irq(bdata->irq, isr, irqflags, desc, bdata); if (error < 0) { dev_err(dev, "Unable to claim irq %d; error %d/n", bdata->irq, error); goto fail; } return 0;fail://.........这里部分代码省略.........
开发者ID:arshull,项目名称:halaszk-UNIVERSAL5420,代码行数:101,
示例20: p54p_probestatic int __devinit p54p_probe(struct pci_dev *pdev, const struct pci_device_id *id){ struct p54p_priv *priv; struct ieee80211_hw *dev; unsigned long mem_addr, mem_len; int err; err = pci_enable_device(pdev); if (err) { dev_err(&pdev->dev, "Cannot enable new PCI device/n"); return err; } mem_addr = pci_resource_start(pdev, 0); mem_len = pci_resource_len(pdev, 0); if (mem_len < sizeof(struct p54p_csr)) { dev_err(&pdev->dev, "Too short PCI resources/n"); goto err_disable_dev; } err = pci_request_regions(pdev, "p54pci"); if (err) { dev_err(&pdev->dev, "Cannot obtain PCI resources/n"); goto err_disable_dev; } if (pci_set_dma_mask(pdev, DMA_BIT_MASK(32)) || pci_set_consistent_dma_mask(pdev, DMA_BIT_MASK(32))) { dev_err(&pdev->dev, "No suitable DMA available/n"); goto err_free_reg; } pci_set_master(pdev); pci_try_set_mwi(pdev); pci_write_config_byte(pdev, 0x40, 0); pci_write_config_byte(pdev, 0x41, 0); dev = p54_init_common(sizeof(*priv)); if (!dev) { dev_err(&pdev->dev, "ieee80211 alloc failed/n"); err = -ENOMEM; goto err_free_reg; } priv = dev->priv; priv->pdev = pdev; SET_IEEE80211_DEV(dev, &pdev->dev); pci_set_drvdata(pdev, dev); priv->map = ioremap(mem_addr, mem_len); if (!priv->map) { dev_err(&pdev->dev, "Cannot map device memory/n"); err = -ENOMEM; goto err_free_dev; } priv->ring_control = pci_alloc_consistent(pdev, sizeof(*priv->ring_control), &priv->ring_control_dma); if (!priv->ring_control) { dev_err(&pdev->dev, "Cannot allocate rings/n"); err = -ENOMEM; goto err_iounmap; } priv->common.open = p54p_open; priv->common.stop = p54p_stop; priv->common.tx = p54p_tx; spin_lock_init(&priv->lock); tasklet_init(&priv->tasklet, p54p_tasklet, (unsigned long)dev); err = request_firmware(&priv->firmware, "isl3886pci", &priv->pdev->dev); if (err) { dev_err(&pdev->dev, "Cannot find firmware (isl3886pci)/n"); err = request_firmware(&priv->firmware, "isl3886", &priv->pdev->dev); if (err) goto err_free_common; } err = p54p_open(dev); if (err) goto err_free_common; err = p54_read_eeprom(dev); p54p_stop(dev); if (err) goto err_free_common; err = p54_register_common(dev, &pdev->dev); if (err) goto err_free_common; return 0; err_free_common: release_firmware(priv->firmware); pci_free_consistent(pdev, sizeof(*priv->ring_control),//.........这里部分代码省略.........
开发者ID:5ha5hank,项目名称:tera-compat-wireless,代码行数:101,
示例21: nwpserial_register_portint nwpserial_register_port(struct uart_port *port){ struct nwpserial_port *up = NULL; int ret = -1; int i; static int first = 1; int dcr_len; int dcr_base; struct device_node *dn; mutex_lock(&nwpserial_mutex); dn = port->dev->of_node; if (dn == NULL) goto out; /* get dcr base. */ dcr_base = dcr_resource_start(dn, 0); /* find matching entry */ for (i = 0; i < NWPSERIAL_NR; i++) if (nwpserial_ports[i].port.iobase == dcr_base) { up = &nwpserial_ports[i]; break; } /* we didn't find a mtching entry, search for a free port */ if (up == NULL) for (i = 0; i < NWPSERIAL_NR; i++) if (nwpserial_ports[i].port.type == PORT_UNKNOWN && nwpserial_ports[i].port.iobase == 0) { up = &nwpserial_ports[i]; break; } if (up == NULL) { ret = -EBUSY; goto out; } if (first) uart_register_driver(&nwpserial_reg); first = 0; up->port.membase = port->membase; up->port.irq = port->irq; up->port.uartclk = port->uartclk; up->port.fifosize = port->fifosize; up->port.regshift = port->regshift; up->port.iotype = port->iotype; up->port.flags = port->flags; up->port.mapbase = port->mapbase; up->port.private_data = port->private_data; if (port->dev) up->port.dev = port->dev; if (up->port.iobase != dcr_base) { up->port.ops = &nwpserial_pops; up->port.fifosize = 16; spin_lock_init(&up->port.lock); up->port.iobase = dcr_base; dcr_len = dcr_resource_len(dn, 0); up->dcr_host = dcr_map(dn, dcr_base, dcr_len); if (!DCR_MAP_OK(up->dcr_host)) { printk(KERN_ERR "Cannot map DCR resources for NWPSERIAL"); goto out; } } ret = uart_add_one_port(&nwpserial_reg, &up->port); if (ret == 0) ret = up->port.line;out: mutex_unlock(&nwpserial_mutex); return ret;}
开发者ID:7799,项目名称:linux,代码行数:82,
示例22: cypress_probe//.........这里部分代码省略......... (endpoint->bEndpointAddress & USB_DIR_IN) && ((endpoint->bmAttributes & USB_ENDPOINT_XFERTYPE_MASK) == USB_ENDPOINT_XFER_BULK) ) { /* we found a bulk in endpoint */ buffer_size = endpoint->wMaxPacketSize; dev->bulk_in_size = buffer_size; dev->bulk_in_endpointAddr = endpoint->bEndpointAddress; dev->read_urb = usb_alloc_urb(0, GFP_ATOMIC); if( dev->read_urb == NULL ) { printk("No free urbs available"); goto error; } dev->read_urb->transfer_flags = (URB_NO_TRANSFER_DMA_MAP); dev->bulk_in_buffer = usb_alloc_coherent (udev, buffer_size, GFP_ATOMIC, &dev->read_urb->transfer_dma); if( dev->bulk_in_buffer == NULL ) { printk("Couldn't allocate bulk_in_buffer"); goto error; } usb_fill_bulk_urb(dev->read_urb, udev, usb_rcvbulkpipe(udev, endpoint->bEndpointAddress), dev->bulk_in_buffer, buffer_size, (usb_complete_t)cypress_read_bulk_callback, dev); } if( !dev->bulk_out_endpointAddr && !(endpoint->bEndpointAddress & USB_DIR_IN) && ((endpoint->bmAttributes & USB_ENDPOINT_XFERTYPE_MASK) == USB_ENDPOINT_XFER_BULK) ) { /* we found a bulk out endpoint */ /* a probe() may sleep and has no restrictions on memory allocations */ dev->write_urb = usb_alloc_urb(0, GFP_ATOMIC); if( dev->write_urb == NULL ) { printk("No free urbs available"); goto error; } dev->bulk_out_endpointAddr = endpoint->bEndpointAddress; /* on some platforms using this kind of buffer alloc * call eliminates a dma "bounce buffer". * * NOTE: you'd normally want i/o buffers that hold * more than one packet, so that i/o delays between * packets don't hurt throughput. */ buffer_size = endpoint->wMaxPacketSize; dev->bulk_out_size = buffer_size; dev->write_urb->transfer_flags = (URB_NO_TRANSFER_DMA_MAP); dev->bulk_out_buffer = usb_alloc_coherent (udev, buffer_size, GFP_ATOMIC, &dev->write_urb->transfer_dma); if( dev->bulk_out_buffer == NULL ) { printk("Couldn't allocate bulk_out_buffer"); goto error; } usb_fill_bulk_urb(dev->write_urb, udev, usb_sndbulkpipe(udev, endpoint->bEndpointAddress), dev->bulk_out_buffer, buffer_size, (usb_complete_t)cypress_write_bulk_callback, dev); } } if (!(dev->bulk_in_endpointAddr && dev->bulk_out_endpointAddr)) { printk("Couldn't find both bulk-in and bulk-out endpoints"); goto error; } dev->present = 1; /* allow device read, write and ioctl */ usb_set_intfdata (interface, dev); /* we can register the device now, as it is ready */ spin_lock_init(&(dev->lock)); /* initialize spinlock to unlocked (new kerenel method) */ /* HK: Begin- connect filesystem hooks */ /* we can register the device now, as it is ready */ retval = usb_register_dev(interface, &cypress_class); if (retval) { /* something prevented us from registering this driver */ printk("Not able to get a minor for this device."); usb_set_intfdata(interface, NULL); goto error; } dev_info(&interface->dev, "BRL USB device now attached to minor: %d/n", interface->minor); /* let the user know the device minor */ dev->read_task = NULL; /* Initialize fs read_task. */ addNode(dev); return 0; error: // please please please remove goto statements! HK:Why? printk("cypress_probe: error occured!/n"); cypress_delete (dev); return retval;}
开发者ID:iitbombay,项目名称:usb-board-driver,代码行数:101,
示例23: GobiUSBNetOpen/*===========================================================================METHOD: GobiUSBNetOpen (Public Method)DESCRIPTION: Wrapper to usbnet_open, correctly handling autosuspend Start AutoPM threadPARAMETERS pNet [ I ] - Pointer to net deviceRETURN VALUE: int - 0 for success Negative errno for error===========================================================================*/int GobiUSBNetOpen( struct net_device * pNet ){ int status = 0; struct sGobiUSBNet * pGobiDev; struct usbnet * pDev = netdev_priv( pNet ); if (pDev == NULL) { DBG( "failed to get usbnet device/n" ); return -ENXIO; } pGobiDev = (sGobiUSBNet *)pDev->data[0]; if (pGobiDev == NULL) { DBG( "failed to get QMIDevice/n" ); return -ENXIO; } DBG( "/n" ); // Start the AutoPM thread pGobiDev->mAutoPM.mpIntf = pGobiDev->mpIntf; pGobiDev->mAutoPM.mbExit = false; pGobiDev->mAutoPM.mpURBList = NULL; pGobiDev->mAutoPM.mpActiveURB = NULL; spin_lock_init( &pGobiDev->mAutoPM.mURBListLock ); spin_lock_init( &pGobiDev->mAutoPM.mActiveURBLock ); init_completion( &pGobiDev->mAutoPM.mThreadDoWork ); pGobiDev->mAutoPM.mpThread = kthread_run( GobiUSBNetAutoPMThread, &pGobiDev->mAutoPM, "GobiUSBNetAutoPMThread" ); if (IS_ERR( pGobiDev->mAutoPM.mpThread )) { DBG( "AutoPM thread creation error/n" ); return PTR_ERR( pGobiDev->mAutoPM.mpThread ); } // Allow traffic GobiClearDownReason( pGobiDev, NET_IFACE_STOPPED ); // Pass to usbnet_open if defined if (pGobiDev->mpUSBNetOpen != NULL) { status = pGobiDev->mpUSBNetOpen( pNet ); // If usbnet_open was successful enable Auto PM if (status == 0) {#if (LINUX_VERSION_CODE < KERNEL_VERSION( 2,6,33 )) usb_autopm_enable( pGobiDev->mpIntf );#else usb_autopm_put_interface( pGobiDev->mpIntf );#endif } } else { DBG( "no USBNetOpen defined/n" ); } return status;}
开发者ID:ckkeo,项目名称:gobi-drivers,代码行数:79,
示例24: snd_bcm2835_playback_open/* open callback */static int snd_bcm2835_playback_open(struct snd_pcm_substream *substream){ bcm2835_chip_t *chip = snd_pcm_substream_chip(substream); struct snd_pcm_runtime *runtime = substream->runtime; bcm2835_alsa_stream_t *alsa_stream; int idx; int err; audio_info(" .. IN (%d)/n", substream->number); audio_info("Alsa open (%d)/n", substream->number); idx = substream->number; if (idx > MAX_SUBSTREAMS) { audio_error ("substream(%d) device doesn't exist max(%d) substreams allowed/n", idx, MAX_SUBSTREAMS); err = -ENODEV; goto out; } /* Check if we are ready */ if (!(chip->avail_substreams & (1 << idx))) { /* We are not ready yet */ audio_error("substream(%d) device is not ready yet/n", idx); err = -EAGAIN; goto out; } alsa_stream = kzalloc(sizeof(bcm2835_alsa_stream_t), GFP_KERNEL); if (alsa_stream == NULL) { return -ENOMEM; } /* Initialise alsa_stream */ alsa_stream->chip = chip; alsa_stream->substream = substream; alsa_stream->idx = idx; chip->alsa_stream[idx] = alsa_stream; sema_init(&alsa_stream->buffers_update_sem, 0); sema_init(&alsa_stream->control_sem, 0); spin_lock_init(&alsa_stream->lock); /* Enabled in start trigger, called on each "fifo irq" after that */ alsa_stream->enable_fifo_irq = 0; alsa_stream->fifo_irq_handler = bcm2835_playback_fifo_irq; runtime->private_data = alsa_stream; runtime->private_free = snd_bcm2835_playback_free; runtime->hw = snd_bcm2835_playback_hw; /* minimum 16 bytes alignment (for vchiq bulk transfers) */ snd_pcm_hw_constraint_step(runtime, 0, SNDRV_PCM_HW_PARAM_PERIOD_BYTES, 16); err = bcm2835_audio_open(alsa_stream); if (err != 0) { kfree(alsa_stream); return err; } alsa_stream->open = 1; alsa_stream->draining = 1;out: audio_info(" .. OUT =%d/n", err); return err;}
开发者ID:markosilla,项目名称:linux-raspberry,代码行数:70,
示例25: nfp_flower_initstatic int nfp_flower_init(struct nfp_app *app){ const struct nfp_pf *pf = app->pf; struct nfp_flower_priv *app_priv; u64 version, features; int err; if (!pf->eth_tbl) { nfp_warn(app->cpp, "FlowerNIC requires eth table/n"); return -EINVAL; } if (!pf->mac_stats_bar) { nfp_warn(app->cpp, "FlowerNIC requires mac_stats BAR/n"); return -EINVAL; } if (!pf->vf_cfg_bar) { nfp_warn(app->cpp, "FlowerNIC requires vf_cfg BAR/n"); return -EINVAL; } version = nfp_rtsym_read_le(app->pf->rtbl, "hw_flower_version", &err); if (err) { nfp_warn(app->cpp, "FlowerNIC requires hw_flower_version memory symbol/n"); return err; } /* We need to ensure hardware has enough flower capabilities. */ if (version != NFP_FLOWER_ALLOWED_VER) { nfp_warn(app->cpp, "FlowerNIC: unsupported firmware version/n"); return -EINVAL; } app_priv = vzalloc(sizeof(struct nfp_flower_priv)); if (!app_priv) return -ENOMEM; app->priv = app_priv; app_priv->app = app; skb_queue_head_init(&app_priv->cmsg_skbs_high); skb_queue_head_init(&app_priv->cmsg_skbs_low); INIT_WORK(&app_priv->cmsg_work, nfp_flower_cmsg_process_rx); init_waitqueue_head(&app_priv->reify_wait_queue); init_waitqueue_head(&app_priv->mtu_conf.wait_q); spin_lock_init(&app_priv->mtu_conf.lock); err = nfp_flower_metadata_init(app); if (err) goto err_free_app_priv; /* Extract the extra features supported by the firmware. */ features = nfp_rtsym_read_le(app->pf->rtbl, "_abi_flower_extra_features", &err); if (err) app_priv->flower_ext_feats = 0; else app_priv->flower_ext_feats = features; /* Tell the firmware that the driver supports lag. */ err = nfp_rtsym_write_le(app->pf->rtbl, "_abi_flower_balance_sync_enable", 1); if (!err) { app_priv->flower_ext_feats |= NFP_FL_FEATS_LAG; nfp_flower_lag_init(&app_priv->nfp_lag); } else if (err == -ENOENT) { nfp_warn(app->cpp, "LAG not supported by FW./n"); } else { goto err_cleanup_metadata; } return 0;err_cleanup_metadata: nfp_flower_metadata_cleanup(app);err_free_app_priv: vfree(app->priv); return err;}
开发者ID:krzk,项目名称:linux,代码行数:80,
注:本文中的spin_lock_init函数示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 C++ spin_lock_irq函数代码示例 C++ spin_lock_bh函数代码示例 |