sh: dma-sysfs fixes.
Handle the case where no registered DMACs exist somewhat more gracefully. While we're at it, check for sysdev_create_file() failing. Signed-off-by: Paul Mundt <lethal@linux-sh.org>
This commit is contained in:
Родитель
e0969e0c9b
Коммит
4dfc119f1c
|
@ -3,7 +3,7 @@
|
||||||
*
|
*
|
||||||
* sysfs interface for SH DMA API
|
* sysfs interface for SH DMA API
|
||||||
*
|
*
|
||||||
* Copyright (C) 2004, 2005 Paul Mundt
|
* Copyright (C) 2004 - 2006 Paul Mundt
|
||||||
*
|
*
|
||||||
* This file is subject to the terms and conditions of the GNU General Public
|
* This file is subject to the terms and conditions of the GNU General Public
|
||||||
* License. See the file "COPYING" in the main directory of this archive
|
* License. See the file "COPYING" in the main directory of this archive
|
||||||
|
@ -21,7 +21,6 @@
|
||||||
static struct sysdev_class dma_sysclass = {
|
static struct sysdev_class dma_sysclass = {
|
||||||
set_kset_name("dma"),
|
set_kset_name("dma"),
|
||||||
};
|
};
|
||||||
|
|
||||||
EXPORT_SYMBOL(dma_sysclass);
|
EXPORT_SYMBOL(dma_sysclass);
|
||||||
|
|
||||||
static ssize_t dma_show_devices(struct sys_device *dev, char *buf)
|
static ssize_t dma_show_devices(struct sys_device *dev, char *buf)
|
||||||
|
@ -31,7 +30,10 @@ static ssize_t dma_show_devices(struct sys_device *dev, char *buf)
|
||||||
|
|
||||||
for (i = 0; i < MAX_DMA_CHANNELS; i++) {
|
for (i = 0; i < MAX_DMA_CHANNELS; i++) {
|
||||||
struct dma_info *info = get_dma_info(i);
|
struct dma_info *info = get_dma_info(i);
|
||||||
struct dma_channel *channel = &info->channels[i];
|
struct dma_channel *channel = get_dma_channel(i);
|
||||||
|
|
||||||
|
if (unlikely(!info) || !channel)
|
||||||
|
continue;
|
||||||
|
|
||||||
len += sprintf(buf + len, "%2d: %14s %s\n",
|
len += sprintf(buf + len, "%2d: %14s %s\n",
|
||||||
channel->chan, info->name,
|
channel->chan, info->name,
|
||||||
|
@ -125,11 +127,16 @@ int dma_create_sysfs_files(struct dma_channel *chan, struct dma_info *info)
|
||||||
if (ret)
|
if (ret)
|
||||||
return ret;
|
return ret;
|
||||||
|
|
||||||
sysdev_create_file(dev, &attr_dev_id);
|
ret |= sysdev_create_file(dev, &attr_dev_id);
|
||||||
sysdev_create_file(dev, &attr_count);
|
ret |= sysdev_create_file(dev, &attr_count);
|
||||||
sysdev_create_file(dev, &attr_mode);
|
ret |= sysdev_create_file(dev, &attr_mode);
|
||||||
sysdev_create_file(dev, &attr_flags);
|
ret |= sysdev_create_file(dev, &attr_flags);
|
||||||
sysdev_create_file(dev, &attr_config);
|
ret |= sysdev_create_file(dev, &attr_config);
|
||||||
|
|
||||||
|
if (unlikely(ret)) {
|
||||||
|
dev_err(&info->pdev->dev, "Failed creating attrs\n");
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
|
||||||
snprintf(name, sizeof(name), "dma%d", chan->chan);
|
snprintf(name, sizeof(name), "dma%d", chan->chan);
|
||||||
return sysfs_create_link(&info->pdev->dev.kobj, &dev->kobj, name);
|
return sysfs_create_link(&info->pdev->dev.kobj, &dev->kobj, name);
|
||||||
|
|
Загрузка…
Ссылка в новой задаче