* re: amd-xgbe: Add support for MDIO attached PHYs
@ 2016-11-15 13:07 Colin Ian King
2016-11-15 14:17 ` Tom Lendacky
0 siblings, 1 reply; 2+ messages in thread
From: Colin Ian King @ 2016-11-15 13:07 UTC (permalink / raw)
To: Tom Lendacky; +Cc: netdev@vger.kernel.org, David S. Miller
Hi,
Commit:
amd-xgbe: Add support for MDIO attached PHYs
Use the phylib support in the kernel to communicate with and control an
MDIO attached PHY. Use the hardware's MDIO communication mechanism to
communicate with the PHY.
+static int xgbe_clr_gpio(struct xgbe_prv_data *pdata, unsigned int gpio)
+{
+ unsigned int reg;
+
+ if (gpio > 16)
+ return -EINVAL;
is gpio in the range 0..15?
if (gpio > 15)
return -EINVAL;
+
+ reg = XGMAC_IOREAD(pdata, MAC_GPIOSR);
+
+ reg &= ~(1 << (gpio + 16));
if gpio is 16, we get 1 << 32 which I believe is undefined behaviour.
+ XGMAC_IOWRITE(pdata, MAC_GPIOSR, reg);
+
+ return 0;
+}
Same applies for function xgbe_clr_gpio().
Colin
^ permalink raw reply [flat|nested] 2+ messages in thread* Re: amd-xgbe: Add support for MDIO attached PHYs
2016-11-15 13:07 amd-xgbe: Add support for MDIO attached PHYs Colin Ian King
@ 2016-11-15 14:17 ` Tom Lendacky
0 siblings, 0 replies; 2+ messages in thread
From: Tom Lendacky @ 2016-11-15 14:17 UTC (permalink / raw)
To: Colin Ian King; +Cc: netdev@vger.kernel.org, David S. Miller
On 11/15/2016 7:07 AM, Colin Ian King wrote:
> Hi,
>
> Commit:
>
> amd-xgbe: Add support for MDIO attached PHYs
>
> Use the phylib support in the kernel to communicate with and control an
> MDIO attached PHY. Use the hardware's MDIO communication mechanism to
> communicate with the PHY.
>
>
> +static int xgbe_clr_gpio(struct xgbe_prv_data *pdata, unsigned int gpio)
> +{
> + unsigned int reg;
> +
> + if (gpio > 16)
> + return -EINVAL;
>
> is gpio in the range 0..15?
>
> if (gpio > 15)
> return -EINVAL;
Yes, the GPIO range is 0 to 15. I'll submit a patch to change the
constraint check.
Thanks,
Tom
>
> +
> + reg = XGMAC_IOREAD(pdata, MAC_GPIOSR);
> +
> + reg &= ~(1 << (gpio + 16));
>
> if gpio is 16, we get 1 << 32 which I believe is undefined behaviour.
>
> + XGMAC_IOWRITE(pdata, MAC_GPIOSR, reg);
> +
> + return 0;
> +}
>
>
> Same applies for function xgbe_clr_gpio().
>
> Colin
>
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2016-11-15 14:17 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2016-11-15 13:07 amd-xgbe: Add support for MDIO attached PHYs Colin Ian King
2016-11-15 14:17 ` Tom Lendacky
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox