lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Date:	Fri, 4 Nov 2011 05:53:01 +0000
From:	"Mohammed, Afzal" <afzal@...com>
To:	Kyle Manna <kyle.manna@...l7.com>,
	"linux-kernel@...r.kernel.org" <linux-kernel@...r.kernel.org>,
	"linux-omap@...r.kernel.org" <linux-omap@...r.kernel.org>
CC:	Jorge Eduardo Candelaria <jedu@...mlogic.co.uk>,
	Mark Brown <broonie@...nsource.wolfsonmicro.com>,
	"Girdwood, Liam" <lrg@...com>, Samuel Ortiz <sameo@...ux.intel.com>
Subject: RE: [PATCH v3 1/6] mfd: TPS65910: Handle non-existent devices

Hi Kyla,

On Thu, Nov 03, 2011 at 22:38:01, Kyle Manna wrote:
> The JTAGREVNUM register contains a silicon revision number in the lower
> four bits and the upper four bits are to always read 0.
> 
> To detect the presence of the device, attempt to read JTAGREVNUM
> register and check that it returns a valid value.  If the I2C device
> fails to respond or returns an invalid value, return -ENODEV.
> 
:
:
> +	/* Check that the device is there */
> +	ret = tps65910_i2c_read(tps65910, TPS65910_JTAGVERNUM, 1, &reg);
> +	if (ret < 0 || (reg & ~JTAGVERNUM_VERNUM_MASK)) {
> +		dev_err(tps65910->dev, "unknown version: JTAGREVNUM = 0x%x\n",
> +				       reg);
> +		ret = -ENODEV;
>  		goto err;
> +	}

If i2c read fails, "0" would get printed as version.

Perhaps it would be better to print version irrespective of whether it
is unknown or not, and return error for unknown value, something like,

        unsigned char buff;

        /* Check that the device is actually there */
        ret = tps65910_i2c_read(tps65910, 0x0, 1, &buff);
        if (ret < 0) {
                dev_err(tps65910->dev, "could not be detected\n");
                ret = -ENODEV;
                goto err;
        }

        dev_info(tps65910->dev, "JTAGREVNUM 0x%x\n", buff);

        if (buff & ~JTAGVERNUM_VERNUM_MASK) {
                dev_err(tps65910->dev, "unknown version\n");
                ret = -ENODEV;
                goto err;
        }



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

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ