From: Zach Brown <zach.brown@ni.com>
To: <f.fainelli@gmail.com>
Cc: devel@driverdev.osuosl.org, florian.c.schilhabel@googlemail.com,
andrew@lunn.ch, netdev@vger.kernel.org,
linux-kernel@vger.kernel.org, rpurdie@rpsys.net,
gregkh@linuxfoundation.org, Larry.Finger@lwfinger.net,
j.anaszewski@samsung.com, linux-leds@vger.kernel.org,
mlindner@marvell.com
Subject: [PATCH v5 3/4] net: phy: Create phy_supported_speeds function which lists speeds currently supported by a phydevice
Date: Mon, 17 Oct 2016 10:49:54 -0500 [thread overview]
Message-ID: <1476719395-28273-4-git-send-email-zach.brown@ni.com> (raw)
In-Reply-To: <1476719395-28273-1-git-send-email-zach.brown@ni.com>
phy_supported_speeds provides a means to get a list of all the speeds a
phy device currently supports.
Signed-off-by: Zach Brown <zach.brown@ni.com>
---
drivers/net/phy/phy.c | 35 +++++++++++++++++++++++++++++++++++
include/linux/phy.h | 15 +++++++++++++++
2 files changed, 50 insertions(+)
diff --git a/drivers/net/phy/phy.c b/drivers/net/phy/phy.c
index f5721db..82ee233 100644
--- a/drivers/net/phy/phy.c
+++ b/drivers/net/phy/phy.c
@@ -261,6 +261,41 @@ static inline unsigned int phy_find_valid(unsigned int idx, u32 features)
}
/**
+ * phy_supported_speeds - return all speeds currently supported by a phy device
+ * @phy: The phy device to return supported speeds of.
+ * @speeds: buffer to store supported speeds in.
+ * @size: size of speeds buffer.
+ *
+ * Description: Returns the number of supported speeds, and fills the speeds
+ * buffer with the supported speeds. If speeds buffer is too small to contain
+ * all currently supported speeds, will return as many speeds as can fit.
+ */
+unsigned int phy_supported_speeds(struct phy_device *phy,
+ unsigned int *speeds,
+ unsigned int size)
+{
+ unsigned int count = 0;
+ unsigned int idx = 0;
+
+ while (idx < MAX_NUM_SETTINGS && count < size) {
+ idx = phy_find_valid(idx, phy->supported);
+
+ if (!(settings[idx].setting & phy->supported))
+ break;
+
+ /* Assumes settings are grouped by speed */
+ if ((count == 0) ||
+ (speeds[count - 1] != settings[idx].speed)) {
+ speeds[count] = settings[idx].speed;
+ count++;
+ }
+ idx++;
+ }
+
+ return count;
+}
+
+/**
* phy_check_valid - check if there is a valid PHY setting which matches
* speed, duplex, and feature mask
* @speed: speed to match
diff --git a/include/linux/phy.h b/include/linux/phy.h
index e25f183..8761f30 100644
--- a/include/linux/phy.h
+++ b/include/linux/phy.h
@@ -85,6 +85,21 @@ typedef enum {
} phy_interface_t;
/**
+ * phy_supported_speeds - return all speeds currently supported by a phy device
+ * @phy: The phy device to return supported speeds of.
+ * @speeds: buffer to store supported speeds in.
+ * @size: size of speeds buffer.
+ *
+ * Description: Returns the number of supported speeds, and
+ * fills the speeds * buffer with the supported speeds. If speeds buffer is
+ * too small to contain * all currently supported speeds, will return as
+ * many speeds as can fit.
+ */
+unsigned int phy_supported_speeds(struct phy_device *phy,
+ unsigned int *speeds,
+ unsigned int size);
+
+/**
* It maps 'enum phy_interface_t' found in include/linux/phy.h
* into the device tree binding of 'phy-mode', so that Ethernet
* device driver can get phy interface from device tree.
--
2.7.4
next prev parent reply other threads:[~2016-10-17 15:49 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-10-17 15:49 [PATCH v5 0/4] Add support for led triggers on phy link state change Zach Brown
2016-10-17 15:49 ` [PATCH v5 1/4] skge: Rename LED_OFF and LED_ON in marvel skge driver to avoid conflicts with leds namespace Zach Brown
2016-10-17 15:49 ` [PATCH v5 2/4] net: phy: Encapsulate actions performed during link state changes into function phy_adjust_link Zach Brown
2016-10-17 15:49 ` Zach Brown [this message]
2016-10-17 15:49 ` [PATCH v5 4/4] net: phy: leds: add support for led triggers on phy link state change Zach Brown
2016-10-18 7:13 ` Andrew Lunn
2016-10-18 14:50 ` Zach Brown
2016-10-18 15:57 ` [PATCH v5 0/4] Add " David Miller
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=1476719395-28273-4-git-send-email-zach.brown@ni.com \
--to=zach.brown@ni.com \
--cc=Larry.Finger@lwfinger.net \
--cc=andrew@lunn.ch \
--cc=devel@driverdev.osuosl.org \
--cc=f.fainelli@gmail.com \
--cc=florian.c.schilhabel@googlemail.com \
--cc=gregkh@linuxfoundation.org \
--cc=j.anaszewski@samsung.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-leds@vger.kernel.org \
--cc=mlindner@marvell.com \
--cc=netdev@vger.kernel.org \
--cc=rpurdie@rpsys.net \
/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;
as well as URLs for NNTP newsgroup(s).