From: Tudor Ambarus <tudor.ambarus@microchip.com>
To: Marek Vasut <marek.vasut@gmail.com>,
<cyrille.pitchen@microchip.com>, <dwmw2@infradead.org>,
<computersforpeace@gmail.com>, <boris.brezillon@bootlin.com>,
<richard@nod.at>
Cc: <linux-mtd@lists.infradead.org>,
<linux-arm-kernel@lists.infradead.org>,
<linux-kernel@vger.kernel.org>, <nicolas.ferre@microchip.com>,
<Cristian.Birsan@microchip.com>
Subject: Re: [RESEND PATCH v2 2/3] mtd: spi-nor: parse SFDP Sector Map Parameter Table
Date: Fri, 7 Sep 2018 12:10:30 +0300 [thread overview]
Message-ID: <78a6ebd0-f0e4-cee4-ab66-b393366b2fe5@microchip.com> (raw)
In-Reply-To: <1bfbb5f7-39ee-08cb-8f7b-5c3f441f66a2@gmail.com>
On 09/03/2018 08:40 PM, Marek Vasut wrote:
> On 08/27/2018 12:26 PM, Tudor Ambarus wrote:
> [...]
>> +static const u32 *spi_nor_get_map_in_use(struct spi_nor *nor, const u32 *smpt)
>> +{
>> + const u32 *ret = NULL;
>> + u32 i, addr;
>> + int err;
>> + u8 addr_width, read_opcode, read_dummy;
>> + u8 read_data_mask, data_byte, map_id;
>> +
>> + addr_width = nor->addr_width;
>> + read_dummy = nor->read_dummy;
>> + read_opcode = nor->read_opcode;
>> +
>> + map_id = 0;
>> + i = 0;
>> + /* Determine if there are any optional Detection Command Descriptors */
>> + while (!(smpt[i] & SMPT_DESC_TYPE_MAP)) {
>> + read_data_mask = SMPT_CMD_READ_DATA(smpt[i]);
>> + nor->addr_width = spi_nor_smpt_addr_width(nor, smpt[i]);
>> + nor->read_dummy = spi_nor_smpt_read_dummy(nor, smpt[i]);
>> + nor->read_opcode = SMPT_CMD_OPCODE(smpt[i]);
>> + addr = smpt[i + 1];
>> +
>> + err = spi_nor_read_raw(nor, addr, 1, &data_byte);
>> + if (err)
>> + goto out;
>> +
>> + /*
>> + * Build an index value that is used to select the Sector Map
>> + * Configuration that is currently in use.
>> + */
>> + map_id = map_id << 1 | (!(data_byte & read_data_mask) ? 0 : 1);
>
> You can drop the ternary operator part completely ^
I'll use !! instead.
>
>> + i = i + 2;
>> + }
>> +
>> + /* Find the matching configuration map */
>> + while (SMPT_MAP_ID(smpt[i]) != map_id) {
>> + if (smpt[i] & SMPT_DESC_END)
>> + goto out;
>> + /* increment the table index to the next map */
>> + i += SMPT_MAP_REGION_COUNT(smpt[i]) + 1;
>> + }
>> +
>> + ret = smpt + i;
>> + /* fall through */
>> +out:
>> + nor->addr_width = addr_width;
>> + nor->read_dummy = read_dummy;
>> + nor->read_opcode = read_opcode;
>> + return ret;
>> +}
>> +
>> +static void
>> +spi_nor_region_check_overlay(struct spi_nor_erase_region *region,
>> + const struct spi_nor_erase_type *erase,
>> + const u8 erase_type)
>> +{
>> + int i;
>> +
>> + for (i = 0; i < SNOR_ERASE_TYPE_MAX; i++) {
>> + if (!(erase_type & BIT(i)))
>> + continue;
>> + if (region->size & erase[i].size_mask) {
>> + spi_nor_region_mark_overlay(region);
>> + return;
>> + }
>> + }
>> +}
>> +
>> +static int spi_nor_init_non_uniform_erase_map(struct spi_nor *nor,
>> + const u32 *smpt)
>> +{
>> + struct spi_nor_erase_map *map = &nor->erase_map;
>> + const struct spi_nor_erase_type *erase = map->erase_type;
>> + struct spi_nor_erase_region *region;
>> + u64 offset;
>> + u32 region_count;
>> + int i, j;
>> + u8 erase_type;
>> +
>> + region_count = SMPT_MAP_REGION_COUNT(*smpt);
>> + region = devm_kcalloc(nor->dev, region_count, sizeof(*region),
>> + GFP_KERNEL);
>
> Is this memory always correctly free'd ?
Yes. It will be free'd when the driver detaches from the device.
Thanks,
ta
next prev parent reply other threads:[~2018-09-07 9:10 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-08-27 10:26 [RESEND PATCH v2 0/3] add support to non-uniform SFDP SPI NOR flash memories Tudor Ambarus
2018-08-27 10:26 ` [RESEND PATCH v2 1/3] mtd: spi-nor: " Tudor Ambarus
2018-09-03 17:37 ` Marek Vasut
2018-09-07 8:51 ` Tudor Ambarus
2018-09-07 20:31 ` Marek Vasut
2018-09-10 10:18 ` Tudor Ambarus
2018-09-10 10:58 ` Marek Vasut
2018-08-27 10:26 ` [RESEND PATCH v2 2/3] mtd: spi-nor: parse SFDP Sector Map Parameter Table Tudor Ambarus
2018-09-03 17:40 ` Marek Vasut
2018-09-07 9:10 ` Tudor Ambarus [this message]
2018-08-27 10:26 ` [RESEND PATCH v2 3/3] mtd: spi-nor: parse SFDP 4-byte Address Instruction Table Tudor Ambarus
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=78a6ebd0-f0e4-cee4-ab66-b393366b2fe5@microchip.com \
--to=tudor.ambarus@microchip.com \
--cc=Cristian.Birsan@microchip.com \
--cc=boris.brezillon@bootlin.com \
--cc=computersforpeace@gmail.com \
--cc=cyrille.pitchen@microchip.com \
--cc=dwmw2@infradead.org \
--cc=linux-arm-kernel@lists.infradead.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-mtd@lists.infradead.org \
--cc=marek.vasut@gmail.com \
--cc=nicolas.ferre@microchip.com \
--cc=richard@nod.at \
/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
all inboxes | Powered by JetHome®