/*
 * Initialize readers
 *
 * Called during sc_establish_context(), when the driver
 * is loaded
 */
static int
openct_reader_init(sc_context_t *ctx, void **priv_data)
{
	unsigned int	i,max;
	scconf_block *conf_block;

	SC_FUNC_CALLED(ctx, 1);

	max=OPENCT_MAX_READERS; 

        conf_block = sc_get_conf_block(ctx, "reader_driver", "openct", 1);
	if (conf_block) {
		max = scconf_get_int(conf_block, "readers", OPENCT_MAX_READERS);
	}

	for (i = 0; i < max; i++) {
		ct_info_t	info;

		if (ct_reader_info(i, &info) >= 0) {
			openct_add_reader(ctx, i, &info);
		} else if (i < PREALLOCATE) {
			openct_add_reader(ctx, i, NULL);
		}
	}

	return SC_NO_ERROR;
}
示例#2
0
/*
 * Initialize readers
 *
 * Called during sc_establish_context(), when the driver
 * is loaded
 */
static int
openct_reader_init(sc_context_t *ctx)
{
	unsigned int	i,max_virtual;
	scconf_block *conf_block;

	SC_FUNC_CALLED(ctx, SC_LOG_DEBUG_VERBOSE);

	max_virtual = 2;
	conf_block = sc_get_conf_block(ctx, "reader_driver", "openct", 1);
	if (conf_block) {
		max_virtual = scconf_get_int(conf_block, "readers", max_virtual);
	}

	for (i = 0; i < OPENCT_MAX_READERS; i++) {
		ct_info_t	info;
		/* XXX: As long as OpenCT has slots, multislot readers should create several instances here. */
		if (ct_reader_info(i, &info) >= 0) {
			openct_add_reader(ctx, i, &info);
		} else if (i < max_virtual) {
			openct_add_reader(ctx, i, NULL);
		}
	}

	return SC_SUCCESS;
}