rain 65 drivers/media/usb/rainshadow-cec/rainshadow-cec.c static void rain_process_msg(struct rain *rain) rain 68 drivers/media/usb/rainshadow-cec/rainshadow-cec.c const char *cmd = rain->cmd + 3; rain 88 drivers/media/usb/rainshadow-cec/rainshadow-cec.c if (rain->cmd[0] == 'R') { rain 90 drivers/media/usb/rainshadow-cec/rainshadow-cec.c cec_received_msg(rain->adap, &msg); rain 96 drivers/media/usb/rainshadow-cec/rainshadow-cec.c cec_transmit_attempt_done(rain->adap, CEC_TX_STATUS_OK); rain 99 drivers/media/usb/rainshadow-cec/rainshadow-cec.c cec_transmit_attempt_done(rain->adap, CEC_TX_STATUS_NACK); rain 102 drivers/media/usb/rainshadow-cec/rainshadow-cec.c cec_transmit_attempt_done(rain->adap, CEC_TX_STATUS_LOW_DRIVE); rain 109 drivers/media/usb/rainshadow-cec/rainshadow-cec.c struct rain *rain = rain 110 drivers/media/usb/rainshadow-cec/rainshadow-cec.c container_of(work, struct rain, work); rain 116 drivers/media/usb/rainshadow-cec/rainshadow-cec.c spin_lock_irqsave(&rain->buf_lock, flags); rain 117 drivers/media/usb/rainshadow-cec/rainshadow-cec.c if (!rain->buf_len) { rain 118 drivers/media/usb/rainshadow-cec/rainshadow-cec.c spin_unlock_irqrestore(&rain->buf_lock, flags); rain 122 drivers/media/usb/rainshadow-cec/rainshadow-cec.c data = rain->buf[rain->buf_rd_idx]; rain 123 drivers/media/usb/rainshadow-cec/rainshadow-cec.c rain->buf_len--; rain 124 drivers/media/usb/rainshadow-cec/rainshadow-cec.c rain->buf_rd_idx = (rain->buf_rd_idx + 1) & 0xff; rain 126 drivers/media/usb/rainshadow-cec/rainshadow-cec.c spin_unlock_irqrestore(&rain->buf_lock, flags); rain 128 drivers/media/usb/rainshadow-cec/rainshadow-cec.c if (!rain->cmd_started && data != '?') rain 133 drivers/media/usb/rainshadow-cec/rainshadow-cec.c rain->cmd[rain->cmd_idx] = '\0'; rain 134 drivers/media/usb/rainshadow-cec/rainshadow-cec.c dev_dbg(rain->dev, "received: %s\n", rain->cmd); rain 135 drivers/media/usb/rainshadow-cec/rainshadow-cec.c if (!memcmp(rain->cmd, "REC", 3) || rain 136 drivers/media/usb/rainshadow-cec/rainshadow-cec.c !memcmp(rain->cmd, "STA", 3)) { rain 137 drivers/media/usb/rainshadow-cec/rainshadow-cec.c rain_process_msg(rain); rain 139 drivers/media/usb/rainshadow-cec/rainshadow-cec.c strscpy(rain->cmd_reply, rain->cmd, rain 140 drivers/media/usb/rainshadow-cec/rainshadow-cec.c sizeof(rain->cmd_reply)); rain 141 drivers/media/usb/rainshadow-cec/rainshadow-cec.c complete(&rain->cmd_done); rain 143 drivers/media/usb/rainshadow-cec/rainshadow-cec.c rain->cmd_idx = 0; rain 144 drivers/media/usb/rainshadow-cec/rainshadow-cec.c rain->cmd_started = false; rain 148 drivers/media/usb/rainshadow-cec/rainshadow-cec.c rain->cmd_idx = 0; rain 149 drivers/media/usb/rainshadow-cec/rainshadow-cec.c rain->cmd_started = false; rain 153 drivers/media/usb/rainshadow-cec/rainshadow-cec.c rain->cmd_idx = 0; rain 154 drivers/media/usb/rainshadow-cec/rainshadow-cec.c rain->cmd_started = true; rain 158 drivers/media/usb/rainshadow-cec/rainshadow-cec.c if (rain->cmd_idx >= DATA_SIZE - 1) { rain 159 drivers/media/usb/rainshadow-cec/rainshadow-cec.c dev_dbg(rain->dev, rain 160 drivers/media/usb/rainshadow-cec/rainshadow-cec.c "throwing away %d bytes of garbage\n", rain->cmd_idx); rain 161 drivers/media/usb/rainshadow-cec/rainshadow-cec.c rain->cmd_idx = 0; rain 163 drivers/media/usb/rainshadow-cec/rainshadow-cec.c rain->cmd[rain->cmd_idx++] = data; rain 172 drivers/media/usb/rainshadow-cec/rainshadow-cec.c struct rain *rain = serio_get_drvdata(serio); rain 174 drivers/media/usb/rainshadow-cec/rainshadow-cec.c if (rain->buf_len == DATA_SIZE) { rain 175 drivers/media/usb/rainshadow-cec/rainshadow-cec.c dev_warn_once(rain->dev, "buffer overflow\n"); rain 178 drivers/media/usb/rainshadow-cec/rainshadow-cec.c spin_lock(&rain->buf_lock); rain 179 drivers/media/usb/rainshadow-cec/rainshadow-cec.c rain->buf_len++; rain 180 drivers/media/usb/rainshadow-cec/rainshadow-cec.c rain->buf[rain->buf_wr_idx] = data; rain 181 drivers/media/usb/rainshadow-cec/rainshadow-cec.c rain->buf_wr_idx = (rain->buf_wr_idx + 1) & 0xff; rain 182 drivers/media/usb/rainshadow-cec/rainshadow-cec.c spin_unlock(&rain->buf_lock); rain 183 drivers/media/usb/rainshadow-cec/rainshadow-cec.c schedule_work(&rain->work); rain 189 drivers/media/usb/rainshadow-cec/rainshadow-cec.c struct rain *rain = serio_get_drvdata(serio); rain 191 drivers/media/usb/rainshadow-cec/rainshadow-cec.c cancel_work_sync(&rain->work); rain 192 drivers/media/usb/rainshadow-cec/rainshadow-cec.c cec_unregister_adapter(rain->adap); rain 196 drivers/media/usb/rainshadow-cec/rainshadow-cec.c kfree(rain); rain 199 drivers/media/usb/rainshadow-cec/rainshadow-cec.c static int rain_send(struct rain *rain, const char *command) rain 201 drivers/media/usb/rainshadow-cec/rainshadow-cec.c int err = serio_write(rain->serio, '!'); rain 203 drivers/media/usb/rainshadow-cec/rainshadow-cec.c dev_dbg(rain->dev, "send: %s\n", command); rain 205 drivers/media/usb/rainshadow-cec/rainshadow-cec.c err = serio_write(rain->serio, *command++); rain 207 drivers/media/usb/rainshadow-cec/rainshadow-cec.c err = serio_write(rain->serio, '~'); rain 212 drivers/media/usb/rainshadow-cec/rainshadow-cec.c static int rain_send_and_wait(struct rain *rain, rain 217 drivers/media/usb/rainshadow-cec/rainshadow-cec.c init_completion(&rain->cmd_done); rain 219 drivers/media/usb/rainshadow-cec/rainshadow-cec.c mutex_lock(&rain->write_lock); rain 220 drivers/media/usb/rainshadow-cec/rainshadow-cec.c err = rain_send(rain, cmd); rain 224 drivers/media/usb/rainshadow-cec/rainshadow-cec.c if (!wait_for_completion_timeout(&rain->cmd_done, HZ)) { rain 228 drivers/media/usb/rainshadow-cec/rainshadow-cec.c if (reply && strncmp(rain->cmd_reply, reply, strlen(reply))) { rain 229 drivers/media/usb/rainshadow-cec/rainshadow-cec.c dev_dbg(rain->dev, rain 231 drivers/media/usb/rainshadow-cec/rainshadow-cec.c cmd, rain->cmd_reply, reply); rain 235 drivers/media/usb/rainshadow-cec/rainshadow-cec.c mutex_unlock(&rain->write_lock); rain 239 drivers/media/usb/rainshadow-cec/rainshadow-cec.c static int rain_setup(struct rain *rain, struct serio *serio, rain 244 drivers/media/usb/rainshadow-cec/rainshadow-cec.c err = rain_send_and_wait(rain, "R", "REV"); rain 247 drivers/media/usb/rainshadow-cec/rainshadow-cec.c dev_info(rain->dev, "Firmware version %s\n", rain->cmd_reply + 4); rain 249 drivers/media/usb/rainshadow-cec/rainshadow-cec.c err = rain_send_and_wait(rain, "Q 1", "QTY"); rain 252 drivers/media/usb/rainshadow-cec/rainshadow-cec.c err = rain_send_and_wait(rain, "c0000", "CFG"); rain 255 drivers/media/usb/rainshadow-cec/rainshadow-cec.c return rain_send_and_wait(rain, "A F 0000", "ADR"); rain 265 drivers/media/usb/rainshadow-cec/rainshadow-cec.c struct rain *rain = cec_get_drvdata(adap); rain 271 drivers/media/usb/rainshadow-cec/rainshadow-cec.c return rain_send_and_wait(rain, cmd, "ADR"); rain 277 drivers/media/usb/rainshadow-cec/rainshadow-cec.c struct rain *rain = cec_get_drvdata(adap); rain 294 drivers/media/usb/rainshadow-cec/rainshadow-cec.c mutex_lock(&rain->write_lock); rain 295 drivers/media/usb/rainshadow-cec/rainshadow-cec.c err = rain_send(rain, cmd); rain 296 drivers/media/usb/rainshadow-cec/rainshadow-cec.c mutex_unlock(&rain->write_lock); rain 309 drivers/media/usb/rainshadow-cec/rainshadow-cec.c struct rain *rain; rain 314 drivers/media/usb/rainshadow-cec/rainshadow-cec.c rain = kzalloc(sizeof(*rain), GFP_KERNEL); rain 316 drivers/media/usb/rainshadow-cec/rainshadow-cec.c if (!rain) rain 319 drivers/media/usb/rainshadow-cec/rainshadow-cec.c rain->serio = serio; rain 320 drivers/media/usb/rainshadow-cec/rainshadow-cec.c rain->adap = cec_allocate_adapter(&rain_cec_adap_ops, rain, rain 322 drivers/media/usb/rainshadow-cec/rainshadow-cec.c err = PTR_ERR_OR_ZERO(rain->adap); rain 326 drivers/media/usb/rainshadow-cec/rainshadow-cec.c rain->dev = &serio->dev; rain 327 drivers/media/usb/rainshadow-cec/rainshadow-cec.c serio_set_drvdata(serio, rain); rain 328 drivers/media/usb/rainshadow-cec/rainshadow-cec.c INIT_WORK(&rain->work, rain_irq_work_handler); rain 329 drivers/media/usb/rainshadow-cec/rainshadow-cec.c mutex_init(&rain->write_lock); rain 330 drivers/media/usb/rainshadow-cec/rainshadow-cec.c spin_lock_init(&rain->buf_lock); rain 336 drivers/media/usb/rainshadow-cec/rainshadow-cec.c err = rain_setup(rain, serio, &log_addrs, &pa); rain 340 drivers/media/usb/rainshadow-cec/rainshadow-cec.c err = cec_register_adapter(rain->adap, &serio->dev); rain 344 drivers/media/usb/rainshadow-cec/rainshadow-cec.c rain->dev = &rain->adap->devnode.dev; rain 350 drivers/media/usb/rainshadow-cec/rainshadow-cec.c cec_delete_adapter(rain->adap); rain 353 drivers/media/usb/rainshadow-cec/rainshadow-cec.c kfree(rain);