/alps/bar_resolve

To get this branch, use:
bzr branch http://darksoft.org/webbzr/alps/bar_resolve

« back to all changes in this revision

Viewing changes to dev.c

  • Committer: Suren A. Chilingaryan
  • Date: 2016-03-02 05:45:24 UTC
  • Revision ID: csa@suren.me-20160302054524-aqefho92o0ljk3eh
Test application for resolving user-space BAR addresses

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
#include <linux/init.h>
 
2
#include <linux/module.h>
 
3
#include <linux/device.h>
 
4
#include <linux/types.h>
 
5
#include <linux/cdev.h>
 
6
#include <linux/fs.h>
 
7
#include <linux/slab.h>
 
8
 
 
9
#include "mod.h"
 
10
#include "dev.h"
 
11
#include "debug.h"
 
12
 
 
13
#define sysfs_attr(name) do { \
 
14
        if (device_create_file(dev->dev, &dev_attr_##name) != 0) \
 
15
                                goto probe_device_create_fail; \
 
16
    } while (0)
 
17
 
 
18
 
 
19
int test_device_open(struct inode *inode, struct file *filp)
 
20
{
 
21
    test_dev_t *test;
 
22
 
 
23
    test = container_of( inode->i_cdev, test_dev_t, cdev);
 
24
    filp->private_data = test;
 
25
    
 
26
    mod_info("open\n");
 
27
 
 
28
    
 
29
    return 0;
 
30
}
 
31
 
 
32
int test_device_release(struct inode *inode, struct file *filp)
 
33
{
 
34
    test_dev_t *test = (test_dev_t*)filp->private_data;
 
35
 
 
36
    mod_info("close\n");
 
37
 
 
38
    return 0;
 
39
}
 
40
 
 
41
 
 
42
static struct file_operations test_fops = {
 
43
    .owner = THIS_MODULE,
 
44
//      .unlocked_ioctl = pcidriver_ioctl,
 
45
//      .mmap = pcidriver_mmap,
 
46
    .open = test_device_open,
 
47
    .release = test_device_release,
 
48
};
 
49
 
 
50
const struct file_operations *test_get_fops(void)
 
51
{
 
52
    return &test_fops;
 
53
}