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