Commit b4f63bbf authored by Bjorn Andersson's avatar Bjorn Andersson Committed by Bjorn Andersson
Browse files

soc: qcom: aoss: Tidy up qmp_send() callers



With qmp_send() handling variable length messages and string formatting
he callers of qmp_send() can be cleaned up to not care about these
things.

Drop the QMP_MSG_LEN sized buffers and use the message formatting, as
appropriate.

Reviewed-by: default avatarKonrad Dybcio <konrad.dybcio@linaro.org>
Signed-off-by: default avatarBjorn Andersson <quic_bjorande@quicinc.com>
Link: https://lore.kernel.org/r/20230811205839.727373-5-quic_bjorande@quicinc.com


Signed-off-by: default avatarBjorn Andersson <andersson@kernel.org>
parent 8873d1e2
Loading
Loading
Loading
Loading
+1 −4
Original line number Diff line number Diff line
@@ -324,15 +324,12 @@ void ipa_power_retention(struct ipa *ipa, bool enable)
{
	static const char fmt[] = "{ class: bcm, res: ipa_pc, val: %c }";
	struct ipa_power *power = ipa->power;
	char buf[36];	/* Exactly enough for fmt[]; size a multiple of 4 */
	int ret;

	if (!power->qmp)
		return;		/* Not needed on this platform */

	(void)snprintf(buf, sizeof(buf), fmt, enable ? '1' : '0');

	ret = qmp_send(power->qmp, buf);
	ret = qmp_send(power->qmp, fmt, enable ? '1' : '0');
	if (ret)
		dev_err(power->dev, "error %d sending QMP %sable request\n",
			ret, enable ? "en" : "dis");
+1 −7
Original line number Diff line number Diff line
@@ -23,19 +23,13 @@

static int q6v5_load_state_toggle(struct qcom_q6v5 *q6v5, bool enable)
{
	char buf[Q6V5_LOAD_STATE_MSG_LEN];
	int ret;

	if (!q6v5->qmp)
		return 0;

	ret = snprintf(buf, sizeof(buf),
		       "{class: image, res: load_state, name: %s, val: %s}",
	ret = qmp_send(q6v5->qmp, "{class: image, res: load_state, name: %s, val: %s}",
		       q6v5->load_state, enable ? "on" : "off");

	WARN_ON(ret >= Q6V5_LOAD_STATE_MSG_LEN);

	ret = qmp_send(q6v5->qmp, buf);
	if (ret)
		dev_err(q6v5->dev, "failed to toggle load state\n");

+4 −10
Original line number Diff line number Diff line
@@ -264,7 +264,7 @@ EXPORT_SYMBOL(qmp_send);

static int qmp_qdss_clk_prepare(struct clk_hw *hw)
{
	static const char buf[QMP_MSG_LEN] = "{class: clock, res: qdss, val: 1}";
	static const char *buf = "{class: clock, res: qdss, val: 1}";
	struct qmp *qmp = container_of(hw, struct qmp, qdss_clk);

	return qmp_send(qmp, buf);
@@ -272,7 +272,7 @@ static int qmp_qdss_clk_prepare(struct clk_hw *hw)

static void qmp_qdss_clk_unprepare(struct clk_hw *hw)
{
	static const char buf[QMP_MSG_LEN] = "{class: clock, res: qdss, val: 0}";
	static const char *buf = "{class: clock, res: qdss, val: 0}";
	struct qmp *qmp = container_of(hw, struct qmp, qdss_clk);

	qmp_send(qmp, buf);
@@ -334,7 +334,6 @@ static int qmp_cdev_set_cur_state(struct thermal_cooling_device *cdev,
				  unsigned long state)
{
	struct qmp_cooling_device *qmp_cdev = cdev->devdata;
	char buf[QMP_MSG_LEN] = {};
	bool cdev_state;
	int ret;

@@ -344,13 +343,8 @@ static int qmp_cdev_set_cur_state(struct thermal_cooling_device *cdev,
	if (qmp_cdev->state == state)
		return 0;

	snprintf(buf, sizeof(buf),
		 "{class: volt_flr, event:zero_temp, res:%s, value:%s}",
			qmp_cdev->name,
			cdev_state ? "on" : "off");

	ret = qmp_send(qmp_cdev->qmp, buf);

	ret = qmp_send(qmp_cdev->qmp, "{class: volt_flr, event:zero_temp, res:%s, value:%s}",
		       qmp_cdev->name, cdev_state ? "on" : "off");
	if (!ret)
		qmp_cdev->state = cdev_state;