]> git.baikalelectronics.ru Git - kernel.git/commit
MFD: mcp-core: sanitize host creation/removal
authorRussell King <rmk+kernel@arm.linux.org.uk>
Fri, 20 Jan 2012 22:51:07 +0000 (22:51 +0000)
committerRussell King <rmk+kernel@arm.linux.org.uk>
Fri, 3 Feb 2012 17:37:48 +0000 (17:37 +0000)
commit4234b6d789ff5c69a9d4831900615eba8362478a
tree689f82c11f0a1097bbd0e715178f94aa345fcebf
parent33cf8755ed68029a196a978be033f0af4722ee67
MFD: mcp-core: sanitize host creation/removal

host_unregister() gives us no chance between removing the device
and the mcp data structure being freed to access the data inbetween,
which drivers may need to do if they need to iounmap() pointers in
their private data structures.

Therefore, re-jig the interfaces, which are now, on creation:

mcp = mcp_host_alloc()
if (mcp) {
ret = mcp_host_add(mcp, data);

if (!ret)
mcp_host_free(mcp);
}

and on removal:

mcp_host_del(mcp);
... access mcp ...
mcp_host_free(mcp);

The free does the final put_device() on the struct device as one would
expect.

Acked-by: Jochen Friedrich <jochen@scram.de>
Signed-off-by: Russell King <rmk+kernel@arm.linux.org.uk>
drivers/mfd/mcp-core.c
drivers/mfd/mcp-sa11x0.c
include/linux/mfd/mcp.h