Commit 3be7a243 authored by Greg Kroah-Hartman's avatar Greg Kroah-Hartman Committed by Petr Vandrovec

i2c: actually register the i2c client device with the driver core.

We have to initialize the client structure with 0 to keep the
driver core from oopsing.

Now everything is hooked up enough to start removing the i2c sysctl
and proc crud.
parent cacdd414
......@@ -221,6 +221,8 @@ static int adm1021_detect(struct i2c_adapter *adapter, int address,
err = -ENOMEM;
goto error0;
}
memset(new_client, 0x00, sizeof(struct i2c_client) +
sizeof(struct adm1021_data));
data = (struct adm1021_data *) (new_client + 1);
i2c_set_clientdata(new_client, data);
......
......@@ -140,6 +140,8 @@ static int lm75_detect(struct i2c_adapter *adapter, int address,
err = -ENOMEM;
goto error0;
}
memset(new_client, 0x00, sizeof(struct i2c_client) +
sizeof(struct lm75_data));
data = (struct lm75_data *) (new_client + 1);
i2c_set_clientdata(new_client, data);
......
......@@ -378,6 +378,15 @@ int i2c_attach_client(struct i2c_client *client)
if (client->flags & I2C_CLIENT_ALLOW_USE)
client->usage_count = 0;
client->dev.parent = &client->adapter->dev;
client->dev.driver = &client->driver->driver;
client->dev.bus = &i2c_bus_type;
snprintf(&client->dev.bus_id[0], sizeof(client->dev.bus_id), "i2c_dev_%d", i);
printk("registering %s\n", client->dev.bus_id);
device_register(&client->dev);
return 0;
}
......@@ -414,6 +423,7 @@ int i2c_detach_client(struct i2c_client *client)
res = -ENODEV;
out_unlock:
device_unregister(&client->dev);
up(&adapter->list);
out:
return res;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment