From: richardretanubun <richardretanubun@ruggedcom.com>
To: u-boot@lists.denx.de
Subject: [U-Boot] [U-boot] [PATCHv2 1/2] NET: QE: UEC: Make uec_miiphy_read() and uec_miiphy_write() use the devname arg.
Date: Tue, 16 Sep 2008 08:49:20 -0400 [thread overview]
Message-ID: <48CFAB50.9010605@ruggedcom.com> (raw)
In-Reply-To: <48C0B5F3.2090506@gmail.com>
Hi Ben,
Ben Warren wrote:
> Hi Richard,
>
> richardretanubun wrote:
>> Hi Ben,
>>
>> Thanks for the feedback. I've made the changes you suggested.
>> Here is the patch re-pasted (please let me know if this is not the
>> proper way to submit patch v2).
>> --------------------------------------------
>>
> I started to fix this up so that it would apply, but it's been badly
> mangled by your mailer. Would you mind please re-sending? If you're
> using Thunderbird or Evolution, select the "preformat" text type when
> you paste the patch. If using something else, please just attach the
> patch file.
>
Sorry for replying so late (and twice, I forgot to cc the mailing list). Here is the patch in preformat form
and also attached, just in case.
> regards,
> Ben
>
>
Thanks for all your help
Richard
-------------------------------------
Added a new function uec_miiphy_find_dev_by_name to allow
uec_miiphy_read and uec_miiphy_write to use the passed devname and not
hardcoded to devlist[0]
Signed-off-by: Richard Retanubun <RichardRetanubun_at_ruggedcom.com>
diff --git a/drivers/qe/uec.c b/drivers/qe/uec.c
index 344c649..9b0b3bc 100644
--- a/drivers/qe/uec.c
+++ b/drivers/qe/uec.c
@@ -639,16 +639,51 @@ static void phy_change(struct eth_device *dev)
&& !defined(BITBANGMII)
/*
+ * Find a device index from the devlist by name
+ *
+ * Returns:
+ * The index where the device is located, -1 on error
+ */
+static int uec_miiphy_find_dev_by_name(char *devname)
+{
+ int i;
+
+
+ for (i = 0; i < MAXCONTROLLERS; i++) {
+ if (strncmp(devname, devlist[i]->name, strlen(devname)) == 0) {
+ break;
+ }
+ }
+
+ /* If device cannot be found, returns -1 */
+ if (i == MAXCONTROLLERS) {
+ debug ("%s: device %s not found in devlist\n", __FUNCTION__,
devname);
+ i = -1;
+ }
+
+ return i;
+}
+
+/*
* Read a MII PHY register.
*
* Returns:
* 0 on success
*/
static int uec_miiphy_read(char *devname, unsigned char addr,
- unsigned char reg, unsigned short *value)
+ unsigned char reg, unsigned short *value)
{
- *value = uec_read_phy_reg(devlist[0], addr, reg);
+ int devindex = 0;
+
+ if (devname == NULL || value == NULL) {
+ debug("%s: NULL pointer given\n", __FUNCTION__);
+ } else {
+ devindex = uec_miiphy_find_dev_by_name(devname);
+ if (devindex >= 0) {
+ *value = uec_read_phy_reg(devlist[devindex], addr, reg);
+ }
+ }
return 0;
}
@@ -659,13 +694,21 @@ static int uec_miiphy_read(char *devname, unsigned
char addr,
* 0 on success
*/
static int uec_miiphy_write(char *devname, unsigned char addr,
- unsigned char reg, unsigned short value)
+ unsigned char reg, unsigned short value)
{
- uec_write_phy_reg(devlist[0], addr, reg, value);
+ int devindex = 0;
+
+ if (devname == NULL) {
+ debug("%s: NULL pointer given\n", __FUNCTION__);
+ } else {
+ devindex = uec_miiphy_find_dev_by_name(devname);
+ if (devindex >= 0) {
+ uec_write_phy_reg(devlist[devindex], addr, reg, value);
+ }
+ }
return 0;
}
-
#endif
static int uec_set_mac_address(uec_private_t *uec, u8 *mac_addr)
-------------- next part --------------
A non-text attachment was scrubbed...
Name: qe_uec_miiphy_not_hardcode.patch
Type: text/x-patch
Size: 2441 bytes
Desc: not available
Url : http://lists.denx.de/pipermail/u-boot/attachments/20080916/6fb10861/attachment.bin
next prev parent reply other threads:[~2008-09-16 12:49 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2008-08-18 19:46 [U-Boot] [U-boot] [PATCH 1/2] NET: QE: UEC: Make uec_miiphy_read() and uec_miiphy_write() use the devname arg richardretanubun
2008-08-18 21:00 ` Ben Warren
2008-08-18 22:28 ` [U-Boot] [U-boot] [PATCHv2 " richardretanubun
2008-09-05 4:30 ` Ben Warren
2008-09-16 12:49 ` richardretanubun [this message]
2008-09-24 22:10 ` richardretanubun
2008-09-26 6:46 ` Ben Warren
2008-09-26 12:52 ` richardretanubun
2008-09-26 12:59 ` richardretanubun
2008-10-06 19:36 ` richardretanubun
2008-10-14 5:52 ` Ben Warren
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=48CFAB50.9010605@ruggedcom.com \
--to=richardretanubun@ruggedcom.com \
--cc=u-boot@lists.denx.de \
/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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.