/*
 * fa_zio_init
 *
 * It checks if we can register this device.  If it is possibile, the function
 * registers both device and trigger. The FMC probe invokes this function.
 */
int fa_zio_init(struct fa_dev *fa)
{
	struct device *msgdev = &fa->fmc->dev;
	int err;


	/* Allocate the hardware zio_device for registration */
	fa->hwzdev = zio_allocate_device();
	if (IS_ERR(fa->hwzdev)) {
		dev_err(msgdev, "Cannot allocate ZIO device\n");
		return PTR_ERR(fa->hwzdev);
	}

	/* Mandatory fields */
	fa->hwzdev->owner = THIS_MODULE;
	fa->hwzdev->priv_d = fa;

	/* Register the hardware zio_device */
	err = zio_register_device(fa->hwzdev, "adc-100m14b",
				  fa->fmc->device_id);
	if (err) {
		dev_err(msgdev, "Cannot register ZIO device fmc-adc-100m14b\n");
		zio_free_device(fa->hwzdev);
	}
	return err;
}
Exemple #2
0
static int __init zdtc_init(void)
{
	int err;

	err = zio_register_driver(&zdtc_zdrv);
	if (err)
		return err;

	zdtc_init_dev = zio_allocate_device();
	if (IS_ERR(zdtc_init_dev)) {
		err = PTR_ERR(zdtc_init_dev);
		goto out_alloc;
	}
	zdtc_init_dev->owner = THIS_MODULE;
	err = zio_register_device(zdtc_init_dev, "zdtc", 0);
	if (err)
		goto out_register;

	hrtimer_init(&zdtc.timer, CLOCK_REALTIME, HRTIMER_MODE_ABS);
	zdtc.timer.function = zdtc_fn;
	return 0;

out_register:
	zio_free_device(zdtc_init_dev);
out_alloc:
	zio_unregister_driver(&zdtc_zdrv);
	return err;
}
Exemple #3
0
static int ob_fmc_probe(struct fmc_device *fmc)
{
	struct ob_dev *ob;
	char *fwname;
	int err;

	/* Validate the new FMC device */
	err = fmc->op->validate(fmc, &ob_fmc_drv);
	if (err < 0) {
		dev_info(fmc->hwdev, "not using \"%s\" according to "
			 "modparam\n", KBUILD_MODNAME);
		return -ENODEV;
	}

	/* Driver data */
	ob = devm_kzalloc(&fmc->dev, sizeof(struct ob_dev), GFP_KERNEL);
	if (!ob)
		return -ENOMEM;
	fmc_set_drvdata(fmc, ob);
	ob->fmc = fmc;

	if (fmc->flags & FMC_DEVICE_HAS_GOLDEN || ob_fmc_drv.gw_n) {
		if (ob_fmc_drv.gw_n)
			fwname = "";	/* reprogram will pick from module parameter */
		else
			fwname = OB_DEFAULT_GATEWARE;
		dev_info(fmc->hwdev, "Gateware (%s)\n", fwname);

		/* We first write a new binary (and lm32) within the carrier */
		err = fmc_reprogram(fmc, &ob_fmc_drv, fwname, 0x0);
		if (err) {
			dev_err(fmc->hwdev, "write firmware \"%s\": error %i\n",
				fwname, err);
			return err;
		}
		dev_info(fmc->hwdev, "Gateware successfully loaded\n");
	} else {
		dev_info(fmc->hwdev,
			 "Gateware already there. Set the \"gateware\" parameter to overwrite the current gateware\n");
	}

	err = __ob_sdb_get_device(ob);
	if (err < 0)
		return err;

	ob->hwzdev = zio_allocate_device();
	if (IS_ERR(ob->hwzdev)) {
		dev_err(fmc->hwdev, "Cannot allocate ZIO device\n");
		return PTR_ERR(ob->hwzdev);
	}
	/* Mandatory fields */
	ob->hwzdev->owner = THIS_MODULE;
	ob->hwzdev->priv_d = ob;
	/* Register the hardware zio_device */
	err = zio_register_device(ob->hwzdev, "obsbox",
				  ob->fmc->device_id);
	if (err) {
		dev_err(fmc->hwdev, "Cannot register ZIO device obs-box\n");
		zio_free_device(ob->hwzdev);
		return err;
	}

	return 0;
}