Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

mfd: core: Fix platform-device id generation

Make sure to always honour multi-function devices registered with
PLATFORM_DEVID_NONE (-1) or PLATFORM_DEVID_AUTO (-2) as id base. In this
case it does not make sense to append the cell id to the mfd-id base and
potentially change the requested behaviour.

Specifically this will allow multi-function devices to be registered
with PLATFORM_DEVID_AUTO while still having non-zero cell ids.

Signed-off-by: Johan Hovold <johan@kernel.org>
Signed-off-by: Lee Jones <lee.jones@linaro.org>

authored by

Johan Hovold and committed by
Lee Jones
6e3f62f0 16b5fe29

+7 -1
+7 -1
drivers/mfd/mfd-core.c
··· 125 125 struct platform_device *pdev; 126 126 struct device_node *np = NULL; 127 127 int ret = -ENOMEM; 128 + int platform_id; 128 129 int r; 129 130 130 - pdev = platform_device_alloc(cell->name, id + cell->id); 131 + if (id < 0) 132 + platform_id = id; 133 + else 134 + platform_id = id + cell->id; 135 + 136 + pdev = platform_device_alloc(cell->name, platform_id); 131 137 if (!pdev) 132 138 goto fail_alloc; 133 139