Lines Matching refs:hd

24 int gb_hd_output(struct gb_host_device *hd, void *req, u16 size, u8 cmd,
27 if (!hd || !hd->driver || !hd->driver->output)
29 return hd->driver->output(hd, req, size, cmd, async);
36 struct gb_host_device *hd = to_gb_host_device(dev);
38 return sprintf(buf, "%d\n", hd->bus_id);
48 int gb_hd_cport_reserve(struct gb_host_device *hd, u16 cport_id)
50 struct ida *id_map = &hd->cport_id_map;
55 dev_err(&hd->dev, "failed to reserve cport %u\n", cport_id);
63 void gb_hd_cport_release_reserved(struct gb_host_device *hd, u16 cport_id)
65 struct ida *id_map = &hd->cport_id_map;
72 int gb_hd_cport_allocate(struct gb_host_device *hd, int cport_id,
75 struct ida *id_map = &hd->cport_id_map;
78 if (hd->driver->cport_allocate)
79 return hd->driver->cport_allocate(hd, cport_id, flags);
83 ida_end = hd->num_cports - 1;
84 } else if (cport_id < hd->num_cports) {
88 dev_err(&hd->dev, "cport %d not available\n", cport_id);
96 void gb_hd_cport_release(struct gb_host_device *hd, u16 cport_id)
98 if (hd->driver->cport_release) {
99 hd->driver->cport_release(hd, cport_id);
103 ida_free(&hd->cport_id_map, cport_id);
108 struct gb_host_device *hd = to_gb_host_device(dev);
110 trace_gb_hd_release(hd);
112 if (hd->svc)
113 gb_svc_put(hd->svc);
114 ida_free(&gb_hd_bus_id_map, hd->bus_id);
115 ida_destroy(&hd->cport_id_map);
116 kfree(hd);
129 struct gb_host_device *hd;
137 dev_err(parent, "mandatory hd-callbacks missing\n");
161 hd = kzalloc(sizeof(*hd) + driver->hd_priv_size, GFP_KERNEL);
162 if (!hd)
167 kfree(hd);
170 hd->bus_id = ret;
172 hd->driver = driver;
173 INIT_LIST_HEAD(&hd->modules);
174 INIT_LIST_HEAD(&hd->connections);
175 ida_init(&hd->cport_id_map);
176 hd->buffer_size_max = buffer_size_max;
177 hd->num_cports = num_cports;
179 hd->dev.parent = parent;
180 hd->dev.bus = &greybus_bus_type;
181 hd->dev.type = &greybus_hd_type;
182 hd->dev.groups = bus_groups;
183 hd->dev.dma_mask = hd->dev.parent->dma_mask;
184 device_initialize(&hd->dev);
185 dev_set_name(&hd->dev, "greybus%d", hd->bus_id);
187 trace_gb_hd_create(hd);
189 hd->svc = gb_svc_create(hd);
190 if (!hd->svc) {
191 dev_err(&hd->dev, "failed to create svc\n");
192 put_device(&hd->dev);
196 return hd;
200 int gb_hd_add(struct gb_host_device *hd)
204 ret = device_add(&hd->dev);
208 ret = gb_svc_add(hd->svc);
210 device_del(&hd->dev);
214 trace_gb_hd_add(hd);
220 void gb_hd_del(struct gb_host_device *hd)
222 trace_gb_hd_del(hd);
228 gb_svc_del(hd->svc);
230 device_del(&hd->dev);
234 void gb_hd_shutdown(struct gb_host_device *hd)
236 gb_svc_del(hd->svc);
240 void gb_hd_put(struct gb_host_device *hd)
242 put_device(&hd->dev);