Commit ffa21283 authored by Andrew Davis's avatar Andrew Davis Committed by Sebastian Reichel

power: reset: syscon-poweroff: Move device data into a struct

Currently all these device data elements are top level global variables.
Move these into a struct. This will be used in the next patch when
the global variable usage is removed. Doing this in two steps makes
the patches easier to read.
Signed-off-by: default avatarAndrew Davis <afd@ti.com>
Reviewed-by: default avatarAngeloGioacchino Del Regno <angelogioacchino.delregno@collabora.com>
Link: https://lore.kernel.org/r/20240212162831.67838-19-afd@ti.comSigned-off-by: default avatarSebastian Reichel <sebastian.reichel@collabora.com>
parent c3ede0b6
...@@ -15,15 +15,19 @@ ...@@ -15,15 +15,19 @@
#include <linux/pm.h> #include <linux/pm.h>
#include <linux/regmap.h> #include <linux/regmap.h>
static struct regmap *map; struct syscon_poweroff_data {
static u32 offset; struct regmap *map;
static u32 value; u32 offset;
static u32 mask; u32 value;
u32 mask;
};
static struct syscon_poweroff_data *data;
static void syscon_poweroff(void) static void syscon_poweroff(void)
{ {
/* Issue the poweroff */ /* Issue the poweroff */
regmap_update_bits(map, offset, mask, value); regmap_update_bits(data->map, data->offset, data->mask, data->value);
mdelay(1000); mdelay(1000);
...@@ -35,22 +39,26 @@ static int syscon_poweroff_probe(struct platform_device *pdev) ...@@ -35,22 +39,26 @@ static int syscon_poweroff_probe(struct platform_device *pdev)
struct device *dev = &pdev->dev; struct device *dev = &pdev->dev;
int mask_err, value_err; int mask_err, value_err;
map = syscon_regmap_lookup_by_phandle(dev->of_node, "regmap"); data = devm_kzalloc(dev, sizeof(*data), GFP_KERNEL);
if (IS_ERR(map)) { if (!data)
map = syscon_node_to_regmap(dev->parent->of_node); return -ENOMEM;
if (IS_ERR(map)) {
data->map = syscon_regmap_lookup_by_phandle(dev->of_node, "regmap");
if (IS_ERR(data->map)) {
data->map = syscon_node_to_regmap(dev->parent->of_node);
if (IS_ERR(data->map)) {
dev_err(dev, "unable to get syscon"); dev_err(dev, "unable to get syscon");
return PTR_ERR(map); return PTR_ERR(data->map);
} }
} }
if (of_property_read_u32(dev->of_node, "offset", &offset)) { if (of_property_read_u32(dev->of_node, "offset", &data->offset)) {
dev_err(dev, "unable to read 'offset'"); dev_err(dev, "unable to read 'offset'");
return -EINVAL; return -EINVAL;
} }
value_err = of_property_read_u32(dev->of_node, "value", &value); value_err = of_property_read_u32(dev->of_node, "value", &data->value);
mask_err = of_property_read_u32(dev->of_node, "mask", &mask); mask_err = of_property_read_u32(dev->of_node, "mask", &data->mask);
if (value_err && mask_err) { if (value_err && mask_err) {
dev_err(dev, "unable to read 'value' and 'mask'"); dev_err(dev, "unable to read 'value' and 'mask'");
return -EINVAL; return -EINVAL;
...@@ -58,11 +66,11 @@ static int syscon_poweroff_probe(struct platform_device *pdev) ...@@ -58,11 +66,11 @@ static int syscon_poweroff_probe(struct platform_device *pdev)
if (value_err) { if (value_err) {
/* support old binding */ /* support old binding */
value = mask; data->value = data->mask;
mask = 0xFFFFFFFF; data->mask = 0xFFFFFFFF;
} else if (mask_err) { } else if (mask_err) {
/* support value without mask*/ /* support value without mask*/
mask = 0xFFFFFFFF; data->mask = 0xFFFFFFFF;
} }
if (pm_power_off) { if (pm_power_off) {
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment