Lines Matching +full:device +full:- +full:addr
1 // SPDX-License-Identifier: GPL-2.0+
3 // em28xx-i2c.c - driver for Empia EM2800/EM2820/2840 USB video capture devices
20 #include <media/v4l2-common.h>
23 /* ----------------------------------------------------------- */
35 dev_printk(KERN_DEBUG, &dev->intf->dev, \
41 * 35ms is the maximum time a SMBUS device could wait when
54 switch (dev->i2c_speed & 0x03) { in em28xx_i2c_timeout()
71 * send up to 4 bytes to the em2800 i2c device
73 static int em2800_i2c_send_bytes(struct em28xx *dev, u8 addr, u8 *buf, u16 len) in em2800_i2c_send_bytes() argument
80 return -EOPNOTSUPP; in em2800_i2c_send_bytes()
82 b2[5] = 0x80 + len - 1; in em2800_i2c_send_bytes()
83 b2[4] = addr; in em2800_i2c_send_bytes()
93 ret = dev->em28xx_write_regs(dev, 4 - len, &b2[4 - len], 2 + len); in em2800_i2c_send_bytes()
95 dev_warn(&dev->intf->dev, in em2800_i2c_send_bytes()
97 addr, ret); in em2800_i2c_send_bytes()
98 return (ret < 0) ? ret : -EIO; in em2800_i2c_send_bytes()
102 ret = dev->em28xx_read_reg(dev, 0x05); in em2800_i2c_send_bytes()
103 if (ret == 0x80 + len - 1) in em2800_i2c_send_bytes()
105 if (ret == 0x94 + len - 1) { in em2800_i2c_send_bytes()
107 return -ENXIO; in em2800_i2c_send_bytes()
110 dev_warn(&dev->intf->dev, in em2800_i2c_send_bytes()
117 dprintk(0, "write to i2c device at 0x%x timed out\n", addr); in em2800_i2c_send_bytes()
118 return -ETIMEDOUT; in em2800_i2c_send_bytes()
123 * read up to 4 bytes from the em2800 i2c device
125 static int em2800_i2c_recv_bytes(struct em28xx *dev, u8 addr, u8 *buf, u16 len) in em2800_i2c_recv_bytes() argument
133 return -EOPNOTSUPP; in em2800_i2c_recv_bytes()
136 buf2[1] = 0x84 + len - 1; in em2800_i2c_recv_bytes()
137 buf2[0] = addr; in em2800_i2c_recv_bytes()
138 ret = dev->em28xx_write_regs(dev, 0x04, buf2, 2); in em2800_i2c_recv_bytes()
140 dev_warn(&dev->intf->dev, in em2800_i2c_recv_bytes()
142 addr, ret); in em2800_i2c_recv_bytes()
143 return (ret < 0) ? ret : -EIO; in em2800_i2c_recv_bytes()
148 ret = dev->em28xx_read_reg(dev, 0x05); in em2800_i2c_recv_bytes()
149 if (ret == 0x84 + len - 1) in em2800_i2c_recv_bytes()
151 if (ret == 0x94 + len - 1) { in em2800_i2c_recv_bytes()
154 return -ENXIO; in em2800_i2c_recv_bytes()
157 dev_warn(&dev->intf->dev, in em2800_i2c_recv_bytes()
164 if (ret != 0x84 + len - 1) in em2800_i2c_recv_bytes()
165 dprintk(0, "read from i2c device at 0x%x timed out\n", addr); in em2800_i2c_recv_bytes()
168 ret = dev->em28xx_read_reg_req_len(dev, 0x00, 4 - len, buf2, len); in em2800_i2c_recv_bytes()
170 dev_warn(&dev->intf->dev, in em2800_i2c_recv_bytes()
171 …"reading from i2c device at 0x%x failed: couldn't get the received message from the bridge (error=… in em2800_i2c_recv_bytes()
172 addr, ret); in em2800_i2c_recv_bytes()
173 return (ret < 0) ? ret : -EIO; in em2800_i2c_recv_bytes()
176 buf[i] = buf2[len - 1 - i]; in em2800_i2c_recv_bytes()
183 * check if there is an i2c device at the supplied address
185 static int em2800_i2c_check_for_device(struct em28xx *dev, u8 addr) in em2800_i2c_check_for_device() argument
190 ret = em2800_i2c_recv_bytes(dev, addr, &buf, 1); in em2800_i2c_check_for_device()
193 return (ret < 0) ? ret : -EIO; in em2800_i2c_check_for_device()
199 static int em28xx_i2c_send_bytes(struct em28xx *dev, u16 addr, u8 *buf, in em28xx_i2c_send_bytes() argument
206 return -EOPNOTSUPP; in em28xx_i2c_send_bytes()
209 * Zero length reads always succeed, even if no device is connected in em28xx_i2c_send_bytes()
212 /* Write to i2c device */ in em28xx_i2c_send_bytes()
213 ret = dev->em28xx_write_regs_req(dev, stop ? 2 : 3, addr, buf, len); in em28xx_i2c_send_bytes()
216 dev_warn(&dev->intf->dev, in em28xx_i2c_send_bytes()
217 "writing to i2c device at 0x%x failed (error=%i)\n", in em28xx_i2c_send_bytes()
218 addr, ret); in em28xx_i2c_send_bytes()
221 dev_warn(&dev->intf->dev, in em28xx_i2c_send_bytes()
222 "%i bytes write to i2c device at 0x%x requested, but %i bytes written\n", in em28xx_i2c_send_bytes()
223 len, addr, ret); in em28xx_i2c_send_bytes()
224 return -EIO; in em28xx_i2c_send_bytes()
229 ret = dev->em28xx_read_reg(dev, 0x05); in em28xx_i2c_send_bytes()
233 dprintk(1, "I2C ACK error on writing to addr 0x%02x\n", in em28xx_i2c_send_bytes()
234 addr); in em28xx_i2c_send_bytes()
235 return -ENXIO; in em28xx_i2c_send_bytes()
238 dev_warn(&dev->intf->dev, in em28xx_i2c_send_bytes()
254 "write to i2c device at 0x%x timed out (status=%i)\n", in em28xx_i2c_send_bytes()
255 addr, ret); in em28xx_i2c_send_bytes()
256 return -ETIMEDOUT; in em28xx_i2c_send_bytes()
259 dev_warn(&dev->intf->dev, in em28xx_i2c_send_bytes()
260 "write to i2c device at 0x%x failed with unknown error (status=%i)\n", in em28xx_i2c_send_bytes()
261 addr, ret); in em28xx_i2c_send_bytes()
262 return -EIO; in em28xx_i2c_send_bytes()
267 * read a byte from the i2c device
269 static int em28xx_i2c_recv_bytes(struct em28xx *dev, u16 addr, u8 *buf, u16 len) in em28xx_i2c_recv_bytes() argument
274 return -EOPNOTSUPP; in em28xx_i2c_recv_bytes()
277 * Zero length reads always succeed, even if no device is connected in em28xx_i2c_recv_bytes()
280 /* Read data from i2c device */ in em28xx_i2c_recv_bytes()
281 ret = dev->em28xx_read_reg_req_len(dev, 2, addr, buf, len); in em28xx_i2c_recv_bytes()
283 dev_warn(&dev->intf->dev, in em28xx_i2c_recv_bytes()
284 "reading from i2c device at 0x%x failed (error=%i)\n", in em28xx_i2c_recv_bytes()
285 addr, ret); in em28xx_i2c_recv_bytes()
288 dev_dbg(&dev->intf->dev, in em28xx_i2c_recv_bytes()
289 "%i bytes read from i2c device at 0x%x requested, but %i bytes written\n", in em28xx_i2c_recv_bytes()
290 ret, addr, len); in em28xx_i2c_recv_bytes()
295 * specified slave address before AND no device is present at the in em28xx_i2c_recv_bytes()
297 * Anyway, the next check will fail with -ENXIO in this case, so avoid in em28xx_i2c_recv_bytes()
298 * spamming the system log on device probing and do nothing here. in em28xx_i2c_recv_bytes()
302 ret = dev->em28xx_read_reg(dev, 0x05); in em28xx_i2c_recv_bytes()
306 dev_warn(&dev->intf->dev, in em28xx_i2c_recv_bytes()
312 dprintk(1, "I2C ACK error on writing to addr 0x%02x\n", in em28xx_i2c_recv_bytes()
313 addr); in em28xx_i2c_recv_bytes()
314 return -ENXIO; in em28xx_i2c_recv_bytes()
320 "write to i2c device at 0x%x timed out (status=%i)\n", in em28xx_i2c_recv_bytes()
321 addr, ret); in em28xx_i2c_recv_bytes()
322 return -ETIMEDOUT; in em28xx_i2c_recv_bytes()
325 dev_warn(&dev->intf->dev, in em28xx_i2c_recv_bytes()
326 "read from i2c device at 0x%x failed with unknown error (status=%i)\n", in em28xx_i2c_recv_bytes()
327 addr, ret); in em28xx_i2c_recv_bytes()
328 return -EIO; in em28xx_i2c_recv_bytes()
335 static int em28xx_i2c_check_for_device(struct em28xx *dev, u16 addr) in em28xx_i2c_check_for_device() argument
340 ret = em28xx_i2c_recv_bytes(dev, addr, &buf, 1); in em28xx_i2c_check_for_device()
343 return (ret < 0) ? ret : -EIO; in em28xx_i2c_check_for_device()
348 * write bytes to the i2c device
350 static int em25xx_bus_B_send_bytes(struct em28xx *dev, u16 addr, u8 *buf, in em25xx_bus_B_send_bytes() argument
356 return -EOPNOTSUPP; in em25xx_bus_B_send_bytes()
359 * Zero length reads always succeed, even if no device is connected in em25xx_bus_B_send_bytes()
363 ret = dev->em28xx_write_regs_req(dev, 0x06, addr, buf, len); in em25xx_bus_B_send_bytes()
366 dev_warn(&dev->intf->dev, in em25xx_bus_B_send_bytes()
367 "writing to i2c device at 0x%x failed (error=%i)\n", in em25xx_bus_B_send_bytes()
368 addr, ret); in em25xx_bus_B_send_bytes()
372 dev_warn(&dev->intf->dev, in em25xx_bus_B_send_bytes()
373 "%i bytes write to i2c device at 0x%x requested, but %i bytes written\n", in em25xx_bus_B_send_bytes()
374 len, addr, ret); in em25xx_bus_B_send_bytes()
375 return -EIO; in em25xx_bus_B_send_bytes()
378 ret = dev->em28xx_read_reg_req(dev, 0x08, 0x0000); in em25xx_bus_B_send_bytes()
381 * 0x01 when the slave device is not present in em25xx_bus_B_send_bytes()
388 return -ENXIO; in em25xx_bus_B_send_bytes()
395 * slave device or even no second i2c bus provided) in em25xx_bus_B_send_bytes()
401 * read bytes from the i2c device
403 static int em25xx_bus_B_recv_bytes(struct em28xx *dev, u16 addr, u8 *buf, in em25xx_bus_B_recv_bytes() argument
409 return -EOPNOTSUPP; in em25xx_bus_B_recv_bytes()
412 * Zero length reads always succeed, even if no device is connected in em25xx_bus_B_recv_bytes()
416 ret = dev->em28xx_read_reg_req_len(dev, 0x06, addr, buf, len); in em25xx_bus_B_recv_bytes()
418 dev_warn(&dev->intf->dev, in em25xx_bus_B_recv_bytes()
419 "reading from i2c device at 0x%x failed (error=%i)\n", in em25xx_bus_B_recv_bytes()
420 addr, ret); in em25xx_bus_B_recv_bytes()
426 * specified slave address before AND no device is present at the in em25xx_bus_B_recv_bytes()
428 * Anyway, the next check will fail with -ENXIO in this case, so avoid in em25xx_bus_B_recv_bytes()
429 * spamming the system log on device probing and do nothing here. in em25xx_bus_B_recv_bytes()
433 ret = dev->em28xx_read_reg_req(dev, 0x08, 0x0000); in em25xx_bus_B_recv_bytes()
436 * 0x01 when the slave device is not present in em25xx_bus_B_recv_bytes()
443 return -ENXIO; in em25xx_bus_B_recv_bytes()
450 * slave device or even no second i2c bus provided) in em25xx_bus_B_recv_bytes()
456 * check if there is a i2c device at the supplied address
458 static int em25xx_bus_B_check_for_device(struct em28xx *dev, u16 addr) in em25xx_bus_B_check_for_device() argument
463 ret = em25xx_bus_B_recv_bytes(dev, addr, &buf, 1); in em25xx_bus_B_check_for_device()
470 * it seems to succeed ALWAYS ! (even if no device connected) in em25xx_bus_B_check_for_device()
474 static inline int i2c_check_for_device(struct em28xx_i2c_bus *i2c_bus, u16 addr) in i2c_check_for_device() argument
476 struct em28xx *dev = i2c_bus->dev; in i2c_check_for_device()
477 int rc = -EOPNOTSUPP; in i2c_check_for_device()
479 if (i2c_bus->algo_type == EM28XX_I2C_ALGO_EM28XX) in i2c_check_for_device()
480 rc = em28xx_i2c_check_for_device(dev, addr); in i2c_check_for_device()
481 else if (i2c_bus->algo_type == EM28XX_I2C_ALGO_EM2800) in i2c_check_for_device()
482 rc = em2800_i2c_check_for_device(dev, addr); in i2c_check_for_device()
483 else if (i2c_bus->algo_type == EM28XX_I2C_ALGO_EM25XX_BUS_B) in i2c_check_for_device()
484 rc = em25xx_bus_B_check_for_device(dev, addr); in i2c_check_for_device()
491 struct em28xx *dev = i2c_bus->dev; in i2c_recv_bytes()
492 u16 addr = msg.addr << 1; in i2c_recv_bytes() local
493 int rc = -EOPNOTSUPP; in i2c_recv_bytes()
495 if (i2c_bus->algo_type == EM28XX_I2C_ALGO_EM28XX) in i2c_recv_bytes()
496 rc = em28xx_i2c_recv_bytes(dev, addr, msg.buf, msg.len); in i2c_recv_bytes()
497 else if (i2c_bus->algo_type == EM28XX_I2C_ALGO_EM2800) in i2c_recv_bytes()
498 rc = em2800_i2c_recv_bytes(dev, addr, msg.buf, msg.len); in i2c_recv_bytes()
499 else if (i2c_bus->algo_type == EM28XX_I2C_ALGO_EM25XX_BUS_B) in i2c_recv_bytes()
500 rc = em25xx_bus_B_recv_bytes(dev, addr, msg.buf, msg.len); in i2c_recv_bytes()
507 struct em28xx *dev = i2c_bus->dev; in i2c_send_bytes()
508 u16 addr = msg.addr << 1; in i2c_send_bytes() local
509 int rc = -EOPNOTSUPP; in i2c_send_bytes()
511 if (i2c_bus->algo_type == EM28XX_I2C_ALGO_EM28XX) in i2c_send_bytes()
512 rc = em28xx_i2c_send_bytes(dev, addr, msg.buf, msg.len, stop); in i2c_send_bytes()
513 else if (i2c_bus->algo_type == EM28XX_I2C_ALGO_EM2800) in i2c_send_bytes()
514 rc = em2800_i2c_send_bytes(dev, addr, msg.buf, msg.len); in i2c_send_bytes()
515 else if (i2c_bus->algo_type == EM28XX_I2C_ALGO_EM25XX_BUS_B) in i2c_send_bytes()
516 rc = em25xx_bus_B_send_bytes(dev, addr, msg.buf, msg.len); in i2c_send_bytes()
527 struct em28xx_i2c_bus *i2c_bus = i2c_adap->algo_data; in em28xx_i2c_xfer()
528 struct em28xx *dev = i2c_bus->dev; in em28xx_i2c_xfer()
529 unsigned int bus = i2c_bus->bus; in em28xx_i2c_xfer()
530 int addr, rc, i; in em28xx_i2c_xfer() local
534 * prevent i2c xfer attempts after device is disconnected in em28xx_i2c_xfer()
538 if (dev->disconnected) in em28xx_i2c_xfer()
539 return -ENODEV; in em28xx_i2c_xfer()
541 if (!rt_mutex_trylock(&dev->i2c_bus_lock)) in em28xx_i2c_xfer()
542 return -EAGAIN; in em28xx_i2c_xfer()
545 if (bus != dev->cur_i2c_bus && in em28xx_i2c_xfer()
546 i2c_bus->algo_type == EM28XX_I2C_ALGO_EM28XX) { in em28xx_i2c_xfer()
553 dev->cur_i2c_bus = bus; in em28xx_i2c_xfer()
557 addr = msgs[i].addr << 1; in em28xx_i2c_xfer()
560 * no len: check only for device presence in em28xx_i2c_xfer()
561 * This code is only called during device probe. in em28xx_i2c_xfer()
563 rc = i2c_check_for_device(i2c_bus, addr); in em28xx_i2c_xfer()
565 if (rc == -ENXIO) in em28xx_i2c_xfer()
566 rc = -ENODEV; in em28xx_i2c_xfer()
572 rc = i2c_send_bytes(i2c_bus, msgs[i], i == num - 1); in em28xx_i2c_xfer()
578 dprintk(2, "%s %s addr=%02x len=%d: %*ph\n", in em28xx_i2c_xfer()
580 i == num - 1 ? "stop" : "nonstop", in em28xx_i2c_xfer()
581 addr, msgs[i].len, in em28xx_i2c_xfer()
585 rt_mutex_unlock(&dev->i2c_bus_lock); in em28xx_i2c_xfer()
589 dprintk(2, "%s %s addr=%02x len=%d: %sERROR: %i\n", in em28xx_i2c_xfer()
591 i == num - 1 ? "stop" : "nonstop", in em28xx_i2c_xfer()
592 addr, msgs[i].len, in em28xx_i2c_xfer()
593 (rc == -ENODEV) ? "no device " : "", in em28xx_i2c_xfer()
596 rt_mutex_unlock(&dev->i2c_bus_lock); in em28xx_i2c_xfer()
615 len = -1; in em28xx_hash_mem()
621 if ((len & (32 / 8 - 1)) == 0) in em28xx_hash_mem()
625 return (hash >> (32 - bits)) & 0xffffffffUL; in em28xx_hash_mem()
632 static int em28xx_i2c_read_block(struct em28xx *dev, unsigned int bus, u16 addr, in em28xx_i2c_read_block() argument
639 if (addr + remain > (addr_w16 * 0xff00 + 0xff + 1)) in em28xx_i2c_read_block()
640 return -EINVAL; in em28xx_i2c_read_block()
642 buf[0] = addr >> 8; in em28xx_i2c_read_block()
643 buf[1] = addr & 0xff; in em28xx_i2c_read_block()
644 ret = i2c_master_send(&dev->i2c_client[bus], in em28xx_i2c_read_block()
649 if (dev->board.is_em2800) in em28xx_i2c_read_block()
659 ret = i2c_master_recv(&dev->i2c_client[bus], data, rsize); in em28xx_i2c_read_block()
663 remain -= rsize; in em28xx_i2c_read_block()
676 * calculation and returned device dataset. Simplifies the code a lot, in em28xx_i2c_eeprom()
688 dev->i2c_client[bus].addr = 0xa0 >> 1; in em28xx_i2c_eeprom()
691 err = i2c_master_recv(&dev->i2c_client[bus], &buf, 0); in em28xx_i2c_eeprom()
693 dev_info(&dev->intf->dev, "board has no eeprom\n"); in em28xx_i2c_eeprom()
694 return -ENODEV; in em28xx_i2c_eeprom()
699 return -ENOMEM; in em28xx_i2c_eeprom()
703 dev->eeprom_addrwidth_16bit, in em28xx_i2c_eeprom()
706 dev_err(&dev->intf->dev, in em28xx_i2c_eeprom()
716 if (dev->eeprom_addrwidth_16bit) in em28xx_i2c_eeprom()
717 dev_info(&dev->intf->dev, in em28xx_i2c_eeprom()
721 if (dev->eeprom_addrwidth_16bit && in em28xx_i2c_eeprom()
723 /* new eeprom format; size 4-64kb */ in em28xx_i2c_eeprom()
727 dev->hash = em28xx_hash_mem(data, len, 32); in em28xx_i2c_eeprom()
730 dev_info(&dev->intf->dev, in em28xx_i2c_eeprom()
732 data, dev->hash); in em28xx_i2c_eeprom()
733 dev_info(&dev->intf->dev, in em28xx_i2c_eeprom()
735 dev_info(&dev->intf->dev, in em28xx_i2c_eeprom()
742 * [2] USB device speed: 1 = force Full Speed; 0 = auto detect in em28xx_i2c_eeprom()
743 * [4] 1 = force fast mode and no suspend for device testing in em28xx_i2c_eeprom()
744 * [5:7] USB PHY tuning registers; determined by device in em28xx_i2c_eeprom()
755 dev_err(&dev->intf->dev, in em28xx_i2c_eeprom()
774 dev_err(&dev->intf->dev, in em28xx_i2c_eeprom()
784 dev_info(&dev->intf->dev, in em28xx_i2c_eeprom()
795 } else if (!dev->eeprom_addrwidth_16bit && in em28xx_i2c_eeprom()
798 dev->hash = em28xx_hash_mem(data, len, 32); in em28xx_i2c_eeprom()
799 dev_info(&dev->intf->dev, in em28xx_i2c_eeprom()
801 data, dev->hash); in em28xx_i2c_eeprom()
802 dev_info(&dev->intf->dev, in em28xx_i2c_eeprom()
805 dev_info(&dev->intf->dev, in em28xx_i2c_eeprom()
807 err = -ENODEV; in em28xx_i2c_eeprom()
815 switch (le16_to_cpu(dev_config->chip_conf) >> 4 & 0x3) { in em28xx_i2c_eeprom()
817 dev_info(&dev->intf->dev, "\tNo audio on board.\n"); in em28xx_i2c_eeprom()
820 dev_info(&dev->intf->dev, "\tAC97 audio (5 sample rates)\n"); in em28xx_i2c_eeprom()
823 if (dev->chip_id < CHIP_ID_EM2860) in em28xx_i2c_eeprom()
824 dev_info(&dev->intf->dev, in em28xx_i2c_eeprom()
827 dev_info(&dev->intf->dev, in em28xx_i2c_eeprom()
831 if (dev->chip_id < CHIP_ID_EM2860) in em28xx_i2c_eeprom()
832 dev_info(&dev->intf->dev, in em28xx_i2c_eeprom()
835 dev_info(&dev->intf->dev, in em28xx_i2c_eeprom()
840 if (le16_to_cpu(dev_config->chip_conf) & 1 << 3) in em28xx_i2c_eeprom()
841 dev_info(&dev->intf->dev, "\tUSB Remote wakeup capable\n"); in em28xx_i2c_eeprom()
843 if (le16_to_cpu(dev_config->chip_conf) & 1 << 2) in em28xx_i2c_eeprom()
844 dev_info(&dev->intf->dev, "\tUSB Self power capable\n"); in em28xx_i2c_eeprom()
846 switch (le16_to_cpu(dev_config->chip_conf) & 0x3) { in em28xx_i2c_eeprom()
848 dev_info(&dev->intf->dev, "\t500mA max power\n"); in em28xx_i2c_eeprom()
851 dev_info(&dev->intf->dev, "\t400mA max power\n"); in em28xx_i2c_eeprom()
854 dev_info(&dev->intf->dev, "\t300mA max power\n"); in em28xx_i2c_eeprom()
857 dev_info(&dev->intf->dev, "\t200mA max power\n"); in em28xx_i2c_eeprom()
860 dev_info(&dev->intf->dev, in em28xx_i2c_eeprom()
862 dev_config->string_idx_table, in em28xx_i2c_eeprom()
863 le16_to_cpu(dev_config->string1), in em28xx_i2c_eeprom()
864 le16_to_cpu(dev_config->string2), in em28xx_i2c_eeprom()
865 le16_to_cpu(dev_config->string3)); in em28xx_i2c_eeprom()
874 /* ----------------------------------------------------------- */
881 struct em28xx_i2c_bus *i2c_bus = i2c_adap->algo_data; in functionality()
883 if (i2c_bus->algo_type == EM28XX_I2C_ALGO_EM28XX || in functionality()
884 i2c_bus->algo_type == EM28XX_I2C_ALGO_EM25XX_BUS_B) { in functionality()
886 } else if (i2c_bus->algo_type == EM28XX_I2C_ALGO_EM2800) { in functionality()
910 /* ----------------------------------------------------------- */
949 dev->i2c_client[bus].addr = i; in em28xx_do_i2c_scan()
950 rc = i2c_master_recv(&dev->i2c_client[bus], &buf, 0); in em28xx_do_i2c_scan()
954 dev_info(&dev->intf->dev, in em28xx_do_i2c_scan()
955 "found i2c device @ 0x%x on bus %d [%s]\n", in em28xx_do_i2c_scan()
959 if (bus == dev->def_i2c_bus) in em28xx_do_i2c_scan()
960 dev->i2c_hash = em28xx_hash_mem(i2c_devicelist, in em28xx_do_i2c_scan()
973 if (WARN_ON(!dev->em28xx_write_regs || !dev->em28xx_read_reg || in em28xx_i2c_register()
974 !dev->em28xx_write_regs_req || !dev->em28xx_read_reg_req)) in em28xx_i2c_register()
975 return -ENODEV; in em28xx_i2c_register()
978 return -ENODEV; in em28xx_i2c_register()
980 dev->i2c_adap[bus] = em28xx_adap_template; in em28xx_i2c_register()
981 dev->i2c_adap[bus].dev.parent = &dev->intf->dev; in em28xx_i2c_register()
982 strscpy(dev->i2c_adap[bus].name, dev_name(&dev->intf->dev), in em28xx_i2c_register()
983 sizeof(dev->i2c_adap[bus].name)); in em28xx_i2c_register()
985 dev->i2c_bus[bus].bus = bus; in em28xx_i2c_register()
986 dev->i2c_bus[bus].algo_type = algo_type; in em28xx_i2c_register()
987 dev->i2c_bus[bus].dev = dev; in em28xx_i2c_register()
988 dev->i2c_adap[bus].algo_data = &dev->i2c_bus[bus]; in em28xx_i2c_register()
990 retval = i2c_add_adapter(&dev->i2c_adap[bus]); in em28xx_i2c_register()
992 dev_err(&dev->intf->dev, in em28xx_i2c_register()
998 dev->i2c_client[bus] = em28xx_client_template; in em28xx_i2c_register()
999 dev->i2c_client[bus].adapter = &dev->i2c_adap[bus]; in em28xx_i2c_register()
1004 &dev->eedata, &dev->eedata_len); in em28xx_i2c_register()
1005 if (retval < 0 && retval != -ENODEV) { in em28xx_i2c_register()
1006 dev_err(&dev->intf->dev, in em28xx_i2c_register()
1025 return -ENODEV; in em28xx_i2c_unregister()
1027 i2c_del_adapter(&dev->i2c_adap[bus]); in em28xx_i2c_unregister()