Re: [PATCH 1/3] regmap: Add OneWire (W1) bus support
From: Alex A. Mihaylov
Date: Mon May 29 2017 - 12:38:09 EST
29.05.17 16:13, Mark Brown ÐÐÑÐÑ:
+ int ret = -ENODEV;
+
+ mutex_lock(&sl->master->bus_mutex);
+ if (!w1_reset_select_slave(sl)) {
+ w1_write_8(sl->master, W1_CMD_READ_DATA);
+ w1_write_8(sl->master, reg);
+ *val = w1_read_8(sl->master);
+ ret = 0;
+ }
I asked you to move the error handling into the else case in these :(
Why do you want to see exactly the construction of if/else?
I already wrote that for me this will worsen the quality and
understanding of the code. And another point - in fact it is not an
error handler. This is a completely normal and permissible situation.
There is no "disconnect" event for this bus, and consequently at any
arbitrary time the kernel can not be sure that the device is still
available.
My ret = -ENODEV is exactly about this.
I can see this pattern in other kernel place, like:
drivers/usb/musb/da8xx.c line 374
drivers/usb/musb/davinci.c line 381
drivers/usb/host/xhci-mtk.c line 531
and many other palces.