···1414 struct device *dev;1515 struct urb *ir_urb;1616 struct rc_dev *rcdev;1717- u8 ir_buf[8] __aligned(__alignof__(u64));1717+ __be64 ir_buf;1818 char phys[64];1919};2020···2929static void imon_ir_data(struct imon *imon)3030{3131 struct ir_raw_event rawir = {};3232- u64 d = be64_to_cpup((__be64 *)imon->ir_buf) >> 24;3232+ u64 data = be64_to_cpu(imon->ir_buf);3333+ u8 packet_no = data & 0xff;3334 int offset = 40;3435 int bit;35363636- dev_dbg(imon->dev, "data: %*ph", 8, imon->ir_buf);3737+ if (packet_no == 0xff)3838+ return;3939+4040+ dev_dbg(imon->dev, "data: %*ph", 8, &imon->ir_buf);4141+4242+ /*4343+ * Only the first 5 bytes contain IR data. Right shift so we move4444+ * the IR bits to the lower 40 bits.4545+ */4646+ data >>= 24;37473848 do {3939- bit = fls64(d & (BIT_ULL(offset) - 1));4949+ /*5050+ * Find highest set bit which is less or equal to offset5151+ *5252+ * offset is the bit above (base 0) where we start looking.5353+ *5454+ * data & (BIT_ULL(offset) - 1) masks off any unwanted bits,5555+ * so we have just bits less than offset.5656+ *5757+ * fls will tell us the highest bit set plus 1 (or 0 if no5858+ * bits are set).5959+ */6060+ bit = fls64(data & (BIT_ULL(offset) - 1));4061 if (bit < offset) {4162 dev_dbg(imon->dev, "pulse: %d bits", offset - bit);4263 rawir.pulse = true;···7049 offset = bit;7150 }72517373- bit = fls64(~d & (BIT_ULL(offset) - 1));5252+ /*5353+ * Find highest clear bit which is less than offset.5454+ *5555+ * Just invert the data and use same trick as above.5656+ */5757+ bit = fls64(~data & (BIT_ULL(offset) - 1));7458 dev_dbg(imon->dev, "space: %d bits", offset - bit);75597660 rawir.pulse = false;···8559 offset = bit;8660 } while (offset > 0);87618888- if (imon->ir_buf[7] == 0x0a) {6262+ if (packet_no == 0x0a) {8963 ir_raw_event_set_idle(imon->rcdev, true);9064 ir_raw_event_handle(imon->rcdev);9165 }···98729973 switch (urb->status) {10074 case 0:101101- if (imon->ir_buf[7] != 0xff)102102- imon_ir_data(imon);7575+ imon_ir_data(imon);10376 break;10477 case -ECONNRESET:10578 case -ENOENT:···154129 imon->dev = &intf->dev;155130 usb_fill_int_urb(imon->ir_urb, udev,156131 usb_rcvintpipe(udev, ir_ep->bEndpointAddress),157157- imon->ir_buf, sizeof(imon->ir_buf),132132+ &imon->ir_buf, sizeof(imon->ir_buf),158133 imon_ir_rx, imon, ir_ep->bInterval);159134160135 rcdev = devm_rc_allocate_device(&intf->dev, RC_DRIVER_IR_RAW);