hwmon: (ibmpowernv) change create_hwmon_attr_name() prototype
It simplifies the creation of the hwmon attributes and will help when support for a new device tree layout is added. The patch also changes the name of the routine to parse_opal_node_name(). Signed-off-by: Cédric Le Goater <clg@fr.ibm.com> Signed-off-by: Guenter Roeck <linux@roeck-us.net>
This commit is contained in:
parent
ccc9ac6cc9
commit
f9f54f16bf
@ -152,29 +152,22 @@ static const char *convert_opal_attr_name(enum sensors type,
|
|||||||
* which need to be mapped as fan2_input, temp1_max respectively before
|
* which need to be mapped as fan2_input, temp1_max respectively before
|
||||||
* populating them inside hwmon device class.
|
* populating them inside hwmon device class.
|
||||||
*/
|
*/
|
||||||
static int create_hwmon_attr_name(struct device *dev, enum sensors type,
|
static const char *parse_opal_node_name(const char *node_name,
|
||||||
const char *node_name,
|
enum sensors type, u32 *index)
|
||||||
char *hwmon_attr_name)
|
|
||||||
{
|
{
|
||||||
char attr_suffix[MAX_ATTR_LEN];
|
char attr_suffix[MAX_ATTR_LEN];
|
||||||
const char *attr_name;
|
const char *attr_name;
|
||||||
u32 index;
|
|
||||||
int err;
|
int err;
|
||||||
|
|
||||||
err = get_sensor_index_attr(node_name, &index, attr_suffix);
|
err = get_sensor_index_attr(node_name, index, attr_suffix);
|
||||||
if (err) {
|
if (err)
|
||||||
dev_err(dev, "Sensor device node name '%s' is invalid\n",
|
return ERR_PTR(err);
|
||||||
node_name);
|
|
||||||
return err;
|
|
||||||
}
|
|
||||||
|
|
||||||
attr_name = convert_opal_attr_name(type, attr_suffix);
|
attr_name = convert_opal_attr_name(type, attr_suffix);
|
||||||
if (!attr_name)
|
if (!attr_name)
|
||||||
return -ENOENT;
|
return ERR_PTR(-ENOENT);
|
||||||
|
|
||||||
snprintf(hwmon_attr_name, MAX_ATTR_LEN, "%s%d_%s",
|
return attr_name;
|
||||||
sensor_groups[type].name, index, attr_name);
|
|
||||||
return 0;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static int get_sensor_type(struct device_node *np)
|
static int get_sensor_type(struct device_node *np)
|
||||||
@ -249,6 +242,9 @@ static int create_device_attrs(struct platform_device *pdev)
|
|||||||
}
|
}
|
||||||
|
|
||||||
for_each_child_of_node(opal, np) {
|
for_each_child_of_node(opal, np) {
|
||||||
|
const char *attr_name;
|
||||||
|
u32 opal_index;
|
||||||
|
|
||||||
if (np->name == NULL)
|
if (np->name == NULL)
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
@ -265,10 +261,17 @@ static int create_device_attrs(struct platform_device *pdev)
|
|||||||
|
|
||||||
sdata[count].id = sensor_id;
|
sdata[count].id = sensor_id;
|
||||||
sdata[count].type = type;
|
sdata[count].type = type;
|
||||||
err = create_hwmon_attr_name(&pdev->dev, type, np->name,
|
|
||||||
sdata[count].name);
|
attr_name = parse_opal_node_name(np->name, type, &opal_index);
|
||||||
if (err)
|
if (IS_ERR(attr_name)) {
|
||||||
|
dev_err(&pdev->dev, "Sensor device node name '%s' is invalid\n",
|
||||||
|
np->name);
|
||||||
|
err = PTR_ERR(attr_name);
|
||||||
goto exit_put_node;
|
goto exit_put_node;
|
||||||
|
}
|
||||||
|
|
||||||
|
snprintf(sdata[count].name, MAX_ATTR_LEN, "%s%d_%s",
|
||||||
|
sensor_groups[type].name, opal_index, attr_name);
|
||||||
|
|
||||||
sysfs_attr_init(&sdata[count].dev_attr.attr);
|
sysfs_attr_init(&sdata[count].dev_attr.attr);
|
||||||
sdata[count].dev_attr.attr.name = sdata[count].name;
|
sdata[count].dev_attr.attr.name = sdata[count].name;
|
||||||
|
Loading…
Reference in New Issue
Block a user