Re: [PATCH] soc: add polarfire soc system controller

From
Arnd Bergmann <arnd@arndb.de>
Date
2021-11-08 15:39:19
Reply to
Conor.Dooley@microchip.com, 2021-11-08
On Mon, Nov 8, 2021 at 4:19 PM [off-list ref] wrote:
On 21/10/2021 19:34, Arnd Bergmann wrote:
quoted
quoted
quoted
quoted
+int mpfs_blocking_transaction(struct mpfs_sys_controller *mpfs_client, void *msg)
+{
+    int ret;
+
+    mutex_lock_interruptible(&transaction_lock);
When you do a mutex_lock_interruptible(), you have to check its return code and
handle the interruption, usually by passing down -EINTR to the caller.
quoted
quoted
quoted
+struct mpfs_sys_controller *
+mpfs_sys_controller_get(struct device_node *mss_node)
+{
+    struct platform_device *pdev = of_find_device_by_node(mss_node);
+
+    if (!pdev)
+            return NULL;
+
+    return platform_get_drvdata(pdev);
+}
+EXPORT_SYMBOL(mpfs_sys_controller_get);
There should probably be a check in here to ensure that this is actually
a system controller and it's bound do this driver, rather than returning a
random device's driver data >
It might also help to make this take a phandle instead of a device node
for lookup, to spare the client the extra phandle to node conversion.
Finally got around to this again, is it sufficient to just check that
platform_get_drvdata returns non null, or should I also check if the
pdev matches the drivers compatible strings? Only found one example of
the latter and a mix of the former & what I had done when I went looking
around at other drivers.
Neither of those helps at all, it could still be a random other device.

I would check that the device is bound to mpfs_sys_controller_driver here,
that should be the easiest way. Looking at it some more, I suspect the
reference counting needs to be improved as well, to ensure that the
device is not going away here. You only hold a reference on the
of_node (which you apparently never release either), but not on the device.

    Arnd

_______________________________________________
linux-riscv mailing list
linux-riscv@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-riscv
Thread (8 messages) 8 messages, 3 authors, last reply 2021-11-08
Keyboard shortcuts
hback out one level
jnext message in thread / next series-diff position
kprevious message in thread / previous series-diff position
ldrill in
Escclose help / fold thread tree
?toggle this help