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: Russell King <rmk+kernel@arm.linux.org.uk> Acked-by: Sascha Hauer <s.hauer@pengutronix.de> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
This commit is contained in:
parent
8007875f06
commit
4ae078d58a
|
@ -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++,
|
|
||||||
®->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++, ®->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;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue