1 // SPDX-License-Identifier: GPL-2.0-only
2 // Copyright (c) 2021 Intel Corporation
4 #include <linux/device.h>
5 #include <linux/kernel.h>
6 #include <linux/peci.h>
10 static int rescan_controller(struct device *dev, void *data)
12 if (dev->type != &peci_controller_type)
15 return peci_controller_scan_devices(to_peci_controller(dev));
18 static ssize_t rescan_store(struct bus_type *bus, const char *buf, size_t count)
23 ret = kstrtobool(buf, &res);
30 ret = bus_for_each_dev(&peci_bus_type, NULL, NULL, rescan_controller);
36 static BUS_ATTR_WO(rescan);
38 static struct attribute *peci_bus_attrs[] = {
39 &bus_attr_rescan.attr,
43 static const struct attribute_group peci_bus_group = {
44 .attrs = peci_bus_attrs,
47 const struct attribute_group *peci_bus_groups[] = {
52 static ssize_t remove_store(struct device *dev, struct device_attribute *attr,
53 const char *buf, size_t count)
55 struct peci_device *device = to_peci_device(dev);
59 ret = kstrtobool(buf, &res);
63 if (res && device_remove_file_self(dev, attr))
64 peci_device_destroy(device);
68 static DEVICE_ATTR_IGNORE_LOCKDEP(remove, 0200, NULL, remove_store);
70 static struct attribute *peci_device_attrs[] = {
71 &dev_attr_remove.attr,
75 static const struct attribute_group peci_device_group = {
76 .attrs = peci_device_attrs,
79 const struct attribute_group *peci_device_groups[] = {