这篇教程C++ BITS_TO_LONGS函数代码示例写得很实用,希望能帮到您。
本文整理汇总了C++中BITS_TO_LONGS函数的典型用法代码示例。如果您正苦于以下问题:C++ BITS_TO_LONGS函数的具体用法?C++ BITS_TO_LONGS怎么用?C++ BITS_TO_LONGS使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。 在下文中一共展示了BITS_TO_LONGS函数的28个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。 示例1: mlx4_bitmap_initint mlx4_bitmap_init(struct mlx4_bitmap *bitmap, u32 num, u32 mask, u32 reserved_bot, u32 reserved_top){ /* num must be a power of 2 */ if (num != roundup_pow_of_two(num)) return -EINVAL; bitmap->last = 0; bitmap->top = 0; bitmap->max = num - reserved_top; bitmap->mask = mask; bitmap->reserved_top = reserved_top; spin_lock_init(&bitmap->lock); bitmap->table = kzalloc(BITS_TO_LONGS(bitmap->max) * sizeof (long), GFP_KERNEL); if (!bitmap->table) return -ENOMEM; bitmap_set(bitmap->table, 0, reserved_bot); return 0;}
开发者ID:Addision,项目名称:LVS,代码行数:22,
示例2: BITS_TO_LONGSstatic __init struct cma *cma_create_area(unsigned long base_pfn, unsigned long carved_out_count, unsigned long count){ int bitmap_size = BITS_TO_LONGS(count) * sizeof(long); struct cma *cma; int ret = -ENOMEM; pr_debug("%s(base %08lx, count %lx)/n", __func__, base_pfn, count); cma = kzalloc(sizeof *cma, GFP_KERNEL); if (!cma) return ERR_PTR(-ENOMEM); cma->base_pfn = base_pfn; cma->count = count; cma->free_count = count; cma->bitmap = kzalloc(bitmap_size, GFP_KERNEL);#ifdef CMA_NO_MIGRATION cma->isolated = true;#endif if (!cma->bitmap) goto no_mem; ret = cma_activate_area(base_pfn, carved_out_count); if (ret) goto error; pr_debug("%s: returned %p/n", __func__, (void *)cma); return cma;error: kfree(cma->bitmap);no_mem: kfree(cma); return ERR_PTR(ret);}
开发者ID:Hani-K,项目名称:H-Vitamin,代码行数:38,
示例3: cma_activate_areastatic int __init cma_activate_area(struct cma *cma){ int bitmap_size = BITS_TO_LONGS(cma->count) * sizeof(long); unsigned long base_pfn = cma->base_pfn, pfn = base_pfn; unsigned i = cma->count >> pageblock_order; struct zone *zone; cma->bitmap = kzalloc(bitmap_size, GFP_KERNEL); if (!cma->bitmap) return -ENOMEM; WARN_ON_ONCE(!pfn_valid(pfn)); zone = page_zone(pfn_to_page(pfn)); do { unsigned j; base_pfn = pfn; for (j = pageblock_nr_pages; j; --j, pfn++) { WARN_ON_ONCE(!pfn_valid(pfn)); /* * alloc_contig_range requires the pfn range * specified to be in the same zone. Make this * simple by forcing the entire CMA resv range * to be in the same zone. */ if (page_zone(pfn_to_page(pfn)) != zone) goto err; } init_cma_reserved_pageblock(pfn_to_page(base_pfn)); } while (--i); return 0;err: kfree(cma->bitmap); return -EINVAL;}
开发者ID:AdaLovelance,项目名称:lxcGrsecKernels,代码行数:38,
示例4: bits_to_userstatic int bits_to_user(unsigned long *bits, unsigned int maxbit, unsigned int maxlen, void __user *p, int compat){ int len, i; if (compat) { len = BITS_TO_LONGS_COMPAT(maxbit) * sizeof(compat_long_t); if (len > maxlen) len = maxlen; for (i = 0; i < len / sizeof(compat_long_t); i++) if (copy_to_user((compat_long_t __user *) p + i, (compat_long_t *) bits + i + 1 - ((i % 2) << 1), sizeof(compat_long_t))) return -EFAULT; } else { len = BITS_TO_LONGS(maxbit) * sizeof(long); if (len > maxlen) len = maxlen; if (copy_to_user(p, bits, len)) return -EFAULT; } return len;}
开发者ID:faux123,项目名称:pantech_vega_racer_2_kernel,代码行数:23,
示例5: i915_gem_object_save_bit_17_swizzlevoidi915_gem_object_save_bit_17_swizzle(struct drm_i915_gem_object *obj){ int page_count = obj->base.size >> PAGE_SHIFT; int i; if (obj->bit_17 == NULL) { obj->bit_17 = kmalloc(BITS_TO_LONGS(page_count) * sizeof(long), GFP_KERNEL); if (obj->bit_17 == NULL) { DRM_ERROR("Failed to allocate memory for bit 17 " "record/n"); return; } } for (i = 0; i < page_count; i++) { if (page_to_phys(obj->pages[i]) & (1 << 17)) __set_bit(i, obj->bit_17); else __clear_bit(i, obj->bit_17); }}
开发者ID:TheDudeWithThreeHands,项目名称:ubuntu-precise-lowlatency,代码行数:23,
示例6: ath10k_htt_tx_allocint ath10k_htt_tx_alloc(struct ath10k_htt *htt){ struct ath10k *ar = htt->ar; spin_lock_init(&htt->tx_lock); if (test_bit(ATH10K_FW_FEATURE_WMI_10X, htt->ar->fw_features)) htt->max_num_pending_tx = TARGET_10X_NUM_MSDU_DESC; else htt->max_num_pending_tx = TARGET_NUM_MSDU_DESC; ath10k_dbg(ar, ATH10K_DBG_BOOT, "htt tx max num pending tx %d/n", htt->max_num_pending_tx); htt->pending_tx = kzalloc(sizeof(*htt->pending_tx) * htt->max_num_pending_tx, GFP_KERNEL); if (!htt->pending_tx) return -ENOMEM; htt->used_msdu_ids = kzalloc(sizeof(unsigned long) * BITS_TO_LONGS(htt->max_num_pending_tx), GFP_KERNEL); if (!htt->used_msdu_ids) { kfree(htt->pending_tx); return -ENOMEM; } htt->tx_pool = dma_pool_create("ath10k htt tx pool", htt->ar->dev, sizeof(struct ath10k_htt_txbuf), 4, 0); if (!htt->tx_pool) { kfree(htt->used_msdu_ids); kfree(htt->pending_tx); return -ENOMEM; } return 0;}
开发者ID:383530895,项目名称:linux,代码行数:37,
示例7: intel_setup_irq_remappingstatic int intel_setup_irq_remapping(struct intel_iommu *iommu, int mode){ struct ir_table *ir_table; struct page *pages; unsigned long *bitmap; ir_table = iommu->ir_table = kzalloc(sizeof(struct ir_table), GFP_ATOMIC); if (!iommu->ir_table) return -ENOMEM; pages = alloc_pages_node(iommu->node, GFP_ATOMIC | __GFP_ZERO, INTR_REMAP_PAGE_ORDER); if (!pages) { pr_err("IR%d: failed to allocate pages of order %d/n", iommu->seq_id, INTR_REMAP_PAGE_ORDER); kfree(iommu->ir_table); return -ENOMEM; } bitmap = kcalloc(BITS_TO_LONGS(INTR_REMAP_TABLE_ENTRIES), sizeof(long), GFP_ATOMIC); if (bitmap == NULL) { pr_err("IR%d: failed to allocate bitmap/n", iommu->seq_id); __free_pages(pages, INTR_REMAP_PAGE_ORDER); kfree(ir_table); return -ENOMEM; } ir_table->base = page_address(pages); ir_table->bitmap = bitmap; iommu_set_irq_remapping(iommu, mode); return 0;}
开发者ID:spacex,项目名称:kernel-centos7,代码行数:37,
示例8: hclge_set_vf_mc_mta_statusstatic int hclge_set_vf_mc_mta_status(struct hclge_vport *vport, u8 *msg, u8 idx, bool is_end){#define HCLGE_MTA_STATUS_MSG_SIZE 13#define HCLGE_MTA_STATUS_MSG_BITS / (HCLGE_MTA_STATUS_MSG_SIZE * BITS_PER_BYTE)#define HCLGE_MTA_STATUS_MSG_END_BITS / (HCLGE_MTA_TBL_SIZE % HCLGE_MTA_STATUS_MSG_BITS) unsigned long status[BITS_TO_LONGS(HCLGE_MTA_STATUS_MSG_BITS)]; u16 tbl_cnt; u16 tbl_idx; u8 msg_ofs; u8 msg_bit; tbl_cnt = is_end ? HCLGE_MTA_STATUS_MSG_END_BITS : HCLGE_MTA_STATUS_MSG_BITS; /* set msg field */ msg_ofs = 0; msg_bit = 0; memset(status, 0, sizeof(status)); for (tbl_idx = 0; tbl_idx < tbl_cnt; tbl_idx++) { if (msg[msg_ofs] & BIT(msg_bit)) set_bit(tbl_idx, status); msg_bit++; if (msg_bit == BITS_PER_BYTE) { msg_bit = 0; msg_ofs++; } } return hclge_update_mta_status_common(vport, status, idx * HCLGE_MTA_STATUS_MSG_BITS, tbl_cnt, is_end);}
开发者ID:Lyude,项目名称:linux,代码行数:36,
示例9: mlxsw_sp2_kvdl_part_initstatic struct mlxsw_sp2_kvdl_part *mlxsw_sp2_kvdl_part_init(struct mlxsw_sp *mlxsw_sp, const struct mlxsw_sp2_kvdl_part_info *info){ unsigned int indexes_per_usage_bit; struct mlxsw_sp2_kvdl_part *part; unsigned int index_range; unsigned int usage_bit_count; size_t usage_size; if (!mlxsw_core_res_valid(mlxsw_sp->core, info->usage_bit_count_res_id) || !mlxsw_core_res_valid(mlxsw_sp->core, info->index_range_res_id)) return ERR_PTR(-EIO); usage_bit_count = mlxsw_core_res_get(mlxsw_sp->core, info->usage_bit_count_res_id); index_range = mlxsw_core_res_get(mlxsw_sp->core, info->index_range_res_id); /* For some partitions, one usage bit represents a group of indexes. * That's why we compute the number of indexes per usage bit here, * according to queried resources. */ indexes_per_usage_bit = index_range / usage_bit_count; usage_size = BITS_TO_LONGS(usage_bit_count) * sizeof(unsigned long); part = kzalloc(sizeof(*part) + usage_size, GFP_KERNEL); if (!part) return ERR_PTR(-ENOMEM); part->info = info; part->usage_bit_count = usage_bit_count; part->indexes_per_usage_bit = indexes_per_usage_bit; part->last_allocated_bit = usage_bit_count - 1; return part;}
开发者ID:AlexShiLucky,项目名称:linux,代码行数:36,
示例10: mlx5_mpfs_initint mlx5_mpfs_init(struct mlx5_core_dev *dev){ int l2table_size = 1 << MLX5_CAP_GEN(dev, log_max_l2_table); struct mlx5_mpfs *mpfs; if (!MLX5_VPORT_MANAGER(dev)) return 0; mpfs = kzalloc(sizeof(*mpfs), GFP_KERNEL); if (!mpfs) return -ENOMEM; mutex_init(&mpfs->lock); mpfs->size = l2table_size; mpfs->bitmap = kcalloc(BITS_TO_LONGS(l2table_size), sizeof(uintptr_t), GFP_KERNEL); if (!mpfs->bitmap) { kfree(mpfs); return -ENOMEM; } dev->priv.mpfs = mpfs; return 0;}
开发者ID:ReneNyffenegger,项目名称:linux,代码行数:24,
示例11: hns_roce_bitmap_initint hns_roce_bitmap_init(struct hns_roce_bitmap *bitmap, u32 num, u32 mask, u32 reserved_bot, u32 reserved_top){ u32 i; if (num != roundup_pow_of_two(num)) return -EINVAL; bitmap->last = 0; bitmap->top = 0; bitmap->max = num - reserved_top; bitmap->mask = mask; bitmap->reserved_top = reserved_top; spin_lock_init(&bitmap->lock); bitmap->table = kcalloc(BITS_TO_LONGS(bitmap->max), sizeof(long), GFP_KERNEL); if (!bitmap->table) return -ENOMEM; for (i = 0; i < reserved_bot; ++i) set_bit(i, bitmap->table); return 0;}
开发者ID:AlexShiLucky,项目名称:linux,代码行数:24,
示例12: iio_scan_mask_set/** * iio_scan_mask_set() - set particular bit in the scan mask * @buffer: the buffer whose scan mask we are interested in * @bit: the bit to be set. **/int iio_scan_mask_set(struct iio_buffer *buffer, int bit){ struct iio_dev *indio_dev = buffer->indio_dev; unsigned long *mask; unsigned long *trialmask; trialmask = kmalloc(sizeof(*trialmask)* BITS_TO_LONGS(indio_dev->masklength), GFP_KERNEL); if (trialmask == NULL) return -ENOMEM; if (!indio_dev->masklength) { WARN_ON("trying to set scanmask prior to registering buffer/n"); kfree(trialmask); return -EINVAL; } bitmap_copy(trialmask, buffer->scan_mask, indio_dev->masklength); set_bit(bit, trialmask); if (indio_dev->available_scan_masks) { mask = iio_scan_mask_match(indio_dev->available_scan_masks, indio_dev->masklength, trialmask); if (!mask) { kfree(trialmask); return -EINVAL; } } bitmap_copy(buffer->scan_mask, trialmask, indio_dev->masklength); buffer->scan_count++; kfree(trialmask); return 0;};
开发者ID:GerardGarcia,项目名称:linux,代码行数:41,
示例13: msi_bitmap_allocint msi_bitmap_alloc(struct msi_bitmap *bmp, unsigned int irq_count, struct device_node *of_node){ int size; if (!irq_count) return -EINVAL; size = BITS_TO_LONGS(irq_count) * sizeof(long); pr_debug("msi_bitmap: allocator bitmap size is 0x%x bytes/n", size); bmp->bitmap = zalloc_maybe_bootmem(size, GFP_KERNEL); if (!bmp->bitmap) { pr_debug("msi_bitmap: ENOMEM allocating allocator bitmap!/n"); return -ENOMEM; } /* We zalloc'ed the bitmap, so all irqs are free by default */ spin_lock_init(&bmp->lock); bmp->of_node = of_node_get(of_node); bmp->irq_count = irq_count; return 0;}
开发者ID:quadcores,项目名称:cbs_4.2.4,代码行数:24,
示例14: i915_gem_object_save_bit_17_swizzlevoidi915_gem_object_save_bit_17_swizzle(struct drm_i915_gem_object *obj){ int page_count = obj->base.size >> PAGE_SHIFT; int i; if (obj->bit_17 == NULL) { obj->bit_17 = kmalloc(BITS_TO_LONGS(page_count) * sizeof(long), DRM_I915_GEM, M_WAITOK); if (obj->bit_17 == NULL) { DRM_ERROR("Failed to allocate memory for bit 17 " "record/n"); return; } } /* XXXKIB: review locking, atomics might be not needed there */ for (i = 0; i < page_count; i++) { if (VM_PAGE_TO_PHYS(obj->pages[i]) & (1 << 17)) set_bit(i, obj->bit_17); else clear_bit(i, obj->bit_17); }}
开发者ID:victoredwardocallaghan,项目名称:DragonFlyBSD,代码行数:24,
示例15: LIST_HEAD * EV_ABS events which should not be cached are listed here. */static unsigned int input_abs_bypass_init_data[] __initdata = { ABS_MT_TOUCH_MAJOR, ABS_MT_TOUCH_MINOR, ABS_MT_WIDTH_MAJOR, ABS_MT_WIDTH_MINOR, ABS_MT_ORIENTATION, ABS_MT_POSITION_X, ABS_MT_POSITION_Y, ABS_MT_TOOL_TYPE, ABS_MT_BLOB_ID, ABS_MT_PRESSURE, 0};static unsigned long input_abs_bypass[BITS_TO_LONGS(ABS_CNT)];static LIST_HEAD(input_dev_list);static LIST_HEAD(input_handler_list);/* * input_mutex protects access to both input_dev_list and input_handler_list. * This also causes input_[un]register_device and input_[un]register_handler * be mutually exclusive which simplifies locking in drivers implementing * input handlers. */static DEFINE_MUTEX(input_mutex);static struct input_handler *input_table[8];static inline int is_event_supported(unsigned int code,
开发者ID:souljaboy11792,项目名称:ZCF-kernel,代码行数:31,
示例16: deferred_restart */#include <linux/input.h>#include <linux/keyreset.h>#include <linux/module.h>#include <linux/platform_device.h>#include <linux/reboot.h>#include <linux/sched.h>#include <linux/slab.h>#include <linux/syscalls.h>#include <linux/workqueue.h>struct keyreset_state { struct input_handler input_handler; unsigned long keybit[BITS_TO_LONGS(KEY_CNT)]; unsigned long upbit[BITS_TO_LONGS(KEY_CNT)]; unsigned long key[BITS_TO_LONGS(KEY_CNT)]; spinlock_t lock; int key_down_target; int key_down; int key_up; int restart_disabled; int restart_requested; int (*reset_fn)(void); int down_time_ms; struct delayed_work restart_work;};static void deferred_restart(struct work_struct *work){
开发者ID:figue,项目名称:android_kernel_mako,代码行数:31,
示例17: DECLARE_RWSEM#include <linux/debugfs.h>#include <linux/slab.h>#include "heartbeat.h"#include "tcp.h"#include "nodemanager.h"#include "quorum.h"#include "masklog.h"static DECLARE_RWSEM(o2hb_callback_sem);static DEFINE_SPINLOCK(o2hb_live_lock);static struct list_head o2hb_live_slots[O2NM_MAX_NODES];static unsigned long o2hb_live_node_bitmap[BITS_TO_LONGS(O2NM_MAX_NODES)];static LIST_HEAD(o2hb_node_events);static DECLARE_WAIT_QUEUE_HEAD(o2hb_steady_queue);#define O2HB_DEBUG_DIR "o2hb"#define O2HB_DEBUG_LIVENODES "livenodes"static struct dentry *o2hb_debug_dir;static struct dentry *o2hb_debug_livenodes;static LIST_HEAD(o2hb_all_regions);static struct o2hb_callback { struct list_head list;} o2hb_callbacks[O2HB_NUM_CB];static struct o2hb_callback *hbcall_from_type(enum o2hb_callback_type type);
开发者ID:flwh,项目名称:Alcatel_OT_985_kernel,代码行数:31,
示例18: #include <hv/hypervisor.h>#define TILE_MAX_COUNTERS 4#define PERF_COUNT_0_IDX 0#define PERF_COUNT_1_IDX 1#define AUX_PERF_COUNT_0_IDX 2#define AUX_PERF_COUNT_1_IDX 3struct cpu_hw_events { int n_events; struct perf_event *events[TILE_MAX_COUNTERS]; /* counter order */ struct perf_event *event_list[TILE_MAX_COUNTERS]; /* enabled order */ int assign[TILE_MAX_COUNTERS]; unsigned long active_mask[BITS_TO_LONGS(TILE_MAX_COUNTERS)]; unsigned long used_mask;};/* TILE arch specific performance monitor unit */struct tile_pmu { const char *name; int version; const int *hw_events; /* generic hw events table */ /* generic hw cache events table */ const int (*cache_events)[PERF_COUNT_HW_CACHE_MAX] [PERF_COUNT_HW_CACHE_OP_MAX] [PERF_COUNT_HW_CACHE_RESULT_MAX]; int (*map_hw_event)(u64); /*method used to map hw events */ int (*map_cache_event)(u64); /*method used to map
开发者ID:0-T-0,项目名称:ps4-linux,代码行数:31,
示例19: bfin_write_PFCTL bfin_write_PFCTL((bfin_read_PFCTL() & mask) | val);}static void bfin_pfmon_disable_all(void){ bfin_write_PFCTL(bfin_read_PFCTL() & ~PFPWR);}static void bfin_pfmon_enable_all(void){ bfin_write_PFCTL(bfin_read_PFCTL() | PFPWR);}struct cpu_hw_events { struct perf_event *events[MAX_HWEVENTS]; unsigned long used_mask[BITS_TO_LONGS(MAX_HWEVENTS)];};DEFINE_PER_CPU(struct cpu_hw_events, cpu_hw_events);static int hw_perf_cache_event(int config, int *evp){ unsigned long type, op, result; int ev; /* unpack config */ type = config & 0xff; op = (config >> 8) & 0xff; result = (config >> 16) & 0xff; if (type >= PERF_COUNT_HW_CACHE_MAX || op >= PERF_COUNT_HW_CACHE_OP_MAX ||
开发者ID:0-T-0,项目名称:ps4-linux,代码行数:31,
示例20: ocfs2_node_map_initstatic void ocfs2_node_map_init(struct ocfs2_node_map *map){ map->num_nodes = OCFS2_NODE_MAP_MAX_NODES; memset(map->map, 0, BITS_TO_LONGS(OCFS2_NODE_MAP_MAX_NODES) * sizeof(unsigned long));}
开发者ID:MiniBlu,项目名称:cm11_kernel_htc_msm8974a3ul,代码行数:6,
示例21: sysrq_reinject_alt_sysrq#ifdef CONFIG_INPUT/* Simple translation table for the SysRq keys */static const unsigned char sysrq_xlate[KEY_CNT] = "/000/0331234567890-=/177/t" /* 0x00 - 0x0f */ "qwertyuiop[]/r/000as" /* 0x10 - 0x1f */ "dfghjkl;'`/000//zxcv" /* 0x20 - 0x2f */ "bnm,.//000*/000 /000/201/202/203/204/205" /* 0x30 - 0x3f */ "/206/207/210/211/212/000/000789-456+1" /* 0x40 - 0x4f */ "230/177/000/000/213/214/000/000/000/000/000/000/000/000/000/000" /* 0x50 - 0x5f */ "/r/000/"; /* 0x60 - 0x6f */struct sysrq_state { struct input_handle handle; struct work_struct reinject_work; unsigned long key_down[BITS_TO_LONGS(KEY_CNT)]; unsigned int alt; unsigned int alt_use; bool active; bool need_reinject; bool reinjecting;};static void sysrq_reinject_alt_sysrq(struct work_struct *work){ struct sysrq_state *sysrq = container_of(work, struct sysrq_state, reinject_work); struct input_handle *handle = &sysrq->handle; unsigned int alt_code = sysrq->alt_use; if (sysrq->need_reinject) {
开发者ID:ASAZING,项目名称:Android-Kernel-Gt-s7390l,代码行数:31,
示例22: dhd_flow_rings_init/* Init Flow Ring specific data structures */intdhd_flow_rings_init(dhd_pub_t *dhdp, uint32 num_flow_rings){ uint32 idx; uint32 flow_ring_table_sz; uint32 if_flow_lkup_sz; void * flowid_allocator; flow_ring_table_t *flow_ring_table; if_flow_lkup_t *if_flow_lkup = NULL;#ifdef PCIE_TX_DEFERRAL uint32 count;#endif void *lock = NULL; unsigned long flags; DHD_INFO(("%s/n", __FUNCTION__)); /* Construct a 16bit flow1d allocator */ flowid_allocator = id16_map_init(dhdp->osh, num_flow_rings - FLOW_RING_COMMON, FLOWID_RESERVED); if (flowid_allocator == NULL) { DHD_ERROR(("%s: flowid allocator init failure/n", __FUNCTION__)); return BCME_NOMEM; } /* Allocate a flow ring table, comprising of requested number of rings */ flow_ring_table_sz = (num_flow_rings * sizeof(flow_ring_node_t)); flow_ring_table = (flow_ring_table_t *)MALLOC(dhdp->osh, flow_ring_table_sz); if (flow_ring_table == NULL) { DHD_ERROR(("%s: flow ring table alloc failure/n", __FUNCTION__)); goto fail; } /* Initialize flow ring table state */ bzero((uchar *)flow_ring_table, flow_ring_table_sz); for (idx = 0; idx < num_flow_rings; idx++) { flow_ring_table[idx].status = FLOW_RING_STATUS_CLOSED; flow_ring_table[idx].flowid = (uint16)idx; flow_ring_table[idx].lock = dhd_os_spin_lock_init(dhdp->osh); if (flow_ring_table[idx].lock == NULL) { DHD_ERROR(("%s: Failed to init spinlock for queue!/n", __FUNCTION__)); goto fail; } dll_init(&flow_ring_table[idx].list); /* Initialize the per flow ring backup queue */ dhd_flow_queue_init(dhdp, &flow_ring_table[idx].queue, FLOW_RING_QUEUE_THRESHOLD); } /* Allocate per interface hash table */ if_flow_lkup_sz = sizeof(if_flow_lkup_t) * DHD_MAX_IFS; if_flow_lkup = (if_flow_lkup_t *)DHD_OS_PREALLOC(dhdp, DHD_PREALLOC_IF_FLOW_LKUP, if_flow_lkup_sz); if (if_flow_lkup == NULL) { DHD_ERROR(("%s: if flow lkup alloc failure/n", __FUNCTION__)); goto fail; } /* Initialize per interface hash table */ bzero((uchar *)if_flow_lkup, if_flow_lkup_sz); for (idx = 0; idx < DHD_MAX_IFS; idx++) { int hash_ix; if_flow_lkup[idx].status = 0; if_flow_lkup[idx].role = 0; for (hash_ix = 0; hash_ix < DHD_FLOWRING_HASH_SIZE; hash_ix++) if_flow_lkup[idx].fl_hash[hash_ix] = NULL; }#ifdef PCIE_TX_DEFERRAL count = BITS_TO_LONGS(num_flow_rings); dhdp->bus->delete_flow_map = kzalloc(count, GFP_ATOMIC); if (!dhdp->bus->delete_flow_map) { DHD_ERROR(("%s: delete_flow_map alloc failure/n", __FUNCTION__)); goto fail; }#endif lock = dhd_os_spin_lock_init(dhdp->osh); if (lock == NULL) goto fail; dhdp->flow_prio_map_type = DHD_FLOW_PRIO_AC_MAP; bcopy(prio2ac, dhdp->flow_prio_map, sizeof(uint8) * NUMPRIO); /* Now populate into dhd pub */ DHD_FLOWID_LOCK(lock, flags); dhdp->num_flow_rings = num_flow_rings; dhdp->flowid_allocator = (void *)flowid_allocator; dhdp->flow_ring_table = (void *)flow_ring_table; dhdp->if_flow_lkup = (void *)if_flow_lkup; dhdp->flowid_lock = lock; DHD_FLOWID_UNLOCK(lock, flags); DHD_INFO(("%s done/n", __FUNCTION__)); return BCME_OK;fail://.........这里部分代码省略.........
开发者ID:GREYFOXRGR,项目名称:BPI-M3-bsp,代码行数:101,
示例23: __mfn_valid#include <xen/config.h>#include <xen/init.h>#include <xen/mm.h>#include <xen/bitops.h>/* Parameters for PFN/MADDR compression. */unsigned long __read_mostly max_pdx;unsigned long __read_mostly pfn_pdx_bottom_mask = ~0UL;unsigned long __read_mostly ma_va_bottom_mask = ~0UL;unsigned long __read_mostly pfn_top_mask = 0;unsigned long __read_mostly ma_top_mask = 0;unsigned long __read_mostly pfn_hole_mask = 0;unsigned int __read_mostly pfn_pdx_hole_shift = 0;unsigned long __read_mostly pdx_group_valid[BITS_TO_LONGS( (FRAMETABLE_NR + PDX_GROUP_COUNT - 1) / PDX_GROUP_COUNT)] = { [0] = 1 };int __mfn_valid(unsigned long mfn){ return likely(mfn < max_page) && likely(!(mfn & pfn_hole_mask)) && likely(test_bit(pfn_to_pdx(mfn) / PDX_GROUP_COUNT, pdx_group_valid));}/* Sets all bits from the most-significant 1-bit down to the LSB */static u64 __init fill_mask(u64 mask){ while (mask & (mask + 1)) mask |= mask + 1; return mask;
开发者ID:CPFL,项目名称:xen,代码行数:31,
示例24: DEFINE_SPINLOCK .sig = 0,};/* * Variables exported for vt.c */int shift_state = 0;/* * Internal Data. */static struct input_handler kbd_handler;static DEFINE_SPINLOCK(kbd_event_lock);static unsigned long key_down[BITS_TO_LONGS(KEY_CNT)]; /* keyboard key bitmap */static unsigned char shift_down[NR_SHIFT]; /* shift state counters.. */static bool dead_key_next;static int npadch = -1; /* -1 or number assembled on pad */static unsigned int diacr;static char rep; /* flag telling character repeat */static unsigned char ledstate = 0xff; /* undefined */static unsigned char ledioctl;static struct ledptr { unsigned int *addr; unsigned int mask; unsigned char valid:1;} ledptrs[3];
开发者ID:novic,项目名称:AniDroid-Hardened-Kernel,代码行数:30,
示例25: test_rhashtablestatic s64 __init test_rhashtable(struct rhashtable *ht, struct test_obj *array, unsigned int entries){ struct test_obj *obj; int err; unsigned int i, insert_retries = 0; s64 start, end; /* * Insertion Test: * Insert entries into table with all keys even numbers */ pr_info(" Adding %d keys/n", entries); start = ktime_get_ns(); for (i = 0; i < entries; i++) { struct test_obj *obj = &array[i]; obj->value.id = i * 2; err = insert_retry(ht, obj, test_rht_params); if (err > 0) insert_retries += err; else if (err) return err; } if (insert_retries) pr_info(" %u insertions retried due to memory pressure/n", insert_retries); test_bucket_stats(ht, entries); rcu_read_lock(); test_rht_lookup(ht, array, entries); rcu_read_unlock(); test_bucket_stats(ht, entries); pr_info(" Deleting %d keys/n", entries); for (i = 0; i < entries; i++) { struct test_obj_val key = { .id = i * 2, }; if (array[i].value.id != TEST_INSERT_FAIL) { obj = rhashtable_lookup_fast(ht, &key, test_rht_params); BUG_ON(!obj); rhashtable_remove_fast(ht, &obj->node, test_rht_params); } cond_resched(); } end = ktime_get_ns(); pr_info(" Duration of test: %lld ns/n", end - start); return end - start;}static struct rhashtable ht;static struct rhltable rhlt;static int __init test_rhltable(unsigned int entries){ struct test_obj_rhl *rhl_test_objects; unsigned long *obj_in_table; unsigned int i, j, k; int ret, err; if (entries == 0) entries = 1; rhl_test_objects = vzalloc(sizeof(*rhl_test_objects) * entries); if (!rhl_test_objects) return -ENOMEM; ret = -ENOMEM; obj_in_table = vzalloc(BITS_TO_LONGS(entries) * sizeof(unsigned long)); if (!obj_in_table) goto out_free; /* nulls_base not supported in rhlist interface */ test_rht_params.nulls_base = 0; err = rhltable_init(&rhlt, &test_rht_params); if (WARN_ON(err)) goto out_free; k = prandom_u32(); ret = 0; for (i = 0; i < entries; i++) { rhl_test_objects[i].value.id = k; err = rhltable_insert(&rhlt, &rhl_test_objects[i].list_node, test_rht_params); if (WARN(err, "error %d on element %d/n", err, i)) break; if (err == 0) set_bit(i, obj_in_table); } if (err) ret = err;//.........这里部分代码省略.........
开发者ID:the-snowwhite,项目名称:linux-socfpga,代码行数:101,
示例26: __set_direction *//* * Based on (mostly copied from) plat-orion based Linux 2.6 kernel driver. * Removed orion_gpiochip struct and kernel level irq handling. * * Dieter Kiermaier [email C++ BIT_CHECK函数代码示例 C++ BITSWAP8函数代码示例
|