From ba3198ddb1ee36ff56bcd334bb5bf6f5783ad0cb Mon Sep 17 00:00:00 2001 From: Himateja Reddy Date: Tue, 23 May 2023 14:35:05 -0700 Subject: [PATCH] msm: adsprpc: Fail bus match when device is closing Currently probe is failing if device is closed. Driver registration with device might already be finished, if match is successful, even though probe fails. Fail the bus match when device is closed, so driver does not gets registered with device. Change-Id: I0511c7b3a27ddd4c2cd30d4aea9f961d1f4355d9 Signed-off-by: Himateja Reddy --- dsp/adsprpc.c | 27 ++++++++++++++------------- 1 file changed, 14 insertions(+), 13 deletions(-) diff --git a/dsp/adsprpc.c b/dsp/adsprpc.c index f18a42f724..4158910824 100644 --- a/dsp/adsprpc.c +++ b/dsp/adsprpc.c @@ -8508,32 +8508,33 @@ static struct device fastrpc_bus = { static int fastrpc_bus_match(struct device *dev, struct device_driver *driver) { + struct fastrpc_apps *me = &gfa; struct fastrpc_driver *frpc_driver = to_fastrpc_driver(driver); struct fastrpc_device *frpc_device = to_fastrpc_device(dev); + unsigned long irq_flags = 0; - if (frpc_device->handle == frpc_driver->handle) + if (frpc_device->handle == frpc_driver->handle) { + spin_lock_irqsave(&me->hlock, irq_flags); + /* If device is being closed, fail the match */ + if (frpc_device->dev_close) { + spin_unlock_irqrestore(&me->hlock, irq_flags); + return 0; + } + frpc_device->refs++; + frpc_driver->device = dev; + spin_unlock_irqrestore(&me->hlock, irq_flags); return 1; + } return 0; } static int fastrpc_bus_probe(struct device *dev) { - struct fastrpc_apps *me = &gfa; struct fastrpc_device *frpc_dev = to_fastrpc_device(dev); struct fastrpc_driver *frpc_drv = to_fastrpc_driver(dev->driver); - unsigned long irq_flags = 0; - if (frpc_drv && frpc_drv->probe) { - spin_lock_irqsave(&me->hlock, irq_flags); - if (frpc_dev->dev_close) { - spin_unlock_irqrestore(&me->hlock, irq_flags); - return 0; - } - frpc_dev->refs++; - frpc_drv->device = dev; - spin_unlock_irqrestore(&me->hlock, irq_flags); + if (frpc_drv && frpc_drv->probe) return frpc_drv->probe(frpc_dev); - } return 0; }