Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit c697e3f5 authored by Linux Build Service Account's avatar Linux Build Service Account Committed by Gerrit - the friendly Code Review server
Browse files

Merge "PM / OPP: Expose OPP tables to userspace via a device attribute"

parents 6274ad1b a2c4299d
Loading
Loading
Loading
Loading
+26 −0
Original line number Diff line number Diff line
@@ -378,6 +378,29 @@ struct dev_pm_opp *dev_pm_opp_find_freq_floor(struct device *dev,
}
EXPORT_SYMBOL_GPL(dev_pm_opp_find_freq_floor);

static ssize_t opp_table_show(struct device *dev, struct device_attribute *attr,
			      char *buf)
{
	struct dev_pm_opp *opp;
	ssize_t count = 0;
	unsigned long freq = 0;

	rcu_read_lock();
	while ((opp = dev_pm_opp_find_freq_ceil(dev, &freq))) {
		if (IS_ERR(opp))
			break;
		count += scnprintf(&buf[count], PAGE_SIZE - count, "%lu %lu\n",
				freq, opp->u_volt);
		if (count <= 0)
			break;
		freq++;
	}
	rcu_read_unlock();

	return count;
}
static DEVICE_ATTR_RO(opp_table);

/**
 * dev_pm_opp_add()  - Add an OPP table from a table definitions
 * @dev:	device for which we do this operation
@@ -448,6 +471,9 @@ int dev_pm_opp_add(struct device *dev, unsigned long freq, unsigned long u_volt)
		/* Secure the device list modification */
		list_add_rcu(&dev_opp->node, &dev_opp_list);
		head = &dev_opp->opp_list;
		/*  attribute here */
		WARN(device_create_file(dev, &dev_attr_opp_table),
		     "Unable to add opp_table device attribute.\n");
		goto list_add;
	}