]> git.baikalelectronics.ru Git - kernel.git/commitdiff
Bluetooth: hci_qca: Fix NULL vs IS_ERR_OR_NULL check in qca_serdev_probe
authorMiaoqian Lin <linmq006@gmail.com>
Fri, 24 Dec 2021 08:02:49 +0000 (08:02 +0000)
committerMarcel Holtmann <marcel@holtmann.org>
Thu, 6 Jan 2022 13:53:57 +0000 (14:53 +0100)
The function devm_gpiod_get_index() return error pointers on error.
Thus devm_gpiod_get_index_optional() could return NULL and error pointers.
The same as devm_gpiod_get_optional() function. Using IS_ERR_OR_NULL()
check to catch error pointers.

Fixes: a9a483f2 ("Bluetooth: hci_qca: Replace devm_gpiod_get() with devm_gpiod_get_optional()")
Signed-off-by: Miaoqian Lin <linmq006@gmail.com>
Signed-off-by: Marcel Holtmann <marcel@holtmann.org>
drivers/bluetooth/hci_qca.c

index 9e99311038ae8e953e689bd3d435403acf2b906c..f6e91fb432a3b59a2585c7ed5fe2aa89af908e3c 100644 (file)
@@ -2059,14 +2059,14 @@ static int qca_serdev_probe(struct serdev_device *serdev)
 
                qcadev->bt_en = devm_gpiod_get_optional(&serdev->dev, "enable",
                                               GPIOD_OUT_LOW);
-               if (!qcadev->bt_en && data->soc_type == QCA_WCN6750) {
+               if (IS_ERR_OR_NULL(qcadev->bt_en) && data->soc_type == QCA_WCN6750) {
                        dev_err(&serdev->dev, "failed to acquire BT_EN gpio\n");
                        power_ctrl_enabled = false;
                }
 
                qcadev->sw_ctrl = devm_gpiod_get_optional(&serdev->dev, "swctrl",
                                               GPIOD_IN);
-               if (!qcadev->sw_ctrl && data->soc_type == QCA_WCN6750)
+               if (IS_ERR_OR_NULL(qcadev->sw_ctrl) && data->soc_type == QCA_WCN6750)
                        dev_warn(&serdev->dev, "failed to acquire SW_CTRL gpio\n");
 
                qcadev->susclk = devm_clk_get_optional(&serdev->dev, NULL);
@@ -2088,7 +2088,7 @@ static int qca_serdev_probe(struct serdev_device *serdev)
 
                qcadev->bt_en = devm_gpiod_get_optional(&serdev->dev, "enable",
                                               GPIOD_OUT_LOW);
-               if (!qcadev->bt_en) {
+               if (IS_ERR_OR_NULL(qcadev->bt_en)) {
                        dev_warn(&serdev->dev, "failed to acquire enable gpio\n");
                        power_ctrl_enabled = false;
                }