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

Commit 3d89b273 authored by Christian Gromm's avatar Christian Gromm Committed by Greg Kroah-Hartman
Browse files

staging: most: core: add configfs interface functions



This patch adds the core's interface to configfs file.

Signed-off-by: default avatarChristian Gromm <christian.gromm@microchip.com>
Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
parent dfee92dd
Loading
Loading
Loading
Loading
+142 −0
Original line number Diff line number Diff line
@@ -783,6 +783,127 @@ static ssize_t add_link_store(struct device_driver *drv,
	return len;
}

int most_set_cfg_buffer_size(char *mdev, char *mdev_ch, u16 val)
{
	struct most_channel *c = get_channel(mdev, mdev_ch);

	if (!c)
		return -ENODEV;
	c->cfg.buffer_size = val;
	return 0;
}

int most_set_cfg_subbuffer_size(char *mdev, char *mdev_ch, u16 val)
{
	struct most_channel *c = get_channel(mdev, mdev_ch);

	if (!c)
		return -ENODEV;
	c->cfg.subbuffer_size = val;
	return 0;
}

int most_set_cfg_dbr_size(char *mdev, char *mdev_ch, u16 val)
{
	struct most_channel *c = get_channel(mdev, mdev_ch);

	if (!c)
		return -ENODEV;
	c->cfg.dbr_size = val;
	return 0;
}

int most_set_cfg_num_buffers(char *mdev, char *mdev_ch, u16 val)
{
	struct most_channel *c = get_channel(mdev, mdev_ch);

	if (!c)
		return -ENODEV;
	c->cfg.num_buffers = val;
	return 0;
}

int most_set_cfg_datatype(char *mdev, char *mdev_ch, char *buf)
{
	int i;
	struct most_channel *c = get_channel(mdev, mdev_ch);

	if (!c)
		return -ENODEV;
	for (i = 0; i < ARRAY_SIZE(ch_data_type); i++) {
		if (!strcmp(buf, ch_data_type[i].name)) {
			c->cfg.data_type = ch_data_type[i].most_ch_data_type;
			break;
		}
	}

	if (i == ARRAY_SIZE(ch_data_type))
		pr_info("WARN: invalid attribute settings\n");
	return 0;
}

int most_set_cfg_direction(char *mdev, char *mdev_ch, char *buf)
{
	struct most_channel *c = get_channel(mdev, mdev_ch);

	if (!c)
		return -ENODEV;
	if (!strcmp(buf, "dir_rx\n")) {
		c->cfg.direction = MOST_CH_RX;
	} else if (!strcmp(buf, "rx\n")) {
		c->cfg.direction = MOST_CH_RX;
	} else if (!strcmp(buf, "dir_tx\n")) {
		c->cfg.direction = MOST_CH_TX;
	} else if (!strcmp(buf, "tx\n")) {
		c->cfg.direction = MOST_CH_TX;
	} else {
		pr_info("Invalid direction\n");
		return -ENODATA;
	}
	return 0;
}

int most_set_cfg_packets_xact(char *mdev, char *mdev_ch, u16 val)
{
	struct most_channel *c = get_channel(mdev, mdev_ch);

	if (!c)
		return -ENODEV;
	c->cfg.packets_per_xact = val;
	return 0;
}

int most_cfg_complete(char *comp_name)
{
	struct core_component *comp;

	comp = match_component(comp_name);
	if (!comp)
		return -ENODEV;

	return comp->cfg_complete();
}

int most_add_link(char *mdev, char *mdev_ch, char *comp_name, char *link_name,
		  char *comp_param)
{
	struct most_channel *c;
	struct core_component *comp;
	char buf[STRING_SIZE];

	comp = match_component(comp_name);
	if (!comp)
		return -ENODEV;
	if (!comp_param || *comp_param == 0) {
		snprintf(buf, sizeof(buf), "%s-%s", mdev, mdev_ch);
		comp_param = buf;
	}
	c = get_channel(mdev, mdev_ch);
	if (!c)
		return -ENODEV;

	return link_channel_to_component(c, comp, link_name, comp_param);
}
/**
 * remove_link_store - store function for remove_link attribute
 * @drv: device driver
@@ -825,6 +946,27 @@ static ssize_t remove_link_store(struct device_driver *drv,
	return len;
}

int most_remove_link(char *mdev, char *mdev_ch, char *comp_name)
{
	struct most_channel *c;
	struct core_component *comp;

	comp = match_component(comp_name);
	if (!comp)
		return -ENODEV;
	c = get_channel(mdev, mdev_ch);
	if (!c)
		return -ENODEV;

	if (comp->disconnect_channel(c->iface, c->channel_id))
		return -EIO;
	if (c->pipe0.comp == comp)
		c->pipe0.comp = NULL;
	if (c->pipe1.comp == comp)
		c->pipe1.comp = NULL;
	return 0;
}

#define DRV_ATTR(_name)  (&driver_attr_##_name.attr)

static DRIVER_ATTR_RO(links);
+15 −1
Original line number Diff line number Diff line
@@ -272,6 +272,7 @@ struct core_component {
				  int channel_idx);
	int (*rx_completion)(struct mbo *mbo);
	int (*tx_completion)(struct most_interface *iface, int channel_idx);
	int (*cfg_complete)(void);
};

/**
@@ -319,5 +320,18 @@ int most_start_channel(struct most_interface *iface, int channel_idx,
		       struct core_component *comp);
int most_stop_channel(struct most_interface *iface, int channel_idx,
		      struct core_component *comp);

int __init configfs_init(void);
int most_register_configfs_subsys(struct core_component *comp);
void most_deregister_configfs_subsys(struct core_component *comp);
int most_add_link(char *mdev, char *mdev_ch, char *comp_name, char *link_name,
		  char *comp_param);
int most_remove_link(char *mdev, char *mdev_ch, char *comp_name);
int most_set_cfg_buffer_size(char *mdev, char *mdev_ch, u16 val);
int most_set_cfg_subbuffer_size(char *mdev, char *mdev_ch, u16 val);
int most_set_cfg_dbr_size(char *mdev, char *mdev_ch, u16 val);
int most_set_cfg_num_buffers(char *mdev, char *mdev_ch, u16 val);
int most_set_cfg_datatype(char *mdev, char *mdev_ch, char *buf);
int most_set_cfg_direction(char *mdev, char *mdev_ch, char *buf);
int most_set_cfg_packets_xact(char *mdev, char *mdev_ch, u16 val);
int most_cfg_complete(char *comp_name);
#endif /* MOST_CORE_H_ */