[QUEUED v20180920 07/16] stm class: Switch over to the protocol driver

From: Alexander Shishkin
Date: Thu Sep 20 2018 - 08:46:32 EST


Now that the default framing protocol is factored out into its own driver,
switch over to using the driver for writing data.

Signed-off-by: Alexander Shishkin <alexander.shishkin@xxxxxxxxxxxxxxx>
---
drivers/hwtracing/stm/core.c | 27 ++++++++++++++-------------
1 file changed, 14 insertions(+), 13 deletions(-)

diff --git a/drivers/hwtracing/stm/core.c b/drivers/hwtracing/stm/core.c
index 9ed2f06deb47..fb224574b3db 100644
--- a/drivers/hwtracing/stm/core.c
+++ b/drivers/hwtracing/stm/core.c
@@ -598,17 +598,21 @@ ssize_t notrace stm_data_write(struct stm_data *data, unsigned int m,
}
EXPORT_SYMBOL_GPL(stm_data_write);

-static ssize_t notrace stm_write(struct stm_data *data, unsigned int master,
- unsigned int channel, const char *buf, size_t count)
+static ssize_t notrace
+stm_write(struct stm_device *stm, struct stm_output *output,
+ unsigned int chan, const char *buf, size_t count)
{
- ssize_t sz;
+ int err;
+
+ /* stm->pdrv is serialized against policy_mutex */
+ if (!stm->pdrv)
+ return -ENODEV;

- sz = stm_data_write(data, master, channel, true, buf, count);
- if (sz > 0)
- data->packet(data, master, channel, STP_PACKET_FLAG, 0, 0,
- buf);
+ err = stm->pdrv->write(stm->data, output, chan, buf, count);
+ if (err < 0)
+ return err;

- return sz;
+ return err;
}

static ssize_t stm_char_write(struct file *file, const char __user *buf,
@@ -655,8 +659,7 @@ static ssize_t stm_char_write(struct file *file, const char __user *buf,

pm_runtime_get_sync(&stm->dev);

- count = stm_write(stm->data, stmf->output.master, stmf->output.channel,
- kbuf, count);
+ count = stm_write(stm, &stmf->output, 0, kbuf, count);

pm_runtime_mark_last_busy(&stm->dev);
pm_runtime_put_autosuspend(&stm->dev);
@@ -1306,9 +1309,7 @@ int notrace stm_source_write(struct stm_source_data *data,

stm = srcu_dereference(src->link, &stm_source_srcu);
if (stm)
- count = stm_write(stm->data, src->output.master,
- src->output.channel + chan,
- buf, count);
+ count = stm_write(stm, &src->output, chan, buf, count);
else
count = -ENODEV;

--
2.18.0