Commit 29aab5fc authored by Vikram Narayanan's avatar Vikram Narayanan

foobar: Add more test cases

parent 0368827b
......@@ -22,6 +22,17 @@ static irqreturn_t foobar_irq_handler(int irq, void *data)
return IRQ_HANDLED;
}
void foobar_update_fields(struct foobar_device *dev)
{
dev->f1 = 0xadd;
dev->f2 = 0xbad;
dev->f3 = 0xdad;
foobar_bar(dev);
foobar_bar2(dev);
}
static int dummy_dev_init(struct foobar_device *dev)
{
int ret;
......@@ -41,6 +52,8 @@ static int dummy_dev_init(struct foobar_device *dev)
return -EINVAL;
}
foobar_update_fields(dev);
return 0;
}
......
......@@ -147,3 +147,30 @@ int do_foobar_async_send(int dev_id, unsigned tag, unsigned data) {
}
}
}
void foobar_bar(struct foobar_device *dev) {
unsigned long fields = 0;
fields |= dev->f1;
printk("%s, fields %lx\n", __func__, fields);
}
EXPORT_SYMBOL(foobar_bar);
void foobar_bar2(struct foobar_device *dev) {
unsigned long fields = 0;
fields |= dev->f3;
printk("%s, fields %lx\n", __func__, fields);
}
EXPORT_SYMBOL(foobar_bar2);
/* Called from a syscall or irq context */
void foobar_baz(int dev_id, unsigned long field) {
struct foobar_device *dev;
list_for_each_entry(dev, &foobar_dev_list, dev_list) {
if (dev->id == dev_id) {
if (dev->f2) {
printk("%s, f2 active\n", __func__);
}
}
}
}
......@@ -66,6 +66,9 @@ struct foobar_device {
const struct foobar_device_ops *foobardev_ops;
struct list_head dev_list;
unsigned long f1;
unsigned long f2;
unsigned long f3;
};
int register_foobar(struct foobar_device *dev);
......@@ -75,6 +78,8 @@ void free_foobardev(struct foobar_device *dev);
void foobar_init_stats(struct foobar_device *dev);
int foobar_state_change(struct foobar_device *dev);
void foobar_notify(struct foobar_device *dev);
void foobar_bar(struct foobar_device *dev);
void foobar_bar2(struct foobar_device *dev);
static inline void *foobardev_priv(const struct foobar_device *dev)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment