コード例 #1
0
ファイル: ccid.c プロジェクト: A2109devs/lenovo_a2109a_kernel
static int ccid_activate(struct ccid_operations *ccid_ops)
{
	int err = -ENOBUFS;

	ccid_ops->ccid_hc_rx_slab =
			ccid_kmem_cache_create(ccid_ops->ccid_hc_rx_obj_size,
					       ccid_ops->ccid_hc_rx_slab_name,
					       "ccid%u_hc_rx_sock",
					       ccid_ops->ccid_id);
	if (ccid_ops->ccid_hc_rx_slab == NULL)
		goto out;

	ccid_ops->ccid_hc_tx_slab =
			ccid_kmem_cache_create(ccid_ops->ccid_hc_tx_obj_size,
					       ccid_ops->ccid_hc_tx_slab_name,
					       "ccid%u_hc_tx_sock",
					       ccid_ops->ccid_id);
	if (ccid_ops->ccid_hc_tx_slab == NULL)
		goto out_free_rx_slab;

	pr_info("CCID: Activated CCID %d (%s)\n",
		ccid_ops->ccid_id, ccid_ops->ccid_name);
	err = 0;
out:
	return err;
out_free_rx_slab:
	ccid_kmem_cache_destroy(ccid_ops->ccid_hc_rx_slab);
	ccid_ops->ccid_hc_rx_slab = NULL;
	goto out;
}
コード例 #2
0
ファイル: ccid.c プロジェクト: 274914765/C
int ccid_register(struct ccid_operations *ccid_ops)
{
    int err = -ENOBUFS;

    ccid_ops->ccid_hc_rx_slab =
            ccid_kmem_cache_create(ccid_ops->ccid_hc_rx_obj_size,
                           "ccid%u_hc_rx_sock",
                           ccid_ops->ccid_id);
    if (ccid_ops->ccid_hc_rx_slab == NULL)
        goto out;

    ccid_ops->ccid_hc_tx_slab =
            ccid_kmem_cache_create(ccid_ops->ccid_hc_tx_obj_size,
                           "ccid%u_hc_tx_sock",
                           ccid_ops->ccid_id);
    if (ccid_ops->ccid_hc_tx_slab == NULL)
        goto out_free_rx_slab;

    ccids_write_lock();
    err = -EEXIST;
    if (ccids[ccid_ops->ccid_id] == NULL) {
        ccids[ccid_ops->ccid_id] = ccid_ops;
        err = 0;
    }
    ccids_write_unlock();
    if (err != 0)
        goto out_free_tx_slab;

    pr_info("CCID: Registered CCID %d (%s)\n",
        ccid_ops->ccid_id, ccid_ops->ccid_name);
out:
    return err;
out_free_tx_slab:
    ccid_kmem_cache_destroy(ccid_ops->ccid_hc_tx_slab);
    ccid_ops->ccid_hc_tx_slab = NULL;
    goto out;
out_free_rx_slab:
    ccid_kmem_cache_destroy(ccid_ops->ccid_hc_rx_slab);
    ccid_ops->ccid_hc_rx_slab = NULL;
    goto out;
}