コード例 #1
0
ファイル: net-sysfs.c プロジェクト: lfd/PreemptRT
static ssize_t store_rps_map(struct netdev_rx_queue *queue,
			     const char *buf, size_t len)
{
	struct rps_map *old_map, *map;
	cpumask_var_t mask;
	int err, cpu, i;
	static DEFINE_MUTEX(rps_map_mutex);

	if (!capable(CAP_NET_ADMIN))
		return -EPERM;

	if (!alloc_cpumask_var(&mask, GFP_KERNEL))
		return -ENOMEM;

	err = bitmap_parse(buf, len, cpumask_bits(mask), nr_cpumask_bits);
	if (err) {
		free_cpumask_var(mask);
		return err;
	}

	map = kzalloc(max_t(unsigned int,
			    RPS_MAP_SIZE(cpumask_weight(mask)), L1_CACHE_BYTES),
		      GFP_KERNEL);
	if (!map) {
		free_cpumask_var(mask);
		return -ENOMEM;
	}

	i = 0;
	for_each_cpu_and(cpu, mask, cpu_online_mask)
		map->cpus[i++] = cpu;

	if (i) {
		map->len = i;
	} else {
		kfree(map);
		map = NULL;
	}

	mutex_lock(&rps_map_mutex);
	old_map = rcu_dereference_protected(queue->rps_map,
					    mutex_is_locked(&rps_map_mutex));
	rcu_assign_pointer(queue->rps_map, map);

	if (map)
		static_key_slow_inc(&rps_needed);
	if (old_map)
		static_key_slow_dec(&rps_needed);

	mutex_unlock(&rps_map_mutex);

	if (old_map)
		kfree_rcu(old_map, rcu);

	free_cpumask_var(mask);
	return len;
}
コード例 #2
0
Bitmap* engine_load_asset (Context* context, char* fpath) {
	char* buf;
	Bitmap* bitmap = (Bitmap*) malloc(sizeof(Bitmap));
	AAsset* bitmap_asset = AAssetManager_open(
		context->app->activity->assetManager
		, fpath
		, AASSET_MODE_BUFFER
	);
	
	buf = (char*) AAsset_getBuffer(bitmap_asset);
	bitmap_parse(bitmap, NULL, buf);
	AAsset_close(bitmap_asset);
	
	return bitmap;
}
コード例 #3
0
ファイル: g13.c プロジェクト: vpeurala/g13driver
static void g13_urb_complete(struct urb *urb) {
    const u8* transfer_buffer_content = (unsigned char*) urb->transfer_buffer;
    /* actual_length is always 8 with G13 input channel */
    const u32 actual_length = urb->actual_length;
    int bm_index = 0;
    int safety_limit_index = 0;
    int bitmap_parse_result;
    int sprintf_result;
    int i;
    char hex_string[16];
    DECLARE_BITMAP(input_bitmap, 64);
    printk("\n");
    for (i = 0; i < actual_length; i++) {
        printk("%x ", transfer_buffer_content[i]);
    }
    sprintf_result = sprintf(hex_string, "%02x%02x%02x%02x,%02x%02x%02x%02x", transfer_buffer_content[0], transfer_buffer_content[1], transfer_buffer_content[2], transfer_buffer_content[3], transfer_buffer_content[4], transfer_buffer_content[5], transfer_buffer_content[6], transfer_buffer_content[7]); 
    printk("sprintf_result: %d\n", sprintf_result);
    printk("hex_string: %s\n", hex_string);
    printk("\n");
    bitmap_parse_result = bitmap_parse(hex_string, 33, &input_bitmap, 64);
    printk("transfer: %s\n", eight_bytes_to_bit_string(transfer_buffer_content));
    printk("bitmap_parse_result: %d\n", bitmap_parse_result);
    REPORT_BUTTON(1, 1-1);
    REPORT_BUTTON(2, 2-1);
    REPORT_BUTTON(3, 3-1);
    REPORT_BUTTON(4, 4-1);
    REPORT_BUTTON(5, 5-1);
    REPORT_BUTTON(6, 6-1);
    REPORT_BUTTON(7, 7-1);
    REPORT_BUTTON(8, 8-1);
    REPORT_BUTTON(9, 9-1);
    REPORT_BUTTON(10, 10-1);
    REPORT_BUTTON(11, 11-1);
    REPORT_BUTTON(12, 12-1);
    REPORT_BUTTON(13, 13-1);
    REPORT_BUTTON(14, 14-1);
    REPORT_BUTTON(15, 15-1);
    REPORT_BUTTON(16, 16-1);
    REPORT_BUTTON(17, 17-1);
    REPORT_BUTTON(18, 18-1);
    REPORT_BUTTON(19, 19-1);
    REPORT_BUTTON(20, 20-1);
    REPORT_BUTTON(21, 21-1);
    REPORT_BUTTON(22, 22-1);
    REPORT_BUTTON(23, 23-1);
    REPORT_BUTTON(24, 24-1);
    REPORT_BUTTON(25, 25-1);
    REPORT_BUTTON(26, 26-1);
    REPORT_BUTTON(27, 27-1);
    REPORT_BUTTON(28, 28-1);
    REPORT_BUTTON(29, 29-1);
    REPORT_BUTTON(30, 30-1);
    REPORT_BUTTON(31, 31-1);
    REPORT_BUTTON(32, 32-1);
    REPORT_BUTTON(33, 33-1);
    REPORT_BUTTON(34, 34-1);
    REPORT_BUTTON(35, 35-1);
    REPORT_BUTTON(36, 36-1);
    REPORT_BUTTON(37, 37-1);
    REPORT_BUTTON(38, 38-1);
    REPORT_BUTTON(39, 39-1);
    REPORT_BUTTON(40, 40-1);
    REPORT_BUTTON(41, 41-1);
    REPORT_BUTTON(42, 42-1);
    REPORT_BUTTON(43, 43-1);
    REPORT_BUTTON(44, 44-1);
    REPORT_BUTTON(45, 45-1);
    REPORT_BUTTON(46, 46-1);
    REPORT_BUTTON(47, 47-1);
    REPORT_BUTTON(48, 48-1);
    REPORT_BUTTON(49, 49-1);
    REPORT_BUTTON(50, 50-1);
    REPORT_BUTTON(51, 51-1);
    REPORT_BUTTON(52, 52-1);
    REPORT_BUTTON(53, 53-1);
    REPORT_BUTTON(54, 54-1);
    REPORT_BUTTON(55, 55-1);
    REPORT_BUTTON(56, 56-1);
    REPORT_BUTTON(57, 57-1);
    REPORT_BUTTON(58, 58-1);
    REPORT_BUTTON(59, 59-1);
    REPORT_BUTTON(60, 60-1);
    REPORT_BUTTON(61, 61-1);
    REPORT_BUTTON(62, 62-1);
    REPORT_BUTTON(63, 63-1);
    input_sync(g13_input_device);
    /* FIXME VP 27.12.2010: Hardcoded A for every key */
    /*
    input_report_key(g13_input_device, KEY_A, 1);
    input_report_key(g13_input_device, KEY_A, 0);
    input_sync(g13_input_device);
    */
    /* TODO VP 30.12.2010: Do we actually need this memset? */
    memset(urb->transfer_buffer, '\0', urb->transfer_buffer_length);
    usb_submit_urb(urb, GFP_ATOMIC);
};