--- zzzz-none-000/linux-3.10.107/drivers/mtd/maps/physmap.c 2017-06-27 09:49:32.000000000 +0000 +++ scorpion-7490-727/linux-3.10.107/drivers/mtd/maps/physmap.c 2021-02-04 17:41:59.000000000 +0000 @@ -31,6 +31,66 @@ int vpp_refcnt; }; +static struct platform_device *physmap_map2pdev(struct map_info *map) +{ + return (struct platform_device *) map->map_priv_1; +} + +static void physmap_lock(struct map_info *map) +{ + struct platform_device *pdev; + struct physmap_flash_data *physmap_data; + + pdev = physmap_map2pdev(map); + physmap_data = pdev->dev.platform_data; + physmap_data->lock(pdev); +} + +static void physmap_unlock(struct map_info *map) +{ + struct platform_device *pdev; + struct physmap_flash_data *physmap_data; + + pdev = physmap_map2pdev(map); + physmap_data = pdev->dev.platform_data; + physmap_data->unlock(pdev); +} + +static map_word physmap_flash_read_lock(struct map_info *map, unsigned long ofs) +{ + map_word ret; + + physmap_lock(map); + ret = inline_map_read(map, ofs); + physmap_unlock(map); + + return ret; +} + +static void physmap_flash_write_lock(struct map_info *map, map_word d, + unsigned long ofs) +{ + physmap_lock(map); + inline_map_write(map, d, ofs); + physmap_unlock(map); +} + +static void physmap_flash_copy_from_lock(struct map_info *map, void *to, + unsigned long from, ssize_t len) +{ + physmap_lock(map); + inline_map_copy_from(map, to, from, len); + physmap_unlock(map); +} + +static void physmap_flash_copy_to_lock(struct map_info *map, unsigned long to, + const void *from, ssize_t len) +{ + physmap_lock(map); + inline_map_copy_to(map, to, from, len); + physmap_unlock(map); +} + static int physmap_flash_remove(struct platform_device *dev) { struct physmap_flash_info *info; @@ -40,9 +100,8 @@ info = platform_get_drvdata(dev); if (info == NULL) return 0; - platform_set_drvdata(dev, NULL); - physmap_data = dev->dev.platform_data; + physmap_data = dev_get_platdata(&dev->dev); if (info->cmtd) { mtd_device_unregister(info->cmtd); @@ -69,7 +128,7 @@ unsigned long flags; pdev = (struct platform_device *)map->map_priv_1; - physmap_data = pdev->dev.platform_data; + physmap_data = dev_get_platdata(&pdev->dev); if (!physmap_data->set_vpp) return; @@ -103,7 +162,7 @@ int i; int devices_found = 0; - physmap_data = dev->dev.platform_data; + physmap_data = dev_get_platdata(&dev->dev); if (physmap_data == NULL) return -ENODEV; @@ -154,6 +213,13 @@ simple_map_init(&info->map[i]); + if (physmap_data->lock && physmap_data->unlock) { + info->map[i].read = physmap_flash_read_lock; + info->map[i].write = physmap_flash_write_lock; + info->map[i].copy_from = physmap_flash_copy_from_lock; + info->map[i].copy_to = physmap_flash_copy_to_lock; + } + probe_type = rom_probe_types; if (physmap_data->probe_type == NULL) { for (; info->mtd[i] == NULL && *probe_type != NULL; probe_type++) @@ -168,7 +234,6 @@ } else { devices_found++; } - info->mtd[i]->owner = THIS_MODULE; info->mtd[i]->dev.parent = &dev->dev; } @@ -218,7 +283,6 @@ .shutdown = physmap_flash_shutdown, .driver = { .name = "physmap-flash", - .owner = THIS_MODULE, }, };