Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 242155
b: refs/heads/master
c: 5c07134
h: refs/heads/master
i:
  242153: 45804be
  242151: f8e1daf
v: v3
  • Loading branch information
Andy Walls authored and Mauro Carvalho Chehab committed Mar 22, 2011
1 parent 02cb849 commit aa5ebb0
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 29 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: 9b28500a59d7ee5da5adb43bcb384391cac401c4
refs/heads/master: 5c07134fff9e6b1f9a3c75e62bbb827d1faa72eb
59 changes: 31 additions & 28 deletions trunk/drivers/staging/lirc/lirc_zilog.c
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,8 @@ struct IR_tx {
};

struct IR {
struct list_head list;

struct lirc_driver l;

struct mutex ir_lock;
Expand All @@ -99,9 +101,9 @@ struct IR {
struct IR_tx *tx;
};

/* Minor -> data mapping */
static struct mutex ir_devices_lock;
static struct IR *ir_devices[MAX_IRCTL_DEVICES];
/* IR transceiver instance object list */
static DEFINE_MUTEX(ir_devices_lock);
static LIST_HEAD(ir_devices_list);

/* Block size for IR transmitter */
#define TX_BLOCK_SIZE 99
Expand Down Expand Up @@ -1063,10 +1065,16 @@ static long ioctl(struct file *filep, unsigned int cmd, unsigned long arg)
/* ir_devices_lock must be held */
static struct IR *find_ir_device_by_minor(unsigned int minor)
{
if (minor >= MAX_IRCTL_DEVICES)
struct IR *ir;

if (list_empty(&ir_devices_list))
return NULL;

return ir_devices[minor];
list_for_each_entry(ir, &ir_devices_list, list)
if (ir->l.minor == minor)
return ir;

return NULL;
}

/*
Expand Down Expand Up @@ -1172,25 +1180,21 @@ static void destroy_rx_kthread(struct IR_rx *rx)
/* ir_devices_lock must be held */
static int add_ir_device(struct IR *ir)
{
int i;

for (i = 0; i < MAX_IRCTL_DEVICES; i++)
if (ir_devices[i] == NULL) {
ir_devices[i] = ir;
break;
}

return i == MAX_IRCTL_DEVICES ? -ENOMEM : i;
list_add_tail(&ir->list, &ir_devices_list);
return 0;
}

/* ir_devices_lock must be held */
static void del_ir_device(struct IR *ir)
{
int i;
struct IR *p;

if (list_empty(&ir_devices_list))
return;

for (i = 0; i < MAX_IRCTL_DEVICES; i++)
if (ir_devices[i] == ir) {
ir_devices[i] = NULL;
list_for_each_entry(p, &ir_devices_list, list)
if (p == ir) {
list_del(&p->list);
break;
}
}
Expand Down Expand Up @@ -1237,17 +1241,16 @@ static int ir_remove(struct i2c_client *client)
/* ir_devices_lock must be held */
static struct IR *find_ir_device_by_adapter(struct i2c_adapter *adapter)
{
int i;
struct IR *ir = NULL;
struct IR *ir;

for (i = 0; i < MAX_IRCTL_DEVICES; i++)
if (ir_devices[i] != NULL &&
ir_devices[i]->adapter == adapter) {
ir = ir_devices[i];
break;
}
if (list_empty(&ir_devices_list))
return NULL;

list_for_each_entry(ir, &ir_devices_list, list)
if (ir->adapter == adapter)
return ir;

return ir;
return NULL;
}

static int ir_probe(struct i2c_client *client, const struct i2c_device_id *id)
Expand Down Expand Up @@ -1284,6 +1287,7 @@ static int ir_probe(struct i2c_client *client, const struct i2c_device_id *id)
goto out_no_ir;
}
/* store for use in ir_probe() again, and open() later on */
INIT_LIST_HEAD(&ir->list);
ret = add_ir_device(ir);
if (ret)
goto out_free_ir;
Expand Down Expand Up @@ -1421,7 +1425,6 @@ static int __init zilog_init(void)
zilog_notify("Zilog/Hauppauge IR driver initializing\n");

mutex_init(&tx_data_lock);
mutex_init(&ir_devices_lock);

request_module("firmware_class");

Expand Down

0 comments on commit aa5ebb0

Please sign in to comment.