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
29 #include "tuner-xc2028.h"
30 #include <media/v4l2-common.h>
33 /* ----------------------------------------------------------- */
45 dev_printk(KERN_DEBUG, &dev->intf->dev, \
51 * 35ms is the maximum time a SMBUS device could wait when
64 switch (dev->i2c_speed & 0x03) { in em28xx_i2c_timeout()
81 * send up to 4 bytes to the em2800 i2c device
83 static int em2800_i2c_send_bytes(struct em28xx *dev, u8 addr, u8 *buf, u16 len) in em2800_i2c_send_bytes() argument
90 return -EOPNOTSUPP; in em2800_i2c_send_bytes()
92 b2[5] = 0x80 + len - 1; in em2800_i2c_send_bytes()
93 b2[4] = addr; in em2800_i2c_send_bytes()
103 ret = dev->em28xx_write_regs(dev, 4 - len, &b2[4 - len], 2 + len); in em2800_i2c_send_bytes()
105 dev_warn(&dev->intf->dev, in em2800_i2c_send_bytes()
107 addr, ret); in em2800_i2c_send_bytes()
108 return (ret < 0) ? ret : -EIO; in em2800_i2c_send_bytes()
112 ret = dev->em28xx_read_reg(dev, 0x05); in em2800_i2c_send_bytes()
113 if (ret == 0x80 + len - 1) in em2800_i2c_send_bytes()
115 if (ret == 0x94 + len - 1) { in em2800_i2c_send_bytes()
117 return -ENXIO; in em2800_i2c_send_bytes()
120 dev_warn(&dev->intf->dev, in em2800_i2c_send_bytes()
127 dprintk(0, "write to i2c device at 0x%x timed out\n", addr); in em2800_i2c_send_bytes()
128 return -ETIMEDOUT; in em2800_i2c_send_bytes()
133 * read up to 4 bytes from the em2800 i2c device
135 static int em2800_i2c_recv_bytes(struct em28xx *dev, u8 addr, u8 *buf, u16 len) in em2800_i2c_recv_bytes() argument
143 return -EOPNOTSUPP; in em2800_i2c_recv_bytes()
146 buf2[1] = 0x84 + len - 1; in em2800_i2c_recv_bytes()
147 buf2[0] = addr; in em2800_i2c_recv_bytes()
148 ret = dev->em28xx_write_regs(dev, 0x04, buf2, 2); in em2800_i2c_recv_bytes()
150 dev_warn(&dev->intf->dev, in em2800_i2c_recv_bytes()
152 addr, ret); in em2800_i2c_recv_bytes()
153 return (ret < 0) ? ret : -EIO; in em2800_i2c_recv_bytes()
158 ret = dev->em28xx_read_reg(dev, 0x05); in em2800_i2c_recv_bytes()
159 if (ret == 0x84 + len - 1) in em2800_i2c_recv_bytes()
161 if (ret == 0x94 + len - 1) { in em2800_i2c_recv_bytes()
164 return -ENXIO; in em2800_i2c_recv_bytes()
167 dev_warn(&dev->intf->dev, in em2800_i2c_recv_bytes()
174 if (ret != 0x84 + len - 1) in em2800_i2c_recv_bytes()
175 dprintk(0, "read from i2c device at 0x%x timed out\n", addr); in em2800_i2c_recv_bytes()
178 ret = dev->em28xx_read_reg_req_len(dev, 0x00, 4 - len, buf2, len); in em2800_i2c_recv_bytes()
180 dev_warn(&dev->intf->dev, in em2800_i2c_recv_bytes()
181 …"reading from i2c device at 0x%x failed: couldn't get the received message from the bridge (error=… in em2800_i2c_recv_bytes()
182 addr, ret); in em2800_i2c_recv_bytes()
183 return (ret < 0) ? ret : -EIO; in em2800_i2c_recv_bytes()
186 buf[i] = buf2[len - 1 - i]; in em2800_i2c_recv_bytes()
193 * check if there is an i2c device at the supplied address
195 static int em2800_i2c_check_for_device(struct em28xx *dev, u8 addr) in em2800_i2c_check_for_device() argument
200 ret = em2800_i2c_recv_bytes(dev, addr, &buf, 1); in em2800_i2c_check_for_device()
203 return (ret < 0) ? ret : -EIO; in em2800_i2c_check_for_device()
209 static int em28xx_i2c_send_bytes(struct em28xx *dev, u16 addr, u8 *buf, in em28xx_i2c_send_bytes() argument
216 return -EOPNOTSUPP; in em28xx_i2c_send_bytes()
219 * Zero length reads always succeed, even if no device is connected in em28xx_i2c_send_bytes()
222 /* Write to i2c device */ in em28xx_i2c_send_bytes()
223 ret = dev->em28xx_write_regs_req(dev, stop ? 2 : 3, addr, buf, len); in em28xx_i2c_send_bytes()
226 dev_warn(&dev->intf->dev, in em28xx_i2c_send_bytes()
227 "writing to i2c device at 0x%x failed (error=%i)\n", in em28xx_i2c_send_bytes()
228 addr, ret); in em28xx_i2c_send_bytes()
231 dev_warn(&dev->intf->dev, in em28xx_i2c_send_bytes()
232 "%i bytes write to i2c device at 0x%x requested, but %i bytes written\n", in em28xx_i2c_send_bytes()
233 len, addr, ret); in em28xx_i2c_send_bytes()
234 return -EIO; in em28xx_i2c_send_bytes()
239 ret = dev->em28xx_read_reg(dev, 0x05); in em28xx_i2c_send_bytes()
243 dprintk(1, "I2C ACK error on writing to addr 0x%02x\n", in em28xx_i2c_send_bytes()
244 addr); in em28xx_i2c_send_bytes()
245 return -ENXIO; in em28xx_i2c_send_bytes()
248 dev_warn(&dev->intf->dev, in em28xx_i2c_send_bytes()
264 "write to i2c device at 0x%x timed out (status=%i)\n", in em28xx_i2c_send_bytes()
265 addr, ret); in em28xx_i2c_send_bytes()
266 return -ETIMEDOUT; in em28xx_i2c_send_bytes()
269 dev_warn(&dev->intf->dev, in em28xx_i2c_send_bytes()
270 "write to i2c device at 0x%x failed with unknown error (status=%i)\n", in em28xx_i2c_send_bytes()
271 addr, ret); in em28xx_i2c_send_bytes()
272 return -EIO; in em28xx_i2c_send_bytes()
277 * read a byte from the i2c device
279 static int em28xx_i2c_recv_bytes(struct em28xx *dev, u16 addr, u8 *buf, u16 len) in em28xx_i2c_recv_bytes() argument
284 return -EOPNOTSUPP; in em28xx_i2c_recv_bytes()
287 * Zero length reads always succeed, even if no device is connected in em28xx_i2c_recv_bytes()
290 /* Read data from i2c device */ in em28xx_i2c_recv_bytes()
291 ret = dev->em28xx_read_reg_req_len(dev, 2, addr, buf, len); in em28xx_i2c_recv_bytes()
293 dev_warn(&dev->intf->dev, in em28xx_i2c_recv_bytes()
294 "reading from i2c device at 0x%x failed (error=%i)\n", in em28xx_i2c_recv_bytes()
295 addr, ret); in em28xx_i2c_recv_bytes()
298 dev_dbg(&dev->intf->dev, in em28xx_i2c_recv_bytes()
299 "%i bytes read from i2c device at 0x%x requested, but %i bytes written\n", in em28xx_i2c_recv_bytes()
300 ret, addr, len); in em28xx_i2c_recv_bytes()
305 * specified slave address before AND no device is present at the in em28xx_i2c_recv_bytes()
307 * Anyway, the next check will fail with -ENXIO in this case, so avoid in em28xx_i2c_recv_bytes()
308 * spamming the system log on device probing and do nothing here. in em28xx_i2c_recv_bytes()
312 ret = dev->em28xx_read_reg(dev, 0x05); in em28xx_i2c_recv_bytes()
316 dev_warn(&dev->intf->dev, in em28xx_i2c_recv_bytes()
322 dprintk(1, "I2C ACK error on writing to addr 0x%02x\n", in em28xx_i2c_recv_bytes()
323 addr); in em28xx_i2c_recv_bytes()
324 return -ENXIO; in em28xx_i2c_recv_bytes()
330 "write to i2c device at 0x%x timed out (status=%i)\n", in em28xx_i2c_recv_bytes()
331 addr, ret); in em28xx_i2c_recv_bytes()
332 return -ETIMEDOUT; in em28xx_i2c_recv_bytes()
335 dev_warn(&dev->intf->dev, in em28xx_i2c_recv_bytes()
336 "read from i2c device at 0x%x failed with unknown error (status=%i)\n", in em28xx_i2c_recv_bytes()
337 addr, ret); in em28xx_i2c_recv_bytes()
338 return -EIO; in em28xx_i2c_recv_bytes()
345 static int em28xx_i2c_check_for_device(struct em28xx *dev, u16 addr) in em28xx_i2c_check_for_device() argument
350 ret = em28xx_i2c_recv_bytes(dev, addr, &buf, 1); in em28xx_i2c_check_for_device()
353 return (ret < 0) ? ret : -EIO; in em28xx_i2c_check_for_device()
358 * write bytes to the i2c device
360 static int em25xx_bus_B_send_bytes(struct em28xx *dev, u16 addr, u8 *buf, in em25xx_bus_B_send_bytes() argument
366 return -EOPNOTSUPP; in em25xx_bus_B_send_bytes()
369 * Zero length reads always succeed, even if no device is connected in em25xx_bus_B_send_bytes()
373 ret = dev->em28xx_write_regs_req(dev, 0x06, addr, buf, len); in em25xx_bus_B_send_bytes()
376 dev_warn(&dev->intf->dev, in em25xx_bus_B_send_bytes()
377 "writing to i2c device at 0x%x failed (error=%i)\n", in em25xx_bus_B_send_bytes()
378 addr, ret); in em25xx_bus_B_send_bytes()
382 dev_warn(&dev->intf->dev, in em25xx_bus_B_send_bytes()
383 "%i bytes write to i2c device at 0x%x requested, but %i bytes written\n", in em25xx_bus_B_send_bytes()
384 len, addr, ret); in em25xx_bus_B_send_bytes()
385 return -EIO; in em25xx_bus_B_send_bytes()
388 ret = dev->em28xx_read_reg_req(dev, 0x08, 0x0000); in em25xx_bus_B_send_bytes()
391 * 0x01 when the slave device is not present in em25xx_bus_B_send_bytes()
398 return -ENXIO; in em25xx_bus_B_send_bytes()
405 * slave device or even no second i2c bus provided) in em25xx_bus_B_send_bytes()
411 * read bytes from the i2c device
413 static int em25xx_bus_B_recv_bytes(struct em28xx *dev, u16 addr, u8 *buf, in em25xx_bus_B_recv_bytes() argument
419 return -EOPNOTSUPP; in em25xx_bus_B_recv_bytes()
422 * Zero length reads always succeed, even if no device is connected in em25xx_bus_B_recv_bytes()
426 ret = dev->em28xx_read_reg_req_len(dev, 0x06, addr, buf, len); in em25xx_bus_B_recv_bytes()
428 dev_warn(&dev->intf->dev, in em25xx_bus_B_recv_bytes()
429 "reading from i2c device at 0x%x failed (error=%i)\n", in em25xx_bus_B_recv_bytes()
430 addr, ret); in em25xx_bus_B_recv_bytes()
436 * specified slave address before AND no device is present at the in em25xx_bus_B_recv_bytes()
438 * Anyway, the next check will fail with -ENXIO in this case, so avoid in em25xx_bus_B_recv_bytes()
439 * spamming the system log on device probing and do nothing here. in em25xx_bus_B_recv_bytes()
443 ret = dev->em28xx_read_reg_req(dev, 0x08, 0x0000); in em25xx_bus_B_recv_bytes()
446 * 0x01 when the slave device is not present in em25xx_bus_B_recv_bytes()
453 return -ENXIO; in em25xx_bus_B_recv_bytes()
460 * slave device or even no second i2c bus provided) in em25xx_bus_B_recv_bytes()
466 * check if there is a i2c device at the supplied address
468 static int em25xx_bus_B_check_for_device(struct em28xx *dev, u16 addr) in em25xx_bus_B_check_for_device() argument
473 ret = em25xx_bus_B_recv_bytes(dev, addr, &buf, 1); in em25xx_bus_B_check_for_device()
480 * it seems to succeed ALWAYS ! (even if no device connected) in em25xx_bus_B_check_for_device()
484 static inline int i2c_check_for_device(struct em28xx_i2c_bus *i2c_bus, u16 addr) in i2c_check_for_device() argument
486 struct em28xx *dev = i2c_bus->dev; in i2c_check_for_device()
487 int rc = -EOPNOTSUPP; in i2c_check_for_device()
489 if (i2c_bus->algo_type == EM28XX_I2C_ALGO_EM28XX) in i2c_check_for_device()
490 rc = em28xx_i2c_check_for_device(dev, addr); in i2c_check_for_device()
491 else if (i2c_bus->algo_type == EM28XX_I2C_ALGO_EM2800) in i2c_check_for_device()
492 rc = em2800_i2c_check_for_device(dev, addr); in i2c_check_for_device()
493 else if (i2c_bus->algo_type == EM28XX_I2C_ALGO_EM25XX_BUS_B) in i2c_check_for_device()
494 rc = em25xx_bus_B_check_for_device(dev, addr); in i2c_check_for_device()
501 struct em28xx *dev = i2c_bus->dev; in i2c_recv_bytes()
502 u16 addr = msg.addr << 1; in i2c_recv_bytes() local
503 int rc = -EOPNOTSUPP; in i2c_recv_bytes()
505 if (i2c_bus->algo_type == EM28XX_I2C_ALGO_EM28XX) in i2c_recv_bytes()
506 rc = em28xx_i2c_recv_bytes(dev, addr, msg.buf, msg.len); in i2c_recv_bytes()
507 else if (i2c_bus->algo_type == EM28XX_I2C_ALGO_EM2800) in i2c_recv_bytes()
508 rc = em2800_i2c_recv_bytes(dev, addr, msg.buf, msg.len); in i2c_recv_bytes()
509 else if (i2c_bus->algo_type == EM28XX_I2C_ALGO_EM25XX_BUS_B) in i2c_recv_bytes()
510 rc = em25xx_bus_B_recv_bytes(dev, addr, msg.buf, msg.len); in i2c_recv_bytes()
517 struct em28xx *dev = i2c_bus->dev; in i2c_send_bytes()
518 u16 addr = msg.addr << 1; in i2c_send_bytes() local
519 int rc = -EOPNOTSUPP; in i2c_send_bytes()
521 if (i2c_bus->algo_type == EM28XX_I2C_ALGO_EM28XX) in i2c_send_bytes()
522 rc = em28xx_i2c_send_bytes(dev, addr, msg.buf, msg.len, stop); in i2c_send_bytes()
523 else if (i2c_bus->algo_type == EM28XX_I2C_ALGO_EM2800) in i2c_send_bytes()
524 rc = em2800_i2c_send_bytes(dev, addr, msg.buf, msg.len); in i2c_send_bytes()
525 else if (i2c_bus->algo_type == EM28XX_I2C_ALGO_EM25XX_BUS_B) in i2c_send_bytes()
526 rc = em25xx_bus_B_send_bytes(dev, addr, msg.buf, msg.len); in i2c_send_bytes()
537 struct em28xx_i2c_bus *i2c_bus = i2c_adap->algo_data; in em28xx_i2c_xfer()
538 struct em28xx *dev = i2c_bus->dev; in em28xx_i2c_xfer()
539 unsigned int bus = i2c_bus->bus; in em28xx_i2c_xfer()
540 int addr, rc, i; in em28xx_i2c_xfer() local
544 * prevent i2c xfer attempts after device is disconnected in em28xx_i2c_xfer()
548 if (dev->disconnected) in em28xx_i2c_xfer()
549 return -ENODEV; in em28xx_i2c_xfer()
551 if (!rt_mutex_trylock(&dev->i2c_bus_lock)) in em28xx_i2c_xfer()
552 return -EAGAIN; in em28xx_i2c_xfer()
555 if (bus != dev->cur_i2c_bus && in em28xx_i2c_xfer()
556 i2c_bus->algo_type == EM28XX_I2C_ALGO_EM28XX) { in em28xx_i2c_xfer()
563 dev->cur_i2c_bus = bus; in em28xx_i2c_xfer()
567 addr = msgs[i].addr << 1; in em28xx_i2c_xfer()
570 * no len: check only for device presence in em28xx_i2c_xfer()
571 * This code is only called during device probe. in em28xx_i2c_xfer()
573 rc = i2c_check_for_device(i2c_bus, addr); in em28xx_i2c_xfer()
575 if (rc == -ENXIO) in em28xx_i2c_xfer()
576 rc = -ENODEV; in em28xx_i2c_xfer()
582 rc = i2c_send_bytes(i2c_bus, msgs[i], i == num - 1); in em28xx_i2c_xfer()
588 dprintk(2, "%s %s addr=%02x len=%d: %*ph\n", in em28xx_i2c_xfer()
590 i == num - 1 ? "stop" : "nonstop", in em28xx_i2c_xfer()
591 addr, msgs[i].len, in em28xx_i2c_xfer()
595 rt_mutex_unlock(&dev->i2c_bus_lock); in em28xx_i2c_xfer()
599 dprintk(2, "%s %s addr=%02x len=%d: %sERROR: %i\n", in em28xx_i2c_xfer()
601 i == num - 1 ? "stop" : "nonstop", in em28xx_i2c_xfer()
602 addr, msgs[i].len, in em28xx_i2c_xfer()
603 (rc == -ENODEV) ? "no device " : "", in em28xx_i2c_xfer()
606 rt_mutex_unlock(&dev->i2c_bus_lock); in em28xx_i2c_xfer()
625 len = -1; in em28xx_hash_mem()
631 if ((len & (32 / 8 - 1)) == 0) in em28xx_hash_mem()
635 return (hash >> (32 - bits)) & 0xffffffffUL; in em28xx_hash_mem()
642 static int em28xx_i2c_read_block(struct em28xx *dev, unsigned int bus, u16 addr, in em28xx_i2c_read_block() argument
649 if (addr + remain > (addr_w16 * 0xff00 + 0xff + 1)) in em28xx_i2c_read_block()
650 return -EINVAL; in em28xx_i2c_read_block()
652 buf[0] = addr >> 8; in em28xx_i2c_read_block()
653 buf[1] = addr & 0xff; in em28xx_i2c_read_block()
654 ret = i2c_master_send(&dev->i2c_client[bus], in em28xx_i2c_read_block()
659 if (dev->board.is_em2800) in em28xx_i2c_read_block()
669 ret = i2c_master_recv(&dev->i2c_client[bus], data, rsize); in em28xx_i2c_read_block()
673 remain -= rsize; in em28xx_i2c_read_block()
686 * calculation and returned device dataset. Simplifies the code a lot, in em28xx_i2c_eeprom()
698 dev->i2c_client[bus].addr = 0xa0 >> 1; in em28xx_i2c_eeprom()
701 err = i2c_master_recv(&dev->i2c_client[bus], &buf, 0); in em28xx_i2c_eeprom()
703 dev_info(&dev->intf->dev, "board has no eeprom\n"); in em28xx_i2c_eeprom()
704 return -ENODEV; in em28xx_i2c_eeprom()
709 return -ENOMEM; in em28xx_i2c_eeprom()
713 dev->eeprom_addrwidth_16bit, in em28xx_i2c_eeprom()
716 dev_err(&dev->intf->dev, in em28xx_i2c_eeprom()
726 if (dev->eeprom_addrwidth_16bit) in em28xx_i2c_eeprom()
727 dev_info(&dev->intf->dev, in em28xx_i2c_eeprom()
731 if (dev->eeprom_addrwidth_16bit && in em28xx_i2c_eeprom()
733 /* new eeprom format; size 4-64kb */ in em28xx_i2c_eeprom()
737 dev->hash = em28xx_hash_mem(data, len, 32); in em28xx_i2c_eeprom()
740 dev_info(&dev->intf->dev, in em28xx_i2c_eeprom()
742 data, dev->hash); in em28xx_i2c_eeprom()
743 dev_info(&dev->intf->dev, in em28xx_i2c_eeprom()
745 dev_info(&dev->intf->dev, in em28xx_i2c_eeprom()
752 * [2] USB device speed: 1 = force Full Speed; 0 = auto detect in em28xx_i2c_eeprom()
753 * [4] 1 = force fast mode and no suspend for device testing in em28xx_i2c_eeprom()
754 * [5:7] USB PHY tuning registers; determined by device in em28xx_i2c_eeprom()
765 dev_err(&dev->intf->dev, in em28xx_i2c_eeprom()
784 dev_err(&dev->intf->dev, in em28xx_i2c_eeprom()
794 dev_info(&dev->intf->dev, in em28xx_i2c_eeprom()
805 } else if (!dev->eeprom_addrwidth_16bit && in em28xx_i2c_eeprom()
808 dev->hash = em28xx_hash_mem(data, len, 32); in em28xx_i2c_eeprom()
809 dev_info(&dev->intf->dev, in em28xx_i2c_eeprom()
811 data, dev->hash); in em28xx_i2c_eeprom()
812 dev_info(&dev->intf->dev, in em28xx_i2c_eeprom()
815 dev_info(&dev->intf->dev, in em28xx_i2c_eeprom()
817 err = -ENODEV; in em28xx_i2c_eeprom()
825 switch (le16_to_cpu(dev_config->chip_conf) >> 4 & 0x3) { in em28xx_i2c_eeprom()
827 dev_info(&dev->intf->dev, "\tNo audio on board.\n"); in em28xx_i2c_eeprom()
830 dev_info(&dev->intf->dev, "\tAC97 audio (5 sample rates)\n"); in em28xx_i2c_eeprom()
833 if (dev->chip_id < CHIP_ID_EM2860) in em28xx_i2c_eeprom()
834 dev_info(&dev->intf->dev, in em28xx_i2c_eeprom()
837 dev_info(&dev->intf->dev, in em28xx_i2c_eeprom()
841 if (dev->chip_id < CHIP_ID_EM2860) in em28xx_i2c_eeprom()
842 dev_info(&dev->intf->dev, in em28xx_i2c_eeprom()
845 dev_info(&dev->intf->dev, in em28xx_i2c_eeprom()
850 if (le16_to_cpu(dev_config->chip_conf) & 1 << 3) in em28xx_i2c_eeprom()
851 dev_info(&dev->intf->dev, "\tUSB Remote wakeup capable\n"); in em28xx_i2c_eeprom()
853 if (le16_to_cpu(dev_config->chip_conf) & 1 << 2) in em28xx_i2c_eeprom()
854 dev_info(&dev->intf->dev, "\tUSB Self power capable\n"); in em28xx_i2c_eeprom()
856 switch (le16_to_cpu(dev_config->chip_conf) & 0x3) { in em28xx_i2c_eeprom()
858 dev_info(&dev->intf->dev, "\t500mA max power\n"); in em28xx_i2c_eeprom()
861 dev_info(&dev->intf->dev, "\t400mA max power\n"); in em28xx_i2c_eeprom()
864 dev_info(&dev->intf->dev, "\t300mA max power\n"); in em28xx_i2c_eeprom()
867 dev_info(&dev->intf->dev, "\t200mA max power\n"); in em28xx_i2c_eeprom()
870 dev_info(&dev->intf->dev, in em28xx_i2c_eeprom()
872 dev_config->string_idx_table, in em28xx_i2c_eeprom()
873 le16_to_cpu(dev_config->string1), in em28xx_i2c_eeprom()
874 le16_to_cpu(dev_config->string2), in em28xx_i2c_eeprom()
875 le16_to_cpu(dev_config->string3)); in em28xx_i2c_eeprom()
884 /* ----------------------------------------------------------- */
891 struct em28xx_i2c_bus *i2c_bus = i2c_adap->algo_data; in functionality()
893 if (i2c_bus->algo_type == EM28XX_I2C_ALGO_EM28XX || in functionality()
894 i2c_bus->algo_type == EM28XX_I2C_ALGO_EM25XX_BUS_B) { in functionality()
896 } else if (i2c_bus->algo_type == EM28XX_I2C_ALGO_EM2800) { in functionality()
920 /* ----------------------------------------------------------- */
959 dev->i2c_client[bus].addr = i; in em28xx_do_i2c_scan()
960 rc = i2c_master_recv(&dev->i2c_client[bus], &buf, 0); in em28xx_do_i2c_scan()
964 dev_info(&dev->intf->dev, in em28xx_do_i2c_scan()
965 "found i2c device @ 0x%x on bus %d [%s]\n", in em28xx_do_i2c_scan()
969 if (bus == dev->def_i2c_bus) in em28xx_do_i2c_scan()
970 dev->i2c_hash = em28xx_hash_mem(i2c_devicelist, in em28xx_do_i2c_scan()
983 if (WARN_ON(!dev->em28xx_write_regs || !dev->em28xx_read_reg || in em28xx_i2c_register()
984 !dev->em28xx_write_regs_req || !dev->em28xx_read_reg_req)) in em28xx_i2c_register()
985 return -ENODEV; in em28xx_i2c_register()
988 return -ENODEV; in em28xx_i2c_register()
990 dev->i2c_adap[bus] = em28xx_adap_template; in em28xx_i2c_register()
991 dev->i2c_adap[bus].dev.parent = &dev->intf->dev; in em28xx_i2c_register()
992 strscpy(dev->i2c_adap[bus].name, dev_name(&dev->intf->dev), in em28xx_i2c_register()
993 sizeof(dev->i2c_adap[bus].name)); in em28xx_i2c_register()
995 dev->i2c_bus[bus].bus = bus; in em28xx_i2c_register()
996 dev->i2c_bus[bus].algo_type = algo_type; in em28xx_i2c_register()
997 dev->i2c_bus[bus].dev = dev; in em28xx_i2c_register()
998 dev->i2c_adap[bus].algo_data = &dev->i2c_bus[bus]; in em28xx_i2c_register()
1000 retval = i2c_add_adapter(&dev->i2c_adap[bus]); in em28xx_i2c_register()
1002 dev_err(&dev->intf->dev, in em28xx_i2c_register()
1008 dev->i2c_client[bus] = em28xx_client_template; in em28xx_i2c_register()
1009 dev->i2c_client[bus].adapter = &dev->i2c_adap[bus]; in em28xx_i2c_register()
1014 &dev->eedata, &dev->eedata_len); in em28xx_i2c_register()
1015 if (retval < 0 && retval != -ENODEV) { in em28xx_i2c_register()
1016 dev_err(&dev->intf->dev, in em28xx_i2c_register()
1035 return -ENODEV; in em28xx_i2c_unregister()
1037 i2c_del_adapter(&dev->i2c_adap[bus]); in em28xx_i2c_unregister()