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>] [day] [month] [year] [list]
Date:	Tue, 20 Apr 2010 18:17:32 -0500
From:	H Hartley Sweeten <hartleys@...ionengravers.com>
To:	Linux Kernel <linux-kernel@...r.kernel.org>,
	"linux-mtd@...ts.infradead.org" <linux-mtd@...ts.infradead.org>
CC:	David Woodhouse <dwmw2@...radead.org>,
	"andre@...ewatersys.com" <andre@...ewatersys.com>,
	"ryan@...ewatersys.com" <ryan@...ewatersys.com>
Subject: [PATCH] sst25l.c: simplify reading the device ManID/DevID

The Read-ID command will continuously output the Manufacture ID and Device ID
until the command is terminated by a low to high transition on the CE# pin.
We can take advantage of this in the sst25l_match_device routine by reading
both bytes in one spi_write_then_read transaction.

Signed-off-by: H Hartley Sweeten <hsweeten@...ionengravers.com>
Cc: David Woodhouse <dwmw2@...radead.org>
Cc: Andre Renaud <andre@...ewatersys.com>
Cc: Ryan Mallon <ryan@...ewatersys.com>

---

diff --git a/drivers/mtd/devices/sst25l.c b/drivers/mtd/devices/sst25l.c
index fe17054..b13ca75 100644
--- a/drivers/mtd/devices/sst25l.c
+++ b/drivers/mtd/devices/sst25l.c
@@ -328,7 +328,7 @@ out:
 static struct flash_info *__init sst25l_match_device(struct spi_device *spi)
 {
 	struct flash_info *flash_info = NULL;
-	unsigned char command[4], response;
+	unsigned char command[4], response[2];
 	int i, err;
 	uint16_t id;
 
@@ -336,25 +336,14 @@ static struct flash_info *__init sst25l_match_device(struct spi_device *spi)
 	command[1] = 0;
 	command[2] = 0;
 	command[3] = 0;
-	err = spi_write_then_read(spi, command, sizeof(command), &response, 1);
+	err = spi_write_then_read(spi, command, sizeof(command),
+				       response, sizeof(response));
 	if (err < 0) {
 		dev_err(&spi->dev, "error reading device id msb\n");
 		return NULL;
 	}
 
-	id = response << 8;
-
-	command[0] = SST25L_CMD_READ_ID;
-	command[1] = 0;
-	command[2] = 0;
-	command[3] = 1;
-	err = spi_write_then_read(spi, command, sizeof(command), &response, 1);
-	if (err < 0) {
-		dev_err(&spi->dev, "error reading device id lsb\n");
-		return NULL;
-	}
-
-	id |= response;
+	id = (response[0] << 8) | response[1];
 
 	for (i = 0; i < ARRAY_SIZE(sst25l_flash_info); i++)
 		if (sst25l_flash_info[i].device_id == id)

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ