Lines Matching full:hd

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