Commit 787105b3 authored by Christian Gromm's avatar Christian Gromm Committed by Greg Kroah-Hartman

staging: most: core: make sysfs attributes read-only

This patch changes the access flags of the channel attributes to
read-only. This is needed, because configuration is done via configfs.
Signed-off-by: default avatarChristian Gromm <christian.gromm@microchip.com>
Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
parent 919c03ae
...@@ -272,19 +272,6 @@ static ssize_t set_number_of_buffers_show(struct device *dev, ...@@ -272,19 +272,6 @@ static ssize_t set_number_of_buffers_show(struct device *dev,
return snprintf(buf, PAGE_SIZE, "%d\n", c->cfg.num_buffers); return snprintf(buf, PAGE_SIZE, "%d\n", c->cfg.num_buffers);
} }
static ssize_t set_number_of_buffers_store(struct device *dev,
struct device_attribute *attr,
const char *buf,
size_t count)
{
struct most_channel *c = to_channel(dev);
int ret = kstrtou16(buf, 0, &c->cfg.num_buffers);
if (ret)
return ret;
return count;
}
static ssize_t set_buffer_size_show(struct device *dev, static ssize_t set_buffer_size_show(struct device *dev,
struct device_attribute *attr, struct device_attribute *attr,
char *buf) char *buf)
...@@ -294,19 +281,6 @@ static ssize_t set_buffer_size_show(struct device *dev, ...@@ -294,19 +281,6 @@ static ssize_t set_buffer_size_show(struct device *dev,
return snprintf(buf, PAGE_SIZE, "%d\n", c->cfg.buffer_size); return snprintf(buf, PAGE_SIZE, "%d\n", c->cfg.buffer_size);
} }
static ssize_t set_buffer_size_store(struct device *dev,
struct device_attribute *attr,
const char *buf,
size_t count)
{
struct most_channel *c = to_channel(dev);
int ret = kstrtou16(buf, 0, &c->cfg.buffer_size);
if (ret)
return ret;
return count;
}
static ssize_t set_direction_show(struct device *dev, static ssize_t set_direction_show(struct device *dev,
struct device_attribute *attr, struct device_attribute *attr,
char *buf) char *buf)
...@@ -320,28 +294,6 @@ static ssize_t set_direction_show(struct device *dev, ...@@ -320,28 +294,6 @@ static ssize_t set_direction_show(struct device *dev,
return snprintf(buf, PAGE_SIZE, "unconfigured\n"); return snprintf(buf, PAGE_SIZE, "unconfigured\n");
} }
static ssize_t set_direction_store(struct device *dev,
struct device_attribute *attr,
const char *buf,
size_t count)
{
struct most_channel *c = to_channel(dev);
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("WARN: invalid attribute settings\n");
return -EINVAL;
}
return count;
}
static ssize_t set_datatype_show(struct device *dev, static ssize_t set_datatype_show(struct device *dev,
struct device_attribute *attr, struct device_attribute *attr,
char *buf) char *buf)
...@@ -356,28 +308,6 @@ static ssize_t set_datatype_show(struct device *dev, ...@@ -356,28 +308,6 @@ static ssize_t set_datatype_show(struct device *dev,
return snprintf(buf, PAGE_SIZE, "unconfigured\n"); return snprintf(buf, PAGE_SIZE, "unconfigured\n");
} }
static ssize_t set_datatype_store(struct device *dev,
struct device_attribute *attr,
const char *buf,
size_t count)
{
int i;
struct most_channel *c = to_channel(dev);
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 -EINVAL;
}
return count;
}
static ssize_t set_subbuffer_size_show(struct device *dev, static ssize_t set_subbuffer_size_show(struct device *dev,
struct device_attribute *attr, struct device_attribute *attr,
char *buf) char *buf)
...@@ -387,19 +317,6 @@ static ssize_t set_subbuffer_size_show(struct device *dev, ...@@ -387,19 +317,6 @@ static ssize_t set_subbuffer_size_show(struct device *dev,
return snprintf(buf, PAGE_SIZE, "%d\n", c->cfg.subbuffer_size); return snprintf(buf, PAGE_SIZE, "%d\n", c->cfg.subbuffer_size);
} }
static ssize_t set_subbuffer_size_store(struct device *dev,
struct device_attribute *attr,
const char *buf,
size_t count)
{
struct most_channel *c = to_channel(dev);
int ret = kstrtou16(buf, 0, &c->cfg.subbuffer_size);
if (ret)
return ret;
return count;
}
static ssize_t set_packets_per_xact_show(struct device *dev, static ssize_t set_packets_per_xact_show(struct device *dev,
struct device_attribute *attr, struct device_attribute *attr,
char *buf) char *buf)
...@@ -409,19 +326,6 @@ static ssize_t set_packets_per_xact_show(struct device *dev, ...@@ -409,19 +326,6 @@ static ssize_t set_packets_per_xact_show(struct device *dev,
return snprintf(buf, PAGE_SIZE, "%d\n", c->cfg.packets_per_xact); return snprintf(buf, PAGE_SIZE, "%d\n", c->cfg.packets_per_xact);
} }
static ssize_t set_packets_per_xact_store(struct device *dev,
struct device_attribute *attr,
const char *buf,
size_t count)
{
struct most_channel *c = to_channel(dev);
int ret = kstrtou16(buf, 0, &c->cfg.packets_per_xact);
if (ret)
return ret;
return count;
}
static ssize_t set_dbr_size_show(struct device *dev, static ssize_t set_dbr_size_show(struct device *dev,
struct device_attribute *attr, char *buf) struct device_attribute *attr, char *buf)
{ {
...@@ -430,18 +334,6 @@ static ssize_t set_dbr_size_show(struct device *dev, ...@@ -430,18 +334,6 @@ static ssize_t set_dbr_size_show(struct device *dev,
return snprintf(buf, PAGE_SIZE, "%d\n", c->cfg.dbr_size); return snprintf(buf, PAGE_SIZE, "%d\n", c->cfg.dbr_size);
} }
static ssize_t set_dbr_size_store(struct device *dev,
struct device_attribute *attr,
const char *buf, size_t count)
{
struct most_channel *c = to_channel(dev);
int ret = kstrtou16(buf, 0, &c->cfg.dbr_size);
if (ret)
return ret;
return count;
}
#define to_dev_attr(a) container_of(a, struct device_attribute, attr) #define to_dev_attr(a) container_of(a, struct device_attribute, attr)
static umode_t channel_attr_is_visible(struct kobject *kobj, static umode_t channel_attr_is_visible(struct kobject *kobj,
struct attribute *attr, int index) struct attribute *attr, int index)
...@@ -469,13 +361,13 @@ static DEVICE_ATTR_RO(number_of_stream_buffers); ...@@ -469,13 +361,13 @@ static DEVICE_ATTR_RO(number_of_stream_buffers);
static DEVICE_ATTR_RO(size_of_stream_buffer); static DEVICE_ATTR_RO(size_of_stream_buffer);
static DEVICE_ATTR_RO(size_of_packet_buffer); static DEVICE_ATTR_RO(size_of_packet_buffer);
static DEVICE_ATTR_RO(channel_starving); static DEVICE_ATTR_RO(channel_starving);
static DEVICE_ATTR_RW(set_buffer_size); static DEVICE_ATTR_RO(set_buffer_size);
static DEVICE_ATTR_RW(set_number_of_buffers); static DEVICE_ATTR_RO(set_number_of_buffers);
static DEVICE_ATTR_RW(set_direction); static DEVICE_ATTR_RO(set_direction);
static DEVICE_ATTR_RW(set_datatype); static DEVICE_ATTR_RO(set_datatype);
static DEVICE_ATTR_RW(set_subbuffer_size); static DEVICE_ATTR_RO(set_subbuffer_size);
static DEVICE_ATTR_RW(set_packets_per_xact); static DEVICE_ATTR_RO(set_packets_per_xact);
static DEVICE_ATTR_RW(set_dbr_size); static DEVICE_ATTR_RO(set_dbr_size);
static struct attribute *channel_attrs[] = { static struct attribute *channel_attrs[] = {
DEV_ATTR(available_directions), DEV_ATTR(available_directions),
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment