Skip to content

Commit

Permalink
firmware: raspberrypi: Add backward compatible get_throttled
Browse files Browse the repository at this point in the history
Avoid a hard userspace ABI change by adding a compatible get_throttled
sysfs entry. Its value is now feed by the GET_THROTTLED requests of the
new hwmon driver. The first access to get_throttled will generate
a warning.

Signed-off-by: Stefan Wahren <stefan.wahren@i2se.com>
  • Loading branch information
lategoodbye authored and popcornmix committed Oct 22, 2018
1 parent bbba849 commit 83bf476
Showing 1 changed file with 33 additions and 0 deletions.
33 changes: 33 additions & 0 deletions drivers/firmware/raspberrypi.c
Expand Up @@ -31,6 +31,7 @@ struct rpi_firmware {
struct mbox_chan *chan; /* The property channel. */
struct completion c;
u32 enabled;
u32 get_throttled;
};

static struct platform_device *g_pdev;
Expand Down Expand Up @@ -171,6 +172,12 @@ int rpi_firmware_property(struct rpi_firmware *fw,
data + sizeof(struct rpi_firmware_property_tag_header),
buf_size);

if ((tag == RPI_FIRMWARE_GET_THROTTLED) &&
memcmp(&fw->get_throttled, tag_data, sizeof(fw->get_throttled))) {
memcpy(&fw->get_throttled, tag_data, sizeof(fw->get_throttled));
sysfs_notify(&fw->cl.dev->kobj, NULL, "get_throttled");
}

return ret;
}
EXPORT_SYMBOL_GPL(rpi_firmware_property);
Expand All @@ -195,6 +202,27 @@ static int rpi_firmware_notify_reboot(struct notifier_block *nb,
return 0;
}

static ssize_t get_throttled_show(struct device *dev,
struct device_attribute *attr, char *buf)
{
struct rpi_firmware *fw = dev_get_drvdata(dev);

WARN_ONCE(1, "deprecated, use hwmon sysfs instead\n");

return sprintf(buf, "%x\n", fw->get_throttled);
}

static DEVICE_ATTR_RO(get_throttled);

static struct attribute *rpi_firmware_dev_attrs[] = {
&dev_attr_get_throttled.attr,
NULL,
};

static const struct attribute_group rpi_firmware_dev_group = {
.attrs = rpi_firmware_dev_attrs,
};

static void
rpi_firmware_print_firmware_revision(struct rpi_firmware *fw)
{
Expand Down Expand Up @@ -227,6 +255,11 @@ rpi_register_hwmon_driver(struct device *dev, struct rpi_firmware *fw)

rpi_hwmon = platform_device_register_data(dev, "raspberrypi-hwmon",
-1, NULL, 0);

if (!IS_ERR_OR_NULL(rpi_hwmon)) {
if (devm_device_add_group(dev, &rpi_firmware_dev_group))
dev_err(dev, "Failed to create get_trottled attr\n");
}
}

static int rpi_firmware_probe(struct platform_device *pdev)
Expand Down

0 comments on commit 83bf476

Please sign in to comment.