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()
301 * specified slave address before AND no device is present at the in em28xx_i2c_recv_bytes()
303 * Anyway, the next check will fail with -ENXIO in this case, so avoid in em28xx_i2c_recv_bytes()
304 * spamming the system log on device probing and do nothing here. in em28xx_i2c_recv_bytes()
308 ret = dev->em28xx_read_reg(dev, 0x05); in em28xx_i2c_recv_bytes()
312 dev_warn(&dev->intf->dev, in em28xx_i2c_recv_bytes()
318 dprintk(1, "I2C ACK error on writing to addr 0x%02x\n", in em28xx_i2c_recv_bytes()
319 addr); in em28xx_i2c_recv_bytes()
320 return -ENXIO; in em28xx_i2c_recv_bytes()
326 "write to i2c device at 0x%x timed out (status=%i)\n", in em28xx_i2c_recv_bytes()
327 addr, ret); in em28xx_i2c_recv_bytes()
328 return -ETIMEDOUT; in em28xx_i2c_recv_bytes()
331 dev_warn(&dev->intf->dev, in em28xx_i2c_recv_bytes()
332 "write to i2c device at 0x%x failed with unknown error (status=%i)\n", in em28xx_i2c_recv_bytes()
333 addr, ret); in em28xx_i2c_recv_bytes()
334 return -EIO; in em28xx_i2c_recv_bytes()
341 static int em28xx_i2c_check_for_device(struct em28xx *dev, u16 addr) in em28xx_i2c_check_for_device() argument
346 ret = em28xx_i2c_recv_bytes(dev, addr, &buf, 1); in em28xx_i2c_check_for_device()
349 return (ret < 0) ? ret : -EIO; in em28xx_i2c_check_for_device()
354 * write bytes to the i2c device
356 static int em25xx_bus_B_send_bytes(struct em28xx *dev, u16 addr, u8 *buf, in em25xx_bus_B_send_bytes() argument
362 return -EOPNOTSUPP; in em25xx_bus_B_send_bytes()
365 * Zero length reads always succeed, even if no device is connected in em25xx_bus_B_send_bytes()
369 ret = dev->em28xx_write_regs_req(dev, 0x06, addr, buf, len); in em25xx_bus_B_send_bytes()
372 dev_warn(&dev->intf->dev, in em25xx_bus_B_send_bytes()
373 "writing to i2c device at 0x%x failed (error=%i)\n", in em25xx_bus_B_send_bytes()
374 addr, ret); in em25xx_bus_B_send_bytes()
378 dev_warn(&dev->intf->dev, in em25xx_bus_B_send_bytes()
379 "%i bytes write to i2c device at 0x%x requested, but %i bytes written\n", in em25xx_bus_B_send_bytes()
380 len, addr, ret); in em25xx_bus_B_send_bytes()
381 return -EIO; in em25xx_bus_B_send_bytes()
384 ret = dev->em28xx_read_reg_req(dev, 0x08, 0x0000); in em25xx_bus_B_send_bytes()
387 * 0x01 when the slave device is not present in em25xx_bus_B_send_bytes()
394 return -ENXIO; in em25xx_bus_B_send_bytes()
401 * slave device or even no second i2c bus provided) in em25xx_bus_B_send_bytes()
407 * read bytes from the i2c device
409 static int em25xx_bus_B_recv_bytes(struct em28xx *dev, u16 addr, u8 *buf, in em25xx_bus_B_recv_bytes() argument
415 return -EOPNOTSUPP; in em25xx_bus_B_recv_bytes()
418 * Zero length reads always succeed, even if no device is connected in em25xx_bus_B_recv_bytes()
422 ret = dev->em28xx_read_reg_req_len(dev, 0x06, addr, buf, len); in em25xx_bus_B_recv_bytes()
424 dev_warn(&dev->intf->dev, in em25xx_bus_B_recv_bytes()
425 "reading from i2c device at 0x%x failed (error=%i)\n", in em25xx_bus_B_recv_bytes()
426 addr, ret); in em25xx_bus_B_recv_bytes()
432 * specified slave address before AND no device is present at the in em25xx_bus_B_recv_bytes()
434 * Anyway, the next check will fail with -ENXIO in this case, so avoid in em25xx_bus_B_recv_bytes()
435 * spamming the system log on device probing and do nothing here. in em25xx_bus_B_recv_bytes()
439 ret = dev->em28xx_read_reg_req(dev, 0x08, 0x0000); in em25xx_bus_B_recv_bytes()
442 * 0x01 when the slave device is not present in em25xx_bus_B_recv_bytes()
449 return -ENXIO; in em25xx_bus_B_recv_bytes()
456 * slave device or even no second i2c bus provided) in em25xx_bus_B_recv_bytes()
462 * check if there is a i2c device at the supplied address
464 static int em25xx_bus_B_check_for_device(struct em28xx *dev, u16 addr) in em25xx_bus_B_check_for_device() argument
469 ret = em25xx_bus_B_recv_bytes(dev, addr, &buf, 1); in em25xx_bus_B_check_for_device()
476 * it seems to succeed ALWAYS ! (even if no device connected) in em25xx_bus_B_check_for_device()
480 static inline int i2c_check_for_device(struct em28xx_i2c_bus *i2c_bus, u16 addr) in i2c_check_for_device() argument
482 struct em28xx *dev = i2c_bus->dev; in i2c_check_for_device()
483 int rc = -EOPNOTSUPP; in i2c_check_for_device()
485 if (i2c_bus->algo_type == EM28XX_I2C_ALGO_EM28XX) in i2c_check_for_device()
486 rc = em28xx_i2c_check_for_device(dev, addr); in i2c_check_for_device()
487 else if (i2c_bus->algo_type == EM28XX_I2C_ALGO_EM2800) in i2c_check_for_device()
488 rc = em2800_i2c_check_for_device(dev, addr); in i2c_check_for_device()
489 else if (i2c_bus->algo_type == EM28XX_I2C_ALGO_EM25XX_BUS_B) in i2c_check_for_device()
490 rc = em25xx_bus_B_check_for_device(dev, addr); in i2c_check_for_device()
497 struct em28xx *dev = i2c_bus->dev; in i2c_recv_bytes()
498 u16 addr = msg.addr << 1; in i2c_recv_bytes() local
499 int rc = -EOPNOTSUPP; in i2c_recv_bytes()
501 if (i2c_bus->algo_type == EM28XX_I2C_ALGO_EM28XX) in i2c_recv_bytes()
502 rc = em28xx_i2c_recv_bytes(dev, addr, msg.buf, msg.len); in i2c_recv_bytes()
503 else if (i2c_bus->algo_type == EM28XX_I2C_ALGO_EM2800) in i2c_recv_bytes()
504 rc = em2800_i2c_recv_bytes(dev, addr, msg.buf, msg.len); in i2c_recv_bytes()
505 else if (i2c_bus->algo_type == EM28XX_I2C_ALGO_EM25XX_BUS_B) in i2c_recv_bytes()
506 rc = em25xx_bus_B_recv_bytes(dev, addr, msg.buf, msg.len); in i2c_recv_bytes()
513 struct em28xx *dev = i2c_bus->dev; in i2c_send_bytes()
514 u16 addr = msg.addr << 1; in i2c_send_bytes() local
515 int rc = -EOPNOTSUPP; in i2c_send_bytes()
517 if (i2c_bus->algo_type == EM28XX_I2C_ALGO_EM28XX) in i2c_send_bytes()
518 rc = em28xx_i2c_send_bytes(dev, addr, msg.buf, msg.len, stop); in i2c_send_bytes()
519 else if (i2c_bus->algo_type == EM28XX_I2C_ALGO_EM2800) in i2c_send_bytes()
520 rc = em2800_i2c_send_bytes(dev, addr, msg.buf, msg.len); in i2c_send_bytes()
521 else if (i2c_bus->algo_type == EM28XX_I2C_ALGO_EM25XX_BUS_B) in i2c_send_bytes()
522 rc = em25xx_bus_B_send_bytes(dev, addr, msg.buf, msg.len); in i2c_send_bytes()
533 struct em28xx_i2c_bus *i2c_bus = i2c_adap->algo_data; in em28xx_i2c_xfer()
534 struct em28xx *dev = i2c_bus->dev; in em28xx_i2c_xfer()
535 unsigned int bus = i2c_bus->bus; in em28xx_i2c_xfer()
536 int addr, rc, i; in em28xx_i2c_xfer() local
540 * prevent i2c xfer attempts after device is disconnected in em28xx_i2c_xfer()
544 if (dev->disconnected) in em28xx_i2c_xfer()
545 return -ENODEV; in em28xx_i2c_xfer()
547 if (!rt_mutex_trylock(&dev->i2c_bus_lock)) in em28xx_i2c_xfer()
548 return -EAGAIN; in em28xx_i2c_xfer()
551 if (bus != dev->cur_i2c_bus && in em28xx_i2c_xfer()
552 i2c_bus->algo_type == EM28XX_I2C_ALGO_EM28XX) { in em28xx_i2c_xfer()
559 dev->cur_i2c_bus = bus; in em28xx_i2c_xfer()
563 addr = msgs[i].addr << 1; in em28xx_i2c_xfer()
566 * no len: check only for device presence in em28xx_i2c_xfer()
567 * This code is only called during device probe. in em28xx_i2c_xfer()
569 rc = i2c_check_for_device(i2c_bus, addr); in em28xx_i2c_xfer()
571 if (rc == -ENXIO) in em28xx_i2c_xfer()
572 rc = -ENODEV; in em28xx_i2c_xfer()
578 rc = i2c_send_bytes(i2c_bus, msgs[i], i == num - 1); in em28xx_i2c_xfer()
584 dprintk(2, "%s %s addr=%02x len=%d: %*ph\n", in em28xx_i2c_xfer()
586 i == num - 1 ? "stop" : "nonstop", in em28xx_i2c_xfer()
587 addr, msgs[i].len, in em28xx_i2c_xfer()
591 rt_mutex_unlock(&dev->i2c_bus_lock); in em28xx_i2c_xfer()
595 dprintk(2, "%s %s addr=%02x len=%d: %sERROR: %i\n", in em28xx_i2c_xfer()
597 i == num - 1 ? "stop" : "nonstop", in em28xx_i2c_xfer()
598 addr, msgs[i].len, in em28xx_i2c_xfer()
599 (rc == -ENODEV) ? "no device " : "", in em28xx_i2c_xfer()
602 rt_mutex_unlock(&dev->i2c_bus_lock); in em28xx_i2c_xfer()
621 len = -1; in em28xx_hash_mem()
627 if ((len & (32 / 8 - 1)) == 0) in em28xx_hash_mem()
631 return (hash >> (32 - bits)) & 0xffffffffUL; in em28xx_hash_mem()
638 static int em28xx_i2c_read_block(struct em28xx *dev, unsigned int bus, u16 addr, in em28xx_i2c_read_block() argument
645 if (addr + remain > (addr_w16 * 0xff00 + 0xff + 1)) in em28xx_i2c_read_block()
646 return -EINVAL; in em28xx_i2c_read_block()
648 buf[0] = addr >> 8; in em28xx_i2c_read_block()
649 buf[1] = addr & 0xff; in em28xx_i2c_read_block()
650 ret = i2c_master_send(&dev->i2c_client[bus], in em28xx_i2c_read_block()
655 if (dev->board.is_em2800) in em28xx_i2c_read_block()
665 ret = i2c_master_recv(&dev->i2c_client[bus], data, rsize); in em28xx_i2c_read_block()
669 remain -= rsize; in em28xx_i2c_read_block()
682 * calculation and returned device dataset. Simplifies the code a lot, in em28xx_i2c_eeprom()
694 dev->i2c_client[bus].addr = 0xa0 >> 1; in em28xx_i2c_eeprom()
697 err = i2c_master_recv(&dev->i2c_client[bus], &buf, 0); in em28xx_i2c_eeprom()
699 dev_info(&dev->intf->dev, "board has no eeprom\n"); in em28xx_i2c_eeprom()
700 return -ENODEV; in em28xx_i2c_eeprom()
705 return -ENOMEM; in em28xx_i2c_eeprom()
709 dev->eeprom_addrwidth_16bit, in em28xx_i2c_eeprom()
712 dev_err(&dev->intf->dev, in em28xx_i2c_eeprom()
722 if (dev->eeprom_addrwidth_16bit) in em28xx_i2c_eeprom()
723 dev_info(&dev->intf->dev, in em28xx_i2c_eeprom()
727 if (dev->eeprom_addrwidth_16bit && in em28xx_i2c_eeprom()
729 /* new eeprom format; size 4-64kb */ in em28xx_i2c_eeprom()
733 dev->hash = em28xx_hash_mem(data, len, 32); in em28xx_i2c_eeprom()
736 dev_info(&dev->intf->dev, in em28xx_i2c_eeprom()
738 data, dev->hash); in em28xx_i2c_eeprom()
739 dev_info(&dev->intf->dev, in em28xx_i2c_eeprom()
741 dev_info(&dev->intf->dev, in em28xx_i2c_eeprom()
748 * [2] USB device speed: 1 = force Full Speed; 0 = auto detect in em28xx_i2c_eeprom()
749 * [4] 1 = force fast mode and no suspend for device testing in em28xx_i2c_eeprom()
750 * [5:7] USB PHY tuning registers; determined by device in em28xx_i2c_eeprom()
761 dev_err(&dev->intf->dev, in em28xx_i2c_eeprom()
780 dev_err(&dev->intf->dev, in em28xx_i2c_eeprom()
790 dev_info(&dev->intf->dev, in em28xx_i2c_eeprom()
801 } else if (!dev->eeprom_addrwidth_16bit && in em28xx_i2c_eeprom()
804 dev->hash = em28xx_hash_mem(data, len, 32); in em28xx_i2c_eeprom()
805 dev_info(&dev->intf->dev, in em28xx_i2c_eeprom()
807 data, dev->hash); in em28xx_i2c_eeprom()
808 dev_info(&dev->intf->dev, in em28xx_i2c_eeprom()
811 dev_info(&dev->intf->dev, in em28xx_i2c_eeprom()
813 err = -ENODEV; in em28xx_i2c_eeprom()
821 switch (le16_to_cpu(dev_config->chip_conf) >> 4 & 0x3) { in em28xx_i2c_eeprom()
823 dev_info(&dev->intf->dev, "\tNo audio on board.\n"); in em28xx_i2c_eeprom()
826 dev_info(&dev->intf->dev, "\tAC97 audio (5 sample rates)\n"); in em28xx_i2c_eeprom()
829 if (dev->chip_id < CHIP_ID_EM2860) in em28xx_i2c_eeprom()
830 dev_info(&dev->intf->dev, in em28xx_i2c_eeprom()
833 dev_info(&dev->intf->dev, in em28xx_i2c_eeprom()
837 if (dev->chip_id < CHIP_ID_EM2860) in em28xx_i2c_eeprom()
838 dev_info(&dev->intf->dev, in em28xx_i2c_eeprom()
841 dev_info(&dev->intf->dev, in em28xx_i2c_eeprom()
846 if (le16_to_cpu(dev_config->chip_conf) & 1 << 3) in em28xx_i2c_eeprom()
847 dev_info(&dev->intf->dev, "\tUSB Remote wakeup capable\n"); in em28xx_i2c_eeprom()
849 if (le16_to_cpu(dev_config->chip_conf) & 1 << 2) in em28xx_i2c_eeprom()
850 dev_info(&dev->intf->dev, "\tUSB Self power capable\n"); in em28xx_i2c_eeprom()
852 switch (le16_to_cpu(dev_config->chip_conf) & 0x3) { in em28xx_i2c_eeprom()
854 dev_info(&dev->intf->dev, "\t500mA max power\n"); in em28xx_i2c_eeprom()
857 dev_info(&dev->intf->dev, "\t400mA max power\n"); in em28xx_i2c_eeprom()
860 dev_info(&dev->intf->dev, "\t300mA max power\n"); in em28xx_i2c_eeprom()
863 dev_info(&dev->intf->dev, "\t200mA max power\n"); in em28xx_i2c_eeprom()
866 dev_info(&dev->intf->dev, in em28xx_i2c_eeprom()
868 dev_config->string_idx_table, in em28xx_i2c_eeprom()
869 le16_to_cpu(dev_config->string1), in em28xx_i2c_eeprom()
870 le16_to_cpu(dev_config->string2), in em28xx_i2c_eeprom()
871 le16_to_cpu(dev_config->string3)); in em28xx_i2c_eeprom()
880 /* ----------------------------------------------------------- */
887 struct em28xx_i2c_bus *i2c_bus = i2c_adap->algo_data; in functionality()
889 if (i2c_bus->algo_type == EM28XX_I2C_ALGO_EM28XX || in functionality()
890 i2c_bus->algo_type == EM28XX_I2C_ALGO_EM25XX_BUS_B) { in functionality()
892 } else if (i2c_bus->algo_type == EM28XX_I2C_ALGO_EM2800) { in functionality()
916 /* ----------------------------------------------------------- */
955 dev->i2c_client[bus].addr = i; in em28xx_do_i2c_scan()
956 rc = i2c_master_recv(&dev->i2c_client[bus], &buf, 0); in em28xx_do_i2c_scan()
960 dev_info(&dev->intf->dev, in em28xx_do_i2c_scan()
961 "found i2c device @ 0x%x on bus %d [%s]\n", in em28xx_do_i2c_scan()
965 if (bus == dev->def_i2c_bus) in em28xx_do_i2c_scan()
966 dev->i2c_hash = em28xx_hash_mem(i2c_devicelist, in em28xx_do_i2c_scan()
979 if (WARN_ON(!dev->em28xx_write_regs || !dev->em28xx_read_reg || in em28xx_i2c_register()
980 !dev->em28xx_write_regs_req || !dev->em28xx_read_reg_req)) in em28xx_i2c_register()
981 return -ENODEV; in em28xx_i2c_register()
984 return -ENODEV; in em28xx_i2c_register()
986 dev->i2c_adap[bus] = em28xx_adap_template; in em28xx_i2c_register()
987 dev->i2c_adap[bus].dev.parent = &dev->intf->dev; in em28xx_i2c_register()
988 strscpy(dev->i2c_adap[bus].name, dev_name(&dev->intf->dev), in em28xx_i2c_register()
989 sizeof(dev->i2c_adap[bus].name)); in em28xx_i2c_register()
991 dev->i2c_bus[bus].bus = bus; in em28xx_i2c_register()
992 dev->i2c_bus[bus].algo_type = algo_type; in em28xx_i2c_register()
993 dev->i2c_bus[bus].dev = dev; in em28xx_i2c_register()
994 dev->i2c_adap[bus].algo_data = &dev->i2c_bus[bus]; in em28xx_i2c_register()
996 retval = i2c_add_adapter(&dev->i2c_adap[bus]); in em28xx_i2c_register()
998 dev_err(&dev->intf->dev, in em28xx_i2c_register()
1004 dev->i2c_client[bus] = em28xx_client_template; in em28xx_i2c_register()
1005 dev->i2c_client[bus].adapter = &dev->i2c_adap[bus]; in em28xx_i2c_register()
1010 &dev->eedata, &dev->eedata_len); in em28xx_i2c_register()
1011 if (retval < 0 && retval != -ENODEV) { in em28xx_i2c_register()
1012 dev_err(&dev->intf->dev, in em28xx_i2c_register()
1031 return -ENODEV; in em28xx_i2c_unregister()
1033 i2c_del_adapter(&dev->i2c_adap[bus]); in em28xx_i2c_unregister()