Re: [PATCH v2] iio: adc: exynos5_adc: fix compilation warnings

From: Doug Anderson
Date: Tue Mar 12 2013 - 12:14:41 EST


Naveen,

On Wed, Mar 6, 2013 at 7:09 PM, Naveen Krishna Chatradhi
<ch.naveen@xxxxxxxxxxx> wrote:
> - unsigned int version;
> + unsigned int version;

Given that you've changed exynos_adc_get_version() to return an int,
shouldn't this be an int too (not unsigned)?


> -static inline unsigned int exynos_adc_get_version(struct platform_device *pdev)
> +static inline int exynos_adc_get_version(struct platform_device *pdev)
> {
> const struct of_device_id *match;
>
> match = of_match_node(exynos_adc_match, pdev->dev.of_node);
> - return (unsigned int)match->data;
> + return (int)match->data;

Given that you're now checking for an error code below it seems like
you ought to generate one here. ;)
...AKA: return an error if match is NULL--don't dereference NULL.


> static int exynos_read_raw(struct iio_dev *indio_dev,
> @@ -117,7 +117,7 @@ static int exynos_read_raw(struct iio_dev *indio_dev,
> long mask)
> {
> struct exynos_adc *info = iio_priv(indio_dev);
> - unsigned long timeout;
> + int timeout;

Why change this to an "int" when
wait_for_completion_interruptible_timeout() returns a long? I agree
with the removal of the "unsigned", though.


> + version = exynos_adc_get_version(pdev);
> + if (version < 0) {
> + dev_err(&pdev->dev, "no matching of_node, err = %d\n", version);
> + ret = version;
> + goto err_iio;
> + }
> +
> + info->version = version;

Optional (and perhaps a matter of preference): I'd eliminate the
"version" variable here and just re-use "ret" for storing the result
of exynos_adc_get_version().


-Doug
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/