aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/misc/mei/bus.c
diff options
context:
space:
mode:
authorSamuel Ortiz <sameo@linux.intel.com>2013-03-27 11:29:56 -0400
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>2013-03-29 11:44:12 -0400
commita7b71bc043aded9da4cf51f85271e0779161fe22 (patch)
tree68b69d683542f91b883eb097e2c7bf332b4f3ecf /drivers/misc/mei/bus.c
parent3e8332952dedd2c17bb497e3909e3b6fbac10ce7 (diff)
mei: bus: Add bus related structures to mei_cl
We keep track of all MEI devices on the bus through a specific linked list. We also have a mei_device instance in the mei_cl structure. Signed-off-by: Samuel Ortiz <sameo@linux.intel.com> Signed-off-by: Tomas Winkler <tomas.winkler@intel.com> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Diffstat (limited to 'drivers/misc/mei/bus.c')
-rw-r--r--drivers/misc/mei/bus.c49
1 files changed, 34 insertions, 15 deletions
diff --git a/drivers/misc/mei/bus.c b/drivers/misc/mei/bus.c
index 16c7fff50549..162cd542cac9 100644
--- a/drivers/misc/mei/bus.c
+++ b/drivers/misc/mei/bus.c
@@ -140,36 +140,53 @@ static struct device_type mei_cl_device_type = {
140 .release = mei_cl_dev_release, 140 .release = mei_cl_dev_release,
141}; 141};
142 142
143struct mei_cl_device *mei_cl_add_device(struct mei_device *mei_device, 143static struct mei_cl *mei_bus_find_mei_cl_by_uuid(struct mei_device *dev,
144 uuid_le uuid)
145{
146 struct mei_cl *cl, *next;
147
148 list_for_each_entry_safe(cl, next, &dev->device_list, device_link) {
149 if (!uuid_le_cmp(uuid, cl->device_uuid))
150 return cl;
151 }
152
153 return NULL;
154}
155struct mei_cl_device *mei_cl_add_device(struct mei_device *dev,
144 uuid_le uuid, char *name) 156 uuid_le uuid, char *name)
145{ 157{
146 struct mei_cl_device *device; 158 struct mei_cl_device *device;
159 struct mei_cl *cl;
147 int status; 160 int status;
148 161
162 cl = mei_bus_find_mei_cl_by_uuid(dev, uuid);
163 if (cl == NULL)
164 return NULL;
165
149 device = kzalloc(sizeof(struct mei_cl_device), GFP_KERNEL); 166 device = kzalloc(sizeof(struct mei_cl_device), GFP_KERNEL);
150 if (!device) 167 if (!device)
151 return NULL; 168 return NULL;
152 169
153 device->dev.parent = &mei_device->pdev->dev; 170 device->cl = cl;
171
172 device->dev.parent = &dev->pdev->dev;
154 device->dev.bus = &mei_cl_bus_type; 173 device->dev.bus = &mei_cl_bus_type;
155 device->dev.type = &mei_cl_device_type; 174 device->dev.type = &mei_cl_device_type;
156 175
157 dev_set_name(&device->dev, "%s", name); 176 dev_set_name(&device->dev, "%s", name);
158 177
159 status = device_register(&device->dev); 178 status = device_register(&device->dev);
160 if (status) 179 if (status) {
161 goto out_err; 180 dev_err(&dev->pdev->dev, "Failed to register MEI device\n");
181 kfree(device);
182 return NULL;
183 }
184
185 cl->device = device;
162 186
163 dev_dbg(&device->dev, "client %s registered\n", name); 187 dev_dbg(&device->dev, "client %s registered\n", name);
164 188
165 return device; 189 return device;
166
167out_err:
168 dev_err(device->dev.parent, "Failed to register MEI client\n");
169
170 kfree(device);
171
172 return NULL;
173} 190}
174EXPORT_SYMBOL_GPL(mei_cl_add_device); 191EXPORT_SYMBOL_GPL(mei_cl_add_device);
175 192
@@ -367,9 +384,10 @@ out:
367 384
368int mei_cl_send(struct mei_cl_device *device, u8 *buf, size_t length) 385int mei_cl_send(struct mei_cl_device *device, u8 *buf, size_t length)
369{ 386{
370 struct mei_cl *cl = NULL; 387 struct mei_cl *cl = device->cl;
371 388
372 /* TODO: hook between mei_bus_client and mei_cl */ 389 if (cl == NULL)
390 return -ENODEV;
373 391
374 if (device->ops && device->ops->send) 392 if (device->ops && device->ops->send)
375 return device->ops->send(device, buf, length); 393 return device->ops->send(device, buf, length);
@@ -380,9 +398,10 @@ EXPORT_SYMBOL_GPL(mei_cl_send);
380 398
381int mei_cl_recv(struct mei_cl_device *device, u8 *buf, size_t length) 399int mei_cl_recv(struct mei_cl_device *device, u8 *buf, size_t length)
382{ 400{
383 struct mei_cl *cl = NULL; 401 struct mei_cl *cl = device->cl;
384 402
385 /* TODO: hook between mei_bus_client and mei_cl */ 403 if (cl == NULL)
404 return -ENODEV;
386 405
387 if (device->ops && device->ops->recv) 406 if (device->ops && device->ops->recv)
388 return device->ops->recv(device, buf, length); 407 return device->ops->recv(device, buf, length);