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:   Wed, 7 Aug 2019 05:48:13 +0000
From:   <Tudor.Ambarus@...rochip.com>
To:     <vigneshr@...com>, <miquel.raynal@...tlin.com>, <richard@....at>
CC:     <marek.vasut@...il.com>, <bbrezillon@...nel.org>,
        <linux-kernel@...r.kernel.org>, <linux-mtd@...ts.infradead.org>,
        <tmaimon77@...il.com>
Subject: Re: [PATCH v5 3/3] mtd: spi-nor: Rework hwcaps selection for the
 spi-mem case



On 08/06/2019 08:10 AM, Vignesh Raghavendra wrote:
> +static int spi_nor_spimem_check_op(struct spi_nor *nor,
> +				   struct spi_mem_op *op)
> +{
> +	/*
> +	 * First test with 4 address bytes. The opcode itself might
> +	 * be a 3B addressing opcode but we don't care, because
> +	 * SPI controller implementation should not check the opcode,
> +	 * but just the sequence.
> +	 */
> +	op->addr.nbytes = 4;
> +	if (!spi_mem_supports_op(nor->spimem, op)) {
> +		/* If flash size <16MB, 3 address bytes are sufficient */
> +		if (nor->mtd.size <= SZ_16M) {
> +			op->addr.nbytes = 3;
> +			if (!spi_mem_supports_op(nor->spimem, op))
> +				return -ENOTSUPP;
> +			return 0;
> +		}
> +		return -ENOTSUPP;
> +	}
> +
> +	return 0;
> +}

We can get rid of a level of indentation by writing it as:

static int spi_nor_spimem_check_op(struct spi_nor *nor,
                                   struct spi_mem_op *op)
{
        op->addr.nbytes = 4;
        if (!spi_mem_supports_op(nor->spimem, op)) {
                if (nor->mtd.size > SZ_16M)
			return -ENOTSUPP;

                /* If flash size <16MB, 3 address bytes are sufficient */
		op->addr.nbytes = 3;
		if (!spi_mem_supports_op(nor->spimem, op))
			return -ENOTSUPP;
        }

        return 0;
}

I'll do this by myself when applying, no need to resubmit.

Thanks, Vignesh!
ta

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ