All of lore.kernel.org
 help / color / mirror / Atom feed
From: Pawel Moll <pawel.moll@arm.com>
To: Grant Likely <grant.likely@linaro.org>,
	Rob Herring <robh+dt@kernel.org>,
	Samuel Ortiz <sameo@linux.intel.com>,
	Lee Jones <lee.jones@linaro.org>, Arnd Bergmann <arnd@arndb.de>,
	Greg Kroah-Hartman <gregkh@linuxfoundation.org>,
	Russell King <linux@arm.linux.org.uk>
Cc: linux-kernel@vger.kernel.org,
	linux-arm-kernel@lists.infradead.org, arm@kernel.org,
	Pawel Moll <pawel.moll@arm.com>, Jean Delvare <jdelvare@suse.de>,
	Guenter Roeck <linux@roeck-us.net>,
	lm-sensors@lm-sensors.org
Subject: [PATCH 10/10] hwmon: vexpress: Use devm helper for hwmon device registration
Date: Mon, 28 Apr 2014 18:57:57 +0100	[thread overview]
Message-ID: <1398707877-22596-11-git-send-email-pawel.moll@arm.com> (raw)
In-Reply-To: <1398707877-22596-1-git-send-email-pawel.moll@arm.com>

Use devm_hwmon_device_register_with_groups instead of
the old-style manual attributes and hwmon device registration.

Also, unwind the attribute group macros for better code
readability.

Cc: Jean Delvare <jdelvare@suse.de>
Cc: Guenter Roeck <linux@roeck-us.net>
Cc: lm-sensors@lm-sensors.org
Signed-off-by: Pawel Moll <pawel.moll@arm.com>
---
 drivers/hwmon/vexpress.c | 91 ++++++++++++++++--------------------------------
 1 file changed, 30 insertions(+), 61 deletions(-)

diff --git a/drivers/hwmon/vexpress.c b/drivers/hwmon/vexpress.c
index d853332..ed6bf0e 100644
--- a/drivers/hwmon/vexpress.c
+++ b/drivers/hwmon/vexpress.c
@@ -27,17 +27,8 @@
 struct vexpress_hwmon_data {
 	struct device *hwmon_dev;
 	struct regmap *reg;
-	const char *name;
 };
 
-static ssize_t vexpress_hwmon_name_show(struct device *dev,
-		struct device_attribute *dev_attr, char *buffer)
-{
-	struct vexpress_hwmon_data *data = dev_get_drvdata(dev);
-
-	return sprintf(buffer, "%s\n", data->name);
-}
-
 static ssize_t vexpress_hwmon_label_show(struct device *dev,
 		struct device_attribute *dev_attr, char *buffer)
 {
@@ -95,16 +86,6 @@ static umode_t vexpress_hwmon_attr_is_visible(struct kobject *kobj,
 	return attr->mode;
 }
 
-static DEVICE_ATTR(name, S_IRUGO, vexpress_hwmon_name_show, NULL);
-
-#define VEXPRESS_HWMON_ATTRS(_name, _label_attr, _input_attr)	\
-struct attribute *vexpress_hwmon_attrs_##_name[] = {		\
-	&dev_attr_name.attr,					\
-	&dev_attr_##_label_attr.attr,				\
-	&sensor_dev_attr_##_input_attr.dev_attr.attr,		\
-	NULL							\
-}
-
 struct vexpress_hwmon_type {
 	const char *name;
 	const struct attribute_group **attr_groups;
@@ -114,10 +95,13 @@ struct vexpress_hwmon_type {
 static DEVICE_ATTR(in1_label, S_IRUGO, vexpress_hwmon_label_show, NULL);
 static SENSOR_DEVICE_ATTR(in1_input, S_IRUGO, vexpress_hwmon_u32_show,
 		NULL, 1000);
-static VEXPRESS_HWMON_ATTRS(volt, in1_label, in1_input);
 static struct attribute_group vexpress_hwmon_group_volt = {
 	.is_visible = vexpress_hwmon_attr_is_visible,
-	.attrs = vexpress_hwmon_attrs_volt,
+	.attrs = (struct attribute *[]) {
+		&dev_attr_in1_label.attr,
+		&sensor_dev_attr_in1_input.dev_attr.attr,
+		NULL
+	},
 };
 static struct vexpress_hwmon_type vexpress_hwmon_volt = {
 	.name = "vexpress_volt",
@@ -131,10 +115,13 @@ static struct vexpress_hwmon_type vexpress_hwmon_volt = {
 static DEVICE_ATTR(curr1_label, S_IRUGO, vexpress_hwmon_label_show, NULL);
 static SENSOR_DEVICE_ATTR(curr1_input, S_IRUGO, vexpress_hwmon_u32_show,
 		NULL, 1000);
-static VEXPRESS_HWMON_ATTRS(amp, curr1_label, curr1_input);
 static struct attribute_group vexpress_hwmon_group_amp = {
 	.is_visible = vexpress_hwmon_attr_is_visible,
-	.attrs = vexpress_hwmon_attrs_amp,
+	.attrs = (struct attribute *[]) {
+		&dev_attr_curr1_label.attr,
+		&sensor_dev_attr_curr1_input.dev_attr.attr,
+		NULL
+	},
 };
 static struct vexpress_hwmon_type vexpress_hwmon_amp = {
 	.name = "vexpress_amp",
@@ -147,10 +134,13 @@ static struct vexpress_hwmon_type vexpress_hwmon_amp = {
 static DEVICE_ATTR(temp1_label, S_IRUGO, vexpress_hwmon_label_show, NULL);
 static SENSOR_DEVICE_ATTR(temp1_input, S_IRUGO, vexpress_hwmon_u32_show,
 		NULL, 1000);
-static VEXPRESS_HWMON_ATTRS(temp, temp1_label, temp1_input);
 static struct attribute_group vexpress_hwmon_group_temp = {
 	.is_visible = vexpress_hwmon_attr_is_visible,
-	.attrs = vexpress_hwmon_attrs_temp,
+	.attrs = (struct attribute *[]) {
+		&dev_attr_temp1_label.attr,
+		&sensor_dev_attr_temp1_input.dev_attr.attr,
+		NULL
+	},
 };
 static struct vexpress_hwmon_type vexpress_hwmon_temp = {
 	.name = "vexpress_temp",
@@ -163,10 +153,13 @@ static struct vexpress_hwmon_type vexpress_hwmon_temp = {
 static DEVICE_ATTR(power1_label, S_IRUGO, vexpress_hwmon_label_show, NULL);
 static SENSOR_DEVICE_ATTR(power1_input, S_IRUGO, vexpress_hwmon_u32_show,
 		NULL, 1);
-static VEXPRESS_HWMON_ATTRS(power, power1_label, power1_input);
 static struct attribute_group vexpress_hwmon_group_power = {
 	.is_visible = vexpress_hwmon_attr_is_visible,
-	.attrs = vexpress_hwmon_attrs_power,
+	.attrs = (struct attribute *[]) {
+		&dev_attr_power1_label.attr,
+		&sensor_dev_attr_power1_input.dev_attr.attr,
+		NULL
+	},
 };
 static struct vexpress_hwmon_type vexpress_hwmon_power = {
 	.name = "vexpress_power",
@@ -179,10 +172,13 @@ static struct vexpress_hwmon_type vexpress_hwmon_power = {
 static DEVICE_ATTR(energy1_label, S_IRUGO, vexpress_hwmon_label_show, NULL);
 static SENSOR_DEVICE_ATTR(energy1_input, S_IRUGO, vexpress_hwmon_u64_show,
 		NULL, 1);
-static VEXPRESS_HWMON_ATTRS(energy, energy1_label, energy1_input);
 static struct attribute_group vexpress_hwmon_group_energy = {
 	.is_visible = vexpress_hwmon_attr_is_visible,
-	.attrs = vexpress_hwmon_attrs_energy,
+	.attrs = (struct attribute *[]) {
+		&dev_attr_energy1_label.attr,
+		&sensor_dev_attr_energy1_input.dev_attr.attr,
+		NULL
+	},
 };
 static struct vexpress_hwmon_type vexpress_hwmon_energy = {
 	.name = "vexpress_energy",
@@ -218,7 +214,6 @@ MODULE_DEVICE_TABLE(of, vexpress_hwmon_of_match);
 
 static int vexpress_hwmon_probe(struct platform_device *pdev)
 {
-	int err;
 	const struct of_device_id *match;
 	struct vexpress_hwmon_data *data;
 	const struct vexpress_hwmon_type *type;
@@ -232,45 +227,19 @@ static int vexpress_hwmon_probe(struct platform_device *pdev)
 	if (!match)
 		return -ENODEV;
 	type = match->data;
-	data->name = type->name;
 
 	data->reg = devm_regmap_init_vexpress_config(&pdev->dev);
-	if (!data->reg)
-		return -ENODEV;
-
-	err = sysfs_create_groups(&pdev->dev.kobj, type->attr_groups);
-	if (err)
-		goto error;
-
-	data->hwmon_dev = hwmon_device_register(&pdev->dev);
-	if (IS_ERR(data->hwmon_dev)) {
-		err = PTR_ERR(data->hwmon_dev);
-		goto error;
-	}
+	if (IS_ERR(data->reg))
+		return PTR_ERR(data->reg);
 
-	return 0;
-
-error:
-	sysfs_remove_group(&pdev->dev.kobj, match->data);
-	return err;
-}
-
-static int vexpress_hwmon_remove(struct platform_device *pdev)
-{
-	struct vexpress_hwmon_data *data = platform_get_drvdata(pdev);
-	const struct of_device_id *match;
-
-	hwmon_device_unregister(data->hwmon_dev);
-
-	match = of_match_device(vexpress_hwmon_of_match, &pdev->dev);
-	sysfs_remove_group(&pdev->dev.kobj, match->data);
+	data->hwmon_dev = devm_hwmon_device_register_with_groups(&pdev->dev,
+			type->name, data, type->attr_groups);
 
-	return 0;
+	return PTR_ERR_OR_ZERO(data->hwmon_dev);
 }
 
 static struct platform_driver vexpress_hwmon_driver = {
 	.probe = vexpress_hwmon_probe,
-	.remove = vexpress_hwmon_remove,
 	.driver	= {
 		.name = DRVNAME,
 		.owner = THIS_MODULE,
-- 
1.9.1


WARNING: multiple messages have this Message-ID (diff)
From: pawel.moll@arm.com (Pawel Moll)
To: linux-arm-kernel@lists.infradead.org
Subject: [PATCH 10/10] hwmon: vexpress: Use devm helper for hwmon device registration
Date: Mon, 28 Apr 2014 18:57:57 +0100	[thread overview]
Message-ID: <1398707877-22596-11-git-send-email-pawel.moll@arm.com> (raw)
In-Reply-To: <1398707877-22596-1-git-send-email-pawel.moll@arm.com>

Use devm_hwmon_device_register_with_groups instead of
the old-style manual attributes and hwmon device registration.

Also, unwind the attribute group macros for better code
readability.

Cc: Jean Delvare <jdelvare@suse.de>
Cc: Guenter Roeck <linux@roeck-us.net>
Cc: lm-sensors at lm-sensors.org
Signed-off-by: Pawel Moll <pawel.moll@arm.com>
---
 drivers/hwmon/vexpress.c | 91 ++++++++++++++++--------------------------------
 1 file changed, 30 insertions(+), 61 deletions(-)

diff --git a/drivers/hwmon/vexpress.c b/drivers/hwmon/vexpress.c
index d853332..ed6bf0e 100644
--- a/drivers/hwmon/vexpress.c
+++ b/drivers/hwmon/vexpress.c
@@ -27,17 +27,8 @@
 struct vexpress_hwmon_data {
 	struct device *hwmon_dev;
 	struct regmap *reg;
-	const char *name;
 };
 
-static ssize_t vexpress_hwmon_name_show(struct device *dev,
-		struct device_attribute *dev_attr, char *buffer)
-{
-	struct vexpress_hwmon_data *data = dev_get_drvdata(dev);
-
-	return sprintf(buffer, "%s\n", data->name);
-}
-
 static ssize_t vexpress_hwmon_label_show(struct device *dev,
 		struct device_attribute *dev_attr, char *buffer)
 {
@@ -95,16 +86,6 @@ static umode_t vexpress_hwmon_attr_is_visible(struct kobject *kobj,
 	return attr->mode;
 }
 
-static DEVICE_ATTR(name, S_IRUGO, vexpress_hwmon_name_show, NULL);
-
-#define VEXPRESS_HWMON_ATTRS(_name, _label_attr, _input_attr)	\
-struct attribute *vexpress_hwmon_attrs_##_name[] = {		\
-	&dev_attr_name.attr,					\
-	&dev_attr_##_label_attr.attr,				\
-	&sensor_dev_attr_##_input_attr.dev_attr.attr,		\
-	NULL							\
-}
-
 struct vexpress_hwmon_type {
 	const char *name;
 	const struct attribute_group **attr_groups;
@@ -114,10 +95,13 @@ struct vexpress_hwmon_type {
 static DEVICE_ATTR(in1_label, S_IRUGO, vexpress_hwmon_label_show, NULL);
 static SENSOR_DEVICE_ATTR(in1_input, S_IRUGO, vexpress_hwmon_u32_show,
 		NULL, 1000);
-static VEXPRESS_HWMON_ATTRS(volt, in1_label, in1_input);
 static struct attribute_group vexpress_hwmon_group_volt = {
 	.is_visible = vexpress_hwmon_attr_is_visible,
-	.attrs = vexpress_hwmon_attrs_volt,
+	.attrs = (struct attribute *[]) {
+		&dev_attr_in1_label.attr,
+		&sensor_dev_attr_in1_input.dev_attr.attr,
+		NULL
+	},
 };
 static struct vexpress_hwmon_type vexpress_hwmon_volt = {
 	.name = "vexpress_volt",
@@ -131,10 +115,13 @@ static struct vexpress_hwmon_type vexpress_hwmon_volt = {
 static DEVICE_ATTR(curr1_label, S_IRUGO, vexpress_hwmon_label_show, NULL);
 static SENSOR_DEVICE_ATTR(curr1_input, S_IRUGO, vexpress_hwmon_u32_show,
 		NULL, 1000);
-static VEXPRESS_HWMON_ATTRS(amp, curr1_label, curr1_input);
 static struct attribute_group vexpress_hwmon_group_amp = {
 	.is_visible = vexpress_hwmon_attr_is_visible,
-	.attrs = vexpress_hwmon_attrs_amp,
+	.attrs = (struct attribute *[]) {
+		&dev_attr_curr1_label.attr,
+		&sensor_dev_attr_curr1_input.dev_attr.attr,
+		NULL
+	},
 };
 static struct vexpress_hwmon_type vexpress_hwmon_amp = {
 	.name = "vexpress_amp",
@@ -147,10 +134,13 @@ static struct vexpress_hwmon_type vexpress_hwmon_amp = {
 static DEVICE_ATTR(temp1_label, S_IRUGO, vexpress_hwmon_label_show, NULL);
 static SENSOR_DEVICE_ATTR(temp1_input, S_IRUGO, vexpress_hwmon_u32_show,
 		NULL, 1000);
-static VEXPRESS_HWMON_ATTRS(temp, temp1_label, temp1_input);
 static struct attribute_group vexpress_hwmon_group_temp = {
 	.is_visible = vexpress_hwmon_attr_is_visible,
-	.attrs = vexpress_hwmon_attrs_temp,
+	.attrs = (struct attribute *[]) {
+		&dev_attr_temp1_label.attr,
+		&sensor_dev_attr_temp1_input.dev_attr.attr,
+		NULL
+	},
 };
 static struct vexpress_hwmon_type vexpress_hwmon_temp = {
 	.name = "vexpress_temp",
@@ -163,10 +153,13 @@ static struct vexpress_hwmon_type vexpress_hwmon_temp = {
 static DEVICE_ATTR(power1_label, S_IRUGO, vexpress_hwmon_label_show, NULL);
 static SENSOR_DEVICE_ATTR(power1_input, S_IRUGO, vexpress_hwmon_u32_show,
 		NULL, 1);
-static VEXPRESS_HWMON_ATTRS(power, power1_label, power1_input);
 static struct attribute_group vexpress_hwmon_group_power = {
 	.is_visible = vexpress_hwmon_attr_is_visible,
-	.attrs = vexpress_hwmon_attrs_power,
+	.attrs = (struct attribute *[]) {
+		&dev_attr_power1_label.attr,
+		&sensor_dev_attr_power1_input.dev_attr.attr,
+		NULL
+	},
 };
 static struct vexpress_hwmon_type vexpress_hwmon_power = {
 	.name = "vexpress_power",
@@ -179,10 +172,13 @@ static struct vexpress_hwmon_type vexpress_hwmon_power = {
 static DEVICE_ATTR(energy1_label, S_IRUGO, vexpress_hwmon_label_show, NULL);
 static SENSOR_DEVICE_ATTR(energy1_input, S_IRUGO, vexpress_hwmon_u64_show,
 		NULL, 1);
-static VEXPRESS_HWMON_ATTRS(energy, energy1_label, energy1_input);
 static struct attribute_group vexpress_hwmon_group_energy = {
 	.is_visible = vexpress_hwmon_attr_is_visible,
-	.attrs = vexpress_hwmon_attrs_energy,
+	.attrs = (struct attribute *[]) {
+		&dev_attr_energy1_label.attr,
+		&sensor_dev_attr_energy1_input.dev_attr.attr,
+		NULL
+	},
 };
 static struct vexpress_hwmon_type vexpress_hwmon_energy = {
 	.name = "vexpress_energy",
@@ -218,7 +214,6 @@ MODULE_DEVICE_TABLE(of, vexpress_hwmon_of_match);
 
 static int vexpress_hwmon_probe(struct platform_device *pdev)
 {
-	int err;
 	const struct of_device_id *match;
 	struct vexpress_hwmon_data *data;
 	const struct vexpress_hwmon_type *type;
@@ -232,45 +227,19 @@ static int vexpress_hwmon_probe(struct platform_device *pdev)
 	if (!match)
 		return -ENODEV;
 	type = match->data;
-	data->name = type->name;
 
 	data->reg = devm_regmap_init_vexpress_config(&pdev->dev);
-	if (!data->reg)
-		return -ENODEV;
-
-	err = sysfs_create_groups(&pdev->dev.kobj, type->attr_groups);
-	if (err)
-		goto error;
-
-	data->hwmon_dev = hwmon_device_register(&pdev->dev);
-	if (IS_ERR(data->hwmon_dev)) {
-		err = PTR_ERR(data->hwmon_dev);
-		goto error;
-	}
+	if (IS_ERR(data->reg))
+		return PTR_ERR(data->reg);
 
-	return 0;
-
-error:
-	sysfs_remove_group(&pdev->dev.kobj, match->data);
-	return err;
-}
-
-static int vexpress_hwmon_remove(struct platform_device *pdev)
-{
-	struct vexpress_hwmon_data *data = platform_get_drvdata(pdev);
-	const struct of_device_id *match;
-
-	hwmon_device_unregister(data->hwmon_dev);
-
-	match = of_match_device(vexpress_hwmon_of_match, &pdev->dev);
-	sysfs_remove_group(&pdev->dev.kobj, match->data);
+	data->hwmon_dev = devm_hwmon_device_register_with_groups(&pdev->dev,
+			type->name, data, type->attr_groups);
 
-	return 0;
+	return PTR_ERR_OR_ZERO(data->hwmon_dev);
 }
 
 static struct platform_driver vexpress_hwmon_driver = {
 	.probe = vexpress_hwmon_probe,
-	.remove = vexpress_hwmon_remove,
 	.driver	= {
 		.name = DRVNAME,
 		.owner = THIS_MODULE,
-- 
1.9.1

WARNING: multiple messages have this Message-ID (diff)
From: Pawel Moll <pawel.moll@arm.com>
To: Grant Likely <grant.likely@linaro.org>,
	Rob Herring <robh+dt@kernel.org>,
	Samuel Ortiz <sameo@linux.intel.com>,
	Lee Jones <lee.jones@linaro.org>, Arnd Bergmann <arnd@arndb.de>,
	Greg Kroah-Hartman <gregkh@linuxfoundation.org>,
	Russell King <linux@arm.linux.org.uk>
Cc: linux-kernel@vger.kernel.org,
	linux-arm-kernel@lists.infradead.org, arm@kernel.org,
	Pawel Moll <pawel.moll@arm.com>, Jean Delvare <jdelvare@suse.de>,
	Guenter Roeck <linux@roeck-us.net>,
	lm-sensors@lm-sensors.org
Subject: [lm-sensors] [PATCH 10/10] hwmon: vexpress: Use devm helper for hwmon device registration
Date: Mon, 28 Apr 2014 17:57:57 +0000	[thread overview]
Message-ID: <1398707877-22596-11-git-send-email-pawel.moll@arm.com> (raw)
In-Reply-To: <1398707877-22596-1-git-send-email-pawel.moll@arm.com>

Use devm_hwmon_device_register_with_groups instead of
the old-style manual attributes and hwmon device registration.

Also, unwind the attribute group macros for better code
readability.

Cc: Jean Delvare <jdelvare@suse.de>
Cc: Guenter Roeck <linux@roeck-us.net>
Cc: lm-sensors@lm-sensors.org
Signed-off-by: Pawel Moll <pawel.moll@arm.com>
---
 drivers/hwmon/vexpress.c | 91 ++++++++++++++++--------------------------------
 1 file changed, 30 insertions(+), 61 deletions(-)

diff --git a/drivers/hwmon/vexpress.c b/drivers/hwmon/vexpress.c
index d853332..ed6bf0e 100644
--- a/drivers/hwmon/vexpress.c
+++ b/drivers/hwmon/vexpress.c
@@ -27,17 +27,8 @@
 struct vexpress_hwmon_data {
 	struct device *hwmon_dev;
 	struct regmap *reg;
-	const char *name;
 };
 
-static ssize_t vexpress_hwmon_name_show(struct device *dev,
-		struct device_attribute *dev_attr, char *buffer)
-{
-	struct vexpress_hwmon_data *data = dev_get_drvdata(dev);
-
-	return sprintf(buffer, "%s\n", data->name);
-}
-
 static ssize_t vexpress_hwmon_label_show(struct device *dev,
 		struct device_attribute *dev_attr, char *buffer)
 {
@@ -95,16 +86,6 @@ static umode_t vexpress_hwmon_attr_is_visible(struct kobject *kobj,
 	return attr->mode;
 }
 
-static DEVICE_ATTR(name, S_IRUGO, vexpress_hwmon_name_show, NULL);
-
-#define VEXPRESS_HWMON_ATTRS(_name, _label_attr, _input_attr)	\
-struct attribute *vexpress_hwmon_attrs_##_name[] = {		\
-	&dev_attr_name.attr,					\
-	&dev_attr_##_label_attr.attr,				\
-	&sensor_dev_attr_##_input_attr.dev_attr.attr,		\
-	NULL							\
-}
-
 struct vexpress_hwmon_type {
 	const char *name;
 	const struct attribute_group **attr_groups;
@@ -114,10 +95,13 @@ struct vexpress_hwmon_type {
 static DEVICE_ATTR(in1_label, S_IRUGO, vexpress_hwmon_label_show, NULL);
 static SENSOR_DEVICE_ATTR(in1_input, S_IRUGO, vexpress_hwmon_u32_show,
 		NULL, 1000);
-static VEXPRESS_HWMON_ATTRS(volt, in1_label, in1_input);
 static struct attribute_group vexpress_hwmon_group_volt = {
 	.is_visible = vexpress_hwmon_attr_is_visible,
-	.attrs = vexpress_hwmon_attrs_volt,
+	.attrs = (struct attribute *[]) {
+		&dev_attr_in1_label.attr,
+		&sensor_dev_attr_in1_input.dev_attr.attr,
+		NULL
+	},
 };
 static struct vexpress_hwmon_type vexpress_hwmon_volt = {
 	.name = "vexpress_volt",
@@ -131,10 +115,13 @@ static struct vexpress_hwmon_type vexpress_hwmon_volt = {
 static DEVICE_ATTR(curr1_label, S_IRUGO, vexpress_hwmon_label_show, NULL);
 static SENSOR_DEVICE_ATTR(curr1_input, S_IRUGO, vexpress_hwmon_u32_show,
 		NULL, 1000);
-static VEXPRESS_HWMON_ATTRS(amp, curr1_label, curr1_input);
 static struct attribute_group vexpress_hwmon_group_amp = {
 	.is_visible = vexpress_hwmon_attr_is_visible,
-	.attrs = vexpress_hwmon_attrs_amp,
+	.attrs = (struct attribute *[]) {
+		&dev_attr_curr1_label.attr,
+		&sensor_dev_attr_curr1_input.dev_attr.attr,
+		NULL
+	},
 };
 static struct vexpress_hwmon_type vexpress_hwmon_amp = {
 	.name = "vexpress_amp",
@@ -147,10 +134,13 @@ static struct vexpress_hwmon_type vexpress_hwmon_amp = {
 static DEVICE_ATTR(temp1_label, S_IRUGO, vexpress_hwmon_label_show, NULL);
 static SENSOR_DEVICE_ATTR(temp1_input, S_IRUGO, vexpress_hwmon_u32_show,
 		NULL, 1000);
-static VEXPRESS_HWMON_ATTRS(temp, temp1_label, temp1_input);
 static struct attribute_group vexpress_hwmon_group_temp = {
 	.is_visible = vexpress_hwmon_attr_is_visible,
-	.attrs = vexpress_hwmon_attrs_temp,
+	.attrs = (struct attribute *[]) {
+		&dev_attr_temp1_label.attr,
+		&sensor_dev_attr_temp1_input.dev_attr.attr,
+		NULL
+	},
 };
 static struct vexpress_hwmon_type vexpress_hwmon_temp = {
 	.name = "vexpress_temp",
@@ -163,10 +153,13 @@ static struct vexpress_hwmon_type vexpress_hwmon_temp = {
 static DEVICE_ATTR(power1_label, S_IRUGO, vexpress_hwmon_label_show, NULL);
 static SENSOR_DEVICE_ATTR(power1_input, S_IRUGO, vexpress_hwmon_u32_show,
 		NULL, 1);
-static VEXPRESS_HWMON_ATTRS(power, power1_label, power1_input);
 static struct attribute_group vexpress_hwmon_group_power = {
 	.is_visible = vexpress_hwmon_attr_is_visible,
-	.attrs = vexpress_hwmon_attrs_power,
+	.attrs = (struct attribute *[]) {
+		&dev_attr_power1_label.attr,
+		&sensor_dev_attr_power1_input.dev_attr.attr,
+		NULL
+	},
 };
 static struct vexpress_hwmon_type vexpress_hwmon_power = {
 	.name = "vexpress_power",
@@ -179,10 +172,13 @@ static struct vexpress_hwmon_type vexpress_hwmon_power = {
 static DEVICE_ATTR(energy1_label, S_IRUGO, vexpress_hwmon_label_show, NULL);
 static SENSOR_DEVICE_ATTR(energy1_input, S_IRUGO, vexpress_hwmon_u64_show,
 		NULL, 1);
-static VEXPRESS_HWMON_ATTRS(energy, energy1_label, energy1_input);
 static struct attribute_group vexpress_hwmon_group_energy = {
 	.is_visible = vexpress_hwmon_attr_is_visible,
-	.attrs = vexpress_hwmon_attrs_energy,
+	.attrs = (struct attribute *[]) {
+		&dev_attr_energy1_label.attr,
+		&sensor_dev_attr_energy1_input.dev_attr.attr,
+		NULL
+	},
 };
 static struct vexpress_hwmon_type vexpress_hwmon_energy = {
 	.name = "vexpress_energy",
@@ -218,7 +214,6 @@ MODULE_DEVICE_TABLE(of, vexpress_hwmon_of_match);
 
 static int vexpress_hwmon_probe(struct platform_device *pdev)
 {
-	int err;
 	const struct of_device_id *match;
 	struct vexpress_hwmon_data *data;
 	const struct vexpress_hwmon_type *type;
@@ -232,45 +227,19 @@ static int vexpress_hwmon_probe(struct platform_device *pdev)
 	if (!match)
 		return -ENODEV;
 	type = match->data;
-	data->name = type->name;
 
 	data->reg = devm_regmap_init_vexpress_config(&pdev->dev);
-	if (!data->reg)
-		return -ENODEV;
-
-	err = sysfs_create_groups(&pdev->dev.kobj, type->attr_groups);
-	if (err)
-		goto error;
-
-	data->hwmon_dev = hwmon_device_register(&pdev->dev);
-	if (IS_ERR(data->hwmon_dev)) {
-		err = PTR_ERR(data->hwmon_dev);
-		goto error;
-	}
+	if (IS_ERR(data->reg))
+		return PTR_ERR(data->reg);
 
-	return 0;
-
-error:
-	sysfs_remove_group(&pdev->dev.kobj, match->data);
-	return err;
-}
-
-static int vexpress_hwmon_remove(struct platform_device *pdev)
-{
-	struct vexpress_hwmon_data *data = platform_get_drvdata(pdev);
-	const struct of_device_id *match;
-
-	hwmon_device_unregister(data->hwmon_dev);
-
-	match = of_match_device(vexpress_hwmon_of_match, &pdev->dev);
-	sysfs_remove_group(&pdev->dev.kobj, match->data);
+	data->hwmon_dev = devm_hwmon_device_register_with_groups(&pdev->dev,
+			type->name, data, type->attr_groups);
 
-	return 0;
+	return PTR_ERR_OR_ZERO(data->hwmon_dev);
 }
 
 static struct platform_driver vexpress_hwmon_driver = {
 	.probe = vexpress_hwmon_probe,
-	.remove = vexpress_hwmon_remove,
 	.driver	= {
 		.name = DRVNAME,
 		.owner = THIS_MODULE,
-- 
1.9.1


_______________________________________________
lm-sensors mailing list
lm-sensors@lm-sensors.org
http://lists.lm-sensors.org/mailman/listinfo/lm-sensors

  parent reply	other threads:[~2014-04-28 19:54 UTC|newest]

Thread overview: 96+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-04-28 17:57 [PATCH 00/10] Versatile Express changes for 3.16 Pawel Moll
2014-04-28 17:57 ` Pawel Moll
2014-04-28 17:57 ` [PATCH 01/10] of: Keep track of populated platform devices Pawel Moll
2014-04-28 17:57   ` Pawel Moll
2014-04-28 17:57   ` Pawel Moll
2014-04-28 18:02   ` Rob Herring
2014-04-28 18:02     ` Rob Herring
2014-04-28 18:02     ` Rob Herring
2014-04-29 12:56     ` Grant Likely
2014-04-29 12:56       ` Grant Likely
2014-04-29 12:56       ` Grant Likely
2014-04-30 11:48       ` Pawel Moll
2014-04-30 11:48         ` Pawel Moll
2014-04-30 11:48         ` Pawel Moll
2014-04-30 14:05         ` [PATCH v2] " Pawel Moll
2014-04-30 14:05           ` Pawel Moll
     [not found]           ` <1398866717-20268-1-git-send-email-pawel.moll-5wv7dgnIgG8@public.gmane.org>
2014-04-30 15:22             ` Rob Herring
2014-04-30 15:22               ` Rob Herring
     [not found]               ` <CAL_JsqL=mxqEKpAsXm7Du0vEDpKk4n+dp5-DyvbuGhTA6bP5Lg-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
2014-05-01  9:26                 ` Grant Likely
2014-05-01  9:26                   ` Grant Likely
     [not found]                   ` <20140501092635.05011C409DA-WNowdnHR2B42iJbIjFUEsiwD8/FfD2ys@public.gmane.org>
2014-05-01  9:43                     ` Grant Likely
2014-05-01  9:43                       ` Grant Likely
     [not found]                       ` <CACxGe6usWdey1qQT2JF=7LuE62H-_xtd1QkRT9z_Tj2pxdQEjQ-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
2014-05-07 14:37                         ` Pawel Moll
2014-05-07 14:37                           ` Pawel Moll
2014-05-14 10:56                           ` Grant Likely
2014-05-14 10:56                             ` Grant Likely
     [not found]                             ` <20140514105657.CF966C4153D-WNowdnHR2B42iJbIjFUEsiwD8/FfD2ys@public.gmane.org>
2014-05-15 15:08                               ` Pawel Moll
2014-05-15 15:08                                 ` Pawel Moll
2014-04-28 17:57 ` [PATCH 02/10] mfd: vexpress: Convert custom func API to regmap Pawel Moll
2014-04-28 17:57   ` [lm-sensors] " Pawel Moll
2014-04-28 17:57   ` Pawel Moll
2014-04-29 22:21   ` Mark Brown
2014-04-29 22:21     ` [lm-sensors] " Mark Brown
2014-04-29 22:21     ` Mark Brown
2014-04-30 13:58   ` Lee Jones
2014-04-30 13:58     ` [lm-sensors] " Lee Jones
2014-04-30 13:58     ` Lee Jones
2014-04-30 14:13     ` Pawel Moll
2014-04-30 14:13       ` [lm-sensors] " Pawel Moll
2014-04-30 14:13       ` Pawel Moll
2014-04-30 14:29       ` Lee Jones
2014-04-30 14:29         ` [lm-sensors] " Lee Jones
2014-04-30 14:29         ` Lee Jones
2014-04-30 14:38         ` Pawel Moll
2014-04-30 14:38           ` [lm-sensors] " Pawel Moll
2014-04-30 14:38           ` Pawel Moll
2014-04-30 16:01   ` [PATCH v2] " Pawel Moll
2014-04-30 16:01     ` [lm-sensors] " Pawel Moll
2014-04-30 16:01     ` Pawel Moll
2014-04-30 17:05     ` Guenter Roeck
2014-04-30 17:05       ` [lm-sensors] " Guenter Roeck
2014-04-30 17:05       ` Guenter Roeck
2014-05-01 18:58     ` Mike Turquette
2014-05-01 18:58       ` [lm-sensors] " Mike Turquette
2014-05-01 18:58       ` Mike Turquette
2014-04-28 17:57 ` [PATCH 03/10] mfd: syscon: Add platform data with a regmap config name Pawel Moll
2014-04-28 17:57   ` Pawel Moll
2014-04-28 17:57 ` [PATCH 04/10] mfd: vexpress: Define the device as MFD cells Pawel Moll
2014-04-28 17:57   ` Pawel Moll
2014-05-09 11:24   ` Lee Jones
2014-05-09 11:24     ` Lee Jones
2014-04-28 17:57 ` [PATCH 05/10] clk: versatile: Split config options for sp810 and vexpress_osc Pawel Moll
2014-04-28 17:57   ` Pawel Moll
2014-05-01 18:55   ` Mike Turquette
2014-05-01 18:55     ` Mike Turquette
2014-04-28 17:57 ` [PATCH 06/10] clocksource: Sched clock source for Versatile Express Pawel Moll
2014-04-28 17:57   ` Pawel Moll
2014-04-28 17:57 ` [PATCH 07/10] ARM: vexpress: remove redundant vexpress_dt_cpus_num to get cpu count Pawel Moll
2014-04-28 17:57   ` Pawel Moll
2014-04-28 17:57 ` [PATCH 08/10] ARM: vexpress: Simplify SMP operations for DT-powered system Pawel Moll
2014-04-28 17:57   ` Pawel Moll
2014-04-28 17:57 ` [PATCH 09/10] ARM: vexpress: move HBI check to sysreg driver Pawel Moll
2014-04-28 17:57   ` Pawel Moll
2014-04-30 14:02   ` Lee Jones
2014-04-30 14:02     ` Lee Jones
2014-04-28 17:57 ` Pawel Moll [this message]
2014-04-28 17:57   ` [lm-sensors] [PATCH 10/10] hwmon: vexpress: Use devm helper for hwmon device registration Pawel Moll
2014-04-28 17:57   ` Pawel Moll
2014-04-28 22:59   ` Guenter Roeck
2014-04-28 22:59     ` [lm-sensors] " Guenter Roeck
2014-04-28 22:59     ` Guenter Roeck
2014-04-30 15:16     ` Pawel Moll
2014-04-30 15:16       ` [lm-sensors] " Pawel Moll
2014-04-30 15:16       ` Pawel Moll
2014-04-30 15:27       ` Guenter Roeck
2014-04-30 15:27         ` [lm-sensors] " Guenter Roeck
2014-04-30 15:27         ` Guenter Roeck
2014-04-30 15:33         ` Pawel Moll
2014-04-30 15:33           ` [lm-sensors] " Pawel Moll
2014-04-30 15:33           ` Pawel Moll
     [not found] <Message-ID: <1399473437.3706.25.camel@hornet>
2014-05-13 11:48 ` [PATCH v3] of: Keep track of populated platform devices Pawel Moll
2014-05-13 11:48   ` Pawel Moll
     [not found]   ` <1399981716-24618-1-git-send-email-pawel.moll-5wv7dgnIgG8@public.gmane.org>
2014-05-13 12:24     ` Rob Herring
2014-05-13 12:24       ` Rob Herring
     [not found]       ` <CAL_Jsq+8xZO0LEhVa4tmOfq6CD2a0O+0CaGCnZLqDguz=yN_zg-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
2014-05-14 11:05         ` Grant Likely
2014-05-14 11:05           ` Grant Likely

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1398707877-22596-11-git-send-email-pawel.moll@arm.com \
    --to=pawel.moll@arm.com \
    --cc=arm@kernel.org \
    --cc=arnd@arndb.de \
    --cc=grant.likely@linaro.org \
    --cc=gregkh@linuxfoundation.org \
    --cc=jdelvare@suse.de \
    --cc=lee.jones@linaro.org \
    --cc=linux-arm-kernel@lists.infradead.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux@arm.linux.org.uk \
    --cc=linux@roeck-us.net \
    --cc=lm-sensors@lm-sensors.org \
    --cc=robh+dt@kernel.org \
    --cc=sameo@linux.intel.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.