Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 280081
b: refs/heads/master
c: dc6876a
h: refs/heads/master
i:
  280079: 2653c3b
v: v3
  • Loading branch information
Kay Sievers authored and Greg Kroah-Hartman committed Dec 21, 2011
1 parent d07547e commit 6559d84
Show file tree
Hide file tree
Showing 3 changed files with 44 additions and 43 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: f4e73bfcd9cca0b64cc8096175852936fb1d111f
refs/heads/master: dc6876a288cc6a446a6617ccfcb96082f67fa0c4
81 changes: 41 additions & 40 deletions trunk/arch/sh/drivers/dma/dma-sysfs.c
Original file line number Diff line number Diff line change
Expand Up @@ -12,18 +12,19 @@
#include <linux/kernel.h>
#include <linux/init.h>
#include <linux/stat.h>
#include <linux/sysdev.h>
#include <linux/device.h>
#include <linux/platform_device.h>
#include <linux/err.h>
#include <linux/string.h>
#include <asm/dma.h>

static struct sysdev_class dma_sysclass = {
static struct bus_type dma_subsys = {
.name = "dma",
.dev_name = "dma",
};

static ssize_t dma_show_devices(struct sys_device *dev,
struct sysdev_attribute *attr, char *buf)
static ssize_t dma_show_devices(struct device *dev,
struct device_attribute *attr, char *buf)
{
ssize_t len = 0;
int i;
Expand All @@ -43,40 +44,40 @@ static ssize_t dma_show_devices(struct sys_device *dev,
return len;
}

static SYSDEV_ATTR(devices, S_IRUGO, dma_show_devices, NULL);
static DEVICE_ATTR(devices, S_IRUGO, dma_show_devices, NULL);

static int __init dma_sysclass_init(void)
static int __init dma_subsys_init(void)
{
int ret;

ret = sysdev_class_register(&dma_sysclass);
ret = subsys_system_register(&dma_subsys, NULL);
if (unlikely(ret))
return ret;

return sysfs_create_file(&dma_sysclass.kset.kobj, &attr_devices.attr);
return device_create_file(dma_subsys.dev_root, &dev_attr_devices.attr);
}
postcore_initcall(dma_sysclass_init);
postcore_initcall(dma_subsys_init);

static ssize_t dma_show_dev_id(struct sys_device *dev,
struct sysdev_attribute *attr, char *buf)
static ssize_t dma_show_dev_id(struct device *dev,
struct device_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,
static ssize_t dma_store_dev_id(struct device *dev,
struct device_attribute *attr,
const char *buf, size_t count)
{
struct dma_channel *channel = to_dma_channel(dev);
strcpy(channel->dev_id, buf);
return count;
}

static SYSDEV_ATTR(dev_id, S_IRUGO | S_IWUSR, dma_show_dev_id, dma_store_dev_id);
static DEVICE_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,
static ssize_t dma_store_config(struct device *dev,
struct device_attribute *attr,
const char *buf, size_t count)
{
struct dma_channel *channel = to_dma_channel(dev);
Expand All @@ -88,56 +89,56 @@ static ssize_t dma_store_config(struct sys_device *dev,
return count;
}

static SYSDEV_ATTR(config, S_IWUSR, NULL, dma_store_config);
static DEVICE_ATTR(config, S_IWUSR, NULL, dma_store_config);

static ssize_t dma_show_mode(struct sys_device *dev,
struct sysdev_attribute *attr, char *buf)
static ssize_t dma_show_mode(struct device *dev,
struct device_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,
static ssize_t dma_store_mode(struct device *dev,
struct device_attribute *attr,
const char *buf, size_t count)
{
struct dma_channel *channel = to_dma_channel(dev);
channel->mode = simple_strtoul(buf, NULL, 0);
return count;
}

static SYSDEV_ATTR(mode, S_IRUGO | S_IWUSR, dma_show_mode, dma_store_mode);
static DEVICE_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, \
struct sysdev_attribute *attr, char *buf)\
static ssize_t dma_show_##field(struct device *dev, \
struct device_attribute *attr, char *buf)\
{ \
struct dma_channel *channel = to_dma_channel(dev); \
return sprintf(buf, fmt, channel->field); \
} \
static SYSDEV_ATTR(field, S_IRUGO, dma_show_##field, NULL);
static DEVICE_ATTR(field, S_IRUGO, dma_show_##field, NULL);

dma_ro_attr(count, "0x%08x\n");
dma_ro_attr(flags, "0x%08lx\n");

int dma_create_sysfs_files(struct dma_channel *chan, struct dma_info *info)
{
struct sys_device *dev = &chan->dev;
struct device *dev = &chan->dev;
char name[16];
int ret;

dev->id = chan->vchan;
dev->cls = &dma_sysclass;
dev->bus = &dma_subsys;

ret = sysdev_register(dev);
ret = device_register(dev);
if (ret)
return ret;

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);
ret |= device_create_file(dev, &dev_attr_dev_id);
ret |= device_create_file(dev, &dev_attr_count);
ret |= device_create_file(dev, &dev_attr_mode);
ret |= device_create_file(dev, &dev_attr_flags);
ret |= device_create_file(dev, &dev_attr_config);

if (unlikely(ret)) {
dev_err(&info->pdev->dev, "Failed creating attrs\n");
Expand All @@ -150,17 +151,17 @@ int dma_create_sysfs_files(struct dma_channel *chan, struct dma_info *info)

void dma_remove_sysfs_files(struct dma_channel *chan, struct dma_info *info)
{
struct sys_device *dev = &chan->dev;
struct device *dev = &chan->dev;
char name[16];

sysdev_remove_file(dev, &attr_dev_id);
sysdev_remove_file(dev, &attr_count);
sysdev_remove_file(dev, &attr_mode);
sysdev_remove_file(dev, &attr_flags);
sysdev_remove_file(dev, &attr_config);
device_remove_file(dev, &dev_attr_dev_id);
device_remove_file(dev, &dev_attr_count);
device_remove_file(dev, &dev_attr_mode);
device_remove_file(dev, &dev_attr_flags);
device_remove_file(dev, &dev_attr_config);

snprintf(name, sizeof(name), "dma%d", chan->chan);
sysfs_remove_link(&info->pdev->dev.kobj, name);

sysdev_unregister(dev);
device_unregister(dev);
}
4 changes: 2 additions & 2 deletions trunk/arch/sh/include/asm/dma.h
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
#include <linux/spinlock.h>
#include <linux/wait.h>
#include <linux/sched.h>
#include <linux/sysdev.h>
#include <linux/device.h>
#include <cpu/dma.h>
#include <asm-generic/dma.h>

Expand Down Expand Up @@ -91,7 +91,7 @@ struct dma_channel {

wait_queue_head_t wait_queue;

struct sys_device dev;
struct device dev;
void *priv_data;
};

Expand Down

0 comments on commit 6559d84

Please sign in to comment.