static int adis16400_probe(struct spi_device *spi) { struct adis16400_state *st; struct iio_dev *indio_dev; int ret; indio_dev = devm_iio_device_alloc(&spi->dev, sizeof(*st)); if (indio_dev == NULL) return -ENOMEM; st = iio_priv(indio_dev); /* this is only used for removal purposes */ spi_set_drvdata(spi, indio_dev); /* setup the industrialio driver allocated elements */ st->variant = &adis16400_chips[spi_get_device_id(spi)->driver_data]; indio_dev->dev.parent = &spi->dev; indio_dev->name = spi_get_device_id(spi)->name; indio_dev->channels = st->variant->channels; indio_dev->num_channels = st->variant->num_channels; indio_dev->info = &adis16400_info; indio_dev->modes = INDIO_DIRECT_MODE; if (!(st->variant->flags & ADIS16400_NO_BURST)) { adis16400_setup_chan_mask(st); indio_dev->available_scan_masks = st->avail_scan_mask; } ret = adis_init(&st->adis, indio_dev, spi, &adis16400_data); if (ret) return ret; ret = adis_setup_buffer_and_trigger(&st->adis, indio_dev, adis16400_trigger_handler); if (ret) return ret; /* Get the device into a sane initial state */ ret = adis16400_initial_setup(indio_dev); if (ret) goto error_cleanup_buffer; ret = iio_device_register(indio_dev); if (ret) goto error_cleanup_buffer; adis16400_debugfs_init(indio_dev); return 0; error_cleanup_buffer: adis_cleanup_buffer_and_trigger(&st->adis, indio_dev); return ret; }
static int adis16136_probe(struct spi_device *spi) { const struct spi_device_id *id = spi_get_device_id(spi); struct adis16136 *adis16136; struct iio_dev *indio_dev; int ret; indio_dev = devm_iio_device_alloc(&spi->dev, sizeof(*adis16136)); if (indio_dev == NULL) return -ENOMEM; spi_set_drvdata(spi, indio_dev); adis16136 = iio_priv(indio_dev); adis16136->chip_info = &adis16136_chip_info[id->driver_data]; indio_dev->dev.parent = &spi->dev; indio_dev->name = spi_get_device_id(spi)->name; indio_dev->channels = adis16136_channels; indio_dev->num_channels = ARRAY_SIZE(adis16136_channels); indio_dev->info = &adis16136_info; indio_dev->modes = INDIO_DIRECT_MODE; ret = adis_init(&adis16136->adis, indio_dev, spi, &adis16136_data); if (ret) return ret; ret = adis_setup_buffer_and_trigger(&adis16136->adis, indio_dev, NULL); if (ret) return ret; ret = adis16136_initial_setup(indio_dev); if (ret) goto error_cleanup_buffer; ret = iio_device_register(indio_dev); if (ret) goto error_stop_device; adis16136_debugfs_init(indio_dev); return 0; error_stop_device: adis16136_stop_device(indio_dev); error_cleanup_buffer: adis_cleanup_buffer_and_trigger(&adis16136->adis, indio_dev); return ret; }
static int adis16260_probe(struct spi_device *spi) { struct iio_dev *indio_dev; struct adis *adis; int ret; /* setup the industrialio driver allocated elements */ indio_dev = devm_iio_device_alloc(&spi->dev, sizeof(*adis)); if (!indio_dev) return -ENOMEM; adis = iio_priv(indio_dev); /* this is only used for removal purposes */ spi_set_drvdata(spi, indio_dev); indio_dev->name = spi_get_device_id(spi)->name; indio_dev->dev.parent = &spi->dev; indio_dev->info = &adis16260_info; indio_dev->channels = adis16260_channels; indio_dev->num_channels = ARRAY_SIZE(adis16260_channels); indio_dev->modes = INDIO_DIRECT_MODE; ret = adis_init(adis, indio_dev, spi, &adis16260_data); if (ret) return ret; ret = adis_setup_buffer_and_trigger(adis, indio_dev, NULL); if (ret) return ret; /* Get the device into a sane initial state */ ret = adis_initial_startup(adis); if (ret) goto error_cleanup_buffer_trigger; ret = iio_device_register(indio_dev); if (ret) goto error_cleanup_buffer_trigger; return 0; error_cleanup_buffer_trigger: adis_cleanup_buffer_and_trigger(adis, indio_dev); return ret; }
static int adis16209_probe(struct spi_device *spi) { int ret; struct adis *st; struct iio_dev *indio_dev; indio_dev = devm_iio_device_alloc(&spi->dev, sizeof(*st)); if (!indio_dev) return -ENOMEM; st = iio_priv(indio_dev); spi_set_drvdata(spi, indio_dev); indio_dev->name = spi->dev.driver->name; indio_dev->dev.parent = &spi->dev; indio_dev->info = &adis16209_info; indio_dev->channels = adis16209_channels; indio_dev->num_channels = ARRAY_SIZE(adis16209_channels); indio_dev->modes = INDIO_DIRECT_MODE; ret = adis_init(st, indio_dev, spi, &adis16209_data); if (ret) return ret; ret = adis_setup_buffer_and_trigger(st, indio_dev, NULL); if (ret) return ret; ret = adis_initial_startup(st); if (ret) goto error_cleanup_buffer_trigger; ret = iio_device_register(indio_dev); if (ret) goto error_cleanup_buffer_trigger; return 0; error_cleanup_buffer_trigger: adis_cleanup_buffer_and_trigger(st, indio_dev); return ret; }