Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 206780
b: refs/heads/master
c: 55e77c0
h: refs/heads/master
v: v3
  • Loading branch information
Stefan Richter committed Jul 27, 2010
1 parent dea5c51 commit 65f02b8
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 47 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: 685c3f80b6d88478a6428676f9daab59faf3cd4b
refs/heads/master: 55e77c06c6017a70630cf599770369b8ba07c841
75 changes: 29 additions & 46 deletions trunk/drivers/firewire/nosy.c
Original file line number Diff line number Diff line change
Expand Up @@ -260,68 +260,44 @@ set_phy_reg(struct pcilynx *lynx, int addr, int val)
return 0;
}

static void
nosy_start_snoop(struct client *client)
{
spin_lock_irq(&client->lynx->client_list_lock);
list_add_tail(&client->link, &client->lynx->client_list);
spin_unlock_irq(&client->lynx->client_list_lock);
}

static void
nosy_stop_snoop(struct client *client)
{
spin_lock_irq(&client->lynx->client_list_lock);
list_del_init(&client->link);
spin_unlock_irq(&client->lynx->client_list_lock);
}

static struct client *
nosy_add_client(struct pcilynx *lynx)
static int
nosy_open(struct inode *inode, struct file *file)
{
int minor = iminor(inode);
struct client *client;

if (minor > MAX_MINORS || minors[minor] == NULL)
return -ENODEV;

client = kmalloc(sizeof *client, GFP_KERNEL);
if (client == NULL)
return -ENOMEM;

client->tcode_mask = ~0;
client->lynx = lynx;
client->lynx = minors[minor];
INIT_LIST_HEAD(&client->link);

if (packet_buffer_init(&client->buffer, 128 * 1024) < 0) {
kfree(client);
debug("Failed to allocate packet buffer\n");
return NULL;
return -ENOMEM;
}

return client;
}
file->private_data = client;

static void
nosy_remove_client(struct client *client)
{
nosy_stop_snoop(client);
packet_buffer_destroy(&client->buffer);
kfree(client);
return 0;
}

static int
nosy_open(struct inode *inode, struct file *file)
nosy_release(struct inode *inode, struct file *file)
{
int minor = iminor(inode);

if (minor > MAX_MINORS || minors[minor] == NULL)
return -ENODEV;
struct client *client = file->private_data;

file->private_data = nosy_add_client(minors[minor]);
if (file->private_data == NULL)
return -ENOMEM;
else
return 0;
}
spin_lock_irq(&client->lynx->client_list_lock);
list_del_init(&client->link);
spin_unlock_irq(&client->lynx->client_list_lock);

static int
nosy_release(struct inode *inode, struct file *file)
{
nosy_remove_client(file->private_data);
packet_buffer_destroy(&client->buffer);
kfree(client);

return 0;
}
Expand Down Expand Up @@ -367,17 +343,24 @@ nosy_ioctl(struct file *file, unsigned int cmd, unsigned long arg)
return 0;

case NOSY_IOC_START:
nosy_start_snoop(client);
spin_lock_irq(client_list_lock);
list_add_tail(&client->link, &client->lynx->client_list);
spin_unlock_irq(client_list_lock);

return 0;

case NOSY_IOC_STOP:
nosy_stop_snoop(client);
spin_lock_irq(client_list_lock);
list_del_init(&client->link);
spin_unlock_irq(client_list_lock);

return 0;

case NOSY_IOC_FILTER:
spin_lock_irq(client_list_lock);
client->tcode_mask = arg;
spin_unlock_irq(client_list_lock);

return 0;

default:
Expand Down

0 comments on commit 65f02b8

Please sign in to comment.