diff options
author | Jeff Garzik <jeff@garzik.org> | 2006-10-20 17:43:15 -0400 |
---|---|---|
committer | Jeff Garzik <jeff@garzik.org> | 2006-10-21 14:08:24 -0400 |
commit | 6f0f6d87a2a5fc96fc54e90961d5244d668e5fbb (patch) | |
tree | ce92fab7f69c4400e6834350f76cbd6350ea0ca5 | |
parent | 718ecac2ed7ae1b3d61388ddbff2938a377b1a11 (diff) |
[PATCH] WAN/pc300: handle, propagate minor errors
- move definition of 'tmc' and 'br' locals closer to usage
- handle clock_rate_calc() error
- propagate errors back to upper level open routine
Signed-off-by: Jeff Garzik <jeff@garzik.org>
Cc: Krzysztof Halasa <khc@pm.waw.pl>
Signed-off-by: Andrew Morton <akpm@osdl.org>
Signed-off-by: Jeff Garzik <jeff@garzik.org>
-rw-r--r-- | drivers/net/wan/pc300_drv.c | 24 |
1 files changed, 19 insertions, 5 deletions
diff --git a/drivers/net/wan/pc300_drv.c b/drivers/net/wan/pc300_drv.c index 5823e3bca178..36d1c3ff7078 100644 --- a/drivers/net/wan/pc300_drv.c +++ b/drivers/net/wan/pc300_drv.c | |||
@@ -2867,7 +2867,6 @@ static int ch_config(pc300dev_t * d) | |||
2867 | uclong clktype = chan->conf.phys_settings.clock_type; | 2867 | uclong clktype = chan->conf.phys_settings.clock_type; |
2868 | ucshort encoding = chan->conf.proto_settings.encoding; | 2868 | ucshort encoding = chan->conf.proto_settings.encoding; |
2869 | ucshort parity = chan->conf.proto_settings.parity; | 2869 | ucshort parity = chan->conf.proto_settings.parity; |
2870 | int tmc, br; | ||
2871 | ucchar md0, md2; | 2870 | ucchar md0, md2; |
2872 | 2871 | ||
2873 | /* Reset the channel */ | 2872 | /* Reset the channel */ |
@@ -2940,8 +2939,12 @@ static int ch_config(pc300dev_t * d) | |||
2940 | case PC300_RSV: | 2939 | case PC300_RSV: |
2941 | case PC300_X21: | 2940 | case PC300_X21: |
2942 | if (clktype == CLOCK_INT || clktype == CLOCK_TXINT) { | 2941 | if (clktype == CLOCK_INT || clktype == CLOCK_TXINT) { |
2942 | int tmc, br; | ||
2943 | |||
2943 | /* Calculate the clkrate parameters */ | 2944 | /* Calculate the clkrate parameters */ |
2944 | tmc = clock_rate_calc(clkrate, card->hw.clock, &br); | 2945 | tmc = clock_rate_calc(clkrate, card->hw.clock, &br); |
2946 | if (tmc < 0) | ||
2947 | return -EIO; | ||
2945 | cpc_writeb(scabase + M_REG(TMCT, ch), tmc); | 2948 | cpc_writeb(scabase + M_REG(TMCT, ch), tmc); |
2946 | cpc_writeb(scabase + M_REG(TXS, ch), | 2949 | cpc_writeb(scabase + M_REG(TXS, ch), |
2947 | (TXS_DTRXC | TXS_IBRG | br)); | 2950 | (TXS_DTRXC | TXS_IBRG | br)); |
@@ -3097,14 +3100,16 @@ static int cpc_attach(struct net_device *dev, unsigned short encoding, | |||
3097 | return 0; | 3100 | return 0; |
3098 | } | 3101 | } |
3099 | 3102 | ||
3100 | static void cpc_opench(pc300dev_t * d) | 3103 | static int cpc_opench(pc300dev_t * d) |
3101 | { | 3104 | { |
3102 | pc300ch_t *chan = (pc300ch_t *) d->chan; | 3105 | pc300ch_t *chan = (pc300ch_t *) d->chan; |
3103 | pc300_t *card = (pc300_t *) chan->card; | 3106 | pc300_t *card = (pc300_t *) chan->card; |
3104 | int ch = chan->channel; | 3107 | int ch = chan->channel, rc; |
3105 | void __iomem *scabase = card->hw.scabase; | 3108 | void __iomem *scabase = card->hw.scabase; |
3106 | 3109 | ||
3107 | ch_config(d); | 3110 | rc = ch_config(d); |
3111 | if (rc) | ||
3112 | return rc; | ||
3108 | 3113 | ||
3109 | rx_config(d); | 3114 | rx_config(d); |
3110 | 3115 | ||
@@ -3113,6 +3118,8 @@ static void cpc_opench(pc300dev_t * d) | |||
3113 | /* Assert RTS and DTR */ | 3118 | /* Assert RTS and DTR */ |
3114 | cpc_writeb(scabase + M_REG(CTL, ch), | 3119 | cpc_writeb(scabase + M_REG(CTL, ch), |
3115 | cpc_readb(scabase + M_REG(CTL, ch)) & ~(CTL_RTS | CTL_DTR)); | 3120 | cpc_readb(scabase + M_REG(CTL, ch)) & ~(CTL_RTS | CTL_DTR)); |
3121 | |||
3122 | return 0; | ||
3116 | } | 3123 | } |
3117 | 3124 | ||
3118 | static void cpc_closech(pc300dev_t * d) | 3125 | static void cpc_closech(pc300dev_t * d) |
@@ -3168,9 +3175,16 @@ int cpc_open(struct net_device *dev) | |||
3168 | } | 3175 | } |
3169 | 3176 | ||
3170 | sprintf(ifr.ifr_name, "%s", dev->name); | 3177 | sprintf(ifr.ifr_name, "%s", dev->name); |
3171 | cpc_opench(d); | 3178 | result = cpc_opench(d); |
3179 | if (result) | ||
3180 | goto err_out; | ||
3181 | |||
3172 | netif_start_queue(dev); | 3182 | netif_start_queue(dev); |
3173 | return 0; | 3183 | return 0; |
3184 | |||
3185 | err_out: | ||
3186 | hdlc_close(dev); | ||
3187 | return result; | ||
3174 | } | 3188 | } |
3175 | 3189 | ||
3176 | static int cpc_close(struct net_device *dev) | 3190 | static int cpc_close(struct net_device *dev) |