From: Boris Brezillon <boris.brezillon@free-electrons.com>
To: Andrew Lunn <andrew@lunn.ch>
Cc: dwmw2@infradead.org, linux-mtd@lists.infradead.org, zajec5@gmail.com
Subject: Re: [PATCH v3] mtd: mchp23k256: Add driver for this SPI SRAM device
Date: Wed, 12 Apr 2017 08:41:22 +0200 [thread overview]
Message-ID: <20170412084122.35740e82@bbrezillon> (raw)
In-Reply-To: <1491946212-9226-1-git-send-email-andrew@lunn.ch>
On Tue, 11 Apr 2017 23:30:12 +0200
Andrew Lunn <andrew@lunn.ch> wrote:
> The Microchip 23k256 is a 32K Byte SRAM connected via SPI.
>
> Signed-off-by: Andrew Lunn <andrew@lunn.ch>
> Reviewed-by: Boris Brezillon <boris.brezillon@free-electrons.com>
3 minor things I didn't spot in my previous review.
[...]
> +static int mchp23k256_read(struct mtd_info *mtd, loff_t from, size_t len,
> + size_t *retlen, unsigned char *buf)
Align 'size_t *retlen' to the open parenthesis.
> +{
> + struct mchp23k256_flash *flash = to_mchp23k256_flash(mtd);
> + struct spi_transfer transfer[2] = {};
> + struct spi_message message;
> + unsigned char command[3];
> +
> + spi_message_init(&message);
> +
> + memset(&transfer, 0, sizeof(transfer));
> + command[0] = MCHP23K256_CMD_READ;
> + command[1] = from >> 8;
> + command[2] = from;
> +
> + transfer[0].tx_buf = command;
> + transfer[0].len = sizeof(command);
> + spi_message_add_tail(&transfer[0], &message);
> +
> + transfer[1].rx_buf = buf;
> + transfer[1].len = len;
> + spi_message_add_tail(&transfer[1], &message);
> +
> + mutex_lock(&flash->lock);
> +
> + spi_sync(flash->spi, &message);
> +
> + if (retlen && message.actual_length > sizeof(command))
> + *retlen += message.actual_length - sizeof(command);
> +
> + mutex_unlock(&flash->lock);
> + return 0;
> +}
> +
> +/* Set the device into sequential mode. This allows read/writes to
/*
* Set the device ...
> + * the entire SRAM in a single operation
> + */
> +static int mchp23k256_set_mode(struct spi_device *spi)
> +{
> + struct spi_transfer transfer = {};
> + struct spi_message message;
> + unsigned char command[2];
> +
> + spi_message_init(&message);
> +
> + command[0] = MCHP23K256_CMD_WRITE_STATUS;
> + command[1] = MCHP23K256_MODE_SEQ;
> +
> + transfer.tx_buf = command;
> + transfer.len = sizeof(command);
> + spi_message_add_tail(&transfer, &message);
> +
> + return spi_sync(spi, &message);
> +}
> +
> +
Remove these 2 extra empty lines.
> +
> +static int mchp23k256_probe(struct spi_device *spi)
> +{
> + struct mchp23k256_flash *flash;
> + struct flash_platform_data *data;
> + int err;
> +
> + flash = devm_kzalloc(&spi->dev, sizeof(*flash), GFP_KERNEL);
> + if (!flash)
> + return -ENOMEM;
> +
> + flash->spi = spi;
> + mutex_init(&flash->lock);
> + spi_set_drvdata(spi, flash);
> +
> + err = mchp23k256_set_mode(spi);
> + if (err)
> + return err;
> +
> + data = dev_get_platdata(&spi->dev);
> +
> + flash->mtd.dev.parent = &spi->dev;
> + flash->mtd.type = MTD_RAM;
> + flash->mtd.flags = MTD_CAP_RAM;
> + flash->mtd.writesize = 1;
> + flash->mtd.size = SZ_32K;
> + flash->mtd._read = mchp23k256_read;
> + flash->mtd._write = mchp23k256_write;
> +
> + err = mtd_device_parse_register(&flash->mtd, NULL, NULL,
> + data ? data->parts : NULL,
> + data ? data->nr_parts : 0);
> + if (err)
> + return err;
> +
> + return 0;
> +}
next prev parent reply other threads:[~2017-04-12 6:41 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-04-11 21:30 [PATCH v3] mtd: mchp23k256: Add driver for this SPI SRAM device Andrew Lunn
2017-04-12 6:41 ` Boris Brezillon [this message]
2017-04-15 22:26 ` Rafał Miłecki
2017-04-15 22:31 ` Andrew Lunn
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20170412084122.35740e82@bbrezillon \
--to=boris.brezillon@free-electrons.com \
--cc=andrew@lunn.ch \
--cc=dwmw2@infradead.org \
--cc=linux-mtd@lists.infradead.org \
--cc=zajec5@gmail.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox