Skip to content
Open
Show file tree
Hide file tree
Changes from 5 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions drivers/jesd204/jesd204-core.c
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
#include <linux/kernel.h>
#include <linux/module.h>
#include <linux/device.h>
#include <linux/mutex.h>
#include <linux/of.h>
#include <linux/property.h>
#include <linux/slab.h>
Expand Down Expand Up @@ -725,6 +726,7 @@ static struct jesd204_dev *jesd204_dev_alloc(struct device_node *np)

jdev = &jdev_top->jdev;

mutex_init(&jdev_top->fsm_lock);
jdev_top->topo_id = topo_id;
jdev_top->num_links = ret;
for (i = 0; i < jdev_top->num_links; i++)
Expand Down Expand Up @@ -1177,6 +1179,7 @@ static void jesd204_of_unregister_devices(void)
}
jdev_top = jesd204_dev_top_dev(jdev);
list_del(&jdev_top->entry);
mutex_destroy(&jdev_top->fsm_lock);
kfree(jdev_top);
jesd204_topologies_count--;
}
Expand Down
11 changes: 5 additions & 6 deletions drivers/jesd204/jesd204-fsm.c
Original file line number Diff line number Diff line change
Expand Up @@ -318,7 +318,7 @@ static int jesd204_fsm_propagate_rollback_cb_outputs(struct jesd204_dev *jdev_it
static int jesd204_fsm_propagate_cb_top_level(struct jesd204_dev *jdev_it,
struct jesd204_fsm_data *fsm_data)
{
int i, ret;
int i, ret = 0;

if (fsm_data->link_idx != JESD204_LINKS_ALL)
return jesd204_fsm_handle_con_cb(jdev_it, NULL,
Expand All @@ -330,7 +330,6 @@ static int jesd204_fsm_propagate_cb_top_level(struct jesd204_dev *jdev_it,
if (ret)
break;
}
/* FIXME: error message here? */

return ret;
}
Expand Down Expand Up @@ -1300,10 +1299,6 @@ static int jesd204_fsm_table_single(struct jesd204_dev *jdev,

ret1 = 0;
ret = 0;
/**
* FIXME: the handle_busy_flags logic needs re-visit, we should lock
* here and unlock after the loop is done
*/
while (!jesd204_fsm_table_end(&it->table[0], rollback, jdev->fsm_rb_to_init)) {
it->table = table;

Expand Down Expand Up @@ -1414,6 +1409,8 @@ static int jesd204_fsm_table(struct jesd204_dev *jdev,
if (!jdev_top)
return -EFAULT;

mutex_lock(&jdev_top->fsm_lock);
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

we could use guard(mutex)...


memset(&data, 0, sizeof(data));
data.fsm_change_cb = jesd204_fsm_table_entry_cb;
data.fsm_complete_cb = jesd204_fsm_table_entry_done;
Expand Down Expand Up @@ -1443,6 +1440,8 @@ static int jesd204_fsm_table(struct jesd204_dev *jdev,

jesd204_fsm_run_finished_cb(jdev, jdev_top, link_idx, handle_busy_flags);

mutex_unlock(&jdev_top->fsm_lock);

return ret;
}

Expand Down
2 changes: 2 additions & 0 deletions drivers/jesd204/jesd204-priv.h
Original file line number Diff line number Diff line change
Expand Up @@ -191,6 +191,7 @@ struct jesd204_link_opaque {
* cb_ref on the jesd204_link_opaque struct, but each link
* increments/decrements it, to group transitions of multiple
* JESD204 links
* @fsm_lock mutex to serialize FSM state transitions
* @topo_id topology ID for this device (and top-level device)
* (connections should match against this)
* @link_ids JESD204 link IDs for this top-level device
Expand All @@ -211,6 +212,7 @@ struct jesd204_dev_top {

struct jesd204_fsm_data *fsm_data;
struct kref cb_ref;
struct mutex fsm_lock;

int topo_id;
unsigned int link_ids[JESD204_MAX_LINKS];
Expand Down
14 changes: 8 additions & 6 deletions drivers/jesd204/jesd204-sysfs.c
Original file line number Diff line number Diff line change
Expand Up @@ -212,7 +212,7 @@ static ssize_t jesd204_con_printf(struct jesd204_dev *jdev,

static char *str_cut_from_chr(char *s, char c)
{
char *ptr = strchr(s, '_');
char *ptr = strchr(s, c);
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: I would just argue about a fixes tag given that all callers use _


if (!ptr)
return NULL;
Expand Down Expand Up @@ -308,6 +308,7 @@ static ssize_t jesd204_con_show(struct device *dev,
rc = jesd204_con_printf(e->jdev, ptr1, con, buf);
break;
}
iter_idx++;
}

out:
Expand All @@ -320,7 +321,8 @@ static ssize_t jesd204_show_store_int(u64 *val, size_t usize,
size_t count, bool store, bool is_signed)
{
u64 val1 = 0;
int ret, max;
u64 max;
int ret;

if (!store) {
memcpy(&val1, val, usize);
Expand All @@ -330,21 +332,21 @@ static ssize_t jesd204_show_store_int(u64 *val, size_t usize,
}

if (is_signed)
ret = kstrtoll(rbuf, 0, &val1);
ret = kstrtoll(rbuf, 0, (s64 *)&val1);
else
ret = kstrtoull(rbuf, 0, &val1);
if (ret)
return ret;

switch (usize) {
case 1:
max = 0xff;
max = U8_MAX;
break;
case 2:
max = 0xffff;
max = U16_MAX;
break;
case 4:
max = 0xffffffff;
max = U32_MAX;
break;
case 8:
max = 0;
Expand Down