Re: [PATCH v2 07/22] scsi: hisi_sas: create hisi_sas_get_fw_info()

From: John Garry
Date: Mon May 29 2017 - 07:18:54 EST


is
On 29/05/2017 11:53, Arnd Bergmann wrote:
On Thu, May 25, 2017 at 2:04 PM, John Garry <john.garry@xxxxxxxxxx> wrote:
Move the functionality to retrieve the fw info into
a dedicated device type-agnostic function,
hisi_sas_get_fw_info().

The reasoning is that this function will be required
for future pci-based platforms.


-
if (device_property_read_u8_array(dev, "sas-addr", hisi_hba->sas_addr,
- SAS_ADDR_SIZE))
- goto err_out;
+ SAS_ADDR_SIZE)) {
+ dev_err(dev, "could not get property sas-addr\n");
+ return -ENOENT;
+ }

if (np) {
hisi_hba->ctrl = syscon_regmap_lookup_by_phandle(np,
"hisilicon,sas-syscon");
- if (IS_ERR(hisi_hba->ctrl))
- goto err_out;
+ if (IS_ERR(hisi_hba->ctrl)) {
+ dev_err(dev, "could not get syscon\n");
+ return -ENOENT;
+ }

If I read this right, it will fail to work for a PCI-based driver trying to read
"sas-addr" but not the other properties that would now be hardcoded from
the PCI ID.

Maybe you just need

Hi Arnd,

So we only require these properties for platform device with DT firmware. This code is same as before (apart from adding the comments), but I'll consider adding a verbose comment.

As for the check, effectively I already have what you recommend in how np is evaluated:
+ struct platform_device *pdev = hisi_hba->platform_dev;
+ struct device_node *np = pdev ? pdev->dev.of_node : NULL;
struct clk *refclk;

Much appreciated,
John




- if (np) {
+ if (np && is_platform_device) {

Arnd

.