From: Arnd Bergmann <arnd@arndb.de>
To: Pratyush Anand <pratyush.anand@st.com>
Cc: Kishon Vijay Abraham I <kishon@ti.com>,
spear-devel@list.st.com, linux-arm-kernel@lists.infradead.org,
linux-kernel@vger.kernel.org
Subject: Re: [PATCH V4 6/8] phy: st-miphy-40lp: Add SPEAr1310 and SPEAr1340 PCIe phy support
Date: Thu, 6 Feb 2014 16:37:05 +0100 [thread overview]
Message-ID: <201402061637.05414.arnd@arndb.de> (raw)
In-Reply-To: <dca9c501de8386003142b463469c3d267a049eeb.1391661589.git.pratyush.anand@st.com>
On Thursday 06 February 2014, Pratyush Anand wrote:
> +static int spear1310_pcie_miphy_exit(struct st_miphy40lp_priv *phypriv)
> +{
> + u32 mask;
> +
> + switch (phypriv->id) {
> + case 0:
> + mask = SPEAR1310_PCIE_CFG_MASK(0);
> + break;
> + case 1:
> + mask = SPEAR1310_PCIE_CFG_MASK(1);
> + break;
> + case 2:
> + mask = SPEAR1310_PCIE_CFG_MASK(2);
> + break;
> + default:
> + return -EINVAL;
> + }
> +
> + regmap_update_bits(phypriv->misc, SPEAR1310_PCIE_SATA_CFG,
> + SPEAR1310_PCIE_CFG_MASK(phypriv->id), 0);
> +
> + regmap_update_bits(phypriv->misc, SPEAR1310_PCIE_MIPHY_CFG_1,
> + SPEAR1310_PCIE_SATA_MIPHY_CFG_PCIE_MASK, 0);
> +
> + return 0;
> +}
hmm, you set the mask based on the id, but then use the macro below
and ignore the mask?
> +
> +static int pcie_miphy_init(struct st_miphy40lp_priv *phypriv)
> +{
> + if (of_device_is_compatible(phypriv->np, "st,spear1340-miphy"))
> + return spear1340_pcie_miphy_init(phypriv);
> + else if (of_device_is_compatible(phypriv->np, "st,spear1310-miphy"))
> + return spear1310_pcie_miphy_init(phypriv);
> + else
> + return -EINVAL;
> +}
> +
> +static int pcie_miphy_exit(struct st_miphy40lp_priv *phypriv)
> +{
> + if (of_device_is_compatible(phypriv->np, "st,spear1340-miphy"))
> + return spear1340_pcie_miphy_exit(phypriv);
> + else if (of_device_is_compatible(phypriv->np, "st,spear1310-miphy"))
> + return spear1310_pcie_miphy_exit(phypriv);
> + else
> + return -EINVAL;
> +}
I think it's better to make this code table-driven. Rather than checking
'of_device_is_compatible()', it's much easier to add a .data field to
the of_device_id array that describes the PHY. You can use .data to
point to a structure containing per-device function pointers or
(better) values and offsets to be used.
Arnd
next prev parent reply other threads:[~2014-02-06 15:37 UTC|newest]
Thread overview: 16+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-02-06 4:44 [PATCH V4 0/8]PCI:Add SPEAr13xx PCie support Pratyush Anand
2014-02-06 4:44 ` [PATCH V4 4/8] phy: st-miphy-40lp: Add skeleton driver Pratyush Anand
2014-02-06 6:01 ` Kishon Vijay Abraham I
2014-02-06 6:14 ` Pratyush Anand
2014-02-06 6:23 ` Kishon Vijay Abraham I
2014-02-06 6:25 ` Pratyush Anand
2014-02-06 4:44 ` [PATCH V4 5/8] SPEAr13xx: Fixup: Move SPEAr1340 SATA platform code to phy driver Pratyush Anand
2014-02-06 6:32 ` Kishon Vijay Abraham I
2014-02-06 7:00 ` Pratyush Anand
2014-02-06 8:01 ` Kishon Vijay Abraham I
2014-02-06 8:07 ` Pratyush Anand
2014-02-06 4:44 ` [PATCH V4 6/8] phy: st-miphy-40lp: Add SPEAr1310 and SPEAr1340 PCIe phy support Pratyush Anand
2014-02-06 15:37 ` Arnd Bergmann [this message]
2014-02-07 3:54 ` Pratyush Anand
2014-02-07 6:43 ` Pratyush Anand
2014-02-06 17:30 ` [PATCH V4 0/8]PCI:Add SPEAr13xx PCie support Pratyush Anand
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=201402061637.05414.arnd@arndb.de \
--to=arnd@arndb.de \
--cc=kishon@ti.com \
--cc=linux-arm-kernel@lists.infradead.org \
--cc=linux-kernel@vger.kernel.org \
--cc=pratyush.anand@st.com \
--cc=spear-devel@list.st.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
Powered by JetHome