Source
x
{
struct ibmpex_bmc_data *p, *next;
list_for_each_entry_safe(p, next, &driver_data.bmc_data, list)
if (p->interface == iface)
return p;
return NULL;
}
static ssize_t show_name(struct device *dev, struct device_attribute *devattr,
static ssize_t name_show(struct device *dev, struct device_attribute *devattr,
char *buf)
{
return sprintf(buf, "%s\n", DRVNAME);
}
static SENSOR_DEVICE_ATTR(name, S_IRUGO, show_name, NULL, 0);
static SENSOR_DEVICE_ATTR_RO(name, name, 0);
static ssize_t ibmpex_show_sensor(struct device *dev,
struct device_attribute *devattr,
char *buf)
{
struct sensor_device_attribute_2 *attr = to_sensor_dev_attr_2(devattr);
struct ibmpex_bmc_data *data = dev_get_drvdata(dev);
int mult = data->sensors[attr->index].multiplier;
ibmpex_update_device(data);
return sprintf(buf, "%d\n",
data->sensors[attr->index].values[attr->nr] * mult);
}
static ssize_t ibmpex_reset_high_low(struct device *dev,
static ssize_t ibmpex_high_low_store(struct device *dev,
struct device_attribute *devattr,
const char *buf,
size_t count)
const char *buf, size_t count)
{
struct ibmpex_bmc_data *data = dev_get_drvdata(dev);
ibmpex_reset_high_low_data(data);
return count;
}
static SENSOR_DEVICE_ATTR(reset_high_low, S_IWUSR, NULL,
ibmpex_reset_high_low, 0);
static SENSOR_DEVICE_ATTR_WO(reset_high_low, ibmpex_high_low, 0);
static int is_power_sensor(const char *sensor_id, int len)
{
if (len < PEX_SENSOR_TYPE_LEN)
return 0;
if (!memcmp(sensor_id, power_sensor_sig, PEX_SENSOR_TYPE_LEN))
return 1;
return 0;
}
if (type == TEMP_SENSOR)
sprintf(n, "temp%d_input%s",
counter, sensor_name_suffixes[func]);
else if (type == POWER_SENSOR)
sprintf(n, "power%d_average%s",
counter, sensor_name_suffixes[func]);
sysfs_attr_init(&data->sensors[sensor].attr[func].dev_attr.attr);
data->sensors[sensor].attr[func].dev_attr.attr.name = n;
data->sensors[sensor].attr[func].dev_attr.attr.mode = S_IRUGO;
data->sensors[sensor].attr[func].dev_attr.attr.mode = 0444;
data->sensors[sensor].attr[func].dev_attr.show = ibmpex_show_sensor;
data->sensors[sensor].attr[func].index = sensor;
data->sensors[sensor].attr[func].nr = func;
err = device_create_file(data->bmc_device,
&data->sensors[sensor].attr[func].dev_attr);
if (err) {
data->sensors[sensor].attr[func].dev_attr.attr.name = NULL;
kfree(n);
return err;