public inbox for u-boot@lists.denx.de
 help / color / mirror / Atom feed
From: Marek Vasut <marex@denx.de>
To: u-boot@lists.denx.de
Subject: [PATCH 06/12] net: ks8851: Clean up chip ID readout
Date: Wed, 25 Mar 2020 19:44:55 +0100	[thread overview]
Message-ID: <20200325184501.200580-6-marex@denx.de> (raw)
In-Reply-To: <20200325184501.200580-1-marex@denx.de>

There is only one chip ID in the table of chip IDs for this chip.
Read out the chip ID instead and mask off the last "revision" bit
to check the chip ID, this works for all chips in the family. Then
drop the chip ID passing around.

Signed-off-by: Marek Vasut <marex@denx.de>
Cc: Eugen Hristev <eugen.hristev@microchip.com>
Cc: Joe Hershberger <joe.hershberger@ni.com>
---
 drivers/net/ks8851_mll.c | 21 ++-------------------
 1 file changed, 2 insertions(+), 19 deletions(-)

diff --git a/drivers/net/ks8851_mll.c b/drivers/net/ks8851_mll.c
index 2d854d855d..503da7a3bf 100644
--- a/drivers/net/ks8851_mll.c
+++ b/drivers/net/ks8851_mll.c
@@ -17,11 +17,6 @@
 
 #define RX_BUF_SIZE			2000
 
-static const struct chip_id chip_ids[] =  {
-	{CIDER_ID, "KSZ8851"},
-	{0, NULL},
-};
-
 /*
  * struct ks_net - KS8851 driver private data
  * @bus_width	: i/o bus width.
@@ -331,7 +326,7 @@ static void ks_setup_int(struct eth_device *dev)
 
 static int ks8851_mll_detect_chip(struct eth_device *dev)
 {
-	unsigned short val, i;
+	unsigned short val;
 
 	ks_read_config(dev);
 
@@ -348,19 +343,11 @@ static int ks8851_mll_detect_chip(struct eth_device *dev)
 
 	debug("Read back KS8851 id 0x%x\n", val);
 
-	/* only one entry in the table */
-	val &= 0xfff0;
-	for (i = 0; chip_ids[i].id != 0; i++) {
-		if (chip_ids[i].id == val)
-			break;
-	}
-	if (!chip_ids[i].id) {
+	if ((val & 0xfff0) != CIDER_ID) {
 		printf(DRIVERNAME ": Unknown chip ID %04x\n", val);
 		return -1;
 	}
 
-	dev->priv = (void *)&chip_ids[i];
-
 	return 0;
 }
 
@@ -404,10 +391,6 @@ static void ks8851_mll_enable(struct eth_device *dev)
 
 static int ks8851_mll_init(struct eth_device *dev, bd_t *bd)
 {
-	struct chip_id *id = dev->priv;
-
-	debug(DRIVERNAME ": detected %s controller\n", id->name);
-
 	if (ks_read_selftest(dev)) {
 		printf(DRIVERNAME ": Selftest failed\n");
 		return -1;
-- 
2.25.1

  parent reply	other threads:[~2020-03-25 18:44 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-03-25 18:44 [PATCH 01/12] net: ks8851: Replace malloc()+memset() with calloc() Marek Vasut
2020-03-25 18:44 ` [PATCH 02/12] net: ks8851: Remove RXQCR cache Marek Vasut
2020-03-25 18:44 ` [PATCH 03/12] net: ks8851: Use 16bit RXQCR access Marek Vasut
2020-03-25 18:44 ` [PATCH 04/12] net: ks8851: Trim down struct ks_net Marek Vasut
2020-03-25 18:44 ` [PATCH 05/12] net: ks8851: Remove type_frame_head Marek Vasut
2020-03-25 18:44 ` Marek Vasut [this message]
2020-03-25 18:44 ` [PATCH 07/12] net: ks8851: Checkpatch cleanup Marek Vasut
2020-03-25 18:44 ` [PATCH 08/12] net: ks8851: Pass around driver private data Marek Vasut
2020-03-25 18:44 ` [PATCH 09/12] net: ks8851: Split non-DM specific bits from common code Marek Vasut
2020-03-25 18:44 ` [PATCH 10/12] net: ks8851: Receive one packet per recv call Marek Vasut
2020-03-25 18:45 ` [PATCH 11/12] net: ks8851: Add DM support Marek Vasut
2020-03-25 18:45 ` [PATCH 12/12] net: ks8851: Add Kconfig entries Marek Vasut
2020-04-16 13:06 ` [PATCH 01/12] net: ks8851: Replace malloc()+memset() with calloc() Marek Vasut
2020-04-16 13:57 ` Joe Hershberger

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=20200325184501.200580-6-marex@denx.de \
    --to=marex@denx.de \
    --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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox