Commit de836c4b authored by Stephen Hemminger's avatar Stephen Hemminger

[PATCH] (1/3) skfp - cleanup is_XXX functions

This started out from sparse warnings about calling with fddi_broadcast
that is declared const.  This fixes that and gets rid of some of the namespace
pollution of this driver by moving the predicate function is_individual, is_broadcast, ...
as inline's in the one file that uses them.
Signed-off-by: default avatarStephen Hemminger <shemminger@osdl.org>
parent f08bf6b0
...@@ -571,10 +571,6 @@ int cfm_get_mac_output(struct s_smc *smc); ...@@ -571,10 +571,6 @@ int cfm_get_mac_output(struct s_smc *smc);
int port_to_mib(struct s_smc *smc, int p); int port_to_mib(struct s_smc *smc, int p);
int cem_build_path(struct s_smc *smc, char *to, int path_index); int cem_build_path(struct s_smc *smc, char *to, int path_index);
int sm_mac_get_tx_state(struct s_smc *smc); int sm_mac_get_tx_state(struct s_smc *smc);
int is_individual(struct fddi_addr *addr);
int is_my_addr(struct s_smc *smc, struct fddi_addr *addr);
int is_broadcast(struct fddi_addr *addr);
int is_equal(struct fddi_addr *addr1, struct fddi_addr *addr2);
char *get_pcmstate(struct s_smc *smc, int np); char *get_pcmstate(struct s_smc *smc, int np);
int smt_action(struct s_smc *smc, int class, int code, int index); int smt_action(struct s_smc *smc, int class, int code, int index);
u_short smt_online(struct s_smc *smc, int on); u_short smt_online(struct s_smc *smc, int on);
......
...@@ -76,8 +76,8 @@ static int mac_con_resource_index(struct s_smc *smc, int mac); ...@@ -76,8 +76,8 @@ static int mac_con_resource_index(struct s_smc *smc, int mac);
static int phy_con_resource_index(struct s_smc *smc, int phy); static int phy_con_resource_index(struct s_smc *smc, int phy);
static void smt_send_rdf(struct s_smc *smc, SMbuf *rej, int fc, int reason, static void smt_send_rdf(struct s_smc *smc, SMbuf *rej, int fc, int reason,
int local); int local);
static void smt_send_nif(struct s_smc *smc, struct fddi_addr *dest, int fc, static void smt_send_nif(struct s_smc *smc, const struct fddi_addr *dest,
u_long tid, int type, int local); int fc, u_long tid, int type, int local);
static void smt_send_ecf(struct s_smc *smc, struct fddi_addr *dest, int fc, static void smt_send_ecf(struct s_smc *smc, struct fddi_addr *dest, int fc,
u_long tid, int type, int len); u_long tid, int type, int len);
static void smt_echo_test(struct s_smc *smc, int dna); static void smt_echo_test(struct s_smc *smc, int dna);
...@@ -123,6 +123,45 @@ void hwm_conv_can(struct s_smc *smc, char *data, int len); ...@@ -123,6 +123,45 @@ void hwm_conv_can(struct s_smc *smc, char *data, int len);
#define hwm_conv_can(smc,data,len) #define hwm_conv_can(smc,data,len)
#endif #endif
static inline int is_my_addr(const struct s_smc *smc,
const struct fddi_addr *addr)
{
return(*(short *)(&addr->a[0]) ==
*(short *)(&smc->mib.m[MAC0].fddiMACSMTAddress.a[0])
&& *(short *)(&addr->a[2]) ==
*(short *)(&smc->mib.m[MAC0].fddiMACSMTAddress.a[2])
&& *(short *)(&addr->a[4]) ==
*(short *)(&smc->mib.m[MAC0].fddiMACSMTAddress.a[4])) ;
}
static inline int is_zero(const struct fddi_addr *addr)
{
return(*(short *)(&addr->a[0]) == 0 &&
*(short *)(&addr->a[2]) == 0 &&
*(short *)(&addr->a[4]) == 0 ) ;
}
static inline int is_broadcast(const struct fddi_addr *addr)
{
return(*(u_short *)(&addr->a[0]) == 0xffff &&
*(u_short *)(&addr->a[2]) == 0xffff &&
*(u_short *)(&addr->a[4]) == 0xffff ) ;
}
static inline int is_individual(const struct fddi_addr *addr)
{
return(!(addr->a[0] & GROUP_ADDR)) ;
}
static inline int is_equal(const struct fddi_addr *addr1,
const struct fddi_addr *addr2)
{
return(*(u_short *)(&addr1->a[0]) == *(u_short *)(&addr2->a[0]) &&
*(u_short *)(&addr1->a[2]) == *(u_short *)(&addr2->a[2]) &&
*(u_short *)(&addr1->a[4]) == *(u_short *)(&addr2->a[4]) ) ;
}
/* /*
* list of mandatory paras in frames * list of mandatory paras in frames
*/ */
...@@ -382,7 +421,7 @@ void smt_event(struct s_smc *smc, int event) ...@@ -382,7 +421,7 @@ void smt_event(struct s_smc *smc, int event)
*/ */
if (!smc->sm.pend[SMT_TID_NIF]) if (!smc->sm.pend[SMT_TID_NIF])
smc->sm.pend[SMT_TID_NIF] = smt_get_tid(smc) ; smc->sm.pend[SMT_TID_NIF] = smt_get_tid(smc) ;
smt_send_nif(smc,&fddi_broadcast,FC_SMT_NSA, smt_send_nif(smc,&fddi_broadcast, FC_SMT_NSA,
smc->sm.pend[SMT_TID_NIF], SMT_REQUEST,0) ; smc->sm.pend[SMT_TID_NIF], SMT_REQUEST,0) ;
smc->sm.smt_last_notify = time ; smc->sm.smt_last_notify = time ;
} }
...@@ -926,8 +965,8 @@ static void smt_send_rdf(struct s_smc *smc, SMbuf *rej, int fc, int reason, ...@@ -926,8 +965,8 @@ static void smt_send_rdf(struct s_smc *smc, SMbuf *rej, int fc, int reason,
/* /*
* generate and send NIF * generate and send NIF
*/ */
static void smt_send_nif(struct s_smc *smc, struct fddi_addr *dest, int fc, static void smt_send_nif(struct s_smc *smc, const struct fddi_addr *dest,
u_long tid, int type, int local) int fc, u_long tid, int type, int local)
/* struct fddi_addr *dest; dest address */ /* struct fddi_addr *dest; dest address */
/* int fc; frame control */ /* int fc; frame control */
/* u_long tid; transaction id */ /* u_long tid; transaction id */
...@@ -1688,43 +1727,6 @@ void *sm_to_para(struct s_smc *smc, struct smt_header *sm, int para) ...@@ -1688,43 +1727,6 @@ void *sm_to_para(struct s_smc *smc, struct smt_header *sm, int para)
return(0) ; return(0) ;
} }
int is_my_addr(struct s_smc *smc, struct fddi_addr *addr)
{
return(*(short *)(&addr->a[0]) ==
*(short *)(&smc->mib.m[MAC0].fddiMACSMTAddress.a[0])
&& *(short *)(&addr->a[2]) ==
*(short *)(&smc->mib.m[MAC0].fddiMACSMTAddress.a[2])
&& *(short *)(&addr->a[4]) ==
*(short *)(&smc->mib.m[MAC0].fddiMACSMTAddress.a[4])) ;
}
int is_zero(struct fddi_addr *addr)
{
return(*(short *)(&addr->a[0]) == 0 &&
*(short *)(&addr->a[2]) == 0 &&
*(short *)(&addr->a[4]) == 0 ) ;
}
int is_broadcast(struct fddi_addr *addr)
{
return(*(u_short *)(&addr->a[0]) == 0xffff &&
*(u_short *)(&addr->a[2]) == 0xffff &&
*(u_short *)(&addr->a[4]) == 0xffff ) ;
}
int is_individual(struct fddi_addr *addr)
{
return(!(addr->a[0] & GROUP_ADDR)) ;
}
int is_equal(struct fddi_addr *addr1, struct fddi_addr *addr2)
{
return(*(u_short *)(&addr1->a[0]) == *(u_short *)(&addr2->a[0]) &&
*(u_short *)(&addr1->a[2]) == *(u_short *)(&addr2->a[2]) &&
*(u_short *)(&addr1->a[4]) == *(u_short *)(&addr2->a[4]) ) ;
}
#if 0 #if 0
/* /*
* send ANTC data test frame * send ANTC data test frame
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment