lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite for Android: free password hash cracker in your pocket
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-Id: <1280588752-9340-8-git-send-email-khc@pm.waw.pl>
Date:	Sat, 31 Jul 2010 17:05:31 +0200
From:	Krzysztof Halasa <khc@...waw.pl>
To:	David Miller <davem@...emloft.net>
Cc:	<netdev@...r.kernel.org>
Subject: [PATCH 08/29] LMC: Remove "dummy" media functions.

From: Krzysztof Hałasa <khc@...waw.pl>

Signed-off-by: Krzysztof Hałasa <khc@...waw.pl>
---
 drivers/net/wan/lmc/main.c  |   18 ++++++---
 drivers/net/wan/lmc/media.c |   80 +++++++++++++-----------------------------
 2 files changed, 37 insertions(+), 61 deletions(-)

diff --git a/drivers/net/wan/lmc/main.c b/drivers/net/wan/lmc/main.c
index 13bb6f6..6b7c09a 100644
--- a/drivers/net/wan/lmc/main.c
+++ b/drivers/net/wan/lmc/main.c
@@ -261,7 +261,8 @@ int lmc_ioctl(struct net_device *dev, struct ifreq *ifr, int cmd)
 			break;
 		}
 		spin_lock_irqsave(&sc->lmc_lock, flags);
-		sc->lmc_media->set_circuit_type(sc, ctl.circuit_type);
+		if (sc->lmc_media->set_circuit_type)
+			sc->lmc_media->set_circuit_type(sc, ctl.circuit_type);
 		sc->ictl.circuit_type = ctl.circuit_type;
 		spin_unlock_irqrestore(&sc->lmc_lock, flags);
 		ret = 0;
@@ -356,7 +357,8 @@ int lmc_ioctl(struct net_device *dev, struct ifreq *ifr, int cmd)
 			lmc_gpio_mkinput(sc, 0xff);
 
 			/* Reset the frammer hardware */
-			sc->lmc_media->set_link_status(sc, 1);
+			if (sc->lmc_media->set_link_status)
+				sc->lmc_media->set_link_status(sc, 1);
 			sc->lmc_media->set_status(sc, NULL);
 			/* lmc_softreset(sc); */
 
@@ -856,7 +858,8 @@ static int __devinit lmc_init_one(struct pci_dev *pdev,
 
 	sc->lmc_media->defaults(sc);
 
-	sc->lmc_media->set_link_status(sc, LMC_LINK_UP);
+	if (sc->lmc_media->set_link_status)
+		sc->lmc_media->set_link_status(sc, LMC_LINK_UP);
 
 	/* verify that the PCI Sub System ID matches the Adapter Model number
 	   from the MII register */
@@ -951,7 +954,8 @@ static int lmc_open(struct net_device *dev)
 
 	/* Assert Terminal Active */
 	sc->lmc_miireg16 |= LMC_MII16_LED_ALL;
-	sc->lmc_media->set_link_status(sc, LMC_LINK_UP);
+	if (sc->lmc_media->set_link_status)
+		sc->lmc_media->set_link_status(sc, LMC_LINK_UP);
 
 	/*
 	 * reset to last state.
@@ -1026,7 +1030,8 @@ static void lmc_running_reset(struct net_device *dev)
 	lmc_reset(sc);
 	lmc_softreset(sc);
 	/* sc->lmc_miireg16 |= LMC_MII16_LED_ALL; */
-	sc->lmc_media->set_link_status(sc, 1);
+	if (sc->lmc_media->set_link_status)
+		sc->lmc_media->set_link_status(sc, 1);
 	sc->lmc_media->set_status(sc, NULL);
 
 	netif_wake_queue(dev);
@@ -1054,7 +1059,8 @@ static int lmc_close(struct net_device *dev)
 	lmc_trace(dev, "lmc_close in");
 
 	sc->lmc_ok = 0;
-	sc->lmc_media->set_link_status(sc, 0);
+	if (sc->lmc_media->set_link_status)
+		sc->lmc_media->set_link_status(sc, 0);
 	del_timer(&sc->timer);
 	hdlc_close(sc->lmc_device);
 	lmc_ifdown(dev);
diff --git a/drivers/net/wan/lmc/media.c b/drivers/net/wan/lmc/media.c
index 36b685f..baf6e43 100644
--- a/drivers/net/wan/lmc/media.c
+++ b/drivers/net/wan/lmc/media.c
@@ -78,9 +78,6 @@ static void lmc_t1_set_crc_length(struct card * const, int);
 static void lmc_t1_set_clock(struct card * const, int);
 static void lmc_t1_watchdog(struct card * const);
 
-static void lmc_dummy_set_1(struct card * const, int);
-static void lmc_dummy_set2_1(struct card * const, struct control *);
-
 static inline void write_av9110_bit(struct card *, int);
 static void write_av9110(struct card *, u32, u32, u32, u32, u32);
 
@@ -88,14 +85,10 @@ struct media lmc_ds3_media = {
 	.init = lmc_ds3_init,
 	.defaults = lmc_ds3_default,
 	.set_status = lmc_ds3_set_status,
-	.set_clock_source = lmc_dummy_set_1,
-	.set_speed = lmc_dummy_set2_1,
 	.set_cable_length = lmc_ds3_set_100ft,
 	.set_scrambler = lmc_ds3_set_scram,
 	.get_link_status = lmc_ds3_get_link_status,
-	.set_link_status = lmc_dummy_set_1,
 	.set_crc_length = lmc_ds3_set_crc_length,
-	.set_circuit_type = lmc_dummy_set_1,
 	.watchdog = lmc_ds3_watchdog,
 };
 
@@ -104,13 +97,9 @@ struct media lmc_hssi_media = {
 	.defaults = lmc_hssi_default,
 	.set_status = lmc_hssi_set_status,
 	.set_clock_source = lmc_hssi_set_clock,
-	.set_speed = lmc_dummy_set2_1,
-	.set_cable_length = lmc_dummy_set_1,
-	.set_scrambler = lmc_dummy_set_1,
 	.get_link_status = lmc_hssi_get_link_status,
 	.set_link_status = lmc_hssi_set_link_status,
 	.set_crc_length = lmc_hssi_set_crc_length,
-	.set_circuit_type = lmc_dummy_set_1,
 	.watchdog = lmc_hssi_watchdog,
 };
 
@@ -120,12 +109,9 @@ struct media lmc_ssi_media = {
 	.set_status = lmc_ssi_set_status,
 	.set_clock_source = lmc_ssi_set_clock,
 	.set_speed = lmc_ssi_set_speed,
-	.set_cable_length = lmc_dummy_set_1,
-	.set_scrambler = lmc_dummy_set_1,
 	.get_link_status = lmc_ssi_get_link_status,
 	.set_link_status = lmc_ssi_set_link_status,
 	.set_crc_length = lmc_ssi_set_crc_length,
-	.set_circuit_type = lmc_dummy_set_1,
 	.watchdog = lmc_ssi_watchdog,
 };
 
@@ -134,24 +120,12 @@ struct media lmc_t1_media = {
 	.defaults = lmc_t1_default,
 	.set_status = lmc_t1_set_status,
 	.set_clock_source = lmc_t1_set_clock,
-	.set_speed = lmc_dummy_set2_1,
-	.set_cable_length = lmc_dummy_set_1,
-	.set_scrambler = lmc_dummy_set_1,
 	.get_link_status = lmc_t1_get_link_status,
-	.set_link_status = lmc_dummy_set_1,
 	.set_crc_length = lmc_t1_set_crc_length,
 	.set_circuit_type = lmc_t1_set_circuit_type,
 	.watchdog = lmc_t1_watchdog,
 };
 
-static void lmc_dummy_set_1(struct card * const sc, int a)
-{
-}
-
-static void lmc_dummy_set2_1(struct card * const sc, struct control * a)
-{
-}
-
 /* HSSI methods */
 
 static void lmc_hssi_init(struct card * const sc)
@@ -163,10 +137,9 @@ static void lmc_hssi_init(struct card * const sc)
 static void lmc_hssi_default(struct card * const sc)
 {
 	sc->lmc_miireg16 = LMC_MII16_LED_ALL;
-
-	sc->lmc_media->set_link_status(sc, LMC_LINK_DOWN);
-	sc->lmc_media->set_clock_source(sc, LMC_CTL_CLOCK_SOURCE_EXT);
-	sc->lmc_media->set_crc_length(sc, LMC_CTL_CRC_LENGTH_16);
+	lmc_hssi_set_link_status(sc, LMC_LINK_DOWN);
+	lmc_hssi_set_clock(sc, LMC_CTL_CLOCK_SOURCE_EXT);
+	lmc_hssi_set_crc_length(sc, LMC_CTL_CRC_LENGTH_16);
 }
 
 /* Given a user provided state, set ourselves up to match it.
@@ -174,7 +147,7 @@ static void lmc_hssi_default(struct card * const sc)
 static void lmc_hssi_set_status(struct card * const sc, struct control *ctl)
 {
 	if (ctl == NULL) {
-		sc->lmc_media->set_clock_source(sc, sc->ictl.clock_source);
+		lmc_hssi_set_clock(sc, sc->ictl.clock_source);
 		lmc_set_protocol(sc, NULL);
 
 		return;
@@ -182,11 +155,11 @@ static void lmc_hssi_set_status(struct card * const sc, struct control *ctl)
 
 	/* check for change in clock source */
 	if (ctl->clock_source && !sc->ictl.clock_source) {
-		sc->lmc_media->set_clock_source(sc, LMC_CTL_CLOCK_SOURCE_INT);
+		lmc_hssi_set_clock(sc, LMC_CTL_CLOCK_SOURCE_INT);
 		sc->lmc_timing = LMC_CTL_CLOCK_SOURCE_INT;
 	} else if (!ctl->clock_source && sc->ictl.clock_source) {
 		sc->lmc_timing = LMC_CTL_CLOCK_SOURCE_EXT;
-		sc->lmc_media->set_clock_source(sc, LMC_CTL_CLOCK_SOURCE_EXT);
+		lmc_hssi_set_clock(sc, LMC_CTL_CLOCK_SOURCE_EXT);
 	}
 
 	lmc_set_protocol(sc, ctl);
@@ -272,10 +245,9 @@ static void lmc_ds3_default(struct card * const sc)
 {
 	sc->lmc_miireg16 = LMC_MII16_LED_ALL;
 
-	sc->lmc_media->set_link_status(sc, LMC_LINK_DOWN);
-	sc->lmc_media->set_cable_length(sc, LMC_CTL_CABLE_LENGTH_LT_100FT);
-	sc->lmc_media->set_scrambler(sc, LMC_CTL_OFF);
-	sc->lmc_media->set_crc_length(sc, LMC_CTL_CRC_LENGTH_16);
+	lmc_ds3_set_100ft(sc, LMC_CTL_CABLE_LENGTH_LT_100FT);
+	lmc_ds3_set_scram(sc, LMC_CTL_OFF);
+	lmc_ds3_set_crc_length(sc, LMC_CTL_CRC_LENGTH_16);
 }
 
 /* Given a user provided state, set ourselves up to match it.
@@ -283,8 +255,8 @@ static void lmc_ds3_default(struct card * const sc)
 static void lmc_ds3_set_status(struct card * const sc, struct control *ctl)
 {
 	if (ctl == NULL) {
-		sc->lmc_media->set_cable_length(sc, sc->ictl.cable_length);
-		sc->lmc_media->set_scrambler(sc, sc->ictl.scrambler_onoff);
+		lmc_ds3_set_100ft(sc, sc->ictl.cable_length);
+		lmc_ds3_set_scram(sc, sc->ictl.scrambler_onoff);
 		lmc_set_protocol(sc, NULL);
 		return;
 	}
@@ -480,10 +452,10 @@ static void lmc_ssi_default(struct card * const sc)
 	/* make TXCLOCK always be an output */
 	lmc_gpio_mkoutput(sc, LMC_GEP_SSI_TXCLOCK);
 
-	sc->lmc_media->set_link_status(sc, LMC_LINK_DOWN);
-	sc->lmc_media->set_clock_source(sc, LMC_CTL_CLOCK_SOURCE_EXT);
-	sc->lmc_media->set_speed(sc, NULL);
-	sc->lmc_media->set_crc_length(sc, LMC_CTL_CRC_LENGTH_16);
+	lmc_ssi_set_link_status(sc, LMC_LINK_DOWN);
+	lmc_ssi_set_clock(sc, LMC_CTL_CLOCK_SOURCE_EXT);
+	lmc_ssi_set_speed(sc, NULL);
+	lmc_ssi_set_crc_length(sc, LMC_CTL_CRC_LENGTH_16);
 }
 
 /* Given a user provided state, set ourselves up to match it.
@@ -491,8 +463,8 @@ static void lmc_ssi_default(struct card * const sc)
 static void lmc_ssi_set_status(struct card * const sc, struct control *ctl)
 {
 	if (ctl == NULL) {
-		sc->lmc_media->set_clock_source(sc, sc->ictl.clock_source);
-		sc->lmc_media->set_speed(sc, &sc->ictl);
+		lmc_ssi_set_clock(sc, sc->ictl.clock_source);
+		lmc_ssi_set_speed(sc, &sc->ictl);
 		lmc_set_protocol(sc, NULL);
 		return;
 	}
@@ -500,16 +472,16 @@ static void lmc_ssi_set_status(struct card * const sc, struct control *ctl)
 	/* check for change in clock source */
 	if (ctl->clock_source == LMC_CTL_CLOCK_SOURCE_INT
 	    && sc->ictl.clock_source == LMC_CTL_CLOCK_SOURCE_EXT) {
-		sc->lmc_media->set_clock_source(sc, LMC_CTL_CLOCK_SOURCE_INT);
+		lmc_ssi_set_clock(sc, LMC_CTL_CLOCK_SOURCE_INT);
 		sc->lmc_timing = LMC_CTL_CLOCK_SOURCE_INT;
 	} else if (ctl->clock_source == LMC_CTL_CLOCK_SOURCE_EXT
 		 && sc->ictl.clock_source == LMC_CTL_CLOCK_SOURCE_INT) {
-		sc->lmc_media->set_clock_source(sc, LMC_CTL_CLOCK_SOURCE_EXT);
+		lmc_ssi_set_clock(sc, LMC_CTL_CLOCK_SOURCE_EXT);
 		sc->lmc_timing = LMC_CTL_CLOCK_SOURCE_EXT;
 	}
 
 	if (ctl->clock_rate != sc->ictl.clock_rate)
-		sc->lmc_media->set_speed(sc, ctl);
+		lmc_ssi_set_speed(sc, ctl);
 
 	lmc_set_protocol(sc, ctl);
 }
@@ -833,9 +805,8 @@ static void lmc_t1_init(struct card * const sc)
 static void lmc_t1_default(struct card * const sc)
 {
 	sc->lmc_miireg16 = LMC_MII16_LED_ALL;
-	sc->lmc_media->set_link_status(sc, LMC_LINK_DOWN);
-	sc->lmc_media->set_circuit_type(sc, LMC_CTL_CIRCUIT_TYPE_T1);
-	sc->lmc_media->set_crc_length(sc, LMC_CTL_CRC_LENGTH_16);
+	lmc_t1_set_circuit_type(sc, LMC_CTL_CIRCUIT_TYPE_T1);
+	lmc_t1_set_crc_length(sc, LMC_CTL_CRC_LENGTH_16);
 	/* Right now we can only clock from out internal source */
 	sc->ictl.clock_source = LMC_CTL_CLOCK_SOURCE_INT;
 }
@@ -844,18 +815,17 @@ static void lmc_t1_default(struct card * const sc)
 static void lmc_t1_set_status(struct card * const sc, struct control *ctl)
 {
 	if (ctl == NULL) {
-		sc->lmc_media->set_circuit_type(sc, sc->ictl.circuit_type);
+		lmc_t1_set_circuit_type(sc, sc->ictl.circuit_type);
 		lmc_set_protocol(sc, NULL);
-
 		return;
 	}
 	/* check for change in circuit type */
 	if (ctl->circuit_type == LMC_CTL_CIRCUIT_TYPE_T1
 	    && sc->ictl.circuit_type == LMC_CTL_CIRCUIT_TYPE_E1)
-		sc->lmc_media->set_circuit_type(sc, LMC_CTL_CIRCUIT_TYPE_E1);
+		lmc_t1_set_circuit_type(sc, LMC_CTL_CIRCUIT_TYPE_E1);
 	else if (ctl->circuit_type == LMC_CTL_CIRCUIT_TYPE_E1
 		 && sc->ictl.circuit_type == LMC_CTL_CIRCUIT_TYPE_T1)
-		sc->lmc_media->set_circuit_type(sc, LMC_CTL_CIRCUIT_TYPE_T1);
+		lmc_t1_set_circuit_type(sc, LMC_CTL_CIRCUIT_TYPE_T1);
 	lmc_set_protocol(sc, ctl);
 }
 
-- 
1.7.1.1

--
To unsubscribe from this list: send the line "unsubscribe netdev" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ