aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/hwtracing
diff options
context:
space:
mode:
authorAlexander Shishkin <alexander.shishkin@linux.intel.com>2018-10-05 08:42:57 -0400
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>2018-10-11 06:12:54 -0400
commit24c7bcb6a74914b529859a07fde27a1a55e13ade (patch)
tree5695badc3c5f27c5b3bf907d6ab37d9e3c0f343a /drivers/hwtracing
parenta02509f301c68c9a7f01d75d7d326f7a9b81a630 (diff)
stm class: Switch over to the protocol driver
Now that the default framing protocol is factored out into its own driver, switch over to using the driver for writing data. To that end, make the policy code require a valid protocol name (or absence thereof, which is equivalent to "p_basic"). Also, to make transition easier, make stm class request "p_basic" module at initialization time. Signed-off-by: Alexander Shishkin <alexander.shishkin@linux.intel.com> Tested-by: Mathieu Poirier <mathieu.poirier@linaro.org> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Diffstat (limited to 'drivers/hwtracing')
-rw-r--r--drivers/hwtracing/stm/core.c34
-rw-r--r--drivers/hwtracing/stm/policy.c3
2 files changed, 21 insertions, 16 deletions
diff --git a/drivers/hwtracing/stm/core.c b/drivers/hwtracing/stm/core.c
index b789a5f0688e..93ce3aa740a9 100644
--- a/drivers/hwtracing/stm/core.c
+++ b/drivers/hwtracing/stm/core.c
@@ -603,18 +603,21 @@ ssize_t notrace stm_data_write(struct stm_data *data, unsigned int m,
603} 603}
604EXPORT_SYMBOL_GPL(stm_data_write); 604EXPORT_SYMBOL_GPL(stm_data_write);
605 605
606static ssize_t notrace stm_write(struct stm_data *data, unsigned int master, 606static ssize_t notrace
607 unsigned int channel, const char *buf, size_t count) 607stm_write(struct stm_device *stm, struct stm_output *output,
608 unsigned int chan, const char *buf, size_t count)
608{ 609{
609 const unsigned char nil = 0; 610 int err;
610 ssize_t sz; 611
612 /* stm->pdrv is serialized against policy_mutex */
613 if (!stm->pdrv)
614 return -ENODEV;
611 615
612 sz = stm_data_write(data, master, channel, true, buf, count); 616 err = stm->pdrv->write(stm->data, output, chan, buf, count);
613 if (sz > 0) 617 if (err < 0)
614 data->packet(data, master, channel, STP_PACKET_FLAG, 0, 0, 618 return err;
615 &nil);
616 619
617 return sz; 620 return err;
618} 621}
619 622
620static ssize_t stm_char_write(struct file *file, const char __user *buf, 623static ssize_t stm_char_write(struct file *file, const char __user *buf,
@@ -659,8 +662,7 @@ static ssize_t stm_char_write(struct file *file, const char __user *buf,
659 662
660 pm_runtime_get_sync(&stm->dev); 663 pm_runtime_get_sync(&stm->dev);
661 664
662 count = stm_write(stm->data, stmf->output.master, stmf->output.channel, 665 count = stm_write(stm, &stmf->output, 0, kbuf, count);
663 kbuf, count);
664 666
665 pm_runtime_mark_last_busy(&stm->dev); 667 pm_runtime_mark_last_busy(&stm->dev);
666 pm_runtime_put_autosuspend(&stm->dev); 668 pm_runtime_put_autosuspend(&stm->dev);
@@ -1310,9 +1312,7 @@ int notrace stm_source_write(struct stm_source_data *data,
1310 1312
1311 stm = srcu_dereference(src->link, &stm_source_srcu); 1313 stm = srcu_dereference(src->link, &stm_source_srcu);
1312 if (stm) 1314 if (stm)
1313 count = stm_write(stm->data, src->output.master, 1315 count = stm_write(stm, &src->output, chan, buf, count);
1314 src->output.channel + chan,
1315 buf, count);
1316 else 1316 else
1317 count = -ENODEV; 1317 count = -ENODEV;
1318 1318
@@ -1342,6 +1342,12 @@ static int __init stm_core_init(void)
1342 INIT_LIST_HEAD(&stm_pdrv_head); 1342 INIT_LIST_HEAD(&stm_pdrv_head);
1343 mutex_init(&stm_pdrv_mutex); 1343 mutex_init(&stm_pdrv_mutex);
1344 1344
1345 /*
1346 * So as to not confuse existing users with a requirement
1347 * to load yet another module, do it here.
1348 */
1349 if (IS_ENABLED(CONFIG_STM_PROTO_BASIC))
1350 (void)request_module_nowait("stm_p_basic");
1345 stm_core_up++; 1351 stm_core_up++;
1346 1352
1347 return 0; 1353 return 0;
diff --git a/drivers/hwtracing/stm/policy.c b/drivers/hwtracing/stm/policy.c
index 8bc90432ae69..5e51bed0787b 100644
--- a/drivers/hwtracing/stm/policy.c
+++ b/drivers/hwtracing/stm/policy.c
@@ -454,8 +454,7 @@ stp_policy_make(struct config_group *group, const char *name)
454 err = stm_lookup_protocol(proto, &pdrv, &pdrv_node_type); 454 err = stm_lookup_protocol(proto, &pdrv, &pdrv_node_type);
455 kfree(devname); 455 kfree(devname);
456 456
457 /* We don't have any protocol drivers yet */ 457 if (err) {
458 if (err != -ENOENT) {
459 stm_put_device(stm); 458 stm_put_device(stm);
460 return ERR_PTR(-ENODEV); 459 return ERR_PTR(-ENODEV);
461 } 460 }