]> pilppa.org Git - linux-2.6-omap-h63xx.git/blobdiff - arch/sh/drivers/dma/dma-sysfs.c
sh dreamcast: export board_pci_channels
[linux-2.6-omap-h63xx.git] / arch / sh / drivers / dma / dma-sysfs.c
index 70a5d82eb2f8c8b6a10340e152e77357304ce162..347ee11351ec6c4375c06a8bf3f970733f022181 100644 (file)
@@ -3,7 +3,7 @@
  *
  * 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
  * License.  See the file "COPYING" in the main directory of this archive
 #include <asm/dma.h>
 
 static struct sysdev_class dma_sysclass = {
-       set_kset_name("dma"),
+       .name = "dma",
 };
-
 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,
+                               struct sysdev_attribute *attr, char *buf)
 {
        ssize_t len = 0;
        int i;
 
        for (i = 0; i < MAX_DMA_CHANNELS; 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",
                               channel->chan, info->name,
@@ -48,21 +51,22 @@ static int __init dma_sysclass_init(void)
        int ret;
 
        ret = sysdev_class_register(&dma_sysclass);
-       if (ret == 0)
-               sysfs_create_file(&dma_sysclass.kset.kobj, &attr_devices.attr);
+       if (unlikely(ret))
+               return ret;
 
-       return ret;
+       return sysfs_create_file(&dma_sysclass.kset.kobj, &attr_devices.attr);
 }
-
 postcore_initcall(dma_sysclass_init);
 
-static ssize_t dma_show_dev_id(struct sys_device *dev, char *buf)
+static ssize_t dma_show_dev_id(struct sys_device *dev,
+                               struct sysdev_attribute *attr, char *buf)
 {
        struct dma_channel *channel = to_dma_channel(dev);
        return sprintf(buf, "%s\n", channel->dev_id);
 }
 
 static ssize_t dma_store_dev_id(struct sys_device *dev,
+                               struct sysdev_attribute *attr,
                                const char *buf, size_t count)
 {
        struct dma_channel *channel = to_dma_channel(dev);
@@ -73,6 +77,7 @@ static ssize_t dma_store_dev_id(struct sys_device *dev,
 static SYSDEV_ATTR(dev_id, S_IRUGO | S_IWUSR, dma_show_dev_id, dma_store_dev_id);
 
 static ssize_t dma_store_config(struct sys_device *dev,
+                               struct sysdev_attribute *attr,
                                const char *buf, size_t count)
 {
        struct dma_channel *channel = to_dma_channel(dev);
@@ -86,13 +91,15 @@ static ssize_t dma_store_config(struct sys_device *dev,
 
 static SYSDEV_ATTR(config, S_IWUSR, NULL, dma_store_config);
 
-static ssize_t dma_show_mode(struct sys_device *dev, char *buf)
+static ssize_t dma_show_mode(struct sys_device *dev,
+                               struct sysdev_attribute *attr, char *buf)
 {
        struct dma_channel *channel = to_dma_channel(dev);
        return sprintf(buf, "0x%08x\n", channel->mode);
 }
 
 static ssize_t dma_store_mode(struct sys_device *dev,
+                             struct sysdev_attribute *attr,
                              const char *buf, size_t count)
 {
        struct dma_channel *channel = to_dma_channel(dev);
@@ -103,7 +110,8 @@ static ssize_t dma_store_mode(struct sys_device *dev,
 static SYSDEV_ATTR(mode, S_IRUGO | S_IWUSR, dma_show_mode, dma_store_mode);
 
 #define dma_ro_attr(field, fmt)                                                \
-static ssize_t dma_show_##field(struct sys_device *dev, char *buf)     \
+static ssize_t dma_show_##field(struct sys_device *dev,                \
+                               struct sysdev_attribute *attr, char *buf)\
 {                                                                      \
        struct dma_channel *channel = to_dma_channel(dev);              \
        return sprintf(buf, fmt, channel->field);                       \
@@ -126,11 +134,16 @@ int dma_create_sysfs_files(struct dma_channel *chan, struct dma_info *info)
        if (ret)
                return ret;
 
-       sysdev_create_file(dev, &attr_dev_id);
-       sysdev_create_file(dev, &attr_count);
-       sysdev_create_file(dev, &attr_mode);
-       sysdev_create_file(dev, &attr_flags);
-       sysdev_create_file(dev, &attr_config);
+       ret |= sysdev_create_file(dev, &attr_dev_id);
+       ret |= sysdev_create_file(dev, &attr_count);
+       ret |= sysdev_create_file(dev, &attr_mode);
+       ret |= sysdev_create_file(dev, &attr_flags);
+       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);
        return sysfs_create_link(&info->pdev->dev.kobj, &dev->kobj, name);
@@ -152,4 +165,3 @@ void dma_remove_sysfs_files(struct dma_channel *chan, struct dma_info *info)
 
        sysdev_unregister(dev);
 }
-