Skip to content

Commit 61b5050

Browse files
lategoodbyepopcornmix
authored andcommitted
firmware: raspberrypi: Add backward compatible get_throttled
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 <[email protected]>
1 parent b501dd5 commit 61b5050

File tree

1 file changed

+33
-0
lines changed

1 file changed

+33
-0
lines changed

drivers/firmware/raspberrypi.c

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@ struct rpi_firmware {
2727
struct mbox_chan *chan; /* The property channel. */
2828
struct completion c;
2929
u32 enabled;
30+
u32 get_throttled;
3031
};
3132

3233
static struct platform_device *g_pdev;
@@ -173,6 +174,12 @@ int rpi_firmware_property(struct rpi_firmware *fw,
173174

174175
kfree(data);
175176

177+
if ((tag == RPI_FIRMWARE_GET_THROTTLED) &&
178+
memcmp(&fw->get_throttled, tag_data, sizeof(fw->get_throttled))) {
179+
memcpy(&fw->get_throttled, tag_data, sizeof(fw->get_throttled));
180+
sysfs_notify(&fw->cl.dev->kobj, NULL, "get_throttled");
181+
}
182+
176183
return ret;
177184
}
178185
EXPORT_SYMBOL_GPL(rpi_firmware_property);
@@ -197,6 +204,27 @@ static int rpi_firmware_notify_reboot(struct notifier_block *nb,
197204
return 0;
198205
}
199206

207+
static ssize_t get_throttled_show(struct device *dev,
208+
struct device_attribute *attr, char *buf)
209+
{
210+
struct rpi_firmware *fw = dev_get_drvdata(dev);
211+
212+
WARN_ONCE(1, "deprecated, use hwmon sysfs instead\n");
213+
214+
return sprintf(buf, "%x\n", fw->get_throttled);
215+
}
216+
217+
static DEVICE_ATTR_RO(get_throttled);
218+
219+
static struct attribute *rpi_firmware_dev_attrs[] = {
220+
&dev_attr_get_throttled.attr,
221+
NULL,
222+
};
223+
224+
static const struct attribute_group rpi_firmware_dev_group = {
225+
.attrs = rpi_firmware_dev_attrs,
226+
};
227+
200228
static void
201229
rpi_firmware_print_firmware_revision(struct rpi_firmware *fw)
202230
{
@@ -229,6 +257,11 @@ rpi_register_hwmon_driver(struct device *dev, struct rpi_firmware *fw)
229257

230258
rpi_hwmon = platform_device_register_data(dev, "raspberrypi-hwmon",
231259
-1, NULL, 0);
260+
261+
if (!IS_ERR_OR_NULL(rpi_hwmon)) {
262+
if (devm_device_add_group(dev, &rpi_firmware_dev_group))
263+
dev_err(dev, "Failed to create get_trottled attr\n");
264+
}
232265
}
233266

234267
static int rpi_firmware_probe(struct platform_device *pdev)

0 commit comments

Comments
 (0)