4 * Copyright (C) 2012 Intel Corp
6 * Author: Lan Tianyu <tianyu.lan@intel.com>
8 * This program is free software; you can redistribute it and/or modify
9 * it under the terms of the GNU General Public License version 2 as
10 * published by the Free Software Foundation.
12 * This program is distributed in the hope that it will be useful, but
13 * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
14 * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
21 static void usb_port_device_release(struct device *dev)
23 struct usb_port *port_dev = to_usb_port(dev);
28 struct device_type usb_port_device_type = {
30 .release = usb_port_device_release,
33 int usb_hub_create_port_device(struct usb_hub *hub, int port1)
35 struct usb_port *port_dev = NULL;
38 port_dev = kzalloc(sizeof(*port_dev), GFP_KERNEL);
44 hub->ports[port1 - 1] = port_dev;
45 port_dev->dev.parent = hub->intfdev;
46 port_dev->dev.type = &usb_port_device_type;
47 dev_set_name(&port_dev->dev, "port%d", port1);
49 retval = device_register(&port_dev->dev);
56 put_device(&port_dev->dev);
61 void usb_hub_remove_port_device(struct usb_hub *hub,
64 device_unregister(&hub->ports[port1 - 1]->dev);