layerscape: make uImage with zImage for 32-bit kernel
[openwrt/openwrt.git] / target / linux / layerscape / patches-4.4 / 7191-staging-fsl-mc-bus-rescan-attribute-to-sync-kernel-w.patch
1 From 417d71b1e291725c01893bf1553478924d05952f Mon Sep 17 00:00:00 2001
2 From: Lijun Pan <Lijun.Pan@freescale.com>
3 Date: Mon, 8 Feb 2016 17:40:16 -0600
4 Subject: [PATCH 191/226] staging: fsl-mc: bus rescan attribute to sync kernel
5 with MC
6
7 Introduce the rescan attribute as a bus attribute to
8 synchronize the fsl-mc bus objects and the MC firmware.
9
10 To rescan the fsl-mc bus, e.g.,
11 echo 1 > /sys/bus/fsl-mc/rescan
12
13 Signed-off-by: Lijun Pan <Lijun.Pan@freescale.com>
14 ---
15 drivers/staging/fsl-mc/bus/mc-bus.c | 47 +++++++++++++++++++++++++++++++++++
16 1 file changed, 47 insertions(+)
17
18 --- a/drivers/staging/fsl-mc/bus/mc-bus.c
19 +++ b/drivers/staging/fsl-mc/bus/mc-bus.c
20 @@ -139,11 +139,58 @@ static const struct attribute_group *fsl
21 NULL,
22 };
23
24 +static int scan_fsl_mc_bus(struct device *dev, void *data)
25 +{
26 + unsigned int irq_count;
27 + struct fsl_mc_device *root_mc_dev;
28 + struct fsl_mc_bus *root_mc_bus;
29 +
30 + if (fsl_mc_is_root_dprc(dev)) {
31 + root_mc_dev = to_fsl_mc_device(dev);
32 + root_mc_bus = to_fsl_mc_bus(root_mc_dev);
33 + mutex_lock(&root_mc_bus->scan_mutex);
34 + dprc_scan_objects(root_mc_dev, &irq_count);
35 + mutex_unlock(&root_mc_bus->scan_mutex);
36 + }
37 +
38 + return 0;
39 +}
40 +
41 +static ssize_t bus_rescan_store(struct bus_type *bus,
42 + const char *buf, size_t count)
43 +{
44 + unsigned long val;
45 +
46 + if (kstrtoul(buf, 0, &val) < 0)
47 + return -EINVAL;
48 +
49 + if (val)
50 + bus_for_each_dev(bus, NULL, NULL, scan_fsl_mc_bus);
51 +
52 + return count;
53 +}
54 +static BUS_ATTR(rescan, (S_IWUSR | S_IWGRP), NULL, bus_rescan_store);
55 +
56 +static struct attribute *fsl_mc_bus_attrs[] = {
57 + &bus_attr_rescan.attr,
58 + NULL,
59 +};
60 +
61 +static const struct attribute_group fsl_mc_bus_group = {
62 + .attrs = fsl_mc_bus_attrs,
63 +};
64 +
65 +static const struct attribute_group *fsl_mc_bus_groups[] = {
66 + &fsl_mc_bus_group,
67 + NULL,
68 +};
69 +
70 struct bus_type fsl_mc_bus_type = {
71 .name = "fsl-mc",
72 .match = fsl_mc_bus_match,
73 .uevent = fsl_mc_bus_uevent,
74 .dev_groups = fsl_mc_dev_groups,
75 + .bus_groups = fsl_mc_bus_groups,
76 };
77 EXPORT_SYMBOL_GPL(fsl_mc_bus_type);
78