Ejemplo n.º 1
0
static int ps3_probe_thread(void *data)
{
	struct ps3_repository_device *repo = data;
	int result;
	unsigned int ms = 250;

	pr_debug(" -> %s:%u: kthread started\n", __func__, __LINE__);

	do {
		try_to_freeze();

		pr_debug("%s:%u: probing...\n", __func__, __LINE__);

		do {
			result = ps3_repository_find_device(repo);

			if (result == -ENODEV)
				pr_debug("%s:%u: nothing new\n", __func__,
					__LINE__);
			else if (result)
				pr_debug("%s:%u: find device error.\n",
					__func__, __LINE__);
			else {
				pr_debug("%s:%u: found device (%u:%u:%u)\n",
					 __func__, __LINE__, repo->bus_index,
					 repo->dev_index, repo->dev_type);
				ps3_register_repository_device(repo);
				ps3_repository_bump_device(repo);
				ms = 250;
			}
		} while (!result);

		pr_debug("%s:%u: ms %u\n", __func__, __LINE__, ms);

		if ( ms > 60000)
			break;

		msleep_interruptible(ms);

		/* An exponential backoff. */
		ms <<= 1;

	} while (!kthread_should_stop());

	pr_debug(" <- %s:%u: kthread finished\n", __func__, __LINE__);

	return 0;
}
Ejemplo n.º 2
0
int __devinit ps3_repository_find_devices(enum ps3_bus_type bus_type,
	int (*callback)(const struct ps3_repository_device *repo))
{
	int result = 0;
	struct ps3_repository_device repo;

	pr_devel(" -> %s:%d: find bus_type %u\n", __func__, __LINE__, bus_type);

	repo.bus_type = bus_type;
	result = ps3_repository_find_bus(repo.bus_type, 0, &repo.bus_index);
	if (result) {
		pr_devel(" <- %s:%u: bus not found\n", __func__, __LINE__);
		return result;
	}

	result = ps3_repository_read_bus_id(repo.bus_index, &repo.bus_id);
	if (result) {
		pr_devel("%s:%d read_bus_id(%u) failed\n", __func__, __LINE__,
			 repo.bus_index);
		return result;
	}

	for (repo.dev_index = 0; ; repo.dev_index++) {
		result = ps3_repository_find_device(&repo);
		if (result == -ENODEV) {
			result = 0;
			break;
		} else if (result)
			break;

		result = callback(&repo);
		if (result) {
			pr_devel("%s:%d: abort at callback\n", __func__,
				__LINE__);
			break;
		}
	}

	pr_devel(" <- %s:%d\n", __func__, __LINE__);
	return result;
}