Fixed coding style issue for missing blank lines after variable declarations.
Signed-off-by: Benjamin Young <youngc...@gmail.com> --- drivers/thunderbolt/cap.c | 2 ++ drivers/thunderbolt/ctl.c | 10 ++++++++++ drivers/thunderbolt/eeprom.c | 11 +++++++++++ drivers/thunderbolt/nhi.c | 13 +++++++++++++ drivers/thunderbolt/path.c | 5 +++++ drivers/thunderbolt/switch.c | 8 ++++++++ drivers/thunderbolt/tb.c | 10 ++++++++++ drivers/thunderbolt/tunnel_pci.c | 4 ++++ 8 files changed, 63 insertions(+) diff --git a/drivers/thunderbolt/cap.c b/drivers/thunderbolt/cap.c index a7b47e7..31be7bc 100644 --- a/drivers/thunderbolt/cap.c +++ b/drivers/thunderbolt/cap.c @@ -43,6 +43,7 @@ static enum tb_cap tb_cap(struct tb_cap_any *cap) static u32 tb_cap_next(struct tb_cap_any *cap, u32 offset) { int next; + if (offset == 1) { /* * The first pointer is part of the switch header and always @@ -83,6 +84,7 @@ int tb_find_cap(struct tb_port *port, enum tb_cfg_space space, enum tb_cap cap) struct tb_cap_any header; int res; int retries = 10; + while (retries--) { res = tb_port_read(port, &header, space, offset, 1); if (res) { diff --git a/drivers/thunderbolt/ctl.c b/drivers/thunderbolt/ctl.c index 799634b..0cde9d7 100644 --- a/drivers/thunderbolt/ctl.c +++ b/drivers/thunderbolt/ctl.c @@ -202,6 +202,7 @@ static struct tb_cfg_result decode_error(struct ctl_pkg *response) { struct cfg_error_pkg *pkg = response->buffer; struct tb_cfg_result res = { 0 }; + res.response_route = get_route(pkg->header); res.response_port = 0; res.err = check_header(response, sizeof(*pkg), TB_CFG_PKG_ERROR, @@ -276,6 +277,7 @@ static void tb_cfg_print_error(struct tb_ctl *ctl, static void cpu_to_be32_array(__be32 *dst, u32 *src, size_t len) { int i; + for (i = 0; i < len; i++) dst[i] = cpu_to_be32(src[i]); } @@ -283,6 +285,7 @@ static void cpu_to_be32_array(__be32 *dst, u32 *src, size_t len) static void be32_to_cpu_array(u32 *dst, __be32 *src, size_t len) { int i; + for (i = 0; i < len; i++) dst[i] = be32_to_cpu(src[i]); } @@ -304,6 +307,7 @@ static void tb_ctl_pkg_free(struct ctl_pkg *pkg) static struct ctl_pkg *tb_ctl_pkg_alloc(struct tb_ctl *ctl) { struct ctl_pkg *pkg = kzalloc(sizeof(*pkg), GFP_KERNEL); + if (!pkg) return NULL; pkg->ctl = ctl; @@ -323,6 +327,7 @@ static void tb_ctl_tx_callback(struct tb_ring *ring, struct ring_frame *frame, bool canceled) { struct ctl_pkg *pkg = container_of(frame, typeof(*pkg), frame); + tb_ctl_pkg_free(pkg); } @@ -338,6 +343,7 @@ static int tb_ctl_tx(struct tb_ctl *ctl, void *data, size_t len, { int res; struct ctl_pkg *pkg; + if (len % 4 != 0) { /* required for le->be conversion */ tb_ctl_WARN(ctl, "TX: invalid size: %zu\n", len); return -EINVAL; @@ -370,6 +376,7 @@ static void tb_ctl_handle_plug_event(struct tb_ctl *ctl, struct ctl_pkg *response) { struct cfg_event_pkg *pkg = response->buffer; + u64 route = get_route(pkg->header); if (check_header(response, sizeof(*pkg), TB_CFG_PKG_EVENT, route)) { @@ -475,6 +482,7 @@ struct tb_ctl *tb_ctl_alloc(struct tb_nhi *nhi, hotplug_cb cb, void *cb_data) { int i; struct tb_ctl *ctl = kzalloc(sizeof(*ctl), GFP_KERNEL); + if (!ctl) return NULL; ctl->nhi = nhi; @@ -520,6 +528,7 @@ err: void tb_ctl_free(struct tb_ctl *ctl) { int i; + if (ctl->rx) ring_free(ctl->rx); if (ctl->tx) @@ -541,6 +550,7 @@ void tb_ctl_free(struct tb_ctl *ctl) void tb_ctl_start(struct tb_ctl *ctl) { int i; + tb_ctl_info(ctl, "control channel starting...\n"); ring_start(ctl->tx); /* is used to ack hotplug packets, start first */ ring_start(ctl->rx); diff --git a/drivers/thunderbolt/eeprom.c b/drivers/thunderbolt/eeprom.c index 0dde34e..9ff432b 100644 --- a/drivers/thunderbolt/eeprom.c +++ b/drivers/thunderbolt/eeprom.c @@ -39,6 +39,7 @@ static int tb_eeprom_active(struct tb_switch *sw, bool enable) { struct tb_eeprom_ctl ctl; int res = tb_eeprom_ctl_read(sw, &ctl); + if (res) return res; if (enable) { @@ -68,6 +69,7 @@ static int tb_eeprom_transfer(struct tb_switch *sw, struct tb_eeprom_ctl *ctl, enum tb_eeprom_transfer direction) { int res; + if (direction == TB_EEPROM_OUT) { res = tb_eeprom_ctl_write(sw, ctl); if (res) @@ -94,6 +96,7 @@ static int tb_eeprom_out(struct tb_switch *sw, u8 val) struct tb_eeprom_ctl ctl; int i; int res = tb_eeprom_ctl_read(sw, &ctl); + if (res) return res; for (i = 0; i < 8; i++) { @@ -114,6 +117,7 @@ static int tb_eeprom_in(struct tb_switch *sw, u8 *val) struct tb_eeprom_ctl ctl; int i; int res = tb_eeprom_ctl_read(sw, &ctl); + if (res) return res; *val = 0; @@ -134,6 +138,7 @@ static int tb_eeprom_read_n(struct tb_switch *sw, u16 offset, u8 *val, size_t count) { int i, res; + res = tb_eeprom_active(sw, true); if (res) return res; @@ -158,6 +163,7 @@ static u8 tb_crc8(u8 *data, int len) { int i, j; u8 val = 0xff; + for (i = 0; i < len; i++) { val ^= data[i]; for (j = 0; j < 8; j++) @@ -237,6 +243,7 @@ static int tb_eeprom_get_drom_offset(struct tb_switch *sw, u16 *offset) { struct tb_cap_plug_events cap; int res; + if (!sw->cap_plug_events) { tb_sw_warn(sw, "no TB_CAP_PLUG_EVENTS, cannot read eeprom\n"); return -ENOSYS; @@ -272,6 +279,7 @@ int tb_drom_read_uid_only(struct tb_switch *sw, u64 *uid) u16 drom_offset; u8 crc; int res = tb_eeprom_get_drom_offset(sw, &drom_offset); + if (res) return res; @@ -322,6 +330,7 @@ static int tb_drom_parse_entry(struct tb_switch *sw, if (type == TB_TYPE_PORT) { struct tb_drom_entry_port *entry = (void *) header; + if (header->len != sizeof(*entry)) { tb_sw_warn(sw, "port entry has size %#x (expected %#zx)\n", @@ -346,6 +355,7 @@ static int tb_drom_parse_entries(struct tb_switch *sw) while (pos < drom_size) { struct tb_drom_entry_header *entry = (void *) (sw->drom + pos); + if (pos + 1 == drom_size || pos + entry->len > drom_size || !entry->len) { tb_sw_warn(sw, "drom buffer overrun, aborting\n"); @@ -369,6 +379,7 @@ int tb_drom_read(struct tb_switch *sw) u32 crc; struct tb_drom_header *header; int res; + if (sw->drom) return 0; diff --git a/drivers/thunderbolt/nhi.c b/drivers/thunderbolt/nhi.c index 20a41f7..9bbd216 100644 --- a/drivers/thunderbolt/nhi.c +++ b/drivers/thunderbolt/nhi.c @@ -25,6 +25,7 @@ static int ring_interrupt_index(struct tb_ring *ring) { int bit = ring->hop; + if (!ring->is_tx) bit += ring->nhi->hop_count; return bit; @@ -41,6 +42,7 @@ static void ring_interrupt_active(struct tb_ring *ring, bool active) int bit = ring_interrupt_index(ring) & 31; int mask = 1 << bit; u32 old, new; + old = ioread32(ring->nhi->iobase + reg); if (active) new = old | mask; @@ -81,6 +83,7 @@ static void nhi_disable_interrupts(struct tb_nhi *nhi) static void __iomem *ring_desc_base(struct tb_ring *ring) { void __iomem *io = ring->nhi->iobase; + io += ring->is_tx ? REG_TX_RING_BASE : REG_RX_RING_BASE; io += ring->hop * 16; return io; @@ -89,6 +92,7 @@ static void __iomem *ring_desc_base(struct tb_ring *ring) static void __iomem *ring_options_base(struct tb_ring *ring) { void __iomem *io = ring->nhi->iobase; + io += ring->is_tx ? REG_TX_OPTIONS_BASE : REG_RX_OPTIONS_BASE; io += ring->hop * 32; return io; @@ -134,6 +138,7 @@ static void ring_write_descriptors(struct tb_ring *ring) { struct ring_frame *frame, *n; struct ring_desc *descriptor; + list_for_each_entry_safe(frame, n, &ring->queue, list) { if (ring_full(ring)) break; @@ -167,6 +172,7 @@ static void ring_work(struct work_struct *work) struct ring_frame *frame; bool canceled = false; LIST_HEAD(done); + mutex_lock(&ring->lock); if (!ring->running) { @@ -227,6 +233,7 @@ invoke_callback: int __ring_enqueue(struct tb_ring *ring, struct ring_frame *frame) { int ret = 0; + mutex_lock(&ring->lock); if (ring->running) { list_add_tail(&frame->list, &ring->queue); @@ -242,6 +249,7 @@ static struct tb_ring *ring_alloc(struct tb_nhi *nhi, u32 hop, int size, bool transmit) { struct tb_ring *ring = NULL; + dev_info(&nhi->pdev->dev, "allocating %s ring %d of size %d\n", transmit ? "TX" : "RX", hop, size); @@ -489,6 +497,7 @@ static void nhi_interrupt_work(struct work_struct *work) static irqreturn_t nhi_msi(int irq, void *data) { struct tb_nhi *nhi = data; + schedule_work(&nhi->interrupt_work); return IRQ_HANDLED; } @@ -497,6 +506,7 @@ static int nhi_suspend_noirq(struct device *dev) { struct pci_dev *pdev = to_pci_dev(dev); struct tb *tb = pci_get_drvdata(pdev); + thunderbolt_suspend(tb); return 0; } @@ -505,6 +515,7 @@ static int nhi_resume_noirq(struct device *dev) { struct pci_dev *pdev = to_pci_dev(dev); struct tb *tb = pci_get_drvdata(pdev); + thunderbolt_resume(tb); return 0; } @@ -512,6 +523,7 @@ static int nhi_resume_noirq(struct device *dev) static void nhi_shutdown(struct tb_nhi *nhi) { int i; + dev_info(&nhi->pdev->dev, "shutdown\n"); for (i = 0; i < nhi->hop_count; i++) { @@ -611,6 +623,7 @@ static void nhi_remove(struct pci_dev *pdev) { struct tb *tb = pci_get_drvdata(pdev); struct tb_nhi *nhi = tb->nhi; + thunderbolt_shutdown_and_free(tb); nhi_shutdown(nhi); } diff --git a/drivers/thunderbolt/path.c b/drivers/thunderbolt/path.c index 9562cd0..9e7ac45 100644 --- a/drivers/thunderbolt/path.c +++ b/drivers/thunderbolt/path.c @@ -35,6 +35,7 @@ static void tb_dump_hop(struct tb_port *port, struct tb_regs_hop *hop) struct tb_path *tb_path_alloc(struct tb *tb, int num_hops) { struct tb_path *path = kzalloc(sizeof(*path), GFP_KERNEL); + if (!path) return NULL; path->hops = kcalloc(num_hops, sizeof(*path->hops), GFP_KERNEL); @@ -63,6 +64,7 @@ void tb_path_free(struct tb_path *path) static void __tb_path_deallocate_nfc(struct tb_path *path, int first_hop) { int i, res; + for (i = first_hop; i < path->path_length; i++) { res = tb_port_add_nfc_credits(path->hops[i].in_port, -path->nfc_credits); @@ -77,6 +79,7 @@ static void __tb_path_deactivate_hops(struct tb_path *path, int first_hop) { int i, res; struct tb_regs_hop hop = { }; + for (i = first_hop; i < path->path_length; i++) { res = tb_port_write(path->hops[i].in_port, &hop, TB_CFG_HOPS, 2 * path->hops[i].in_hop_index, 2); @@ -116,6 +119,7 @@ int tb_path_activate(struct tb_path *path) { int i, res; enum tb_path_port out_mask, in_mask; + if (path->activated) { tb_WARN(path->tb, "trying to activate already activated path\n"); return -EINVAL; @@ -224,6 +228,7 @@ err: bool tb_path_is_invalid(struct tb_path *path) { int i = 0; + for (i = 0; i < path->path_length; i++) { if (path->hops[i].in_port->sw->is_unplugged) return true; diff --git a/drivers/thunderbolt/switch.c b/drivers/thunderbolt/switch.c index aeb9829..2a30cc9 100644 --- a/drivers/thunderbolt/switch.c +++ b/drivers/thunderbolt/switch.c @@ -64,6 +64,7 @@ static int tb_port_state(struct tb_port *port) { struct tb_cap_phy phy; int res; + if (port->cap_phy == 0) { tb_port_WARN(port, "does not have a PHY\n"); return -EINVAL; @@ -91,6 +92,7 @@ int tb_wait_for_port(struct tb_port *port, bool wait_if_unplugged) { int retries = 10; int state; + if (!port->cap_phy) { tb_port_WARN(port, "does not have PHY\n"); return -EINVAL; @@ -169,6 +171,7 @@ int tb_port_add_nfc_credits(struct tb_port *port, int credits) int tb_port_clear_counter(struct tb_port *port, int counter) { u32 zero[3] = { 0, 0, 0 }; + tb_port_info(port, "clearing counter %d\n", counter); return tb_port_write(port, zero, TB_CFG_COUNTERS, 3 * counter, 3); } @@ -342,6 +345,7 @@ struct tb_switch *tb_switch_alloc(struct tb *tb, u64 route) int cap; struct tb_switch *sw; int upstream_port = tb_cfg_get_upstream_port(tb->ctl, route); + if (upstream_port < 0) return NULL; @@ -430,6 +434,7 @@ err: void tb_sw_set_unpplugged(struct tb_switch *sw) { int i; + if (sw == sw->tb->root_switch) { tb_sw_WARN(sw, "cannot unplug root switch\n"); return; @@ -449,6 +454,7 @@ int tb_switch_resume(struct tb_switch *sw) { int i, err; u64 uid; + tb_sw_info(sw, "resuming switch\n"); err = tb_drom_read_uid_only(sw, &uid); @@ -475,6 +481,7 @@ int tb_switch_resume(struct tb_switch *sw) /* check for surviving downstream switches */ for (i = 1; i <= sw->config.max_port_number; i++) { struct tb_port *port = &sw->ports[i]; + if (tb_is_upstream_port(port)) continue; if (!port->remote) @@ -492,6 +499,7 @@ int tb_switch_resume(struct tb_switch *sw) void tb_switch_suspend(struct tb_switch *sw) { int i, err; + err = tb_plug_events_active(sw, false); if (err) return; diff --git a/drivers/thunderbolt/tb.c b/drivers/thunderbolt/tb.c index d2c3fe3..fd09dd7 100644 --- a/drivers/thunderbolt/tb.c +++ b/drivers/thunderbolt/tb.c @@ -24,6 +24,7 @@ static void tb_scan_port(struct tb_port *port); static void tb_scan_switch(struct tb_switch *sw) { int i; + for (i = 1; i <= sw->config.max_port_number; i++) tb_scan_port(&sw->ports[i]); } @@ -34,6 +35,7 @@ static void tb_scan_switch(struct tb_switch *sw) static void tb_scan_port(struct tb_port *port) { struct tb_switch *sw; + if (tb_is_upstream_port(port)) return; if (port->config.type != TB_TYPE_PORT) @@ -64,6 +66,7 @@ static void tb_free_invalid_tunnels(struct tb *tb) { struct tb_pci_tunnel *tunnel; struct tb_pci_tunnel *n; + list_for_each_entry_safe(tunnel, n, &tb->tunnel_list, list) { if (tb_pci_is_invalid(tunnel)) { @@ -79,8 +82,10 @@ static void tb_free_invalid_tunnels(struct tb *tb) static void tb_free_unplugged_children(struct tb_switch *sw) { int i; + for (i = 1; i <= sw->config.max_port_number; i++) { struct tb_port *port = &sw->ports[i]; + if (tb_is_upstream_port(port)) continue; if (!port->remote) @@ -101,6 +106,7 @@ static void tb_free_unplugged_children(struct tb_switch *sw) static struct tb_port *tb_find_pci_up_port(struct tb_switch *sw) { int i; + for (i = 1; i <= sw->config.max_port_number; i++) if (sw->ports[i].config.type == TB_TYPE_PCIE_UP) return &sw->ports[i]; @@ -116,6 +122,7 @@ static struct tb_port *tb_find_unused_down_port(struct tb_switch *sw) int cap; int res; int data; + for (i = 1; i <= sw->config.max_port_number; i++) { if (tb_is_upstream_port(&sw->ports[i])) continue; @@ -219,6 +226,7 @@ static void tb_handle_hotplug(struct work_struct *work) struct tb *tb = ev->tb; struct tb_switch *sw; struct tb_port *port; + mutex_lock(&tb->lock); if (!tb->hotplug_active) goto out; /* during init, suspend or shutdown */ @@ -286,6 +294,7 @@ static void tb_schedule_hotplug_handler(void *data, u64 route, u8 port, { struct tb *tb = data; struct tb_hotplug_event *ev = kmalloc(sizeof(*ev), GFP_KERNEL); + if (!ev) return; INIT_WORK(&ev->work, tb_handle_hotplug); @@ -409,6 +418,7 @@ void thunderbolt_suspend(struct tb *tb) void thunderbolt_resume(struct tb *tb) { struct tb_pci_tunnel *tunnel, *n; + tb_info(tb, "resuming...\n"); mutex_lock(&tb->lock); tb_ctl_start(tb->ctl); diff --git a/drivers/thunderbolt/tunnel_pci.c b/drivers/thunderbolt/tunnel_pci.c index baf1cd3..347fe6d 100644 --- a/drivers/thunderbolt/tunnel_pci.c +++ b/drivers/thunderbolt/tunnel_pci.c @@ -59,6 +59,7 @@ struct tb_pci_tunnel *tb_pci_alloc(struct tb *tb, struct tb_port *up, struct tb_port *down) { struct tb_pci_tunnel *tunnel = kzalloc(sizeof(*tunnel), GFP_KERNEL); + if (!tunnel) goto err; tunnel->tb = tb; @@ -148,6 +149,7 @@ static int tb_pci_port_active(struct tb_port *port, bool active) { u32 word = active ? 0x80000000 : 0x0; int cap = tb_find_cap(port, TB_CFG_PORT, TB_CAP_PCIE); + if (cap <= 0) { tb_port_warn(port, "TB_CAP_PCIE not found: %d\n", cap); return cap ? cap : -ENXIO; @@ -161,6 +163,7 @@ static int tb_pci_port_active(struct tb_port *port, bool active) int tb_pci_restart(struct tb_pci_tunnel *tunnel) { int res; + tunnel->path_to_up->activated = false; tunnel->path_to_down->activated = false; @@ -195,6 +198,7 @@ err: int tb_pci_activate(struct tb_pci_tunnel *tunnel) { int res; + if (tunnel->path_to_up->activated || tunnel->path_to_down->activated) { tb_tunnel_WARN(tunnel, "trying to activate an already activated tunnel\n"); -- 2.5.0 -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/