425-v6.3-mtd-ubi-block-wire-up-device-parent.patch 1.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849
  1. From 05b8773ca33253ea562be145cf3145b05ef19f86 Mon Sep 17 00:00:00 2001
  2. From: Daniel Golle <[email protected]>
  3. Date: Thu, 22 Dec 2022 19:33:31 +0000
  4. Subject: [PATCH] mtd: ubi: block: wire-up device parent
  5. ubiblock devices were previously only identifyable by their name, but
  6. not connected to their parent UBI volume device e.g. in sysfs.
  7. Properly parent ubiblock device as descendant of a UBI volume device
  8. to reflect device model hierachy.
  9. Signed-off-by: Daniel Golle <[email protected]>
  10. Signed-off-by: Richard Weinberger <[email protected]>
  11. ---
  12. drivers/mtd/ubi/block.c | 2 +-
  13. drivers/mtd/ubi/kapi.c | 1 +
  14. include/linux/mtd/ubi.h | 1 +
  15. 3 files changed, 3 insertions(+), 1 deletion(-)
  16. --- a/drivers/mtd/ubi/block.c
  17. +++ b/drivers/mtd/ubi/block.c
  18. @@ -452,7 +452,7 @@ int ubiblock_create(struct ubi_volume_in
  19. list_add_tail(&dev->list, &ubiblock_devices);
  20. /* Must be the last step: anyone can call file ops from now on */
  21. - ret = add_disk(dev->gd);
  22. + ret = device_add_disk(vi->dev, dev->gd, NULL);
  23. if (ret)
  24. goto out_destroy_wq;
  25. --- a/drivers/mtd/ubi/kapi.c
  26. +++ b/drivers/mtd/ubi/kapi.c
  27. @@ -79,6 +79,7 @@ void ubi_do_get_volume_info(struct ubi_d
  28. vi->name_len = vol->name_len;
  29. vi->name = vol->name;
  30. vi->cdev = vol->cdev.dev;
  31. + vi->dev = &vol->dev;
  32. }
  33. /**
  34. --- a/include/linux/mtd/ubi.h
  35. +++ b/include/linux/mtd/ubi.h
  36. @@ -110,6 +110,7 @@ struct ubi_volume_info {
  37. int name_len;
  38. const char *name;
  39. dev_t cdev;
  40. + struct device *dev;
  41. };
  42. /**