Thread (26 messages) 26 messages, 6 authors, 2017-08-16

Re: [RFC v2 5/6] max9260: add driver for i2c over GMSL passthrough

From: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Date: 2017-08-16 13:30:21
Also in: linux-i2c, linux-renesas-soc

Hi Ulrich,

On Wednesday 16 Aug 2017 15:23:27 Ulrich Hecht wrote:
On Mon, Jul 31, 2017 at 1:13 PM, Laurent Pinchart wrote:
quoted
quoted
+static int max9260_probe(struct serdev_device *serdev)
+{
+     struct max9260_device *dev;
+     struct i2c_adapter *adap;
+     int ret;
+
+     dev = kzalloc(sizeof(*dev), GFP_KERNEL);
+     if (!dev)
+             return -ENOMEM;
+
+     init_waitqueue_head(&dev->rx_wq);
+
+     dev->serdev = serdev;
+     serdev_device_open(serdev);
+     serdev_device_set_drvdata(serdev, dev);
+
+     serdev_device_set_client_ops(serdev, &max9260_serdev_client_ops);
+
+     ret = max9260_setup(dev);
+     if (ret < 0)
+             goto err_free;
+
+     adap = &dev->adap;
+     i2c_set_adapdata(adap, dev);
+
+     adap->owner = THIS_MODULE;
+     adap->algo = &max9260_i2c_algorithm;
+     adap->dev.parent = &serdev->dev;
+     adap->retries = 5;
+     strlcpy(adap->name, dev_name(&serdev->dev), sizeof(adap->name));
+
+     ret = i2c_add_adapter(adap);
+     if (ret < 0)
+             return ret;
+
+     return 0;
+
+err_free:
No need for a serdev_device_close() ?
serdev_device_{open,close}() actually operate on the controller, so
that would pull the rug from under the other devices connected to that
controller.
My point is that you call open in the .probe() handler and close in the 
.remove() handler. If open needs to be balanced by close, it seems to me that 
you should also call close in the error path.

-- 
Regards,

Laurent Pinchart
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help