struct ahci_host_priv {
/* Input fields */
unsigned int flags; /* AHCI_HFLAG_* */
- u32 mask_port_map; /* mask out particular bits */
+ u32 mask_port_map; /* Mask of valid ports */
void __iomem * mmio; /* bus-independent mem map */
u32 cap; /* cap to use */
int port);
};
+/*
+ * Return true if a port should be ignored because it is excluded from
+ * the host port map.
+ */
+static inline bool ahci_ignore_port(struct ahci_host_priv *hpriv,
+ unsigned int portid)
+{
+ return portid >= hpriv->nports ||
+ !(hpriv->mask_port_map & (1 << portid));
+}
+
extern int ahci_ignore_sss;
extern const struct attribute_group *ahci_shost_groups[];
/* Re-initialize and calibrate the PHY */
for (i = 0; i < hpriv->nports; i++) {
- if (!(hpriv->mask_port_map & (1 << i)))
+ if (ahci_ignore_port(hpriv, i))
continue;
rc = phy_init(hpriv->phys[i]);
goto disable_clks;
for (i = 0; i < hpriv->nports; i++) {
- if (!(hpriv->mask_port_map & (1 << i)))
+ if (ahci_ignore_port(hpriv, i))
continue;
rc = phy_init(hpriv->phys[i]);
ahci_platform_deassert_rsts(hpriv);
for (i = 0; i < hpriv->nports; i++) {
- if (!(hpriv->mask_port_map & (1 << i)))
+ if (ahci_ignore_port(hpriv, i))
continue;
rc = phy_power_on(hpriv->phys[i]);
int rc, i;
for (i = 0; i < hpriv->nports; i++) {
- if (!(hpriv->mask_port_map & (1 << i)))
+ if (ahci_ignore_port(hpriv, i))
continue;
rc = phy_init(hpriv->phys[i]);
disable_phys:
while (--i >= 0) {
- if (!(hpriv->mask_port_map & (1 << i)))
+ if (ahci_ignore_port(hpriv, i))
continue;
phy_power_off(hpriv->phys[i]);
int i;
for (i = 0; i < hpriv->nports; i++) {
- if (!(hpriv->mask_port_map & (1 << i)))
+ if (ahci_ignore_port(hpriv, i))
continue;
phy_power_off(hpriv->phys[i]);