Thread (67 messages) 67 messages, 5 authors, 2012-09-12

Re: [PATCH can-next v6] can: add tx/rx LED trigger support

From: Marc Kleine-Budde <mkl@pengutronix.de>
Date: 2012-09-03 12:40:48
Also in: lkml

On 08/25/2012 12:01 AM, Fabio Baltieri wrote:
Hello Kurt,

On Fri, Aug 24, 2012 at 02:42:48PM +0200, Kurt Van Dijck wrote:
quoted
On Fri, Aug 24, 2012 at 01:28:16PM +0200, Marc Kleine-Budde wrote:
quoted
On 08/24/2012 07:10 AM, Kurt Van Dijck wrote:
quoted
Hello,

I find the CAN led triggers an interesting thing.

And then, this scenario fell crossed my mind:
Imagine I do:
[insert CAN device: can0]
$ ip link set can0 name helga
[insert another CAN device: again 'can0']

Registering 'can0-tx' led trigger will fail for the second CAN device,
since that led trigger name is already reserved for CAN device 'helga'.
Good point.
Yep, thanks for pointing that out!

Interface renaming was something I considered when I first wrote the
code and I had the mac80211-led driver in mind, as that driver uses the
phy name and not the netdev one for its triggers.

The reason why I did not care that much in the end is that on SoC based
systems trigger-led association is made at probe time, based on data
either from platform_data or devicetree, so I imagined that once the
kernel is ported to the board and default triggers are set correctly at
boot time, the userspace is free to rename CAN interfaces and nobody
should notice... :^)

The thing I did not consider are hot-plug interfaces mixed with
renaming, such as in the case you pointed out - it's probably not really
common but still possible.
quoted
quoted
quoted
I'm not sure how to fix such.
If 'rx' & 'tx' may be combined, reusing the netdev name may be possible?
Just wild thinking ...
I think the device's name (not netdev) is unique in the system and
cannot be changed.
but may contain several netdev's ...
Ouch.
The net->ifindex is unique. But it's only an integer. Usually can0 has a
ifindex != 0, so a simple can%d is contra productive here.

Some pointers to related code:
http://lxr.free-electrons.com/source/drivers/base/core.c#L1847
http://lxr.free-electrons.com/source/drivers/base/core.c#L73
http://lxr.free-electrons.com/source/include/linux/device.h#L695

comments?

Marc
-- 
Pengutronix e.K.                  | Marc Kleine-Budde           |
Industrial Linux Solutions        | Phone: +49-231-2826-924     |
Vertretung West/Dortmund          | Fax:   +49-5121-206917-5555 |
Amtsgericht Hildesheim, HRA 2686  | http://www.pengutronix.de   |

Attachments

Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help