Re: [PATCH V5 3/8] usb: move children to struct usb_port

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Fri, 29 Jun 2012, Lan Tianyu wrote:

> Change since v4: remove usb_get_dev() in the usb_hub_get_child().
> rename usb_get_hub_xxx() to usb_hub_get_xxx(). Add hdev->maxchild check
> in the hdev_to_hub().
> 
> Move child's pointer to the struct usb_port since the child device
> is directly associated with the port. Provide usb_hub_get_child()
> to get child's pointer and macrio macro usb_hub_get_each_child to
> iterate all child devices on the hub.
> 
> Signed-off-by: Lan Tianyu <tianyu.lan@xxxxxxxxx>

One little thing...

> +/**
> + * usb_hub_get_child - Get the pointer of child device
> + * attached to the port which is specified by @port1.
> + * @hdev: USB device belonging to the usb hub
> + * @port1: port num to indicate which port the child device
> + *	is attached to.
> + *
> + * USB drivers call this function to get hub's child device
> + * pointer.
> + *
> + * Return NULL if input param is invalid and
> + * child's usb_device pointer if non-NULL.
> + */
> +struct usb_device *usb_hub_get_child(struct usb_device *hdev,
> +		int port1)
> +{
> +	struct usb_hub *hub = hdev_to_hub(hdev);
> +
> +	if (port1 < 1 || port1 > hdev->maxchild)
> +		return NULL;
> +	return hub->ports[port1 - 1]->child;
> +}

Now that this function doesn't take a reference to the child device, it 
shouldn't have "get" in its name.  How about "usb_hub_find_child"?

> +/**
> + * usb_hub_get_each_child - iterate over all child devices on the hub
> + * @hdev:  USB device belonging to the usb hub
> + * @port1: portnum associated with child device
> + * @child: child device pointer
> + *
> + */
> +#define usb_hub_get_each_child(hdev, port1, child) \
> +	for (port1 = 1,	child =	usb_hub_get_child(hdev, port1); \
> +		port1 <= hdev->maxchild; \
> +		child = usb_hub_get_child(hdev, ++port1))

Similarly, this could be "usb_hub_for_each_child".

Alan Stern

--
To unsubscribe from this list: send the line "unsubscribe linux-usb" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[Index of Archives]     [Linux Media]     [Linux Input]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]     [Old Linux USB Devel Archive]

  Powered by Linux