Re: [PATCH v3 2/3] ata: ahci_platform: Manage SATA PHY

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

 



On Thursday 09 January 2014, Roger Quadros wrote:
> >> if (!IS_ERR(hpriv->phy)) {
> >>         rc = phy_init(hpriv->phy);
> >>         if (rc)
> >>                 goto disable_unprepare_clk;
> >>
> >>         rc = phy_power_on(hpriv->phy);
> >>         if (rc) {
> >>                 phy_exit(hpriv->phy);
> >>                 goto disable_unprepare_clk;
> >>         }
> >> }
> > 
> > As I said, I'd prefer to set hpriv->phy to NULL in case of -ENODEV,
> > but functionally it seems right (with the fixup from your other mail).
> > 
> 
> Why do you prefer setting hpriv->phy to NULL instead of using IS_ERR() check
> before hpriv->phy is used?
> The latter seems to be the norm at least among clock framework users.

Two reasons:

1. It feels more natural to read "if (clk)" in driver code as a check for
   "a clock exists" than "if (!IS_ERR(clk))".
2. It clarifies that this code path is only there to check for the
   clk-not-present case, not for other errors.

Obviously the first check after clk_get needs to be IS_ERR() because that
is the documented interface, but then you should decide on the action
based on the specific error.

	Arnd
--
To unsubscribe from this list: send the line "unsubscribe linux-ide" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html




[Index of Archives]     [Linux Filesystems]     [Linux SCSI]     [Linux RAID]     [Git]     [Kernel Newbies]     [Linux Newbie]     [Security]     [Netfilter]     [Bugtraq]     [Yosemite News]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Samba]     [Device Mapper]

  Powered by Linux