Re: [PATCH 4/4] usb: register usb port to usb_bus_type

2013-03-28 Thread Greg KH
On Thu, Mar 28, 2013 at 01:11:04AM +0800, Lan Tianyu wrote:
 Usb port isn't assigned to any bus_type. This seems not good from
 Greg's comments.
   http://marc.info/?l=linux-usbm=136200364929942w=2
 
 This patch is to register usb port to usb_bus_type. The usb port's
 original name is portX. This will cause name confilct after adding
 usb port to usb_bus_type since the usb ports with same port num under
 different hub have the same name. So change the usb port's name format
 to port + (hub dev name) + '.' + (port num) for non-root hub and
 port + (usb bus num) + '-' + (port num) for root hub.
 
 ls /sys/bus/usb/devices
 1-0:1.02-0:1.0  port1-1  port1-1.3  port2-1.2  port2-2  port4-3
 1-12-1  port1-1.1port1-1.4  port2-1.3  port3-1  port4-4
 1-1.1  2-1:1.0  port1-1.2port1-1.5  port2-1.4  port3-2  usb1
 1-1:1.03-0:1.0  port1-1.2.1  port1-1.6  port2-1.5  port3-3  usb2
 1-1.1:1.0  3-1  port1-1.2.2  port1-2port2-1.6  port3-4  usb3
 1-1.2  3-1:1.0  port1-1.2.3  port2-1port2-1.7  port4-1  usb4
 1-1.2:1.0  4-0:1.0  port1-1.2.4  port2-1.1  port2-1.8  port4-2

What does it look like if you reverse the naming scheme (hub dev name +
port)?  Doesn't that show the devices in a bit more logical way?

thanks,

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


Re: [PATCH 4/4] usb: register usb port to usb_bus_type

2013-03-28 Thread Greg KH
On Fri, Mar 29, 2013 at 02:17:02AM +0800, Lan Tianyu wrote:
 On 2013/3/29 1:59, Greg KH wrote:
 On Thu, Mar 28, 2013 at 01:11:04AM +0800, Lan Tianyu wrote:
 Usb port isn't assigned to any bus_type. This seems not good from
 Greg's comments.
 http://marc.info/?l=linux-usbm=136200364929942w=2
 
 This patch is to register usb port to usb_bus_type. The usb port's
 original name is portX. This will cause name confilct after adding
 usb port to usb_bus_type since the usb ports with same port num under
 different hub have the same name. So change the usb port's name format
 to port + (hub dev name) + '.' + (port num) for non-root hub and
 port + (usb bus num) + '-' + (port num) for root hub.
 
 ls /sys/bus/usb/devices
 1-0:1.02-0:1.0  port1-1  port1-1.3  port2-1.2  port2-2  port4-3
 1-12-1  port1-1.1port1-1.4  port2-1.3  port3-1  port4-4
 1-1.1  2-1:1.0  port1-1.2port1-1.5  port2-1.4  port3-2  usb1
 1-1:1.03-0:1.0  port1-1.2.1  port1-1.6  port2-1.5  port3-3  usb2
 1-1.1:1.0  3-1  port1-1.2.2  port1-2port2-1.6  port3-4  usb3
 1-1.2  3-1:1.0  port1-1.2.3  port2-1port2-1.7  port4-1  usb4
 1-1.2:1.0  4-0:1.0  port1-1.2.4  port2-1.1  port2-1.8  port4-2
 
 What does it look like if you reverse the naming scheme (hub dev name +
 port)?  Doesn't that show the devices in a bit more logical way?
 Hi Greg:
   Do you mean e.g port1.2-1, originally it's port2-1.1.
 2-1 is hub dev name?

No, I mean 2-1.port1 as these are the ports on the device, the device
prefix should go first, right?

   If right, how about root hub port and it should be port2.usb1?

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


Re: [PATCH 4/4] usb: register usb port to usb_bus_type

2013-03-28 Thread Lan Tianyu

On 2013/3/29 2:21, Greg KH wrote:

What does it look like if you reverse the naming scheme (hub dev name +
port)?  Doesn't that show the devices in a bit more logical way?

Hi Greg:
Do you mean e.g port1.2-1, originally it's port2-1.1.
2-1 is hub dev name?


No, I mean 2-1.port1 as these are the ports on the device, the device
prefix should go first, right?


If right, how about root hub port and it should be port2.usb1?


usb1.port2

Ok. I get it. Yes, this looks more logical. Thanks. Will refresh soon.




--
Best Regards
Tianyu Lan
linux kernel enabling team
--
To unsubscribe from this list: send the line unsubscribe linux-usb in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH 4/4] usb: register usb port to usb_bus_type

2013-03-28 Thread Alan Stern
On Thu, 28 Mar 2013, Greg KH wrote:

  ls /sys/bus/usb/devices
  1-0:1.02-0:1.0  port1-1  port1-1.3  port2-1.2  port2-2  port4-3
  1-12-1  port1-1.1port1-1.4  port2-1.3  port3-1  port4-4
  1-1.1  2-1:1.0  port1-1.2port1-1.5  port2-1.4  port3-2  usb1
  1-1:1.03-0:1.0  port1-1.2.1  port1-1.6  port2-1.5  port3-3  usb2
  1-1.1:1.0  3-1  port1-1.2.2  port1-2port2-1.6  port3-4  usb3
  1-1.2  3-1:1.0  port1-1.2.3  port2-1port2-1.7  port4-1  usb4
  1-1.2:1.0  4-0:1.0  port1-1.2.4  port2-1.1  port2-1.8  port4-2
  
  What does it look like if you reverse the naming scheme (hub dev name +
  port)?  Doesn't that show the devices in a bit more logical way?
  Hi Greg:
  Do you mean e.g port1.2-1, originally it's port2-1.1.
  2-1 is hub dev name?
 
 No, I mean 2-1.port1 as these are the ports on the device, the device
 prefix should go first, right?
 
  If right, how about root hub port and it should be port2.usb1?
 
 usb1.port2

Is this a good idea?  There are userspace programs that look through
the list of files in /sys/bus/usb/devices, and they probably expect
filenames beginning with a number or with 'usb' to be USB devices and
interfaces.

Alan Stern

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


Re: [PATCH 4/4] usb: register usb port to usb_bus_type

2013-03-28 Thread Greg KH
On Thu, Mar 28, 2013 at 02:44:01PM -0400, Alan Stern wrote:
 On Thu, 28 Mar 2013, Greg KH wrote:
 
   ls /sys/bus/usb/devices
   1-0:1.02-0:1.0  port1-1  port1-1.3  port2-1.2  port2-2  port4-3
   1-12-1  port1-1.1port1-1.4  port2-1.3  port3-1  port4-4
   1-1.1  2-1:1.0  port1-1.2port1-1.5  port2-1.4  port3-2  usb1
   1-1:1.03-0:1.0  port1-1.2.1  port1-1.6  port2-1.5  port3-3  usb2
   1-1.1:1.0  3-1  port1-1.2.2  port1-2port2-1.6  port3-4  usb3
   1-1.2  3-1:1.0  port1-1.2.3  port2-1port2-1.7  port4-1  usb4
   1-1.2:1.0  4-0:1.0  port1-1.2.4  port2-1.1  port2-1.8  port4-2
   
   What does it look like if you reverse the naming scheme (hub dev name +
   port)?  Doesn't that show the devices in a bit more logical way?
   Hi Greg:
 Do you mean e.g port1.2-1, originally it's port2-1.1.
   2-1 is hub dev name?
  
  No, I mean 2-1.port1 as these are the ports on the device, the device
  prefix should go first, right?
  
 If right, how about root hub port and it should be port2.usb1?
  
  usb1.port2
 
 Is this a good idea?  There are userspace programs that look through
 the list of files in /sys/bus/usb/devices, and they probably expect
 filenames beginning with a number or with 'usb' to be USB devices and
 interfaces.

What userspace programs?

And if they do that, then we shouldn't put the ports in here at all.

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


Re: [PATCH 4/4] usb: register usb port to usb_bus_type

2013-03-28 Thread Lan Tianyu

On 2013/3/29 2:44, Alan Stern wrote:

On Thu, 28 Mar 2013, Greg KH wrote:


ls /sys/bus/usb/devices
1-0:1.02-0:1.0  port1-1  port1-1.3  port2-1.2  port2-2  port4-3
1-12-1  port1-1.1port1-1.4  port2-1.3  port3-1  port4-4
1-1.1  2-1:1.0  port1-1.2port1-1.5  port2-1.4  port3-2  usb1
1-1:1.03-0:1.0  port1-1.2.1  port1-1.6  port2-1.5  port3-3  usb2
1-1.1:1.0  3-1  port1-1.2.2  port1-2port2-1.6  port3-4  usb3
1-1.2  3-1:1.0  port1-1.2.3  port2-1port2-1.7  port4-1  usb4
1-1.2:1.0  4-0:1.0  port1-1.2.4  port2-1.1  port2-1.8  port4-2


What does it look like if you reverse the naming scheme (hub dev name +
port)?  Doesn't that show the devices in a bit more logical way?

Hi Greg:
Do you mean e.g port1.2-1, originally it's port2-1.1.
2-1 is hub dev name?


No, I mean 2-1.port1 as these are the ports on the device, the device
prefix should go first, right?


If right, how about root hub port and it should be port2.usb1?


usb1.port2


Is this a good idea?  There are userspace programs that look through
the list of files in /sys/bus/usb/devices, and they probably expect
filenames beginning with a number or with 'usb' to be USB devices and

After updating

ls /sys/bus/usb/devices
1-0:1.0  1-1.1:1.0  1-1.4  1-1.port3  2-1:1.02-1.6  2-1.port2  
2-1.port6  usb1.port1  usb2.port1  usb3.port1  usb4 usb4.port4
1-1  1-1.1:1.1  1-1.4:1.0  1-1.port4  2-1.5  2-1.6:1.0 2-1.port3  
3-0:1.0usb1.port2  usb2.port2  usb3.port2  usb4.port1
1-1.11-1.2  1-1.port1  2-0:1.02-1.5:1.0  2-1.6:1.1 2-1.port4  
4-0:1.0usb1.port3  usb2.port3  usb3.port3  usb4.port2
1-1:1.0  1-1.2:1.0  1-1.port2  2-12-1.5:1.1  2-1.port1 2-1.port5  usb1  
 usb2usb3usb3.port4  usb4.port3

interfaces.

Alan Stern



--
Best Regards
Tianyu Lan
linux kernel enabling team
--
To unsubscribe from this list: send the line unsubscribe linux-usb in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH 4/4] usb: register usb port to usb_bus_type

2013-03-28 Thread Lan Tianyu

On 2013/3/29 2:53, Greg KH wrote:

On Thu, Mar 28, 2013 at 02:44:01PM -0400, Alan Stern wrote:

On Thu, 28 Mar 2013, Greg KH wrote:


ls /sys/bus/usb/devices
1-0:1.02-0:1.0  port1-1  port1-1.3  port2-1.2  port2-2  port4-3
1-12-1  port1-1.1port1-1.4  port2-1.3  port3-1  port4-4
1-1.1  2-1:1.0  port1-1.2port1-1.5  port2-1.4  port3-2  usb1
1-1:1.03-0:1.0  port1-1.2.1  port1-1.6  port2-1.5  port3-3  usb2
1-1.1:1.0  3-1  port1-1.2.2  port1-2port2-1.6  port3-4  usb3
1-1.2  3-1:1.0  port1-1.2.3  port2-1port2-1.7  port4-1  usb4
1-1.2:1.0  4-0:1.0  port1-1.2.4  port2-1.1  port2-1.8  port4-2


What does it look like if you reverse the naming scheme (hub dev name +
port)?  Doesn't that show the devices in a bit more logical way?

Hi Greg:
Do you mean e.g port1.2-1, originally it's port2-1.1.
2-1 is hub dev name?


No, I mean 2-1.port1 as these are the ports on the device, the device
prefix should go first, right?


If right, how about root hub port and it should be port2.usb1?


usb1.port2


Is this a good idea?  There are userspace programs that look through
the list of files in /sys/bus/usb/devices, and they probably expect
filenames beginning with a number or with 'usb' to be USB devices and
interfaces.


What userspace programs?

And if they do that, then we shouldn't put the ports in here at all.

This means usb port should be assigned to usb_bus_type.
How about creating a usb_port class and assign usb port devices to it?
ATA layer does something like this.


greg k-h



--
Best Regards
Tianyu Lan
linux kernel enabling team
--
To unsubscribe from this list: send the line unsubscribe linux-usb in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH 4/4] usb: register usb port to usb_bus_type

2013-03-28 Thread Alan Stern
On Thu, 28 Mar 2013, Greg KH wrote:

 On Thu, Mar 28, 2013 at 02:44:01PM -0400, Alan Stern wrote:
  On Thu, 28 Mar 2013, Greg KH wrote:
  
ls /sys/bus/usb/devices
1-0:1.02-0:1.0  port1-1  port1-1.3  port2-1.2  port2-2  
port4-3
1-12-1  port1-1.1port1-1.4  port2-1.3  port3-1  
port4-4
1-1.1  2-1:1.0  port1-1.2port1-1.5  port2-1.4  port3-2  usb1
1-1:1.03-0:1.0  port1-1.2.1  port1-1.6  port2-1.5  port3-3  usb2
1-1.1:1.0  3-1  port1-1.2.2  port1-2port2-1.6  port3-4  usb3
1-1.2  3-1:1.0  port1-1.2.3  port2-1port2-1.7  port4-1  usb4
1-1.2:1.0  4-0:1.0  port1-1.2.4  port2-1.1  port2-1.8  port4-2

What does it look like if you reverse the naming scheme (hub dev name +
port)?  Doesn't that show the devices in a bit more logical way?
Hi Greg:
Do you mean e.g port1.2-1, originally it's port2-1.1.
2-1 is hub dev name?
   
   No, I mean 2-1.port1 as these are the ports on the device, the device
   prefix should go first, right?
   
If right, how about root hub port and it should be port2.usb1?
   
   usb1.port2
  
  Is this a good idea?  There are userspace programs that look through
  the list of files in /sys/bus/usb/devices, and they probably expect
  filenames beginning with a number or with 'usb' to be USB devices and
  interfaces.
 
 What userspace programs?

In the past I have answered questions from people wanting to know how
to write a program that could go from bus  device numbers to paths in
sysfs.  The answer was to look at all the links in /sys/bus/usb/devices
for names beginning with a digit or with usb, eliminate those whose
names contain ':' as they are interfaces rather than devices, and then
check the busnum and devnum files in each of the remaining directories.

Also, libusb/libusbx uses a similar scheme to search through the
entries in /sys/bus/usb/devices, looking for parent-child
relationships.

 And if they do that, then we shouldn't put the ports in here at all.

This is one of those cloudy issues.  We're probably okay if the name 
begins with something other than a digit or a 'u'.

Alan Stern

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


Re: [PATCH 4/4] usb: register usb port to usb_bus_type

2013-03-28 Thread Greg KH
On Fri, Mar 29, 2013 at 03:08:17AM +0800, Lan Tianyu wrote:
 On 2013/3/29 2:53, Greg KH wrote:
 On Thu, Mar 28, 2013 at 02:44:01PM -0400, Alan Stern wrote:
 On Thu, 28 Mar 2013, Greg KH wrote:
 
 ls /sys/bus/usb/devices
 1-0:1.02-0:1.0  port1-1  port1-1.3  port2-1.2  port2-2  port4-3
 1-12-1  port1-1.1port1-1.4  port2-1.3  port3-1  port4-4
 1-1.1  2-1:1.0  port1-1.2port1-1.5  port2-1.4  port3-2  usb1
 1-1:1.03-0:1.0  port1-1.2.1  port1-1.6  port2-1.5  port3-3  usb2
 1-1.1:1.0  3-1  port1-1.2.2  port1-2port2-1.6  port3-4  usb3
 1-1.2  3-1:1.0  port1-1.2.3  port2-1port2-1.7  port4-1  usb4
 1-1.2:1.0  4-0:1.0  port1-1.2.4  port2-1.1  port2-1.8  port4-2
 
 What does it look like if you reverse the naming scheme (hub dev name +
 port)?  Doesn't that show the devices in a bit more logical way?
 Hi Greg:
   Do you mean e.g port1.2-1, originally it's port2-1.1.
 2-1 is hub dev name?
 
 No, I mean 2-1.port1 as these are the ports on the device, the device
 prefix should go first, right?
 
   If right, how about root hub port and it should be port2.usb1?
 
 usb1.port2
 
 Is this a good idea?  There are userspace programs that look through
 the list of files in /sys/bus/usb/devices, and they probably expect
 filenames beginning with a number or with 'usb' to be USB devices and
 interfaces.
 
 What userspace programs?
 
 And if they do that, then we shouldn't put the ports in here at all.
 This means usb port should be assigned to usb_bus_type.
 How about creating a usb_port class and assign usb port devices to it?
 ATA layer does something like this.

Make it a bus_type and that will be fine with me (we are trying to keep
the spread of new classes down wherever possible, although for something
like this maybe it does make sense...)

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


Re: [PATCH 4/4] usb: register usb port to usb_bus_type

2013-03-28 Thread Greg KH
On Thu, Mar 28, 2013 at 03:16:08PM -0400, Alan Stern wrote:
 On Thu, 28 Mar 2013, Greg KH wrote:
 
  On Thu, Mar 28, 2013 at 02:44:01PM -0400, Alan Stern wrote:
   On Thu, 28 Mar 2013, Greg KH wrote:
   
 ls /sys/bus/usb/devices
 1-0:1.02-0:1.0  port1-1  port1-1.3  port2-1.2  port2-2  
 port4-3
 1-12-1  port1-1.1port1-1.4  port2-1.3  port3-1  
 port4-4
 1-1.1  2-1:1.0  port1-1.2port1-1.5  port2-1.4  port3-2  usb1
 1-1:1.03-0:1.0  port1-1.2.1  port1-1.6  port2-1.5  port3-3  usb2
 1-1.1:1.0  3-1  port1-1.2.2  port1-2port2-1.6  port3-4  usb3
 1-1.2  3-1:1.0  port1-1.2.3  port2-1port2-1.7  port4-1  usb4
 1-1.2:1.0  4-0:1.0  port1-1.2.4  port2-1.1  port2-1.8  port4-2
 
 What does it look like if you reverse the naming scheme (hub dev 
 name +
 port)?  Doesn't that show the devices in a bit more logical way?
 Hi Greg:
   Do you mean e.g port1.2-1, originally it's port2-1.1.
 2-1 is hub dev name?

No, I mean 2-1.port1 as these are the ports on the device, the device
prefix should go first, right?

   If right, how about root hub port and it should be port2.usb1?

usb1.port2
   
   Is this a good idea?  There are userspace programs that look through
   the list of files in /sys/bus/usb/devices, and they probably expect
   filenames beginning with a number or with 'usb' to be USB devices and
   interfaces.
  
  What userspace programs?
 
 In the past I have answered questions from people wanting to know how
 to write a program that could go from bus  device numbers to paths in
 sysfs.  The answer was to look at all the links in /sys/bus/usb/devices
 for names beginning with a digit or with usb, eliminate those whose
 names contain ':' as they are interfaces rather than devices, and then
 check the busnum and devnum files in each of the remaining directories.
 
 Also, libusb/libusbx uses a similar scheme to search through the
 entries in /sys/bus/usb/devices, looking for parent-child
 relationships.

Ok, then we can't put them in this class, it will have to be separate or
things will break.

Has anyone tried this patch with libusb?

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


Re: [PATCH 4/4] usb: register usb port to usb_bus_type

2013-03-28 Thread Sarah Sharp
On Thu, Mar 28, 2013 at 03:56:17PM -0700, Greg KH wrote:
 Has anyone tried this patch with libusb?

At this point, I don't know if it has tested with libusb or even lsusb.
I didn't see this patch until today, and I have not tested it on the
Intel platform that actually implements the port power off mechanism.

I have to NAK this patchset until I can test it.  In the future, Greg,
please don't take any patches that touch the port power off code unless
it comes through my tree.  We really need to make sure this gets tested,
since it has the potential to cause dead ports.

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


[PATCH 4/4] usb: register usb port to usb_bus_type

2013-03-27 Thread Lan Tianyu
Usb port isn't assigned to any bus_type. This seems not good from
Greg's comments.
http://marc.info/?l=linux-usbm=136200364929942w=2

This patch is to register usb port to usb_bus_type. The usb port's
original name is portX. This will cause name confilct after adding
usb port to usb_bus_type since the usb ports with same port num under
different hub have the same name. So change the usb port's name format
to port + (hub dev name) + '.' + (port num) for non-root hub and
port + (usb bus num) + '-' + (port num) for root hub.

ls /sys/bus/usb/devices
1-0:1.02-0:1.0  port1-1  port1-1.3  port2-1.2  port2-2  port4-3
1-12-1  port1-1.1port1-1.4  port2-1.3  port3-1  port4-4
1-1.1  2-1:1.0  port1-1.2port1-1.5  port2-1.4  port3-2  usb1
1-1:1.03-0:1.0  port1-1.2.1  port1-1.6  port2-1.5  port3-3  usb2
1-1.1:1.0  3-1  port1-1.2.2  port1-2port2-1.6  port3-4  usb3
1-1.2  3-1:1.0  port1-1.2.3  port2-1port2-1.7  port4-1  usb4
1-1.2:1.0  4-0:1.0  port1-1.2.4  port2-1.1  port2-1.8  port4-2

Signed-off-by: Lan Tianyu tianyu@intel.com
---
 Documentation/ABI/testing/sysfs-bus-usb |6 +++---
 drivers/usb/core/port.c |   10 +-
 drivers/usb/core/usb-acpi.c |7 +--
 3 files changed, 17 insertions(+), 6 deletions(-)

diff --git a/Documentation/ABI/testing/sysfs-bus-usb 
b/Documentation/ABI/testing/sysfs-bus-usb
index c8baaf5..842e8b8 100644
--- a/Documentation/ABI/testing/sysfs-bus-usb
+++ b/Documentation/ABI/testing/sysfs-bus-usb
@@ -221,14 +221,14 @@ Description:
The file will be present for all speeds of USB devices, and will
always read no for USB 1.1 and USB 2.0 devices.
 
-What:  /sys/bus/usb/devices/.../(hub interface)/portX
+What:  /sys/bus/usb/devices/.../(hub interface)/portX-X
 Date:  August 2012
 Contact:   Lan Tianyu tianyu@intel.com
 Description:
-   The /sys/bus/usb/devices/.../(hub interface)/portX
+   The /sys/bus/usb/devices/.../(hub interface)/portX-X
is usb port device's sysfs directory.
 
-What:  /sys/bus/usb/devices/.../(hub interface)/portX/connect_type
+What:  /sys/bus/usb/devices/.../(hub interface)/portX-X/connect_type
 Date:  January 2013
 Contact:   Lan Tianyu tianyu@intel.com
 Description:
diff --git a/drivers/usb/core/port.c b/drivers/usb/core/port.c
index f14fc72..2c086dc 100644
--- a/drivers/usb/core/port.c
+++ b/drivers/usb/core/port.c
@@ -198,6 +198,7 @@ struct device_type usb_port_device_type = {
 int usb_hub_create_port_device(struct usb_hub *hub, int port1)
 {
struct usb_port *port_dev = NULL;
+   struct usb_device *hdev = hub-hdev;
int retval;
 
port_dev = kzalloc(sizeof(*port_dev), GFP_KERNEL);
@@ -212,7 +213,14 @@ int usb_hub_create_port_device(struct usb_hub *hub, int 
port1)
port_dev-dev.parent = hub-intfdev;
port_dev-dev.groups = port_dev_group;
port_dev-dev.type = usb_port_device_type;
-   dev_set_name(port_dev-dev, port%d, port1);
+   port_dev-dev.bus = usb_bus_type;
+
+   if (!hdev-parent)
+   dev_set_name(port_dev-dev, port%d-%d,
+   hdev-bus-busnum, port1);
+   else
+   dev_set_name(port_dev-dev, port%s.%d,
+   dev_name(hdev-dev), port1);
 
retval = device_register(port_dev-dev);
if (retval)
diff --git a/drivers/usb/core/usb-acpi.c b/drivers/usb/core/usb-acpi.c
index b6f4bad..1cc55c9 100644
--- a/drivers/usb/core/usb-acpi.c
+++ b/drivers/usb/core/usb-acpi.c
@@ -17,7 +17,7 @@
 #include linux/pci.h
 #include acpi/acpi_bus.h
 
-#include usb.h
+#include hub.h
 
 /**
  * usb_acpi_power_manageable - check whether usb port has
@@ -178,7 +178,10 @@ static int usb_acpi_find_device(struct device *dev, 
acpi_handle *handle)
return -ENODEV;
return 0;
} else if (is_usb_port(dev)) {
-   sscanf(dev_name(dev), port%d, port_num);
+   struct usb_port *port_dev = to_usb_port(dev);
+
+   port_num = port_dev-portnum;
+
/* Get the struct usb_device point of port's hub */
udev = to_usb_device(dev-parent-parent);
 
-- 
1.7.9.5

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


Re: [PATCH 4/4] usb: register usb port to usb_bus_type

2013-03-27 Thread Alan Stern
On Thu, 28 Mar 2013, Lan Tianyu wrote:

 Usb port isn't assigned to any bus_type. This seems not good from
 Greg's comments.
   http://marc.info/?l=linux-usbm=136200364929942w=2
 
 This patch is to register usb port to usb_bus_type. The usb port's
 original name is portX. This will cause name confilct after adding
 usb port to usb_bus_type since the usb ports with same port num under
 different hub have the same name. So change the usb port's name format
 to port + (hub dev name) + '.' + (port num) for non-root hub and
 port + (usb bus num) + '-' + (port num) for root hub.
 
 ls /sys/bus/usb/devices
 1-0:1.02-0:1.0  port1-1  port1-1.3  port2-1.2  port2-2  port4-3
 1-12-1  port1-1.1port1-1.4  port2-1.3  port3-1  port4-4
 1-1.1  2-1:1.0  port1-1.2port1-1.5  port2-1.4  port3-2  usb1
 1-1:1.03-0:1.0  port1-1.2.1  port1-1.6  port2-1.5  port3-3  usb2
 1-1.1:1.0  3-1  port1-1.2.2  port1-2port2-1.6  port3-4  usb3
 1-1.2  3-1:1.0  port1-1.2.3  port2-1port2-1.7  port4-1  usb4
 1-1.2:1.0  4-0:1.0  port1-1.2.4  port2-1.1  port2-1.8  port4-2
 
 Signed-off-by: Lan Tianyu tianyu@intel.com

This ends up looking like a mess, but I guess there's no way around it.

Acked-by: Alan Stern st...@rowland.harvard.edu

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