Re: [RFC PATCH 1/2] serial: 8250: Add a notifier chain for driver registration.
From: Grant Likely <hidden>
Date: 2011-03-17 18:47:28
Also in:
linux-devicetree, lkml
On Thu, Mar 17, 2011 at 11:42:19AM -0700, David Daney wrote:
On 03/17/2011 11:25 AM, Grant Likely wrote:quoted
On Thu, Mar 17, 2011 at 12:18:49PM +0000, Alan Cox wrote:quoted
On Wed, 16 Mar 2011 18:26:06 -0700 David Daney[off-list ref] wrote:quoted
The 8250 driver is a bit weird in that in addition to supporting platform devices, extra devices can be added by calling serial8250_register_port(). The problem is that if we call serial8250_register_port() before the driver is initialized Bad Things happen (we dereference NULL pointers). There doesn't seem to be a general way to know if a driver has been initializedI've had a bigger dig into this. I think the correct answer is probably "always go via platform devices or similar". That *is* the notifier in the kernel of today. serial8250_register_port ultimately should I think ultimatly become an internal helper.+1 Depending on serial8250_register_port() definitely the wrong thing to do for platform support code. It would be better to figure out how to get the dt bits you need into 8250.c or of_serial.c.IMHO, of_serial.c is no better than my board/chip specific code that calls serial8250_register_port(). Really what would be ideal would be a hook to add a dev.platform_data pointer to the appropriate struct plat_serial8250_port when the platform device is created. It is possible that the platform bus notifiers could be used for this. We would also want to have a way to add an of_device_id to those recognized by 8250.c If we did that, serial8250_probe() would automatically do the right thing.
Take a look at the way arch/powerpc/platforms/512x/pdm360ng.c uses a notifier for amending a platform_device with additional data.. g.