这篇教程C++ uninitialized_var函数代码示例写得很实用,希望能帮到您。
本文整理汇总了C++中uninitialized_var函数的典型用法代码示例。如果您正苦于以下问题:C++ uninitialized_var函数的具体用法?C++ uninitialized_var怎么用?C++ uninitialized_var使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。 在下文中一共展示了uninitialized_var函数的24个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。 示例1: nvidia_force_enable_hpetstatic void nvidia_force_enable_hpet(struct pci_dev *dev){ u32 uninitialized_var(val); if (hpet_address || force_hpet_address) return; if (!hpet_force_user) { hpet_print_force_info(); return; } pci_write_config_dword(dev, 0x44, 0xfed00001); pci_read_config_dword(dev, 0x44, &val); force_hpet_address = val & 0xfffffffe; force_hpet_resume_type = NVIDIA_FORCE_HPET_RESUME; dev_printk(KERN_DEBUG, &dev->dev, "Force enabled HPET at 0x%lx/n", force_hpet_address); cached_dev = dev; return;}
开发者ID:TheDarkCode,项目名称:linux,代码行数:21,
示例2: old_ich_force_hpet_resumestatic void old_ich_force_hpet_resume(void){ u32 val; u32 uninitialized_var(gen_cntl); if (!force_hpet_address || !cached_dev) return; pci_read_config_dword(cached_dev, 0xD0, &gen_cntl); gen_cntl &= (~(0x7 << 15)); gen_cntl |= (0x4 << 15); pci_write_config_dword(cached_dev, 0xD0, gen_cntl); pci_read_config_dword(cached_dev, 0xD0, &gen_cntl); val = gen_cntl >> 15; val &= 0x7; if (val == 0x4) printk(KERN_DEBUG "Force enabled HPET at resume/n"); else BUG();}
开发者ID:TheDarkCode,项目名称:linux,代码行数:21,
示例3: twl4030_poweroffvoid twl4030_poweroff(void){ u8 uninitialized_var(val); int err; /* Make sure SEQ_OFFSYNC is set so that all the res goes to wait-on */ err = twl_i2c_read_u8(TWL4030_MODULE_PM_MASTER, &val, CFG_P123_TRANSITION); if (err) { pr_warning("I2C error %d while reading TWL4030 PM_MASTER CFG_P123_TRANSITION/n", err); return; } val |= SEQ_OFFSYNC; err = twl_i2c_write_u8(TWL4030_MODULE_PM_MASTER, val, CFG_P123_TRANSITION); if (err) { pr_warning("I2C error %d while writing TWL4030 PM_MASTER CFG_P123_TRANSITION/n", err); return; } err = twl_i2c_read_u8(TWL4030_MODULE_PM_MASTER, &val, PWR_P1_SW_EVENTS); if (err) { pr_warning("I2C error %d while reading TWL4030 PM_MASTER P1_SW_EVENTS/n", err); return; } val |= PWR_STOPON_POWERON | PWR_DEVOFF; err = twl_i2c_write_u8(TWL4030_MODULE_PM_MASTER, val, PWR_P1_SW_EVENTS); if (err) { pr_warning("I2C error %d while writing TWL4030 PM_MASTER P1_SW_EVENTS/n", err); return; } return;}
开发者ID:kpykc,项目名称:ARDrone2.0,代码行数:40,
示例4: is_fpga_tiostatic int is_fpga_tio(int nasid, int *bt){ u16 uninitialized_var(ioboard_type); /* GCC be quiet */ long rc; rc = ia64_sn_sysctl_ioboard_get(nasid, &ioboard_type); if (rc) { printk(KERN_WARNING "ia64_sn_sysctl_ioboard_get failed: %ld/n", rc); return 0; } switch (ioboard_type) { case L1_BRICKTYPE_SA: case L1_BRICKTYPE_ATHENA: case L1_BOARDTYPE_DAYTONA: *bt = ioboard_type; return 1; } return 0;}
开发者ID:erik96,项目名称:Samsung-Galaxy-S-Plus,代码行数:22,
示例5: twl4030_button_stop_off_enablestatic int twl4030_button_stop_off_enable(void){ int err = 0; u8 uninitialized_var(rd_data); err = twl4030_i2c_write_u8(TWL4030_MODULE_PM_MASTER, TWL4030_LOCK_KEY_1, R_PROTECT_KEY); if (err) { pr_warning("twl4030: %s unable to unlock PROTECT_KEY 1, %x/n",__FUNCTION__,TWL4030_LOCK_KEY_1); return err; } err = twl4030_i2c_write_u8(TWL4030_MODULE_PM_MASTER, TWL4030_LOCK_KEY_2, R_PROTECT_KEY); if (err) { pr_warning("twl4030: %s unable to unlock PROTECT_KEY 2, %x/n",__FUNCTION__,TWL4030_LOCK_KEY_2); return err; } err |= twl4030_i2c_read_u8(TWL4030_MODULE_PM_MASTER, &rd_data, PWR_P1_SW_EVENTS); rd_data |= STOPON_PWRON; err |= twl4030_i2c_write_u8(TWL4030_MODULE_PM_MASTER, rd_data, PWR_P1_SW_EVENTS);#if 0 err |= twl4030_i2c_read_u8(TWL4030_MODULE_PM_MASTER, &rd_data, PWR_P2_SW_EVENTS); rd_data |= STOPON_PWRON; err |= twl4030_i2c_write_u8(TWL4030_MODULE_PM_MASTER, rd_data, PWR_P2_SW_EVENTS); err |= twl4030_i2c_read_u8(TWL4030_MODULE_PM_MASTER, &rd_data, PWR_P3_SW_EVENTS); rd_data |= STOPON_PWRON; err |= twl4030_i2c_write_u8(TWL4030_MODULE_PM_MASTER, rd_data, PWR_P3_SW_EVENTS);#endif err |= twl4030_i2c_write_u8(TWL4030_MODULE_PM_MASTER, 0, R_PROTECT_KEY); if (err) printk(KERN_ERR "TWL4030 button off config error/n"); return err;}
开发者ID:madcat207,项目名称:Quickie,代码行数:38,
示例6: twl6030_poweroffstatic void twl6030_poweroff(void){ u8 uninitialized_var(val); int err; err = twl_i2c_read_u8(TWL6030_MODULE_ID0, &val, TWL6030_PHOENIX_DEV_ON); if (err) { pr_warning("I2C error %d reading PHONIX_DEV_ON/n", err); return; } val |= APP_DEVOFF | CON_DEVOFF | MOD_DEVOFF; err = twl_i2c_write_u8(TWL6030_MODULE_ID0, val, TWL6030_PHOENIX_DEV_ON); if (err) { pr_warning("I2C error %d writing PHONIX_DEV_ON/n", err); return; } return;}
开发者ID:mik9,项目名称:android_kernel_acclaim,代码行数:24,
示例7: __nand_calculate_ecc/** * __nand_calculate_ecc - [NAND Interface] Calculate 3-byte ECC for 256/512-byte * block * @buf: input buffer with raw data * @eccsize: data bytes per ECC step (256 or 512) * @code: output buffer with ECC */void __nand_calculate_ecc(const unsigned char *buf, unsigned int eccsize, unsigned char *code){ int i; const uint32_t *bp = (uint32_t *)buf; /* 256 or 512 bytes/ecc */ const uint32_t eccsize_mult = eccsize >> 8; uint32_t cur; /* current value in buffer */ /* rp0..rp15..rp17 are the various accumulated parities (per byte) */ uint32_t rp0, rp1, rp2, rp3, rp4, rp5, rp6, rp7; uint32_t rp8, rp9, rp10, rp11, rp12, rp13, rp14, rp15, rp16; uint32_t uninitialized_var(rp17); /* to make compiler happy */ uint32_t par; /* the cumulative parity for all data */ uint32_t tmppar; /* the cumulative parity for this iteration; for rp12, rp14 and rp16 at the end of the loop */ par = 0; rp4 = 0; rp6 = 0; rp8 = 0; rp10 = 0; rp12 = 0; rp14 = 0; rp16 = 0; /* * The loop is unrolled a number of times; * This avoids if statements to decide on which rp value to update * Also we process the data by longwords. * Note: passing unaligned data might give a performance penalty. * It is assumed that the buffers are aligned. * tmppar is the cumulative sum of this iteration. * needed for calculating rp12, rp14, rp16 and par * also used as a performance improvement for rp6, rp8 and rp10 */ for (i = 0; i < eccsize_mult << 2; i++) { cur = *bp++; tmppar = cur; rp4 ^= cur; cur = *bp++; tmppar ^= cur; rp6 ^= tmppar; cur = *bp++; tmppar ^= cur; rp4 ^= cur; cur = *bp++; tmppar ^= cur; rp8 ^= tmppar; cur = *bp++; tmppar ^= cur; rp4 ^= cur; rp6 ^= cur; cur = *bp++; tmppar ^= cur; rp6 ^= cur; cur = *bp++; tmppar ^= cur; rp4 ^= cur; cur = *bp++; tmppar ^= cur; rp10 ^= tmppar; cur = *bp++; tmppar ^= cur; rp4 ^= cur; rp6 ^= cur; rp8 ^= cur; cur = *bp++; tmppar ^= cur; rp6 ^= cur; rp8 ^= cur; cur = *bp++; tmppar ^= cur; rp4 ^= cur; rp8 ^= cur; cur = *bp++; tmppar ^= cur; rp8 ^= cur; cur = *bp++; tmppar ^= cur; rp4 ^= cur; rp6 ^= cur; cur = *bp++; tmppar ^= cur; rp6 ^= cur; cur = *bp++; tmppar ^= cur; rp4 ^= cur; cur = *bp++; tmppar ^= cur;//.........这里部分代码省略.........
开发者ID:darcyg,项目名称:ap_project_v2,代码行数:101,
示例8: af9015_i2c_xferstatic int af9015_i2c_xfer(struct i2c_adapter *adap, struct i2c_msg msg[], int num){ struct dvb_usb_device *d = i2c_get_adapdata(adap); int ret = 0, i = 0; u16 addr; u8 uninitialized_var(mbox), addr_len; struct req_t req;/* TODO: implement bus lockThe bus lock is needed because there is two tuners both using same I2C-address.Due to that the only way to select correct tuner is use demodulator I2C-gate.................................................. AF9015 includes integrated AF9013 demodulator.. ____________ ____________ . ____________.| uC | | demod | . | tuner |.|------------| |------------| . |------------|.| AF9015 | | AF9013/5 | . | MXL5003 |.| |--+----I2C-------|-----/ -----|-.-----I2C-------| |.| | | | addr 0x38 | . | addr 0xc6 |.|____________| | |____________| . |____________|.................|.............................. | ____________ ____________ | | demod | | tuner | | |------------| |------------| | | AF9013 | | MXL5003 | +----I2C-------|-----/ -----|-------I2C-------| | | addr 0x3a | | addr 0xc6 | |____________| |____________|*/ if (mutex_lock_interruptible(&d->i2c_mutex) < 0) return -EAGAIN; while (i < num) { if (msg[i].addr == af9015_af9013_config[0].demod_address || msg[i].addr == af9015_af9013_config[1].demod_address) { addr = msg[i].buf[0] << 8; addr += msg[i].buf[1]; mbox = msg[i].buf[2]; addr_len = 3; } else { addr = msg[i].buf[0]; addr_len = 1; /* mbox is don't care in that case */ } if (num > i + 1 && (msg[i+1].flags & I2C_M_RD)) { if (msg[i].len > 3 || msg[i+1].len > 61) { ret = -EOPNOTSUPP; goto error; } if (msg[i].addr == af9015_af9013_config[0].demod_address) req.cmd = READ_MEMORY; else req.cmd = READ_I2C; req.i2c_addr = msg[i].addr; req.addr = addr; req.mbox = mbox; req.addr_len = addr_len; req.data_len = msg[i+1].len; req.data = &msg[i+1].buf[0]; ret = af9015_ctrl_msg(d, &req); i += 2; } else if (msg[i].flags & I2C_M_RD) { if (msg[i].len > 61) { ret = -EOPNOTSUPP; goto error; } if (msg[i].addr == af9015_af9013_config[0].demod_address) { ret = -EINVAL; goto error; } req.cmd = READ_I2C; req.i2c_addr = msg[i].addr; req.addr = addr; req.mbox = mbox; req.addr_len = addr_len; req.data_len = msg[i].len; req.data = &msg[i].buf[0]; ret = af9015_ctrl_msg(d, &req); i += 1; } else { if (msg[i].len > 21) { ret = -EOPNOTSUPP; goto error; } if (msg[i].addr == af9015_af9013_config[0].demod_address) req.cmd = WRITE_MEMORY; else req.cmd = WRITE_I2C; req.i2c_addr = msg[i].addr; req.addr = addr; req.mbox = mbox; req.addr_len = addr_len; req.data_len = msg[i].len-addr_len;//.........这里部分代码省略.........
开发者ID:beam,项目名称:linux-tbs-drivers,代码行数:101,
示例9: ide_timer_expiryvoid ide_timer_expiry (unsigned long data){ ide_hwif_t *hwif = (ide_hwif_t *)data; ide_drive_t *uninitialized_var(drive); ide_handler_t *handler; unsigned long flags; unsigned long wait = -1; int plug_device = 0; spin_lock_irqsave(&hwif->lock, flags); handler = hwif->handler; if (handler == NULL || hwif->req_gen != hwif->req_gen_timer) { /* * Either a marginal timeout occurred * (got the interrupt just as timer expired), * or we were "sleeping" to give other devices a chance. * Either way, we don't really want to complain about anything. */ } else { ide_expiry_t *expiry = hwif->expiry; ide_startstop_t startstop = ide_stopped; drive = hwif->cur_dev; if (expiry) { wait = expiry(drive); if (wait > 0) { /* continue */ /* reset timer */ hwif->timer.expires = jiffies + wait; hwif->req_gen_timer = hwif->req_gen; add_timer(&hwif->timer); spin_unlock_irqrestore(&hwif->lock, flags); return; } } hwif->handler = NULL; /* * We need to simulate a real interrupt when invoking * the handler() function, which means we need to * globally mask the specific IRQ: */ spin_unlock(&hwif->lock); /* disable_irq_nosync ?? */ disable_irq(hwif->irq); /* local CPU only, as if we were handling an interrupt */ local_irq_disable(); if (hwif->polling) { startstop = handler(drive); } else if (drive_is_ready(drive)) { if (drive->waiting_for_dma) hwif->dma_ops->dma_lost_irq(drive); (void)ide_ack_intr(hwif); printk(KERN_WARNING "%s: lost interrupt/n", drive->name); startstop = handler(drive); } else { if (drive->waiting_for_dma) startstop = ide_dma_timeout_retry(drive, wait); else startstop = ide_error(drive, "irq timeout", hwif->tp_ops->read_status(hwif)); } spin_lock_irq(&hwif->lock); enable_irq(hwif->irq); if (startstop == ide_stopped) { ide_unlock_port(hwif); plug_device = 1; } } spin_unlock_irqrestore(&hwif->lock, flags); if (plug_device) { ide_unlock_host(hwif->host); ide_plug_device(drive); }}
开发者ID:embest-tech,项目名称:rowboat-kernel,代码行数:78,
示例10: xfs_seek_dataSTATIC loff_txfs_seek_data( struct file *file, loff_t start, u32 type){ struct inode *inode = file->f_mapping->host; struct xfs_inode *ip = XFS_I(inode); struct xfs_mount *mp = ip->i_mount; struct xfs_bmbt_irec map[2]; int nmap = 2; loff_t uninitialized_var(offset); xfs_fsize_t isize; xfs_fileoff_t fsbno; xfs_filblks_t end; uint lock; int error; lock = xfs_ilock_map_shared(ip); isize = i_size_read(inode); if (start >= isize) { error = ENXIO; goto out_unlock; } fsbno = XFS_B_TO_FSBT(mp, start); /* * Try to read extents from the first block indicated * by fsbno to the end block of the file. */ end = XFS_B_TO_FSB(mp, isize); error = xfs_bmapi_read(ip, fsbno, end - fsbno, map, &nmap, XFS_BMAPI_ENTIRE); if (error) goto out_unlock; /* * Treat unwritten extent as data extent since it might * contains dirty data in page cache. */ if (map[0].br_startblock != HOLESTARTBLOCK) { offset = max_t(loff_t, start, XFS_FSB_TO_B(mp, map[0].br_startoff)); } else { if (nmap == 1) { error = ENXIO; goto out_unlock; } offset = max_t(loff_t, start, XFS_FSB_TO_B(mp, map[1].br_startoff)); } if (offset != file->f_pos) file->f_pos = offset;out_unlock: xfs_iunlock_map_shared(ip, lock); if (error) return -error; return offset;}
开发者ID:ARMWorks,项目名称:FA_2451_Linux_Kernel,代码行数:66,
示例11: kvmppc_complete_mmio_loadstatic void kvmppc_complete_mmio_load(struct kvm_vcpu *vcpu, struct kvm_run *run){ u64 uninitialized_var(gpr); if (run->mmio.len > sizeof(gpr)) { printk(KERN_ERR "bad MMIO length: %d/n", run->mmio.len); return; } if (vcpu->arch.mmio_is_bigendian) { switch (run->mmio.len) { case 8: gpr = *(u64 *)run->mmio.data; break; case 4: gpr = *(u32 *)run->mmio.data; break; case 2: gpr = *(u16 *)run->mmio.data; break; case 1: gpr = *(u8 *)run->mmio.data; break; } } else { /* Convert BE data from userland back to LE. */ switch (run->mmio.len) { case 4: gpr = ld_le32((u32 *)run->mmio.data); break; case 2: gpr = ld_le16((u16 *)run->mmio.data); break; case 1: gpr = *(u8 *)run->mmio.data; break; } } if (vcpu->arch.mmio_sign_extend) { switch (run->mmio.len) {#ifdef CONFIG_PPC64 case 4: gpr = (s64)(s32)gpr; break;#endif case 2: gpr = (s64)(s16)gpr; break; case 1: gpr = (s64)(s8)gpr; break; } } kvmppc_set_gpr(vcpu, vcpu->arch.io_gpr, gpr); switch (vcpu->arch.io_gpr & KVM_MMIO_REG_EXT_MASK) { case KVM_MMIO_REG_GPR: kvmppc_set_gpr(vcpu, vcpu->arch.io_gpr, gpr); break; case KVM_MMIO_REG_FPR: vcpu->arch.fpr[vcpu->arch.io_gpr & KVM_MMIO_REG_MASK] = gpr; break;#ifdef CONFIG_PPC_BOOK3S case KVM_MMIO_REG_QPR: vcpu->arch.qpr[vcpu->arch.io_gpr & KVM_MMIO_REG_MASK] = gpr; break; case KVM_MMIO_REG_FQPR: vcpu->arch.fpr[vcpu->arch.io_gpr & KVM_MMIO_REG_MASK] = gpr; vcpu->arch.qpr[vcpu->arch.io_gpr & KVM_MMIO_REG_MASK] = gpr; break;#endif default: BUG(); }}
开发者ID:03199618,项目名称:linux,代码行数:64,
示例12: ide_intrirqreturn_t ide_intr (int irq, void *dev_id){ ide_hwif_t *hwif = (ide_hwif_t *)dev_id; ide_drive_t *uninitialized_var(drive); ide_handler_t *handler; unsigned long flags; ide_startstop_t startstop; irqreturn_t irq_ret = IRQ_NONE; int plug_device = 0; if (hwif->host->host_flags & IDE_HFLAG_SERIALIZE) { if (hwif != hwif->host->cur_port) goto out_early; } spin_lock_irqsave(&hwif->lock, flags); if (!ide_ack_intr(hwif)) goto out; handler = hwif->handler; if (handler == NULL || hwif->polling) { /* * Not expecting an interrupt from this drive. * That means this could be: * (1) an interrupt from another PCI device * sharing the same PCI INT# as us. * or (2) a drive just entered sleep or standby mode, * and is interrupting to let us know. * or (3) a spurious interrupt of unknown origin. * * For PCI, we cannot tell the difference, * so in that case we just ignore it and hope it goes away. * * FIXME: unexpected_intr should be hwif-> then we can * remove all the ifdef PCI crap */#ifdef CONFIG_BLK_DEV_IDEPCI if (hwif->chipset != ide_pci)#endif /* CONFIG_BLK_DEV_IDEPCI */ { /* * Probably not a shared PCI interrupt, * so we can safely try to do something about it: */ unexpected_intr(irq, hwif);#ifdef CONFIG_BLK_DEV_IDEPCI } else { /* * Whack the status register, just in case * we have a leftover pending IRQ. */ (void)hwif->tp_ops->read_status(hwif);#endif /* CONFIG_BLK_DEV_IDEPCI */ } goto out; } drive = hwif->cur_dev; if (!drive_is_ready(drive)) /* * This happens regularly when we share a PCI IRQ with * another device. Unfortunately, it can also happen * with some buggy drives that trigger the IRQ before * their status register is up to date. Hopefully we have * enough advance overhead that the latter isn't a problem. */ goto out; hwif->handler = NULL; hwif->req_gen++; del_timer(&hwif->timer); spin_unlock(&hwif->lock); if (hwif->port_ops && hwif->port_ops->clear_irq) hwif->port_ops->clear_irq(drive); if (drive->dev_flags & IDE_DFLAG_UNMASK) local_irq_enable_in_hardirq(); /* service this interrupt, may set handler for next interrupt */ startstop = handler(drive); spin_lock_irq(&hwif->lock); /* * Note that handler() may have set things up for another * interrupt to occur soon, but it cannot happen until * we exit from this routine, because it will be the * same irq as is currently being serviced here, and Linux * won't allow another of the same (on any CPU) until we return. */ if (startstop == ide_stopped) { BUG_ON(hwif->handler); ide_unlock_port(hwif); plug_device = 1; } irq_ret = IRQ_HANDLED;out://.........这里部分代码省略.........
开发者ID:embest-tech,项目名称:rowboat-kernel,代码行数:101,
示例13: _dev_topology_attributestatic unsigned long _dev_topology_attribute(struct dev_types *dt, const char *attribute, struct device *dev, unsigned long default_value){ const char *sysfs_dir = dm_sysfs_dir(); char path[PATH_MAX], buffer[64]; FILE *fp; struct stat info; dev_t uninitialized_var(primary); unsigned long result = default_value; unsigned long value = 0UL; if (!attribute || !*attribute) goto_out; if (!sysfs_dir || !*sysfs_dir) goto_out; if (!_snprintf_attr(path, sizeof(path), sysfs_dir, attribute, dev->dev)) goto_out; /* * check if the desired sysfs attribute exists * - if not: either the kernel doesn't have topology support * or the device could be a partition */ if (stat(path, &info) == -1) { if (errno != ENOENT) { log_sys_debug("stat", path); goto out; } if (!dev_get_primary_dev(dt, dev, &primary)) goto out; /* get attribute from partition's primary device */ if (!_snprintf_attr(path, sizeof(path), sysfs_dir, attribute, primary)) goto_out; if (stat(path, &info) == -1) { if (errno != ENOENT) log_sys_debug("stat", path); goto out; } } if (!(fp = fopen(path, "r"))) { log_sys_debug("fopen", path); goto out; } if (!fgets(buffer, sizeof(buffer), fp)) { log_sys_debug("fgets", path); goto out_close; } if (sscanf(buffer, "%lu", &value) != 1) { log_warn("sysfs file %s not in expected format: %s", path, buffer); goto out_close; } log_very_verbose("Device %s: %s is %lu%s.", dev_name(dev), attribute, result, default_value ? "" : " bytes"); result = value >> SECTOR_SHIFT;out_close: if (fclose(fp)) log_sys_debug("fclose", path);out: return result;}
开发者ID:amyvmiwei,项目名称:bittern,代码行数:73,
示例14: b43legacy_debugfs_readstatic ssize_t b43legacy_debugfs_read(struct file *file, char __user *userbuf, size_t count, loff_t *ppos){ struct b43legacy_wldev *dev; struct b43legacy_debugfs_fops *dfops; struct b43legacy_dfs_file *dfile; ssize_t uninitialized_var(ret); char *buf; const size_t bufsize = 1024 * 16; /* 16 KiB buffer */ const size_t buforder = get_order(bufsize); int err = 0; if (!count) return 0; dev = file->private_data; if (!dev) return -ENODEV; mutex_lock(&dev->wl->mutex); if (b43legacy_status(dev) < B43legacy_STAT_INITIALIZED) { err = -ENODEV; goto out_unlock; } dfops = container_of(file->f_op, struct b43legacy_debugfs_fops, fops); if (!dfops->read) { err = -ENOSYS; goto out_unlock; } dfile = fops_to_dfs_file(dev, dfops); if (!dfile->buffer) { buf = (char *)__get_free_pages(GFP_KERNEL, buforder); if (!buf) { err = -ENOMEM; goto out_unlock; } memset(buf, 0, bufsize); if (dfops->take_irqlock) { spin_lock_irq(&dev->wl->irq_lock); ret = dfops->read(dev, buf, bufsize); spin_unlock_irq(&dev->wl->irq_lock); } else ret = dfops->read(dev, buf, bufsize); if (ret <= 0) { free_pages((unsigned long)buf, buforder); err = ret; goto out_unlock; } dfile->data_len = ret; dfile->buffer = buf; } ret = simple_read_from_buffer(userbuf, count, ppos, dfile->buffer, dfile->data_len); if (*ppos >= dfile->data_len) { free_pages((unsigned long)dfile->buffer, buforder); dfile->buffer = NULL; dfile->data_len = 0; }out_unlock: mutex_unlock(&dev->wl->mutex); return err ? err : ret;}
开发者ID:Core2idiot,项目名称:Kernel-Samsung-3.0...-,代码行数:66,
示例15: ip_hdrstatic struct sock *xt_socket_lookup_slow_v4(struct net *net, const struct sk_buff *skb, const struct net_device *indev){ const struct iphdr *iph = ip_hdr(skb); struct sk_buff *data_skb = NULL; int doff = 0; __be32 uninitialized_var(daddr), uninitialized_var(saddr); __be16 uninitialized_var(dport), uninitialized_var(sport); u8 uninitialized_var(protocol);#ifdef XT_SOCKET_HAVE_CONNTRACK struct nf_conn const *ct; enum ip_conntrack_info ctinfo;#endif if (iph->protocol == IPPROTO_UDP || iph->protocol == IPPROTO_TCP) { struct udphdr _hdr, *hp; hp = skb_header_pointer(skb, ip_hdrlen(skb), sizeof(_hdr), &_hdr); if (hp == NULL) return NULL; protocol = iph->protocol; saddr = iph->saddr; sport = hp->source; daddr = iph->daddr; dport = hp->dest; data_skb = (struct sk_buff *)skb; doff = iph->protocol == IPPROTO_TCP ? ip_hdrlen(skb) + __tcp_hdrlen((struct tcphdr *)hp) : ip_hdrlen(skb) + sizeof(*hp); } else if (iph->protocol == IPPROTO_ICMP) { if (extract_icmp4_fields(skb, &protocol, &saddr, &daddr, &sport, &dport)) return NULL; } else { return NULL; }#ifdef XT_SOCKET_HAVE_CONNTRACK /* Do the lookup with the original socket address in * case this is a reply packet of an established * SNAT-ted connection. */ ct = nf_ct_get(skb, &ctinfo); if (ct && !nf_ct_is_untracked(ct) && ((iph->protocol != IPPROTO_ICMP && ctinfo == IP_CT_ESTABLISHED_REPLY) || (iph->protocol == IPPROTO_ICMP && ctinfo == IP_CT_RELATED_REPLY)) && (ct->status & IPS_SRC_NAT_DONE)) { daddr = ct->tuplehash[IP_CT_DIR_ORIGINAL].tuple.src.u3.ip; dport = (iph->protocol == IPPROTO_TCP) ? ct->tuplehash[IP_CT_DIR_ORIGINAL].tuple.src.u.tcp.port : ct->tuplehash[IP_CT_DIR_ORIGINAL].tuple.src.u.udp.port; }#endif return xt_socket_get_sock_v4(net, data_skb, doff, protocol, saddr, daddr, sport, dport, indev);}
开发者ID:020gzh,项目名称:linux,代码行数:64,
示例16: gfs2_write_cache_jdatastatic int gfs2_write_cache_jdata(struct address_space *mapping, struct writeback_control *wbc){ int ret = 0; int done = 0; struct pagevec pvec; int nr_pages; pgoff_t uninitialized_var(writeback_index); pgoff_t index; pgoff_t end; pgoff_t done_index; int cycled; int range_whole = 0; int tag; pagevec_init(&pvec, 0); if (wbc->range_cyclic) { writeback_index = mapping->writeback_index; /* prev offset */ index = writeback_index; if (index == 0) cycled = 1; else cycled = 0; end = -1; } else { index = wbc->range_start >> PAGE_CACHE_SHIFT; end = wbc->range_end >> PAGE_CACHE_SHIFT; if (wbc->range_start == 0 && wbc->range_end == LLONG_MAX) range_whole = 1; cycled = 1; /* ignore range_cyclic tests */ } if (wbc->sync_mode == WB_SYNC_ALL || wbc->tagged_writepages) tag = PAGECACHE_TAG_TOWRITE; else tag = PAGECACHE_TAG_DIRTY;retry: if (wbc->sync_mode == WB_SYNC_ALL || wbc->tagged_writepages) tag_pages_for_writeback(mapping, index, end); done_index = index; while (!done && (index <= end)) { nr_pages = pagevec_lookup_tag(&pvec, mapping, &index, tag, min(end - index, (pgoff_t)PAGEVEC_SIZE-1) + 1); if (nr_pages == 0) break; ret = gfs2_write_jdata_pagevec(mapping, wbc, &pvec, nr_pages, end, &done_index); if (ret) done = 1; if (ret > 0) ret = 0; pagevec_release(&pvec); cond_resched(); } if (!cycled && !done) { /* * range_cyclic: * We hit the last page and there is more work to be done: wrap * back to the start of the file */ cycled = 1; index = 0; end = writeback_index - 1; goto retry; } if (wbc->range_cyclic || (range_whole && wbc->nr_to_write > 0)) mapping->writeback_index = done_index; return ret;}
开发者ID:hejin,项目名称:kernel-3.10.0-327.13.1.el7.x86_64-fs,代码行数:72,
示例17: socket_mt4_v0static boolsocket_mt4_v0(const struct sk_buff *skb, struct xt_action_param *par){ static struct xt_socket_mtinfo1 xt_info_v0 = { .flags = 0, }; return socket_match(skb, par, &xt_info_v0);}static boolsocket_mt4_v1_v2_v3(const struct sk_buff *skb, struct xt_action_param *par){ return socket_match(skb, par, par->matchinfo);}#ifdef XT_SOCKET_HAVE_IPV6static intextract_icmp6_fields(const struct sk_buff *skb, unsigned int outside_hdrlen, int *protocol, const struct in6_addr **raddr, const struct in6_addr **laddr, __be16 *rport, __be16 *lport, struct ipv6hdr *ipv6_var){ const struct ipv6hdr *inside_iph; struct icmp6hdr *icmph, _icmph; __be16 *ports, _ports[2]; u8 inside_nexthdr; __be16 inside_fragoff; int inside_hdrlen; icmph = skb_header_pointer(skb, outside_hdrlen, sizeof(_icmph), &_icmph); if (icmph == NULL) return 1; if (icmph->icmp6_type & ICMPV6_INFOMSG_MASK) return 1; inside_iph = skb_header_pointer(skb, outside_hdrlen + sizeof(_icmph), sizeof(*ipv6_var), ipv6_var); if (inside_iph == NULL) return 1; inside_nexthdr = inside_iph->nexthdr; inside_hdrlen = ipv6_skip_exthdr(skb, outside_hdrlen + sizeof(_icmph) + sizeof(*ipv6_var), &inside_nexthdr, &inside_fragoff); if (inside_hdrlen < 0) return 1; /* hjm: Packet has no/incomplete transport layer headers. */ if (inside_nexthdr != IPPROTO_TCP && inside_nexthdr != IPPROTO_UDP) return 1; ports = skb_header_pointer(skb, inside_hdrlen, sizeof(_ports), &_ports); if (ports == NULL) return 1; /* the inside IP packet is the one quoted from our side, thus * its saddr is the local address */ *protocol = inside_nexthdr; *laddr = &inside_iph->saddr; *lport = ports[0]; *raddr = &inside_iph->daddr; *rport = ports[1]; return 0;}static struct sock *xt_socket_get_sock_v6(struct net *net, struct sk_buff *skb, int doff, const u8 protocol, const struct in6_addr *saddr, const struct in6_addr *daddr, const __be16 sport, const __be16 dport, const struct net_device *in){ switch (protocol) { case IPPROTO_TCP: return inet6_lookup(net, &tcp_hashinfo, skb, doff, saddr, sport, daddr, dport, in->ifindex); case IPPROTO_UDP: return udp6_lib_lookup(net, saddr, sport, daddr, dport, in->ifindex); } return NULL;}static struct sock *xt_socket_lookup_slow_v6(struct net *net, const struct sk_buff *skb, const struct net_device *indev){ __be16 uninitialized_var(dport), uninitialized_var(sport);//.........这里部分代码省略.........
开发者ID:020gzh,项目名称:linux,代码行数:101,
示例18: xfs_bmap_rtallocintxfs_bmap_rtalloc( struct xfs_bmalloca *ap) /* bmap alloc argument struct */{ xfs_alloctype_t atype = 0; /* type for allocation routines */ int error; /* error return value */ xfs_mount_t *mp; /* mount point structure */ xfs_extlen_t prod = 0; /* product factor for allocators */ xfs_extlen_t ralen = 0; /* realtime allocation length */ xfs_extlen_t align; /* minimum allocation alignment */ xfs_rtblock_t rtb; mp = ap->ip->i_mount; align = xfs_get_extsz_hint(ap->ip); prod = align / mp->m_sb.sb_rextsize; error = xfs_bmap_extsize_align(mp, &ap->got, &ap->prev, align, 1, ap->eof, 0, ap->conv, &ap->offset, &ap->length); if (error) return error; ASSERT(ap->length); ASSERT(ap->length % mp->m_sb.sb_rextsize == 0); /* * If the offset & length are not perfectly aligned * then kill prod, it will just get us in trouble. */ if (do_mod(ap->offset, align) || ap->length % align) prod = 1; /* * Set ralen to be the actual requested length in rtextents. */ ralen = ap->length / mp->m_sb.sb_rextsize; /* * If the old value was close enough to MAXEXTLEN that * we rounded up to it, cut it back so it's valid again. * Note that if it's a really large request (bigger than * MAXEXTLEN), we don't hear about that number, and can't * adjust the starting point to match it. */ if (ralen * mp->m_sb.sb_rextsize >= MAXEXTLEN) ralen = MAXEXTLEN / mp->m_sb.sb_rextsize; /* * Lock out other modifications to the RT bitmap inode. */ xfs_ilock(mp->m_rbmip, XFS_ILOCK_EXCL); xfs_trans_ijoin(ap->tp, mp->m_rbmip, XFS_ILOCK_EXCL); /* * If it's an allocation to an empty file at offset 0, * pick an extent that will space things out in the rt area. */ if (ap->eof && ap->offset == 0) { xfs_rtblock_t uninitialized_var(rtx); /* realtime extent no */ error = xfs_rtpick_extent(mp, ap->tp, ralen, &rtx); if (error) return error; ap->blkno = rtx * mp->m_sb.sb_rextsize; } else { ap->blkno = 0; } xfs_bmap_adjacent(ap); /* * Realtime allocation, done through xfs_rtallocate_extent. */ atype = ap->blkno == 0 ? XFS_ALLOCTYPE_ANY_AG : XFS_ALLOCTYPE_NEAR_BNO; do_div(ap->blkno, mp->m_sb.sb_rextsize); rtb = ap->blkno; ap->length = ralen; if ((error = xfs_rtallocate_extent(ap->tp, ap->blkno, 1, ap->length, &ralen, atype, ap->wasdel, prod, &rtb))) return error; if (rtb == NULLFSBLOCK && prod > 1 && (error = xfs_rtallocate_extent(ap->tp, ap->blkno, 1, ap->length, &ralen, atype, ap->wasdel, 1, &rtb))) return error; ap->blkno = rtb; if (ap->blkno != NULLFSBLOCK) { ap->blkno *= mp->m_sb.sb_rextsize; ralen *= mp->m_sb.sb_rextsize; ap->length = ralen; ap->ip->i_d.di_nblocks += ralen; xfs_trans_log_inode(ap->tp, ap->ip, XFS_ILOG_CORE); if (ap->wasdel) ap->ip->i_delayed_blks -= ralen; /* * Adjust the disk quota also. This was reserved * earlier. */ xfs_trans_mod_dquot_byino(ap->tp, ap->ip, ap->wasdel ? XFS_TRANS_DQ_DELRTBCOUNT : XFS_TRANS_DQ_RTBCOUNT, (long) ralen); } else { ap->length = 0; }//.........这里部分代码省略.........
开发者ID:Astralix,项目名称:mainline-dss11,代码行数:101,
示例19: _dev_topology_attributestatic unsigned long _dev_topology_attribute(const char *attribute, const char *sysfs_dir, struct device *dev){ const char *sysfs_fmt_str = "%s/dev/block/%d:%d/%s"; char path[PATH_MAX+1], buffer[64]; FILE *fp; struct stat info; dev_t uninitialized_var(primary); unsigned long result = 0UL; if (!attribute || !*attribute) return_0; if (!sysfs_dir || !*sysfs_dir) return_0; if (dm_snprintf(path, PATH_MAX, sysfs_fmt_str, sysfs_dir, (int)MAJOR(dev->dev), (int)MINOR(dev->dev), attribute) < 0) { log_error("dm_snprintf %s failed", attribute); return 0; } /* * check if the desired sysfs attribute exists * - if not: either the kernel doesn't have topology support * or the device could be a partition */ if (stat(path, &info) == -1) { if (errno != ENOENT) { log_sys_error("stat", path); return 0; } if (!get_primary_dev(sysfs_dir, dev, &primary)) return 0; /* get attribute from partition's primary device */ if (dm_snprintf(path, PATH_MAX, sysfs_fmt_str, sysfs_dir, (int)MAJOR(primary), (int)MINOR(primary), attribute) < 0) { log_error("primary dm_snprintf %s failed", attribute); return 0; } if (stat(path, &info) == -1) { if (errno != ENOENT) log_sys_error("stat", path); return 0; } } if (!(fp = fopen(path, "r"))) { log_sys_error("fopen", path); return 0; } if (!fgets(buffer, sizeof(buffer), fp)) { log_sys_error("fgets", path); goto out; } if (sscanf(buffer, "%lu", &result) != 1) { log_error("sysfs file %s not in expected format: %s", path, buffer); goto out; } log_very_verbose("Device %s %s is %lu bytes.", dev_name(dev), attribute, result);out: if (fclose(fp)) log_sys_error("fclose", path); return result >> SECTOR_SHIFT;}
开发者ID:andyvand,项目名称:cyglvm2,代码行数:76,
示例20: f2fs_write_data_page//.........这里部分代码省略......... if (need_balance_fs) f2fs_balance_fs(sbi); if (wbc->for_reclaim) f2fs_submit_merged_bio(sbi, DATA, WRITE); return 0;redirty_out: redirty_page_for_writepage(wbc, page); return AOP_WRITEPAGE_ACTIVATE;}static int __f2fs_writepage(struct page *page, struct writeback_control *wbc, void *data){ struct address_space *mapping = data; int ret = mapping->a_ops->writepage(page, wbc); mapping_set_error(mapping, ret); return ret;}/* * This function was copied from write_cche_pages from mm/page-writeback.c. * The major change is making write step of cold data page separately from * warm/hot data page. */static int f2fs_write_cache_pages(struct address_space *mapping, struct writeback_control *wbc, writepage_t writepage, void *data){ int ret = 0; int done = 0; struct pagevec pvec; int nr_pages; pgoff_t uninitialized_var(writeback_index); pgoff_t index; pgoff_t end; /* Inclusive */ pgoff_t done_index; int cycled; int range_whole = 0; int tag; int step = 0; pagevec_init(&pvec, 0);next: if (wbc->range_cyclic) { writeback_index = mapping->writeback_index; /* prev offset */ index = writeback_index; if (index == 0) cycled = 1; else cycled = 0; end = -1; } else { index = wbc->range_start >> PAGE_CACHE_SHIFT; end = wbc->range_end >> PAGE_CACHE_SHIFT; if (wbc->range_start == 0 && wbc->range_end == LLONG_MAX) range_whole = 1; cycled = 1; /* ignore range_cyclic tests */ } if (wbc->sync_mode == WB_SYNC_ALL || wbc->tagged_writepages) tag = PAGECACHE_TAG_TOWRITE; else tag = PAGECACHE_TAG_DIRTY;retry: if (wbc->sync_mode == WB_SYNC_ALL || wbc->tagged_writepages) tag_pages_for_writeback(mapping, index, end);
开发者ID:aejsmith,项目名称:linux,代码行数:67,
示例21: write_cache_pages/**ltl功能:遍历给定地址空间的"脏"页面,写这些页面参数:返回值:说明:*/int write_cache_pages(struct address_space *mapping, struct writeback_control *wbc, writepage_t writepage, void *data){ int ret = 0; int done = 0; struct pagevec pvec; int nr_pages; pgoff_t uninitialized_var(writeback_index); pgoff_t index;/*要冲刷页面的索引*/ pgoff_t end; /* Inclusive *//*冲刷最后一个页面的索引,-1表示要循环冲刷*/ pgoff_t done_index; int cycled;/*主要用在回绕需要分成两段进行冲刷的情况下,为1表示前一段冲刷已经完成。*/ int range_whole = 0; int tag; pagevec_init(&pvec, 0); if (wbc->range_cyclic) {//是否要循环进行冲刷 writeback_index = mapping->writeback_index; /* prev offset */ index = writeback_index; if (index == 0) cycled = 1; else cycled = 0; end = -1; } else { index = wbc->range_start >> PAGE_CACHE_SHIFT; end = wbc->range_end >> PAGE_CACHE_SHIFT; if (wbc->range_start == 0 && wbc->range_end == LLONG_MAX) range_whole = 1; cycled = 1; /* ignore range_cyclic tests */ } if (wbc->sync_mode == WB_SYNC_ALL) tag = PAGECACHE_TAG_TOWRITE; else tag = PAGECACHE_TAG_DIRTY;retry: if (wbc->sync_mode == WB_SYNC_ALL) tag_pages_for_writeback(mapping, index, end); done_index = index; while (!done && (index <= end)) { int i; /*在地址空间中查找设备了PAGECACHE_TAG_DIRTY标志的页面,将结果保存在pagevec中*/ nr_pages = pagevec_lookup_tag(&pvec, mapping, &index, tag, min(end - index, (pgoff_t)PAGEVEC_SIZE-1) + 1); if (nr_pages == 0) break; //对找到的页面进行处理。 for (i = 0; i < nr_pages; i++) { struct page *page = pvec.pages[i]; /* * At this point, the page may be truncated or * invalidated (changing page->mapping to NULL), or * even swizzled back from swapper_space to tmpfs file * mapping. However, page->index will not change * because we have a reference on the page. */ if (page->index > end) { /* * can't be range_cyclic (1st pass) because * end == -1 in that case. */ done = 1; break; } done_index = page->index + 1; //页面加锁 lock_page(page); /* * Page truncated or invalidated. We can freely skip it * then, even for data integrity operations: the page * has disappeared concurrently, so there could be no * real expectation of this data interity operation * even if there is now a new, dirty page at the same * pagecache address. */ /*由于在加锁过程中可能其它进程对页面做过改动,因此要做以下判断*/ if (unlikely(page->mapping != mapping)) {//页面无效continue_unlock: unlock_page(page); continue; } if (!PageDirty(page)) {//页面回写完成,I_DIRTY标志已经清除。 /* someone wrote it for us */ goto continue_unlock;//.........这里部分代码省略.........
开发者ID:laitianli,项目名称:loongson-linux-2.6.36-3_mips,代码行数:101,
示例22: write_cache_pages/** * write_cache_pages - walk the list of dirty pages of the given address space and write all of them. * @mapping: address space structure to write * @wbc: subtract the number of written pages from *@wbc->nr_to_write * @writepage: function called for each page * @data: data passed to writepage function * * If a page is already under I/O, write_cache_pages() skips it, even * if it's dirty. This is desirable behaviour for memory-cleaning writeback, * but it is INCORRECT for data-integrity system calls such as fsync(). fsync() * and msync() need to guarantee that all the data which was dirty at the time * the call was made get new I/O started against them. If wbc->sync_mode is * WB_SYNC_ALL then we were called for data integrity and we must wait for * existing IO to complete. */int write_cache_pages(struct address_space *mapping, struct writeback_control *wbc, writepage_t writepage, void *data){ struct backing_dev_info *bdi = mapping->backing_dev_info; int ret = 0; int done = 0; struct pagevec pvec; int nr_pages; pgoff_t uninitialized_var(writeback_index); pgoff_t index; pgoff_t end; /* Inclusive */ pgoff_t done_index; int cycled; int range_whole = 0; if (wbc->nonblocking && bdi_write_congested(bdi)) { wbc->encountered_congestion = 1; return 0; } pagevec_init(&pvec, 0); if (wbc->range_cyclic) { writeback_index = mapping->writeback_index; /* prev offset */ index = writeback_index; if (index == 0) cycled = 1; else cycled = 0; end = -1; } else { index = wbc->range_start >> PAGE_CACHE_SHIFT; end = wbc->range_end >> PAGE_CACHE_SHIFT; if (wbc->range_start == 0 && wbc->range_end == LLONG_MAX) range_whole = 1; cycled = 1; /* ignore range_cyclic tests */ }retry: done_index = index; while (!done && (index <= end)) { int i; nr_pages = pagevec_lookup_tag(&pvec, mapping, &index, PAGECACHE_TAG_DIRTY, min(end - index, (pgoff_t)PAGEVEC_SIZE-1) + 1); if (nr_pages == 0) break; for (i = 0; i < nr_pages; i++) { struct page *page = pvec.pages[i]; /* * At this point, the page may be truncated or * invalidated (changing page->mapping to NULL), or * even swizzled back from swapper_space to tmpfs file * mapping. However, page->index will not change * because we have a reference on the page. */ if (page->index > end) { /* * can't be range_cyclic (1st pass) because * end == -1 in that case. */ done = 1; break; } done_index = page->index + 1; lock_page(page); /* * Page truncated or invalidated. We can freely skip it * then, even for data integrity operations: the page * has disappeared concurrently, so there could be no * real expectation of this data interity operation * even if there is now a new, dirty page at the same * pagecache address. */ if (unlikely(page->mapping != mapping)) {continue_unlock: unlock_page(page); continue; }//.........这里部分代码省略.........
开发者ID:khenam,项目名称:ardrone-kernel,代码行数:101,
示例23: handle_tx/* Expects to be always run from workqueue - which acts as * read-size critical section for our kind of RCU. */static void handle_tx(struct vhost_net *net){ struct vhost_net_virtqueue *nvq = &net->vqs[VHOST_NET_VQ_TX]; struct vhost_virtqueue *vq = &nvq->vq; unsigned out, in, s; int head; struct msghdr msg = { .msg_name = NULL, .msg_namelen = 0, .msg_control = NULL, .msg_controllen = 0, .msg_flags = MSG_DONTWAIT, }; size_t len, total_len = 0; int err; size_t hdr_size; struct socket *sock; struct vhost_net_ubuf_ref *uninitialized_var(ubufs); bool zcopy, zcopy_used; mutex_lock(&vq->mutex); sock = vq->private_data; if (!sock) goto out; vhost_disable_notify(&net->dev, vq); hdr_size = nvq->vhost_hlen; zcopy = nvq->ubufs; for (;;) { /* Release DMAs done buffers first */ if (zcopy) vhost_zerocopy_signal_used(net, vq); /* If more outstanding DMAs, queue the work. * Handle upend_idx wrap around */ if (unlikely((nvq->upend_idx + vq->num - VHOST_MAX_PEND) % UIO_MAXIOV == nvq->done_idx)) break; head = vhost_get_vq_desc(vq, vq->iov, ARRAY_SIZE(vq->iov), &out, &in, NULL, NULL); /* On error, stop handling until the next kick. */ if (unlikely(head < 0)) break; /* Nothing new? Wait for eventfd to tell us they refilled. */ if (head == vq->num) { if (unlikely(vhost_enable_notify(&net->dev, vq))) { vhost_disable_notify(&net->dev, vq); continue; } break; } if (in) { vq_err(vq, "Unexpected descriptor format for TX: " "out %d, int %d/n", out, in); break; } /* Skip header. TODO: support TSO. */ s = move_iovec_hdr(vq->iov, nvq->hdr, hdr_size, out); len = iov_length(vq->iov, out); iov_iter_init(&msg.msg_iter, WRITE, vq->iov, out, len); /* Sanity check */ if (!len) { vq_err(vq, "Unexpected header len for TX: " "%zd expected %zd/n", iov_length(nvq->hdr, s), hdr_size); break; } zcopy_used = zcopy && len >= VHOST_GOODCOPY_LEN && (nvq->upend_idx + 1) % UIO_MAXIOV != nvq->done_idx && vhost_net_tx_select_zcopy(net); /* use msg_control to pass vhost zerocopy ubuf info to skb */ if (zcopy_used) { struct ubuf_info *ubuf; ubuf = nvq->ubuf_info + nvq->upend_idx; vq->heads[nvq->upend_idx].id = cpu_to_vhost32(vq, head); vq->heads[nvq->upend_idx].len = VHOST_DMA_IN_PROGRESS; ubuf->callback = vhost_zerocopy_callback; ubuf->ctx = nvq->ubufs; ubuf->desc = nvq->upend_idx; msg.msg_control = ubuf; msg.msg_controllen = sizeof(ubuf); ubufs = nvq->ubufs; atomic_inc(&ubufs->refcount); nvq->upend_idx = (nvq->upend_idx + 1) % UIO_MAXIOV; } else { msg.msg_control = NULL; ubufs = NULL; }//.........这里部分代码省略.........
开发者ID:383530895,项目名称:linux,代码行数:101,
示例24: afs_permissionint afs_permission(struct inode *inode, int mask){ struct afs_vnode *vnode = AFS_FS_I(inode); afs_access_t uninitialized_var(access); struct key *key; int ret; if (mask & MAY_NOT_BLOCK) return -ECHILD; _enter("{{%x:%u},%lx},%x,", vnode->fid.vid, vnode->fid.vnode, vnode->flags, mask); key = afs_request_key(vnode->volume->cell); if (IS_ERR(key)) { _leave(" = %ld [key]", PTR_ERR(key)); return PTR_ERR(key); } if (!vnode->cb_promised) { _debug("not promised"); ret = afs_vnode_fetch_status(vnode, NULL, key); if (ret < 0) goto error; _debug("new promise [fl=%lx]", vnode->flags); } ret = afs_check_permit(vnode, key, &access); if (ret < 0) goto error; _debug("REQ %x ACC %x on %s", mask, access, S_ISDIR(inode->i_mode) ? "dir" : "file"); if (S_ISDIR(inode->i_mode)) { if (mask & MAY_EXEC) { if (!(access & AFS_ACE_LOOKUP)) goto permission_denied; } else if (mask & MAY_READ) { if (!(access & AFS_ACE_READ)) goto permission_denied; } else if (mask & MAY_WRITE) { if (!(access & (AFS_ACE_DELETE | AFS_ACE_INSERT | AFS_ACE_WRITE))) goto permission_denied; } else { BUG(); } } else { if (!(access & AFS_ACE_LOOKUP)) goto permission_denied; if (mask & (MAY_EXEC | MAY_READ)) { if (!(access & AFS_ACE_READ)) goto permission_denied; } else if (mask & MAY_WRITE) { if (!(access & AFS_ACE_WRITE)) goto permission_denied; } } key_put(key); ret = generic_permission(inode, mask); _leave(" = %d", ret); return ret;permission_denied: ret = -EACCES;error: key_put(key); _leave(" = %d", ret); return ret;}
开发者ID:MiniBlu,项目名称:cm11_kernel_htc_msm8974a3ul,代码行数:76,
注:本文中的uninitialized_var函数示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 C++ uninstallErrorHandlerAndTriggerError函数代码示例 C++ uninitialize函数代码示例 |