]> git.karo-electronics.de Git - karo-tx-linux.git/blobdiff - drivers/staging/iio/resolver/ad2s1210.c
Merge remote-tracking branch 'staging/staging-next'
[karo-tx-linux.git] / drivers / staging / iio / resolver / ad2s1210.c
index dcdadbbcf7e864978fbd119721f1cf058ba69234..6966d5f766481befae4cb5d250434842acc06bc1 100644 (file)
@@ -206,10 +206,10 @@ static ssize_t ad2s1210_store_fclkin(struct device *dev,
                                     size_t len)
 {
        struct ad2s1210_state *st = iio_priv(dev_to_iio_dev(dev));
-       unsigned long fclkin;
+       unsigned int fclkin;
        int ret;
 
-       ret = strict_strtoul(buf, 10, &fclkin);
+       ret = kstrtouint(buf, 10, &fclkin);
        if (ret)
                return ret;
        if (fclkin < AD2S1210_MIN_CLKIN || fclkin > AD2S1210_MAX_CLKIN) {
@@ -243,10 +243,10 @@ static ssize_t ad2s1210_store_fexcit(struct device *dev,
                                     const char *buf, size_t len)
 {
        struct ad2s1210_state *st = iio_priv(dev_to_iio_dev(dev));
-       unsigned long fexcit;
+       unsigned int fexcit;
        int ret;
 
-       ret = strict_strtoul(buf, 10, &fexcit);
+       ret = kstrtouint(buf, 10, &fexcit);
        if (ret < 0)
                return ret;
        if (fexcit < AD2S1210_MIN_EXCIT || fexcit > AD2S1210_MAX_EXCIT) {
@@ -282,11 +282,11 @@ static ssize_t ad2s1210_store_control(struct device *dev,
                        const char *buf, size_t len)
 {
        struct ad2s1210_state *st = iio_priv(dev_to_iio_dev(dev));
-       unsigned long udata;
+       unsigned char udata;
        unsigned char data;
        int ret;
 
-       ret = strict_strtoul(buf, 16, &udata);
+       ret = kstrtou8(buf, 16, &udata);
        if (ret)
                return -EINVAL;
 
@@ -337,10 +337,10 @@ static ssize_t ad2s1210_store_resolution(struct device *dev,
 {
        struct ad2s1210_state *st = iio_priv(dev_to_iio_dev(dev));
        unsigned char data;
-       unsigned long udata;
+       unsigned char udata;
        int ret;
 
-       ret = strict_strtoul(buf, 10, &udata);
+       ret = kstrtou8(buf, 10, &udata);
        if (ret || udata < 10 || udata > 16) {
                pr_err("ad2s1210: resolution out of range\n");
                return -EINVAL;
@@ -438,11 +438,11 @@ static ssize_t ad2s1210_store_reg(struct device *dev,
                struct device_attribute *attr, const char *buf, size_t len)
 {
        struct ad2s1210_state *st = iio_priv(dev_to_iio_dev(dev));
-       unsigned long data;
+       unsigned char data;
        int ret;
        struct iio_dev_attr *iattr = to_iio_dev_attr(attr);
 
-       ret = strict_strtoul(buf, 10, &data);
+       ret = kstrtou8(buf, 10, &data);
        if (ret)
                return -EINVAL;
        mutex_lock(&st->lock);
@@ -669,16 +669,14 @@ static int ad2s1210_probe(struct spi_device *spi)
        if (spi->dev.platform_data == NULL)
                return -EINVAL;
 
-       indio_dev = iio_device_alloc(sizeof(*st));
-       if (indio_dev == NULL) {
-               ret = -ENOMEM;
-               goto error_ret;
-       }
+       indio_dev = devm_iio_device_alloc(&spi->dev, sizeof(*st));
+       if (!indio_dev)
+               return -ENOMEM;
        st = iio_priv(indio_dev);
        st->pdata = spi->dev.platform_data;
        ret = ad2s1210_setup_gpios(st);
        if (ret < 0)
-               goto error_free_dev;
+               return ret;
 
        spi_set_drvdata(spi, indio_dev);
 
@@ -709,9 +707,6 @@ static int ad2s1210_probe(struct spi_device *spi)
 
 error_free_gpios:
        ad2s1210_free_gpios(st);
-error_free_dev:
-       iio_device_free(indio_dev);
-error_ret:
        return ret;
 }
 
@@ -721,7 +716,6 @@ static int ad2s1210_remove(struct spi_device *spi)
 
        iio_device_unregister(indio_dev);
        ad2s1210_free_gpios(iio_priv(indio_dev));
-       iio_device_free(indio_dev);
 
        return 0;
 }