[PATCH 2/6] staging: comedi: jr3_pci: tidy up comedi_load_firmware()

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Refactor the function to remove some unnecessary indents and make
it a bit more concise.

Signed-off-by: H Hartley Sweeten <hsweeten@xxxxxxxxxxxxxxxxxxx>
Cc: Ian Abbott <abbotti@xxxxxxxxx>
Cc: Greg Kroah-Hartman <gregkh@xxxxxxxxxxxxxxxxxxx>
---
 drivers/staging/comedi/drivers/jr3_pci.c | 30 +++++++++++++++---------------
 1 file changed, 15 insertions(+), 15 deletions(-)

diff --git a/drivers/staging/comedi/drivers/jr3_pci.c b/drivers/staging/comedi/drivers/jr3_pci.c
index 42e78d1..9b61b55 100644
--- a/drivers/staging/comedi/drivers/jr3_pci.c
+++ b/drivers/staging/comedi/drivers/jr3_pci.c
@@ -95,28 +95,28 @@ struct jr3_pci_subdev_private {
 /* Hotplug firmware loading stuff */
 static int comedi_load_firmware(struct comedi_device *dev, const char *name,
 				int (*cb)(struct comedi_device *dev,
-					const u8 *data, size_t size))
+					  const u8 *data, size_t size))
 {
 	struct pci_dev *pcidev = comedi_to_pci_dev(dev);
-	int result = 0;
 	const struct firmware *fw;
 	char *firmware_path;
+	int ret;
+
+	if (!cb)
+		return -EINVAL;
 
 	firmware_path = kasprintf(GFP_KERNEL, "comedi/%s", name);
-	if (!firmware_path) {
-		result = -ENOMEM;
-	} else {
-		result = request_firmware(&fw, firmware_path, &pcidev->dev);
-		if (result == 0) {
-			if (!cb)
-				result = -EINVAL;
-			else
-				result = cb(dev, fw->data, fw->size);
-			release_firmware(fw);
-		}
-		kfree(firmware_path);
+	if (!firmware_path)
+		return -ENOMEM;
+
+	ret = request_firmware(&fw, firmware_path, &pcidev->dev);
+	if (ret == 0) {
+		ret = cb(dev, fw->data, fw->size);
+		release_firmware(fw);
 	}
-	return result;
+	kfree(firmware_path);
+
+	return ret;
 }
 
 static struct poll_delay_t poll_delay_min_max(int min, int max)
-- 
1.8.1.4

_______________________________________________
devel mailing list
devel@xxxxxxxxxxxxxxxxxxxxxx
http://driverdev.linuxdriverproject.org/mailman/listinfo/devel




[Index of Archives]     [Linux Driver Backports]     [DMA Engine]     [Linux GPIO]     [Linux SPI]     [Video for Linux]     [Linux USB Devel]     [Linux Coverity]     [Linux Audio Users]     [Linux Kernel]     [Linux SCSI]     [Yosemite Backpacking]
  Powered by Linux