[PATCH 1/1 v2] driver:mtd:spi-nor:fix spi_nor_scan overwrite platform ID point

bpqw bpqw at micron.com
Wed Oct 15 17:52:02 PDT 2014


>Won't $info contain an undefined value in case the newly added condition isn't met ? The old code initialized $info to a certain value always, the new code does not do that.

Hi,Marek Vasut
 Thanks.the $info has been defined before as below:

 info = (void *)id->driver_data;
  
Unless id has not been initialized before.If having the following situation,
current linux codes will not properly match platform device data:

For example:

const struct spi_device_id spi_nor_ids[] = {
......
......
......
	{ "n25q064",     INFO(0x20ba17, 0, 64 * 1024,  128, 0) },
	{ "n25q128a11",  INFO(0x20bb18, 0, 64 * 1024,  256, 0) },//former right platform point will be overwrote by this data info.
	{ "n25q128a13",  INFO(0x20bb18, 0x1234, 64 * 1024,  512, SECT_4K) },//this is the right platform data,I want to match this data info.
	{ "n25q256a",    INFO(0x20ba19, 0, 64 * 1024,  512, SECT_4K) },
	{ "n25q512a",    INFO(0x20bb20, 0, 64 * 1024, 1024, SECT_4K) },
......
......
......
};
EXPORT_SYMBOL_GPL(spi_nor_ids);

Maybe my patch should take into account that ID is NULL,
I want to change my patch following, could you please give me some suggestions:

	struct flash_info *tmpinfo;

	tmpinfo = (void *)jid->driver_data;
	if (id == NULL || tmpinfo->jedec_id != info->jedec_id ||
		 (info->ext_id != 0 && tmpinfo->ext_id != info->ext_id)) {
			dev_warn(dev, "found %s, expected %s\n",
				jid->name, id->name);
			id = jid;
			info = (void *)jid->driver_data;
				}


More information about the linux-mtd mailing list