0001
0002
0003
0004 #include <linux/device.h>
0005 #include <linux/kernel.h>
0006 #include <linux/peci.h>
0007
0008 #include "internal.h"
0009
0010 static int rescan_controller(struct device *dev, void *data)
0011 {
0012 if (dev->type != &peci_controller_type)
0013 return 0;
0014
0015 return peci_controller_scan_devices(to_peci_controller(dev));
0016 }
0017
0018 static ssize_t rescan_store(struct bus_type *bus, const char *buf, size_t count)
0019 {
0020 bool res;
0021 int ret;
0022
0023 ret = kstrtobool(buf, &res);
0024 if (ret)
0025 return ret;
0026
0027 if (!res)
0028 return count;
0029
0030 ret = bus_for_each_dev(&peci_bus_type, NULL, NULL, rescan_controller);
0031 if (ret)
0032 return ret;
0033
0034 return count;
0035 }
0036 static BUS_ATTR_WO(rescan);
0037
0038 static struct attribute *peci_bus_attrs[] = {
0039 &bus_attr_rescan.attr,
0040 NULL
0041 };
0042
0043 static const struct attribute_group peci_bus_group = {
0044 .attrs = peci_bus_attrs,
0045 };
0046
0047 const struct attribute_group *peci_bus_groups[] = {
0048 &peci_bus_group,
0049 NULL
0050 };
0051
0052 static ssize_t remove_store(struct device *dev, struct device_attribute *attr,
0053 const char *buf, size_t count)
0054 {
0055 struct peci_device *device = to_peci_device(dev);
0056 bool res;
0057 int ret;
0058
0059 ret = kstrtobool(buf, &res);
0060 if (ret)
0061 return ret;
0062
0063 if (res && device_remove_file_self(dev, attr))
0064 peci_device_destroy(device);
0065
0066 return count;
0067 }
0068 static DEVICE_ATTR_IGNORE_LOCKDEP(remove, 0200, NULL, remove_store);
0069
0070 static struct attribute *peci_device_attrs[] = {
0071 &dev_attr_remove.attr,
0072 NULL
0073 };
0074
0075 static const struct attribute_group peci_device_group = {
0076 .attrs = peci_device_attrs,
0077 };
0078
0079 const struct attribute_group *peci_device_groups[] = {
0080 &peci_device_group,
0081 NULL
0082 };