Skip to contentSkip to conversation

"status" property checks

DISCUSSION Hollis Blanchard 4 participants 7 messages Jan 7, 2010 – Jan 8, 2010 2 messages not in the archive

lore
Share & tools
lore
#0 lore raw

Right now, a number of drivers honor the "status" property on device nodes (via of_device_is_available() checks), but it's open-coded in each driver. I'm thinking of "hiding" arbitrary devices from the kernel, and setting this property seems like the best approach, but at the moment that would require modifying all OF drivers to check for it.

Wouldn't the better approach be to have of_platform_device_probe() itself do the check, and not call the driver's probe() routine if the device isn't available?

Signature · 2 lines
Hollis Blanchard
Mentor Graphics, Embedded Systems Division
#1 lore raw

I think that is definitely a solution. It does centralize the testing for this particular issue. The only thing question I have is if its really better to have the upper level do the check. Shouldn't the driver itself handle the hardware and device node status?

Quoted 10 lines · Hollis Blanchard

Right now, a number of drivers honor the "status" property on device nodes (via of_device_is_available() checks), but it's open-coded in each driver. I'm thinking of "hiding" arbitrary devices from the kernel, and setting this property seems like the best approach, but at the moment that would require modifying all OF drivers to check for it.

Wouldn't the better approach be to have of_platform_device_probe() itself do the check, and not call the driver's probe() routine if the device isn't available?

#2 lore raw
Quoted 4 lines · Hunter Cobbs

I think that is definitely a solution. It does centralize the testing for this particular issue. The only thing question I have is if its really better to have the upper level do the check. Shouldn't the driver itself handle the hardware and device node status?

Practically speaking, all drivers doing the checks today just return -ENODEV. They don't try to do anything to "handle" the situation.

The definition of the status property implies it's outside of software's control, for example:
"disabled"
"Indicates that the device is not presently operational, but it might become operational in the future (for example, something is not plugged in, or switched off)."

If a device is "not operational" in this sense, I don't think there's anything for a device driver to do.

Signature · 2 lines
Hollis Blanchard
Mentor Graphics, Embedded Systems Division
Quoted 13 lines · Hollis Blanchard
Quoted 10 lines

Right now, a number of drivers honor the "status" property on device nodes (via of_device_is_available() checks), but it's open-coded in each driver. I'm thinking of "hiding" arbitrary devices from the kernel, and setting this property seems like the best approach, but at the moment that would require modifying all OF drivers to check for it.

Wouldn't the better approach be to have of_platform_device_probe() itself do the check, and not call the driver's probe() routine if the device isn't available?

A message that is not in the archive (sent off-list or not yet received): 1262975655.31871.67.camel-bi+AKbBUZKY6gyzm1THtWbp2dZbC/[email protected]

#4 lore raw
Quoted 16 lines · Hollis Blanchard
Quoted 4 lines · Hunter Cobbs

I think that is definitely a solution. It does centralize the testing for this particular issue. The only thing question I have is if its really better to have the upper level do the check. Shouldn't the driver itself handle the hardware and device node status?

Practically speaking, all drivers doing the checks today just return -ENODEV. They don't try to do anything to "handle" the situation.

The definition of the status property implies it's outside of software's control, for example:
"disabled"
"Indicates that the device is not presently operational, but it might become operational in the future (for example, something is not plugged in, or switched off)."

Quoted 2 lines

If a device is "not operational" in this sense, I don't think there's anything for a device driver to do.

I could see situations where there is some software action that could enable the device (e.g. multiple devices sharing pins, where only one can be active at a time) -- but it's likely to not be the driver itself that knows how to do that.

If the need arises, there could be a mechanism where the enabling entity can tell the platform bus that it has enabled a previously-disabled device, overriding the status in the device tree (and likewise if it wants take down a device that was previously enabled).

-Scott

A message that is not in the archive (sent off-list or not yet received): [email protected]

#6 lore raw
Quoted 25 lines · Scott Wood
Quoted 16 lines · Hollis Blanchard
Quoted 4 lines · Hunter Cobbs

I think that is definitely a solution. It does centralize the testing for this particular issue. The only thing question I have is if its really better to have the upper level do the check. Shouldn't the driver itself handle the hardware and device node status?

Practically speaking, all drivers doing the checks today just return -ENODEV. They don't try to do anything to "handle" the situation.

The definition of the status property implies it's outside of software's control, for example:
"disabled"
"Indicates that the device is not presently operational, but it might become operational in the future (for example, something is not plugged in, or switched off)."

Quoted 2 lines

If a device is "not operational" in this sense, I don't think there's anything for a device driver to do.

I could see situations where there is some software action that could enable the device (e.g. multiple devices sharing pins, where only one can be active at a time) -- but it's likely to not be the driver itself that knows how to do that.

Quoted 4 lines

If the need arises, there could be a mechanism where the enabling entity can tell the platform bus that it has enabled a previously-disabled device, overriding the status in the device tree (and likewise if it wants take down a device that was previously enabled).

OK, that makes sense to me. I'll put together a patch for the original idea, and the enable/disable part can come later as needed.

Signature · 2 lines
Hollis Blanchard
Mentor Graphics, Embedded Systems Division
#7 lore raw
Quoted 26 lines · Hollis Blanchard
Quoted 25 lines · Scott Wood
Quoted 16 lines · Hollis Blanchard
Quoted 4 lines · Hunter Cobbs

I think that is definitely a solution. It does centralize the testing for this particular issue. The only thing question I have is if its really better to have the upper level do the check. Shouldn't the driver itself handle the hardware and device node status?

Practically speaking, all drivers doing the checks today just return -ENODEV. They don't try to do anything to "handle" the situation.

The definition of the status property implies it's outside of software's control, for example:
"disabled"
"Indicates that the device is not presently operational, but it might become operational in the future (for example, something is not plugged in, or switched off)."

Quoted 2 lines

If a device is "not operational" in this sense, I don't think there's anything for a device driver to do.

I could see situations where there is some software action that could enable the device (e.g. multiple devices sharing pins, where only one can be active at a time) -- but it's likely to not be the driver itself that knows how to do that.

Quoted 7 lines
Quoted 4 lines

If the need arises, there could be a mechanism where the enabling entity can tell the platform bus that it has enabled a previously-disabled device, overriding the status in the device tree (and likewise if it wants take down a device that was previously enabled).

OK, that makes sense to me. I'll put together a patch for the original idea, and the enable/disable part can come later as needed.

Sounds good to me to. Only thing I'd add, is that I'd also suggest a helper function to do an explicit check on the status property (or do we have that already?). This could be useful for drivers which are bound primarily to one device tree node, but also need to (possibly optionally) check/use some other node.

Signature · 4 lines
David Gibson			| I'll have my music baroque, and my code
david AT gibson.dropbear.id.au	| minimalist, thank you.  NOT _the_ _other_
				| _way_ _around_!
http://www.ozlabs.org/~dgibson
#8 lore raw
Quoted 32 lines · David Gibson
Quoted 31 lines · Hollis Blanchard
Quoted 29 lines · Scott Wood
Quoted 16 lines · Hollis Blanchard
Quoted 4 lines · Hunter Cobbs

I think that is definitely a solution. It does centralize the testing for this particular issue. The only thing question I have is if its really better to have the upper level do the check. Shouldn't the driver itself handle the hardware and device node status?

Practically speaking, all drivers doing the checks today just return -ENODEV. They don't try to do anything to "handle" the situation.

The definition of the status property implies it's outside of software's control, for example:
"disabled"
"Indicates that the device is not presently operational, but it might become operational in the future (for example, something is not plugged in, or switched off)."

Quoted 2 lines

If a device is "not operational" in this sense, I don't think there's anything for a device driver to do.

I could see situations where there is some software action that could enable the device (e.g. multiple devices sharing pins, where only one can be active at a time) -- but it's likely to not be the driver itself that knows how to do that.

If the need arises, there could be a mechanism where the enabling entity can tell the platform bus that it has enabled a previously-disabled device, overriding the status in the device tree (and likewise if it wants take down a device that was previously enabled).

Quoted 8 lines
Quoted 2 lines

OK, that makes sense to me. I'll put together a patch for the original idea, and the enable/disable part can come later as needed.

Sounds good to me to. Only thing I'd add, is that I'd also suggest a helper function to do an explicit check on the status property (or do we have that already?). This could be useful for drivers which are bound primarily to one device tree node, but also need to (possibly optionally) check/use some other node.

of_device_is_available() exists and is used already, so I think we're OK there.

Signature · 2 lines
Hollis Blanchard
Mentor Graphics, Embedded Systems Division