861 | 861 |
return -ENOMEM;
|
862 | 862 |
}
|
863 | 863 |
|
864 | |
dev_dbg(dev, "uevent\n");
|
865 | 864 |
return 0;
|
866 | 865 |
}
|
867 | 866 |
|
|
986 | 985 |
/* Can't register until after driver model init */
|
987 | 986 |
if (unlikely(WARN_ON(!ddcci_bus_type.p)))
|
988 | 987 |
return -EAGAIN;
|
|
988 |
|
|
989 |
pr_debug("registering driver [%s]\n", driver->driver.name);
|
989 | 990 |
|
990 | 991 |
/* add the driver to the list of ddcci drivers in the driver core */
|
991 | 992 |
driver->driver.owner = owner;
|
|
1394 | 1395 |
unsigned char cmd[2] = { DDCCI_COMMAND_ID, 0x00 };
|
1395 | 1396 |
|
1396 | 1397 |
/* Check for i2c_master_* functionality */
|
1397 | |
if (!i2c_check_functionality(client->adapter, I2C_FUNC_I2C))
|
|
1398 |
if (!i2c_check_functionality(client->adapter, I2C_FUNC_I2C)) {
|
|
1399 |
pr_debug("i2c adapter %d unsuitable: no i2c_master functionality\n", client->adapter->nr);
|
1398 | 1400 |
return -ENODEV;
|
|
1401 |
}
|
1399 | 1402 |
|
1400 | 1403 |
/* send Identification Request command */
|
1401 | 1404 |
outer_addr = client->addr << 1;
|
|
1422 | 1425 |
msleep(delay);
|
1423 | 1426 |
/* receive answer */
|
1424 | 1427 |
ret = i2c_master_recv(client, buf, 32);
|
1425 | |
if (ret < 3)
|
|
1428 |
if (ret < 3) {
|
|
1429 |
pr_debug("detection failed: no answer\n");
|
1426 | 1430 |
return -ENODEV;
|
|
1431 |
}
|
1427 | 1432 |
|
1428 | 1433 |
/* check response starts with outer addr */
|
1429 | |
if (buf[0] != outer_addr)
|
|
1434 |
if (buf[0] != outer_addr) {
|
|
1435 |
pr_debug("detection failed: invalid answer\n");
|
1430 | 1436 |
return -ENODEV;
|
|
1437 |
}
|
1431 | 1438 |
|
1432 | 1439 |
pr_debug("detected %d:%02x\n", client->adapter->nr, outer_addr);
|
1433 | 1440 |
|
|
1581 | 1588 |
static int __init ddcci_module_init(void)
|
1582 | 1589 |
{
|
1583 | 1590 |
int ret;
|
|
1591 |
|
|
1592 |
pr_debug("initializing ddcci driver\n");
|
1584 | 1593 |
/* Allocate a device number region for the character devices */
|
1585 | 1594 |
ret = alloc_chrdev_region(&ddcci_cdev_first, 0, 128, DEVICE_NAME);
|
1586 | 1595 |
if (ret < 0) {
|
|
1603 | 1612 |
pr_err("failed to register i2c driver\n");
|
1604 | 1613 |
goto err_drvreg;
|
1605 | 1614 |
}
|
|
1615 |
|
|
1616 |
pr_debug("ddcci driver initialized\n");
|
1606 | 1617 |
|
1607 | 1618 |
return 0;
|
1608 | 1619 |
|