}
if (!pdata->clkin) {
- clk = clk_get(&spi->dev, "clkin");
+ clk = devm_clk_get(&spi->dev, "clkin");
if (IS_ERR(clk))
return -EPROBE_DEFER;
return ret;
}
- indio_dev = iio_device_alloc(sizeof(*st));
+ indio_dev = devm_iio_device_alloc(&spi->dev, sizeof(*st));
if (indio_dev == NULL)
return -ENOMEM;
st = iio_priv(indio_dev);
- st->reg = regulator_get(&spi->dev, "vcc");
+ st->reg = devm_regulator_get(&spi->dev, "vcc");
if (!IS_ERR(st->reg)) {
ret = regulator_enable(st->reg);
if (ret)
- goto error_put_reg;
+ goto error_disable_clk;
}
spi_set_drvdata(spi, indio_dev);
memset(st->regs_hw, 0xFF, sizeof(st->regs_hw));
if (gpio_is_valid(pdata->gpio_lock_detect)) {
- ret = gpio_request(pdata->gpio_lock_detect, indio_dev->name);
+ ret = devm_gpio_request(&spi->dev, pdata->gpio_lock_detect,
+ indio_dev->name);
if (ret) {
dev_err(&spi->dev, "fail to request lock detect GPIO-%d",
pdata->gpio_lock_detect);
if (pdata->power_up_frequency) {
ret = adf4350_set_freq(st, pdata->power_up_frequency);
if (ret)
- goto error_free_gpio;
+ goto error_disable_reg;
}
ret = iio_device_register(indio_dev);
if (ret)
- goto error_free_gpio;
+ goto error_disable_reg;
return 0;
-error_free_gpio:
- if (gpio_is_valid(pdata->gpio_lock_detect))
- gpio_free(pdata->gpio_lock_detect);
-
error_disable_reg:
if (!IS_ERR(st->reg))
regulator_disable(st->reg);
-error_put_reg:
- if (!IS_ERR(st->reg))
- regulator_put(st->reg);
-
+error_disable_clk:
if (clk)
clk_disable_unprepare(clk);
- iio_device_free(indio_dev);
return ret;
}
if (!IS_ERR(reg)) {
regulator_disable(reg);
- regulator_put(reg);
}
- if (gpio_is_valid(st->pdata->gpio_lock_detect))
- gpio_free(st->pdata->gpio_lock_detect);
-
- iio_device_free(indio_dev);
-
return 0;
}