Re: [PATCH 9 of 20] ipath - char devices for diagnostics and lightweight subnet management

From: Roland Dreier
Date: Fri Mar 10 2006 - 12:05:55 EST


Bryan> OK. What's a safe way to iterate over the devices in the
Bryan> presence of hotplug, then? I assume it's
Bryan> list_for_each_mumble; I just don't know what mumble is :-)

You need something that takes a reference to each device while you're
looking at it, like for_each_pci_dev(). But in general iterating
through devices is usually the wrong thing to do, because devices can
come and go in the middle of your loop. It's better to be driven by
the add and remove callbacks.

Bryan> No, ipath_max is updated any time a probe routine is
Bryan> called.

Yes, that's true. (BTW, what does making ipath_max an atomic_t get
you? The updates are protected by a lock anyway). But I was talking
about the code in ipath_verbs_init(), which is the only place you call
ipath_verbs_register() that I could find. You make one pass through
the devices that are present when ipath_verbs_init() is called at
module load time, and any devices that get added later are missed.

Similarly, if a device is unplugged while the verbs module is loaded,
there's no notification from the core driver of that, and you'll go
ahead and do ipath_verbs_unregister() on a device that is long gone
when you get to ipath_verbs_cleanup().

- R.

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