Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

staging: ozwpan: Move code from success handling to error handling

The original version was success handling rather than error handling,
therefore this patch reduces nesting.

Signed-off-by: Quentin Lambert <lambert.quentin@gmail.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

authored by

Quentin Lambert and committed by
Greg Kroah-Hartman
6498613d e03b7297

+36 -33
+10 -8
drivers/staging/ozwpan/ozhcd.c
··· 283 283 struct oz_endpoint *ep; 284 284 285 285 ep = kzalloc(sizeof(struct oz_endpoint)+buffer_size, mem_flags); 286 - if (ep) { 287 - INIT_LIST_HEAD(&ep->urb_list); 288 - INIT_LIST_HEAD(&ep->link); 289 - ep->credit = -1; 290 - if (buffer_size) { 291 - ep->buffer_size = buffer_size; 292 - ep->buffer = (u8 *)(ep+1); 293 - } 286 + if (!ep) 287 + return NULL; 288 + 289 + INIT_LIST_HEAD(&ep->urb_list); 290 + INIT_LIST_HEAD(&ep->link); 291 + ep->credit = -1; 292 + if (buffer_size) { 293 + ep->buffer_size = buffer_size; 294 + ep->buffer = (u8 *)(ep+1); 294 295 } 296 + 295 297 return ep; 296 298 } 297 299
+26 -25
drivers/staging/ozwpan/ozpd.c
··· 103 103 struct oz_pd *oz_pd_alloc(const u8 *mac_addr) 104 104 { 105 105 struct oz_pd *pd; 106 + int i; 106 107 107 108 pd = kzalloc(sizeof(struct oz_pd), GFP_ATOMIC); 108 - if (pd) { 109 - int i; 109 + if (!pd) 110 + return NULL; 110 111 111 - atomic_set(&pd->ref_count, 2); 112 - for (i = 0; i < OZ_NB_APPS; i++) 113 - spin_lock_init(&pd->app_lock[i]); 114 - pd->last_rx_pkt_num = 0xffffffff; 115 - oz_pd_set_state(pd, OZ_PD_S_IDLE); 116 - pd->max_tx_size = OZ_MAX_TX_SIZE; 117 - ether_addr_copy(pd->mac_addr, mac_addr); 118 - oz_elt_buf_init(&pd->elt_buff); 119 - spin_lock_init(&pd->tx_frame_lock); 120 - INIT_LIST_HEAD(&pd->tx_queue); 121 - INIT_LIST_HEAD(&pd->farewell_list); 122 - pd->last_sent_frame = &pd->tx_queue; 123 - spin_lock_init(&pd->stream_lock); 124 - INIT_LIST_HEAD(&pd->stream_list); 125 - tasklet_init(&pd->heartbeat_tasklet, oz_pd_heartbeat_handler, 126 - (unsigned long)pd); 127 - tasklet_init(&pd->timeout_tasklet, oz_pd_timeout_handler, 128 - (unsigned long)pd); 129 - hrtimer_init(&pd->heartbeat, CLOCK_MONOTONIC, HRTIMER_MODE_REL); 130 - hrtimer_init(&pd->timeout, CLOCK_MONOTONIC, HRTIMER_MODE_REL); 131 - pd->heartbeat.function = oz_pd_heartbeat_event; 132 - pd->timeout.function = oz_pd_timeout_event; 133 - } 112 + atomic_set(&pd->ref_count, 2); 113 + for (i = 0; i < OZ_NB_APPS; i++) 114 + spin_lock_init(&pd->app_lock[i]); 115 + pd->last_rx_pkt_num = 0xffffffff; 116 + oz_pd_set_state(pd, OZ_PD_S_IDLE); 117 + pd->max_tx_size = OZ_MAX_TX_SIZE; 118 + ether_addr_copy(pd->mac_addr, mac_addr); 119 + oz_elt_buf_init(&pd->elt_buff); 120 + spin_lock_init(&pd->tx_frame_lock); 121 + INIT_LIST_HEAD(&pd->tx_queue); 122 + INIT_LIST_HEAD(&pd->farewell_list); 123 + pd->last_sent_frame = &pd->tx_queue; 124 + spin_lock_init(&pd->stream_lock); 125 + INIT_LIST_HEAD(&pd->stream_list); 126 + tasklet_init(&pd->heartbeat_tasklet, oz_pd_heartbeat_handler, 127 + (unsigned long)pd); 128 + tasklet_init(&pd->timeout_tasklet, oz_pd_timeout_handler, 129 + (unsigned long)pd); 130 + hrtimer_init(&pd->heartbeat, CLOCK_MONOTONIC, HRTIMER_MODE_REL); 131 + hrtimer_init(&pd->timeout, CLOCK_MONOTONIC, HRTIMER_MODE_REL); 132 + pd->heartbeat.function = oz_pd_heartbeat_event; 133 + pd->timeout.function = oz_pd_timeout_event; 134 + 134 135 return pd; 135 136 } 136 137