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
7 Introduce the rescan attribute as a bus attribute to
8 synchronize the fsl-mc bus objects and the MC firmware.
10 To rescan the fsl-mc bus, e.g.,
11 echo 1 > /sys/bus/fsl-mc/rescan
13 Signed-off-by: Lijun Pan <Lijun.Pan@freescale.com>
15 drivers/staging/fsl-mc/bus/mc-bus.c | 47 +++++++++++++++++++++++++++++++++++
16 1 file changed, 47 insertions(+)
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
24 +static int scan_fsl_mc_bus(struct device *dev, void *data)
26 + unsigned int irq_count;
27 + struct fsl_mc_device *root_mc_dev;
28 + struct fsl_mc_bus *root_mc_bus;
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);
41 +static ssize_t bus_rescan_store(struct bus_type *bus,
42 + const char *buf, size_t count)
46 + if (kstrtoul(buf, 0, &val) < 0)
50 + bus_for_each_dev(bus, NULL, NULL, scan_fsl_mc_bus);
54 +static BUS_ATTR(rescan, (S_IWUSR | S_IWGRP), NULL, bus_rescan_store);
56 +static struct attribute *fsl_mc_bus_attrs[] = {
57 + &bus_attr_rescan.attr,
61 +static const struct attribute_group fsl_mc_bus_group = {
62 + .attrs = fsl_mc_bus_attrs,
65 +static const struct attribute_group *fsl_mc_bus_groups[] = {
70 struct bus_type fsl_mc_bus_type = {
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,
77 EXPORT_SYMBOL_GPL(fsl_mc_bus_type);