]> asedeno.scripts.mit.edu Git - linux.git/commitdiff
hisi_sas: use Unified Device Properties API
authorJohn Garry <john.garry@huawei.com>
Wed, 3 Feb 2016 18:26:08 +0000 (02:26 +0800)
committerMartin K. Petersen <martin.petersen@oracle.com>
Wed, 24 Feb 2016 02:27:02 +0000 (21:27 -0500)
The hisi_sas driver is required to support both device tree and
ACPI. The scanning of the device properties now uses the Unified Device
Properties API, which serves both OF and ACPI.

Since syscon is not supported by ACPI, syscon is only used in the driver
when device tree is used.

Signed-off-by: John Garry <john.garry@huawei.com>
Signed-off-by: Zhangfei Gao <zhangfei.gao@linaro.org>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
drivers/scsi/hisi_sas/hisi_sas.h
drivers/scsi/hisi_sas/hisi_sas_main.c

index 9f08c0ca087e19d8198a1348079ba6f4a194d714..5b8affd03635ff1ca38b2881cf719d8a2c083e38 100644 (file)
 #ifndef _HISI_SAS_H_
 #define _HISI_SAS_H_
 
+#include <linux/acpi.h>
 #include <linux/dmapool.h>
 #include <linux/mfd/syscon.h>
 #include <linux/module.h>
 #include <linux/of_address.h>
 #include <linux/platform_device.h>
+#include <linux/property.h>
 #include <linux/regmap.h>
 #include <scsi/sas_ata.h>
 #include <scsi/libsas.h>
index 406b515a54bbd2dc9d1554497eb2c1c07e9839cf..2194917bd84de14ddc446766ba69490362a7d099 100644 (file)
@@ -1167,7 +1167,6 @@ static struct Scsi_Host *hisi_sas_shost_alloc(struct platform_device *pdev,
        struct hisi_hba *hisi_hba;
        struct device *dev = &pdev->dev;
        struct device_node *np = pdev->dev.of_node;
-       struct property *sas_addr_prop;
 
        shost = scsi_host_alloc(&hisi_sas_sht, sizeof(*hisi_hba));
        if (!shost)
@@ -1181,27 +1180,34 @@ static struct Scsi_Host *hisi_sas_shost_alloc(struct platform_device *pdev,
 
        init_timer(&hisi_hba->timer);
 
-       sas_addr_prop = of_find_property(np, "sas-addr", NULL);
-       if (!sas_addr_prop || (sas_addr_prop->length != SAS_ADDR_SIZE))
+       if (device_property_read_u8_array(dev, "sas-addr", hisi_hba->sas_addr,
+                                         SAS_ADDR_SIZE))
                goto err_out;
-       memcpy(hisi_hba->sas_addr, sas_addr_prop->value, SAS_ADDR_SIZE);
 
-       if (of_property_read_u32(np, "ctrl-reset-reg",
-                                &hisi_hba->ctrl_reset_reg))
-               goto err_out;
+       if (np) {
+               hisi_hba->ctrl = syscon_regmap_lookup_by_phandle(np,
+                                       "hisilicon,sas-syscon");
+               if (IS_ERR(hisi_hba->ctrl))
+                       goto err_out;
 
-       if (of_property_read_u32(np, "ctrl-reset-sts-reg",
-                                &hisi_hba->ctrl_reset_sts_reg))
-               goto err_out;
+               if (device_property_read_u32(dev, "ctrl-reset-reg",
+                                            &hisi_hba->ctrl_reset_reg))
+                       goto err_out;
 
-       if (of_property_read_u32(np, "ctrl-clock-ena-reg",
-                                &hisi_hba->ctrl_clock_ena_reg))
-               goto err_out;
+               if (device_property_read_u32(dev, "ctrl-reset-sts-reg",
+                                            &hisi_hba->ctrl_reset_sts_reg))
+                       goto err_out;
 
-       if (of_property_read_u32(np, "phy-count", &hisi_hba->n_phy))
+               if (device_property_read_u32(dev, "ctrl-clock-ena-reg",
+                                            &hisi_hba->ctrl_clock_ena_reg))
+                       goto err_out;
+       }
+
+       if (device_property_read_u32(dev, "phy-count", &hisi_hba->n_phy))
                goto err_out;
 
-       if (of_property_read_u32(np, "queue-count", &hisi_hba->queue_count))
+       if (device_property_read_u32(dev, "queue-count",
+                                    &hisi_hba->queue_count))
                goto err_out;
 
        res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
@@ -1209,11 +1215,6 @@ static struct Scsi_Host *hisi_sas_shost_alloc(struct platform_device *pdev,
        if (IS_ERR(hisi_hba->regs))
                goto err_out;
 
-       hisi_hba->ctrl = syscon_regmap_lookup_by_phandle(
-                               np, "hisilicon,sas-syscon");
-       if (IS_ERR(hisi_hba->ctrl))
-               goto err_out;
-
        if (hisi_sas_alloc(hisi_hba, shost)) {
                hisi_sas_free(hisi_hba);
                goto err_out;