a38907b0bdbd98f78c0859ca085e71c345967808
[openwrt/staging/lynxis.git] / target / linux / layerscape / patches-4.4 / 7190-staging-fsl-mc-root-dprc-rescan-attribute-to-sync-ke.patch
1 From 75b607ff8725eac74f3375b3370f7d121d1827a3 Mon Sep 17 00:00:00 2001
2 From: Lijun Pan <Lijun.Pan@freescale.com>
3 Date: Mon, 8 Feb 2016 17:40:14 -0600
4 Subject: [PATCH 190/226] staging: fsl-mc: root dprc rescan attribute to sync
5 kernel with MC
6
7 Introduce the rescan attribute as a device attribute to
8 synchronize the fsl-mc bus objects and the MC firmware.
9
10 To rescan the root dprc only, e.g.
11 echo 1 > /sys/bus/fsl-mc/devices/dprc.1/rescan
12
13 Signed-off-by: Lijun Pan <Lijun.Pan@freescale.com>
14 [Stuart: resolved merge conflict]
15 Signed-off-by: Stuart Yoder <stuart.yoder@nxp.com>
16 ---
17 drivers/staging/fsl-mc/bus/mc-bus.c | 29 +++++++++++++++++++++++++++++
18 1 file changed, 29 insertions(+)
19
20 --- a/drivers/staging/fsl-mc/bus/mc-bus.c
21 +++ b/drivers/staging/fsl-mc/bus/mc-bus.c
22 @@ -96,8 +96,37 @@ static ssize_t modalias_show(struct devi
23 }
24 static DEVICE_ATTR_RO(modalias);
25
26 +static ssize_t rescan_store(struct device *dev,
27 + struct device_attribute *attr,
28 + const char *buf, size_t count)
29 +{
30 + unsigned long val;
31 + unsigned int irq_count;
32 + struct fsl_mc_device *root_mc_dev;
33 + struct fsl_mc_bus *root_mc_bus;
34 +
35 + if (!fsl_mc_is_root_dprc(dev))
36 + return -EINVAL;
37 +
38 + root_mc_dev = to_fsl_mc_device(dev);
39 + root_mc_bus = to_fsl_mc_bus(root_mc_dev);
40 +
41 + if (kstrtoul(buf, 0, &val) < 0)
42 + return -EINVAL;
43 +
44 + if (val) {
45 + mutex_lock(&root_mc_bus->scan_mutex);
46 + dprc_scan_objects(root_mc_dev, &irq_count);
47 + mutex_unlock(&root_mc_bus->scan_mutex);
48 + }
49 +
50 + return count;
51 +}
52 +static DEVICE_ATTR_WO(rescan);
53 +
54 static struct attribute *fsl_mc_dev_attrs[] = {
55 &dev_attr_modalias.attr,
56 + &dev_attr_rescan.attr,
57 NULL,
58 };
59