提交 4ae078d5 编写于 作者: R Russell King 提交者: Greg Kroah-Hartman

imx-drm: ipu-v3: fix potential CRTC device registration race

Clean up the IPUv3 CRTC device registration; we don't need a separate
function just to call platform_device_register_data(), and we don't
need the return value converted at all.

Update the IPU client id under a mutex, so that parallel probing
doesn't race.
Signed-off-by: NRussell King <rmk+kernel@arm.linux.org.uk>
Acked-by: NSascha Hauer <s.hauer@pengutronix.de>
Signed-off-by: NGreg Kroah-Hartman <gregkh@linuxfoundation.org>
上级 8007875f
...@@ -996,35 +996,35 @@ static const struct ipu_platform_reg client_reg[] = { ...@@ -996,35 +996,35 @@ static const struct ipu_platform_reg client_reg[] = {
}, },
}; };
static DEFINE_MUTEX(ipu_client_id_mutex);
static int ipu_client_id; static int ipu_client_id;
static int ipu_add_subdevice_pdata(struct device *dev,
const struct ipu_platform_reg *reg)
{
struct platform_device *pdev;
pdev = platform_device_register_data(dev, reg->name, ipu_client_id++,
&reg->pdata, sizeof(struct ipu_platform_reg));
return PTR_ERR_OR_ZERO(pdev);
}
static int ipu_add_client_devices(struct ipu_soc *ipu) static int ipu_add_client_devices(struct ipu_soc *ipu)
{ {
int ret; struct device *dev = ipu->dev;
int i; unsigned i;
int id, ret;
mutex_lock(&ipu_client_id_mutex);
id = ipu_client_id;
ipu_client_id += ARRAY_SIZE(client_reg);
mutex_unlock(&ipu_client_id_mutex);
for (i = 0; i < ARRAY_SIZE(client_reg); i++) { for (i = 0; i < ARRAY_SIZE(client_reg); i++) {
const struct ipu_platform_reg *reg = &client_reg[i]; const struct ipu_platform_reg *reg = &client_reg[i];
ret = ipu_add_subdevice_pdata(ipu->dev, reg); struct platform_device *pdev;
if (ret)
pdev = platform_device_register_data(dev, reg->name,
id++, &reg->pdata, sizeof(reg->pdata));
if (IS_ERR(pdev))
goto err_register; goto err_register;
} }
return 0; return 0;
err_register: err_register:
platform_device_unregister_children(to_platform_device(ipu->dev)); platform_device_unregister_children(to_platform_device(dev));
return ret; return ret;
} }
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册