Commit 9b300509 authored by Jarkko Nikula's avatar Jarkko Nikula Committed by Mark Brown

OMAP: McBSP: Use textual values in DMA operating mode sysfs files

Use more descriptive than numerical value when showing and storing the
McBSP DMA operating mode. Show function is using similar syntax than e.g.
the led triggers so that all possible values for store function are
printed but with current value surrounded with square brackets.
Signed-off-by: default avatarJarkko Nikula <jhnikula@gmail.com>
Cc: Peter Ujfalusi <peter.ujfalusi@nokia.com>
Acked-by: default avatarEduardo Valentin <eduardo.valentin@nokia.com>
Signed-off-by: default avatarMark Brown <broonie@opensource.wolfsonmicro.com>
parent 9f0f4ae5
...@@ -1161,25 +1161,31 @@ static DEVICE_ATTR(prop, 0644, prop##_show, prop##_store); ...@@ -1161,25 +1161,31 @@ static DEVICE_ATTR(prop, 0644, prop##_show, prop##_store);
THRESHOLD_PROP_BUILDER(max_tx_thres); THRESHOLD_PROP_BUILDER(max_tx_thres);
THRESHOLD_PROP_BUILDER(max_rx_thres); THRESHOLD_PROP_BUILDER(max_rx_thres);
static const char *dma_op_modes[] = {
"element", "threshold", "frame",
};
static ssize_t dma_op_mode_show(struct device *dev, static ssize_t dma_op_mode_show(struct device *dev,
struct device_attribute *attr, char *buf) struct device_attribute *attr, char *buf)
{ {
struct omap_mcbsp *mcbsp = dev_get_drvdata(dev); struct omap_mcbsp *mcbsp = dev_get_drvdata(dev);
int dma_op_mode; int dma_op_mode, i = 0;
ssize_t len = 0;
const char * const *s;
spin_lock_irq(&mcbsp->lock); spin_lock_irq(&mcbsp->lock);
dma_op_mode = mcbsp->dma_op_mode; dma_op_mode = mcbsp->dma_op_mode;
spin_unlock_irq(&mcbsp->lock); spin_unlock_irq(&mcbsp->lock);
return sprintf(buf, "current mode: %d\n" for (s = &dma_op_modes[i]; i < ARRAY_SIZE(dma_op_modes); s++, i++) {
"possible mode values are:\n" if (dma_op_mode == i)
"%d - %s\n" len += sprintf(buf + len, "[%s] ", *s);
"%d - %s\n" else
"%d - %s\n", len += sprintf(buf + len, "%s ", *s);
dma_op_mode, }
MCBSP_DMA_MODE_ELEMENT, "element mode", len += sprintf(buf + len, "\n");
MCBSP_DMA_MODE_THRESHOLD, "threshold mode",
MCBSP_DMA_MODE_FRAME, "frame mode"); return len;
} }
static ssize_t dma_op_mode_store(struct device *dev, static ssize_t dma_op_mode_store(struct device *dev,
...@@ -1187,26 +1193,22 @@ static ssize_t dma_op_mode_store(struct device *dev, ...@@ -1187,26 +1193,22 @@ static ssize_t dma_op_mode_store(struct device *dev,
const char *buf, size_t size) const char *buf, size_t size)
{ {
struct omap_mcbsp *mcbsp = dev_get_drvdata(dev); struct omap_mcbsp *mcbsp = dev_get_drvdata(dev);
unsigned long val; const char * const *s;
int status; int i = 0;
status = strict_strtoul(buf, 0, &val); for (s = &dma_op_modes[i]; i < ARRAY_SIZE(dma_op_modes); s++, i++)
if (status) if (sysfs_streq(buf, *s))
return status; break;
spin_lock_irq(&mcbsp->lock); if (i == ARRAY_SIZE(dma_op_modes))
return -EINVAL;
spin_lock_irq(&mcbsp->lock);
if (!mcbsp->free) { if (!mcbsp->free) {
size = -EBUSY; size = -EBUSY;
goto unlock; goto unlock;
} }
mcbsp->dma_op_mode = i;
if (val > MCBSP_DMA_MODE_FRAME || val < MCBSP_DMA_MODE_ELEMENT) {
size = -EINVAL;
goto unlock;
}
mcbsp->dma_op_mode = val;
unlock: unlock:
spin_unlock_irq(&mcbsp->lock); spin_unlock_irq(&mcbsp->lock);
......
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