76 "gpio",
77 "cx23418",
78};
79
80int cx18_i2c_register(struct cx18 *cx, unsigned idx)
81{
82 struct i2c_board_info info;
83 struct i2c_client *c;
84 u8 id, bus;
85 int i;
86
87 CX18_DEBUG_I2C("i2c client register\n");
88 if (idx >= ARRAY_SIZE(hw_driverids) || hw_driverids[idx] == 0)
89 return -1;
90 id = hw_driverids[idx];
91 bus = hw_bus[idx];
92 memset(&info, 0, sizeof(info));
93 strlcpy(info.type, hw_devicenames[idx], sizeof(info.type));
94 info.addr = hw_addrs[idx];
95 for (i = 0; i < I2C_CLIENTS_MAX; i++)
96 if (cx->i2c_clients[i] == NULL)
97 break;
98
99 if (i == I2C_CLIENTS_MAX) {
100 CX18_ERR("insufficient room for new I2C client!\n");
101 return -ENOMEM;
102 }
103
104 if (id != I2C_DRIVERID_TUNER) {
105 c = i2c_new_device(&cx->i2c_adap[bus], &info);
106 if (c->driver == NULL)
107 i2c_unregister_device(c);
108 else
109 cx->i2c_clients[i] = c;
110 return cx->i2c_clients[i] ? 0 : -ENODEV;
111 }
112
113
114 c = i2c_new_probed_device(&cx->i2c_adap[1], &info, cx->card_i2c->radio);
115 if (c && c->driver == NULL)
116 i2c_unregister_device(c);