Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 157717
b: refs/heads/master
c: 9b30050
h: refs/heads/master
i:
  157715: db57289
v: v3
  • Loading branch information
Jarkko Nikula authored and Mark Brown committed Aug 25, 2009
1 parent 721cbbf commit 2095f0a
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 24 deletions.
2 changes: 1 addition & 1 deletion [refs]
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
---
refs/heads/master: 9f0f4ae570a148c76be6e86c959c8d4ed912fb1f
refs/heads/master: 9b30050908fad96968497e73b88626056ea33c96
48 changes: 25 additions & 23 deletions trunk/arch/arm/plat-omap/mcbsp.c
Original file line number Diff line number Diff line change
Expand Up @@ -1161,52 +1161,54 @@ static DEVICE_ATTR(prop, 0644, prop##_show, prop##_store);
THRESHOLD_PROP_BUILDER(max_tx_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,
struct device_attribute *attr, char *buf)
{
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);
dma_op_mode = mcbsp->dma_op_mode;
spin_unlock_irq(&mcbsp->lock);

return sprintf(buf, "current mode: %d\n"
"possible mode values are:\n"
"%d - %s\n"
"%d - %s\n"
"%d - %s\n",
dma_op_mode,
MCBSP_DMA_MODE_ELEMENT, "element mode",
MCBSP_DMA_MODE_THRESHOLD, "threshold mode",
MCBSP_DMA_MODE_FRAME, "frame mode");
for (s = &dma_op_modes[i]; i < ARRAY_SIZE(dma_op_modes); s++, i++) {
if (dma_op_mode == i)
len += sprintf(buf + len, "[%s] ", *s);
else
len += sprintf(buf + len, "%s ", *s);
}
len += sprintf(buf + len, "\n");

return len;
}

static ssize_t dma_op_mode_store(struct device *dev,
struct device_attribute *attr,
const char *buf, size_t size)
{
struct omap_mcbsp *mcbsp = dev_get_drvdata(dev);
unsigned long val;
int status;
const char * const *s;
int i = 0;

status = strict_strtoul(buf, 0, &val);
if (status)
return status;
for (s = &dma_op_modes[i]; i < ARRAY_SIZE(dma_op_modes); s++, i++)
if (sysfs_streq(buf, *s))
break;

spin_lock_irq(&mcbsp->lock);
if (i == ARRAY_SIZE(dma_op_modes))
return -EINVAL;

spin_lock_irq(&mcbsp->lock);
if (!mcbsp->free) {
size = -EBUSY;
goto unlock;
}

if (val > MCBSP_DMA_MODE_FRAME || val < MCBSP_DMA_MODE_ELEMENT) {
size = -EINVAL;
goto unlock;
}

mcbsp->dma_op_mode = val;
mcbsp->dma_op_mode = i;

unlock:
spin_unlock_irq(&mcbsp->lock);
Expand Down

0 comments on commit 2095f0a

Please sign in to comment.