1

staging: most: remove string termination dependency from user space data

This patch removes the constraint that user space data has to be terminated
with a new line character. It is needed to let the user choose how the data
is formatted.

Signed-off-by: Christian Gromm <christian.gromm@microchip.com>
Link: https://lore.kernel.org/r/1573138169-27562-1-git-send-email-christian.gromm@microchip.com
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
This commit is contained in:
Christian Gromm 2019-11-07 15:49:28 +01:00 committed by Greg Kroah-Hartman
parent 885961fed4
commit 4df0991b0c
2 changed files with 13 additions and 9 deletions

View File

@ -164,6 +164,7 @@ static ssize_t mdev_link_direction_store(struct config_item *item,
!sysfs_streq(page, "dir_tx") && !sysfs_streq(page, "tx"))
return -EINVAL;
strcpy(mdev_link->direction, page);
strim(mdev_link->direction);
return count;
}
@ -182,6 +183,7 @@ static ssize_t mdev_link_datatype_store(struct config_item *item,
!sysfs_streq(page, "isoc_avp"))
return -EINVAL;
strcpy(mdev_link->datatype, page);
strim(mdev_link->datatype);
return count;
}
@ -196,6 +198,7 @@ static ssize_t mdev_link_device_store(struct config_item *item,
struct mdev_link *mdev_link = to_mdev_link(item);
strcpy(mdev_link->device, page);
strim(mdev_link->device);
return count;
}
@ -210,6 +213,7 @@ static ssize_t mdev_link_channel_store(struct config_item *item,
struct mdev_link *mdev_link = to_mdev_link(item);
strcpy(mdev_link->channel, page);
strim(mdev_link->channel);
return count;
}

View File

@ -84,11 +84,11 @@ static const struct {
int most_ch_data_type;
const char *name;
} ch_data_type[] = {
{ MOST_CH_CONTROL, "control\n" },
{ MOST_CH_ASYNC, "async\n" },
{ MOST_CH_SYNC, "sync\n" },
{ MOST_CH_ISOC, "isoc\n"},
{ MOST_CH_ISOC, "isoc_avp\n"},
{ MOST_CH_CONTROL, "control" },
{ MOST_CH_ASYNC, "async" },
{ MOST_CH_SYNC, "sync" },
{ MOST_CH_ISOC, "isoc"},
{ MOST_CH_ISOC, "isoc_avp"},
};
/**
@ -675,13 +675,13 @@ int most_set_cfg_direction(char *mdev, char *mdev_ch, char *buf)
if (!c)
return -ENODEV;
if (!strcmp(buf, "dir_rx\n")) {
if (!strcmp(buf, "dir_rx")) {
c->cfg.direction = MOST_CH_RX;
} else if (!strcmp(buf, "rx\n")) {
} else if (!strcmp(buf, "rx")) {
c->cfg.direction = MOST_CH_RX;
} else if (!strcmp(buf, "dir_tx\n")) {
} else if (!strcmp(buf, "dir_tx")) {
c->cfg.direction = MOST_CH_TX;
} else if (!strcmp(buf, "tx\n")) {
} else if (!strcmp(buf, "tx")) {
c->cfg.direction = MOST_CH_TX;
} else {
pr_info("Invalid direction\n");