From patchwork Wed Mar 25 18:44:55 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Marek Vasut X-Patchwork-Id: 244280 List-Id: U-Boot discussion From: marex at denx.de (Marek Vasut) Date: Wed, 25 Mar 2020 19:44:55 +0100 Subject: [PATCH 06/12] net: ks8851: Clean up chip ID readout In-Reply-To: <20200325184501.200580-1-marex@denx.de> References: <20200325184501.200580-1-marex@denx.de> Message-ID: <20200325184501.200580-6-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 Cc: Eugen Hristev Cc: Joe Hershberger --- 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;