Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 195966
b: refs/heads/master
c: 0ffe0ce
h: refs/heads/master
v: v3
  • Loading branch information
H Hartley Sweeten authored and David Woodhouse committed May 14, 2010
1 parent 511c654 commit 9415013
Show file tree
Hide file tree
Showing 2 changed files with 34 additions and 25 deletions.
2 changes: 1 addition & 1 deletion [refs]
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
---
refs/heads/master: 46f3e88bd9da010e76a9049d55cf9013560b5903
refs/heads/master: 0ffe0ce36e07185c693e3ff06ab5b3b6c30780ee
57 changes: 33 additions & 24 deletions trunk/drivers/mtd/devices/sst25l.c
Original file line number Diff line number Diff line change
Expand Up @@ -73,15 +73,25 @@ static struct flash_info __initdata sst25l_flash_info[] = {

static int sst25l_status(struct sst25l_flash *flash, int *status)
{
unsigned char command, response;
struct spi_message m;
struct spi_transfer t;
unsigned char cmd_resp[2];
int err;

command = SST25L_CMD_RDSR;
err = spi_write_then_read(flash->spi, &command, 1, &response, 1);
spi_message_init(&m);
memset(&t, 0, sizeof(struct spi_transfer));

cmd_resp[0] = SST25L_CMD_RDSR;
cmd_resp[1] = 0xff;
t.tx_buf = cmd_resp;
t.rx_buf = cmd_resp;
t.len = sizeof(cmd_resp);
spi_message_add_tail(&t, &m);
err = spi_sync(flash->spi, &m);
if (err < 0)
return err;

*status = response;
*status = cmd_resp[1];
return 0;
}

Expand Down Expand Up @@ -328,33 +338,32 @@ static int sst25l_write(struct mtd_info *mtd, loff_t to, size_t len,
static struct flash_info *__init sst25l_match_device(struct spi_device *spi)
{
struct flash_info *flash_info = NULL;
unsigned char command[4], response;
struct spi_message m;
struct spi_transfer t;
unsigned char cmd_resp[6];
int i, err;
uint16_t id;

command[0] = SST25L_CMD_READ_ID;
command[1] = 0;
command[2] = 0;
command[3] = 0;
err = spi_write_then_read(spi, command, sizeof(command), &response, 1);
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);
spi_message_init(&m);
memset(&t, 0, sizeof(struct spi_transfer));

cmd_resp[0] = SST25L_CMD_READ_ID;
cmd_resp[1] = 0;
cmd_resp[2] = 0;
cmd_resp[3] = 0;
cmd_resp[4] = 0xff;
cmd_resp[5] = 0xff;
t.tx_buf = cmd_resp;
t.rx_buf = cmd_resp;
t.len = sizeof(cmd_resp);
spi_message_add_tail(&t, &m);
err = spi_sync(spi, &m);
if (err < 0) {
dev_err(&spi->dev, "error reading device id lsb\n");
dev_err(&spi->dev, "error reading device id\n");
return NULL;
}

id |= response;
id = (cmd_resp[4] << 8) | cmd_resp[5];

for (i = 0; i < ARRAY_SIZE(sst25l_flash_info); i++)
if (sst25l_flash_info[i].device_id == id)
Expand Down

0 comments on commit 9415013

Please sign in to comment.