aboutsummaryrefslogtreecommitdiffstats
path: root/arch/arm/plat-omap/mcbsp.c
diff options
context:
space:
mode:
authorJarkko Nikula <jhnikula@gmail.com>2009-08-24 10:45:50 -0400
committerMark Brown <broonie@opensource.wolfsonmicro.com>2009-08-25 05:14:37 -0400
commit9b30050908fad96968497e73b88626056ea33c96 (patch)
tree80804d58312fa77ff45723fa0113b834f5ce210d /arch/arm/plat-omap/mcbsp.c
parent9f0f4ae570a148c76be6e86c959c8d4ed912fb1f (diff)
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: Jarkko Nikula <jhnikula@gmail.com> Cc: Peter Ujfalusi <peter.ujfalusi@nokia.com> Acked-by: Eduardo Valentin <eduardo.valentin@nokia.com> Signed-off-by: Mark Brown <broonie@opensource.wolfsonmicro.com>
Diffstat (limited to 'arch/arm/plat-omap/mcbsp.c')
-rw-r--r--arch/arm/plat-omap/mcbsp.c48
1 files changed, 25 insertions, 23 deletions
diff --git a/arch/arm/plat-omap/mcbsp.c b/arch/arm/plat-omap/mcbsp.c
index b63a7209b41c..ee60ab68251d 100644
--- a/arch/arm/plat-omap/mcbsp.c
+++ b/arch/arm/plat-omap/mcbsp.c
@@ -1161,25 +1161,31 @@ static DEVICE_ATTR(prop, 0644, prop##_show, prop##_store);
1161THRESHOLD_PROP_BUILDER(max_tx_thres); 1161THRESHOLD_PROP_BUILDER(max_tx_thres);
1162THRESHOLD_PROP_BUILDER(max_rx_thres); 1162THRESHOLD_PROP_BUILDER(max_rx_thres);
1163 1163
1164static const char *dma_op_modes[] = {
1165 "element", "threshold", "frame",
1166};
1167
1164static ssize_t dma_op_mode_show(struct device *dev, 1168static ssize_t dma_op_mode_show(struct device *dev,
1165 struct device_attribute *attr, char *buf) 1169 struct device_attribute *attr, char *buf)
1166{ 1170{
1167 struct omap_mcbsp *mcbsp = dev_get_drvdata(dev); 1171 struct omap_mcbsp *mcbsp = dev_get_drvdata(dev);
1168 int dma_op_mode; 1172 int dma_op_mode, i = 0;
1173 ssize_t len = 0;
1174 const char * const *s;
1169 1175
1170 spin_lock_irq(&mcbsp->lock); 1176 spin_lock_irq(&mcbsp->lock);
1171 dma_op_mode = mcbsp->dma_op_mode; 1177 dma_op_mode = mcbsp->dma_op_mode;
1172 spin_unlock_irq(&mcbsp->lock); 1178 spin_unlock_irq(&mcbsp->lock);
1173 1179
1174 return sprintf(buf, "current mode: %d\n" 1180 for (s = &dma_op_modes[i]; i < ARRAY_SIZE(dma_op_modes); s++, i++) {
1175 "possible mode values are:\n" 1181 if (dma_op_mode == i)
1176 "%d - %s\n" 1182 len += sprintf(buf + len, "[%s] ", *s);
1177 "%d - %s\n" 1183 else
1178 "%d - %s\n", 1184 len += sprintf(buf + len, "%s ", *s);
1179 dma_op_mode, 1185 }
1180 MCBSP_DMA_MODE_ELEMENT, "element mode", 1186 len += sprintf(buf + len, "\n");
1181 MCBSP_DMA_MODE_THRESHOLD, "threshold mode", 1187
1182 MCBSP_DMA_MODE_FRAME, "frame mode"); 1188 return len;
1183} 1189}
1184 1190
1185static ssize_t dma_op_mode_store(struct device *dev, 1191static ssize_t dma_op_mode_store(struct device *dev,
@@ -1187,26 +1193,22 @@ static ssize_t dma_op_mode_store(struct device *dev,
1187 const char *buf, size_t size) 1193 const char *buf, size_t size)
1188{ 1194{
1189 struct omap_mcbsp *mcbsp = dev_get_drvdata(dev); 1195 struct omap_mcbsp *mcbsp = dev_get_drvdata(dev);
1190 unsigned long val; 1196 const char * const *s;
1191 int status; 1197 int i = 0;
1192 1198
1193 status = strict_strtoul(buf, 0, &val); 1199 for (s = &dma_op_modes[i]; i < ARRAY_SIZE(dma_op_modes); s++, i++)
1194 if (status) 1200 if (sysfs_streq(buf, *s))
1195 return status; 1201 break;
1196 1202
1197 spin_lock_irq(&mcbsp->lock); 1203 if (i == ARRAY_SIZE(dma_op_modes))
1204 return -EINVAL;
1198 1205
1206 spin_lock_irq(&mcbsp->lock);
1199 if (!mcbsp->free) { 1207 if (!mcbsp->free) {
1200 size = -EBUSY; 1208 size = -EBUSY;
1201 goto unlock; 1209 goto unlock;
1202 } 1210 }
1203 1211 mcbsp->dma_op_mode = i;
1204 if (val > MCBSP_DMA_MODE_FRAME || val < MCBSP_DMA_MODE_ELEMENT) {
1205 size = -EINVAL;
1206 goto unlock;
1207 }
1208
1209 mcbsp->dma_op_mode = val;
1210 1212
1211unlock: 1213unlock:
1212 spin_unlock_irq(&mcbsp->lock); 1214 spin_unlock_irq(&mcbsp->lock);