Beispiel #1
0
static int __devinit modem_probe(struct platform_device *pdev)
{
	int i;
	struct modem_data *pdata;
	struct modem_ctl *modemctl;
	struct io_device *iod[MAX_NUM_IO_DEV];
	struct link_device *ld;
	struct io_raw_devices *io_raw_devs = NULL;

	pdata = pdev->dev.platform_data;
	memset(iod, 0, sizeof(iod));

	modemctl = create_modemctl_device(pdev);
	if (!modemctl)
		return -ENOMEM;

	/* create link device */
	ld = call_link_init_func(pdev, pdata->link_type);
		if (!ld)
			goto err_free_modemctl;

	io_raw_devs = kzalloc(sizeof(struct io_raw_devices), GFP_KERNEL);
	if (!io_raw_devs)
		return -ENOMEM;

	/* create io deivces and connect to modemctl device */
	for (i = 0; i < pdata->num_iodevs; i++) {
		iod[i] = create_io_device(&pdata->iodevs[i], modemctl,
					pdata->modem_net);
		if (!iod[i])
			goto err_free_modemctl;

		if (iod[i]->format == IPC_RAW) {
			int ch = iod[i]->id & 0x1F;
			io_raw_devs->raw_devices[ch] = iod[i];
			io_raw_devs->num_of_raw_devs++;
			iod[i]->link = ld;
		} else {
			/* connect io devices to one link device */
			ld->attach(ld, iod[i]);
		}

		switch (iod[i]->format) {
		case IPC_FMT:
			wake_lock_init(&iod[i]->wakelock, WAKE_LOCK_SUSPEND,
					iod[i]->name);
			iod[i]->waketime = FMT_WAKE_TIME;
			break;

		case IPC_RFS:
			wake_lock_init(&iod[i]->wakelock, WAKE_LOCK_SUSPEND,
					iod[i]->name);
			iod[i]->waketime = RFS_WAKE_TIME;
			break;

		case IPC_MULTI_RAW:
			iod[i]->private_data = (void *)io_raw_devs;

			wake_lock_init(&iod[i]->wakelock, WAKE_LOCK_SUSPEND,
					iod[i]->name);
			iod[i]->waketime = RAW_WAKE_TIME;
			break;

		default:
			break;
		}
	}

	platform_set_drvdata(pdev, modemctl);

	pr_debug("[MODEM_IF] modem_probe DONE\n");
	return 0;

err_free_modemctl:
	for (i = 0; i < pdata->num_iodevs; i++)
		if (iod[i] != NULL)
			kfree(iod[i]);

	if (io_raw_devs != NULL)
		kfree(io_raw_devs);

	if (modemctl != NULL)
		kfree(modemctl);

	return -ENOMEM;
}
Beispiel #2
0
static int __devinit modem_probe(struct platform_device *pdev)
{
	int i;
	struct modem_data *pdata;
	struct modem_ctl *modemctl;
	struct io_device *iod[MAX_NUM_IO_DEV];
	struct link_device *ld;
	struct io_raw_devices *io_raw_devs = NULL;

	pr_debug("[MIF] <%s> Called!!\n", __func__);
	pdata = pdev->dev.platform_data;
	memset(iod, 0, sizeof(iod));

	modemctl = create_modemctl_device(pdev);
	if (!modemctl) {
		pr_err("[MIF] <%s> create modemctl failed!!\n", __func__);
		return -ENOMEM;
	}

	/* create link device */
	ld = call_link_init_func(pdev, pdata->link_type);
	if (!ld) {
		pr_err("[MIF] <%s> create link_device failed!!\n", __func__);
		goto err_free_modemctl;
	}

	io_raw_devs = kzalloc(sizeof(struct io_raw_devices), GFP_KERNEL);
	if (!io_raw_devs)
		goto err_free_modemctl;

	/* create io deivces and connect to modemctl device */
	for (i = 0; i < pdata->num_iodevs; i++) {
		iod[i] = create_io_device(&pdata->iodevs[i], modemctl,
					pdata);
		if (!iod[i])
			goto err_free_modemctl;

		if (iod[i]->format == IPC_RAW) {
			int ch = iod[i]->id & 0x1F;
			io_raw_devs->raw_devices[ch] = iod[i];
			io_raw_devs->num_of_raw_devs++;
			iod[i]->link = ld;
		} else {
			/* connect io devices to one link device */
			ld->attach(ld, iod[i]);
		}

		if (iod[i]->format == IPC_MULTI_RAW)
			iod[i]->private_data = (void *)io_raw_devs;
	}

	platform_set_drvdata(pdev, modemctl);

	pr_info("[MIF] <%s> modem_probe DONE\n", __func__);
	return 0;

err_free_modemctl:
	for (i = 0; i < pdata->num_iodevs; i++)
		if (iod[i] != NULL)
			kfree(iod[i]);

	if (io_raw_devs != NULL)
		kfree(io_raw_devs);

	if (modemctl != NULL)
		kfree(modemctl);

	return -ENOMEM;
}