ir_probe() makes a number of constant assignments into the lirc_driver object after copying in a template. Make better use of the template.
Showing the changes to drivers/staging/lirc (1 of 1 file). Show all
Unified · Split
| @@ -1116,13 +1116,6 @@ static int close(struct inode *node, struct file *filep) · 1115 unmodified lines | ||
| 1116 | 1116 | return 0; |
| 1117 | 1117 | } |
| 1118 | 1118 | |
| 1119 | −static struct lirc_driver lirc_template = { | |
| 1120 | − .name = "lirc_zilog", | |
| 1121 | − .set_use_inc = set_use_inc, | |
| 1122 | − .set_use_dec = set_use_dec, | |
| 1123 | − .owner = THIS_MODULE | |
| 1124 | −}; | |
| 1125 | − | |
| 1126 | 1119 | static int ir_remove(struct i2c_client *client); |
| 1127 | 1120 | static int ir_probe(struct i2c_client *client, const struct i2c_device_id *id); |
| 1128 | 1121 | |
| @@ -1161,6 +1154,19 @@ static const struct file_operations lirc_fops = { · 32 unmodified lines | ||
| 1161 | 1154 | .release = close |
| 1162 | 1155 | }; |
| 1163 | 1156 | |
| 1157 | +static struct lirc_driver lirc_template = { | |
| 1158 | + .name = "lirc_zilog", | |
| 1159 | + .minor = -1, | |
| 1160 | + .code_length = 13, | |
| 1161 | + .buffer_size = BUFLEN / 2, | |
| 1162 | + .sample_rate = 0, /* tell lirc_dev to not start its own kthread */ | |
| 1163 | + .chunk_size = 2, | |
| 1164 | + .set_use_inc = set_use_inc, | |
| 1165 | + .set_use_dec = set_use_dec, | |
| 1166 | + .fops = &lirc_fops, | |
| 1167 | + .owner = THIS_MODULE, | |
| 1168 | +}; | |
| 1169 | + | |
| 1164 | 1170 | static void destroy_rx_kthread(struct IR_rx *rx) |
| 1165 | 1171 | { |
| 1166 | 1172 | /* end up polling thread */ |
| @@ -1292,14 +1298,9 @@ static int ir_probe(struct i2c_client *client, const struct i2c_device_id *id) · 125 unmodified lines | ||
| 1292 | 1298 | /* set lirc_dev stuff */ |
| 1293 | 1299 | memcpy(&ir->l, &lirc_template, sizeof(struct lirc_driver)); |
| 1294 | 1300 | ir->l.minor = minor; /* module option */ |
| 1295 | − ir->l.code_length = 13; | |
| 1296 | − ir->l.chunk_size = 2; | |
| 1297 | − ir->l.buffer_size = BUFLEN / 2; | |
| 1298 | 1301 | ir->l.rbuf = &ir->rbuf; |
| 1299 | − ir->l.fops = &lirc_fops; | |
| 1300 | 1302 | ir->l.data = ir; |
| 1301 | 1303 | ir->l.dev = &adap->dev; |
| 1302 | − ir->l.sample_rate = 0; | |
| 1303 | 1304 | ret = lirc_buffer_init(ir->l.rbuf, |
| 1304 | 1305 | ir->l.chunk_size, ir->l.buffer_size); |
| 1305 | 1306 | if (ret) |
| @@ -1314,6 +1315,7 @@ static int ir_probe(struct i2c_client *client, const struct i2c_device_id *id) · 8 unmodified lines | ||
| 1314 | 1315 | goto out_free_xx; |
| 1315 | 1316 | } |
| 1316 | 1317 | |
| 1318 | + ir->l.features |= LIRC_CAN_SEND_PULSE; | |
| 1317 | 1319 | ir->tx->c = client; |
| 1318 | 1320 | ir->tx->need_boot = 1; |
| 1319 | 1321 | ir->tx->post_tx_ready_poll = |
| @@ -1326,6 +1328,7 @@ static int ir_probe(struct i2c_client *client, const struct i2c_device_id *id) · 6 unmodified lines | ||
| 1326 | 1328 | goto out_free_xx; |
| 1327 | 1329 | } |
| 1328 | 1330 | |
| 1331 | + ir->l.features |= LIRC_CAN_REC_LIRCCODE; | |
| 1329 | 1332 | ir->rx->c = client; |
| 1330 | 1333 | ir->rx->hdpvr_data_fmt = |
| 1331 | 1334 | (id->driver_data & ID_FLAG_HDPVR) ? true : false; |