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

sh_eth: coding style fixes

Running 'scripts/checkpatch.pl' on the driver files gives numerous warnings:

- block comments using empty /* line;

- unneeded \ at end of lines;

- message string split across lines;

- use of __attribute__((aligned(n))) instead of __aligned(n) macro;

- use of __attribute__((packed)) instead of __packed macro.

Additionally, running 'scripts/checkpatch.pl --strict' gives more complaints:

- including the paragraph about writing to FSF into the heading comment;

- alignment not matching open paren;

- multiple assignments on one line;

- use of CamelCase names;

- missing {} on one of the *if* arms where another has them;

- spinlock definition without a comment.

While fixing these, also do some more style cleanups:

- remove useless () around expressions;

- add {} around multi-line *if* operator's arm;

- remove space before comma;

- add spaces after /* and before */;

- properly align continuation lines of broken up expressions;

- realign comments to the structure fields.

Signed-off-by: Sergei Shtylyov <sergei.shtylyov@cogentembedded.com>
Signed-off-by: David S. Miller <davem@davemloft.net>

authored by

Sergei Shtylyov and committed by
David S. Miller
128296fc 45ea3932

+75 -88
+52 -58
drivers/net/ethernet/renesas/sh_eth.c
··· 1 - /* 2 - * SuperH Ethernet device driver 1 + /* SuperH Ethernet device driver 3 2 * 4 3 * Copyright (C) 2006-2012 Nobuhiro Iwamatsu 5 4 * Copyright (C) 2008-2013 Renesas Solutions Corp. ··· 12 13 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 13 14 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for 14 15 * more details. 15 - * You should have received a copy of the GNU General Public License along with 16 - * this program; if not, write to the Free Software Foundation, Inc., 17 - * 51 Franklin St - Fifth Floor, Boston, MA 02110-1301 USA. 18 16 * 19 17 * The full GNU General Public License is included in this distribution in 20 18 * the file called "COPYING". ··· 642 646 .eesipr_value = DMAC_M_RFRMER | DMAC_M_ECI | 0x003fffff, 643 647 644 648 .tx_check = EESR_TC1 | EESR_FTC, 645 - .eesr_err_check = EESR_TWB1 | EESR_TWB | EESR_TABT | EESR_RABT | \ 646 - EESR_RDE | EESR_RFRMER | EESR_TFE | EESR_TDE | \ 649 + .eesr_err_check = EESR_TWB1 | EESR_TWB | EESR_TABT | EESR_RABT | 650 + EESR_RDE | EESR_RFRMER | EESR_TFE | EESR_TDE | 647 651 EESR_ECI, 648 652 649 653 .apr = 1, ··· 728 732 cd->ecsipr_value = DEFAULT_ECSIPR_INIT; 729 733 730 734 if (!cd->fcftr_value) 731 - cd->fcftr_value = DEFAULT_FIFO_F_D_RFF | \ 735 + cd->fcftr_value = DEFAULT_FIFO_F_D_RFF | 732 736 DEFAULT_FIFO_F_D_RFD; 733 737 734 738 if (!cd->fdr_value) ··· 845 849 return x; 846 850 } 847 851 848 - /* 849 - * Program the hardware MAC address from dev->dev_addr. 850 - */ 852 + /* Program the hardware MAC address from dev->dev_addr. */ 851 853 static void update_mac_address(struct net_device *ndev) 852 854 { 853 855 sh_eth_write(ndev, 854 - (ndev->dev_addr[0] << 24) | (ndev->dev_addr[1] << 16) | 855 - (ndev->dev_addr[2] << 8) | (ndev->dev_addr[3]), MAHR); 856 + (ndev->dev_addr[0] << 24) | (ndev->dev_addr[1] << 16) | 857 + (ndev->dev_addr[2] << 8) | (ndev->dev_addr[3]), MAHR); 856 858 sh_eth_write(ndev, 857 - (ndev->dev_addr[4] << 8) | (ndev->dev_addr[5]), MALR); 859 + (ndev->dev_addr[4] << 8) | (ndev->dev_addr[5]), MALR); 858 860 } 859 861 860 - /* 861 - * Get MAC address from SuperH MAC address register 862 + /* Get MAC address from SuperH MAC address register 862 863 * 863 864 * SuperH's Ethernet device doesn't have 'ROM' to MAC address. 864 865 * This driver get MAC address that use by bootloader(U-boot or sh-ipl+g). ··· 1012 1019 int rx_ringsize = sizeof(*rxdesc) * mdp->num_rx_ring; 1013 1020 int tx_ringsize = sizeof(*txdesc) * mdp->num_tx_ring; 1014 1021 1015 - mdp->cur_rx = mdp->cur_tx = 0; 1016 - mdp->dirty_rx = mdp->dirty_tx = 0; 1022 + mdp->cur_rx = 0; 1023 + mdp->cur_tx = 0; 1024 + mdp->dirty_rx = 0; 1025 + mdp->dirty_tx = 0; 1017 1026 1018 1027 memset(mdp->rx_ring, 0, rx_ringsize); 1019 1028 ··· 1028 1033 if (skb == NULL) 1029 1034 break; 1030 1035 dma_map_single(&ndev->dev, skb->data, mdp->rx_buf_sz, 1031 - DMA_FROM_DEVICE); 1036 + DMA_FROM_DEVICE); 1032 1037 sh_eth_set_receive_align(skb); 1033 1038 1034 1039 /* RX descriptor */ ··· 1076 1081 struct sh_eth_private *mdp = netdev_priv(ndev); 1077 1082 int rx_ringsize, tx_ringsize, ret = 0; 1078 1083 1079 - /* 1080 - * +26 gets the maximum ethernet encapsulation, +7 & ~7 because the 1084 + /* +26 gets the maximum ethernet encapsulation, +7 & ~7 because the 1081 1085 * card needs room to do 8 byte alignment, +2 so we can reserve 1082 1086 * the first 2 bytes, and +16 gets room for the status word from the 1083 1087 * card. ··· 1251 1257 { 1252 1258 struct sh_eth_private *mdp = netdev_priv(ndev); 1253 1259 struct sh_eth_txdesc *txdesc; 1254 - int freeNum = 0; 1260 + int free_num = 0; 1255 1261 int entry = 0; 1256 1262 1257 1263 for (; mdp->cur_tx - mdp->dirty_tx > 0; mdp->dirty_tx++) { ··· 1265 1271 txdesc->buffer_length, DMA_TO_DEVICE); 1266 1272 dev_kfree_skb_irq(mdp->tx_skbuff[entry]); 1267 1273 mdp->tx_skbuff[entry] = NULL; 1268 - freeNum++; 1274 + free_num++; 1269 1275 } 1270 1276 txdesc->status = cpu_to_edmac(mdp, TD_TFP); 1271 1277 if (entry >= mdp->num_tx_ring - 1) ··· 1274 1280 ndev->stats.tx_packets++; 1275 1281 ndev->stats.tx_bytes += txdesc->buffer_length; 1276 1282 } 1277 - return freeNum; 1283 + return free_num; 1278 1284 } 1279 1285 1280 1286 /* Packet receive function */ ··· 1307 1313 if (!(desc_status & RDFEND)) 1308 1314 ndev->stats.rx_length_errors++; 1309 1315 1310 - /* 1311 - * In case of almost all GETHER/ETHERs, the Receive Frame State 1316 + /* In case of almost all GETHER/ETHERs, the Receive Frame State 1312 1317 * (RFS) bits in the Receive Descriptor 0 are from bit 9 to 1313 1318 * bit 0. However, in case of the R8A7740's GETHER, the RFS 1314 1319 * bits are from bit 25 to bit 16. So, the driver needs right ··· 1367 1374 if (skb == NULL) 1368 1375 break; /* Better luck next round. */ 1369 1376 dma_map_single(&ndev->dev, skb->data, mdp->rx_buf_sz, 1370 - DMA_FROM_DEVICE); 1377 + DMA_FROM_DEVICE); 1371 1378 sh_eth_set_receive_align(skb); 1372 1379 1373 1380 skb_checksum_none_assert(skb); ··· 1385 1392 /* If we don't need to check status, don't. -KDU */ 1386 1393 if (!(sh_eth_read(ndev, EDRRR) & EDRRR_R)) { 1387 1394 /* fix the values for the next receiving if RDE is set */ 1388 - if (intr_status & EESR_RDE) 1389 - mdp->cur_rx = mdp->dirty_rx = 1390 - (sh_eth_read(ndev, RDFAR) - 1391 - sh_eth_read(ndev, RDLAR)) >> 4; 1395 + if (intr_status & EESR_RDE) { 1396 + u32 count = (sh_eth_read(ndev, RDFAR) - 1397 + sh_eth_read(ndev, RDLAR)) >> 4; 1398 + 1399 + mdp->cur_rx = count; 1400 + mdp->dirty_rx = count; 1401 + } 1392 1402 sh_eth_write(ndev, EDRRR_R, EDRRR); 1393 1403 } 1394 1404 ··· 1434 1438 if (mdp->ether_link_active_low) 1435 1439 link_stat = ~link_stat; 1436 1440 } 1437 - if (!(link_stat & PHY_ST_LINK)) 1441 + if (!(link_stat & PHY_ST_LINK)) { 1438 1442 sh_eth_rcv_snd_disable(ndev); 1439 - else { 1443 + } else { 1440 1444 /* Link Up */ 1441 1445 sh_eth_write(ndev, sh_eth_read(ndev, EESIPR) & 1442 - ~DMAC_M_ECI, EESIPR); 1443 - /*clear int */ 1446 + ~DMAC_M_ECI, EESIPR); 1447 + /* clear int */ 1444 1448 sh_eth_write(ndev, sh_eth_read(ndev, ECSR), 1445 - ECSR); 1449 + ECSR); 1446 1450 sh_eth_write(ndev, sh_eth_read(ndev, EESIPR) | 1447 - DMAC_M_ECI, EESIPR); 1451 + DMAC_M_ECI, EESIPR); 1448 1452 /* enable tx and rx */ 1449 1453 sh_eth_rcv_snd_enable(ndev); 1450 1454 } ··· 1515 1519 u32 edtrr = sh_eth_read(ndev, EDTRR); 1516 1520 /* dmesg */ 1517 1521 dev_err(&ndev->dev, "TX error. status=%8.8x cur_tx=%8.8x ", 1518 - intr_status, mdp->cur_tx); 1522 + intr_status, mdp->cur_tx); 1519 1523 dev_err(&ndev->dev, "dirty_tx=%8.8x state=%8.8x EDTRR=%8.8x.\n", 1520 - mdp->dirty_tx, (u32) ndev->state, edtrr); 1524 + mdp->dirty_tx, (u32) ndev->state, edtrr); 1521 1525 /* dirty buffer free */ 1522 1526 sh_eth_txfree(ndev); 1523 1527 ··· 1640 1644 } 1641 1645 if (!mdp->link) { 1642 1646 sh_eth_write(ndev, 1643 - (sh_eth_read(ndev, ECMR) & ~ECMR_TXF), ECMR); 1647 + sh_eth_read(ndev, ECMR) & ~ECMR_TXF, 1648 + ECMR); 1644 1649 new_state = 1; 1645 1650 mdp->link = phydev->link; 1646 1651 if (mdp->cd->no_psr || mdp->no_ether_link) ··· 1668 1671 struct phy_device *phydev = NULL; 1669 1672 1670 1673 snprintf(phy_id, sizeof(phy_id), PHY_ID_FMT, 1671 - mdp->mii_bus->id , mdp->phy_id); 1674 + mdp->mii_bus->id, mdp->phy_id); 1672 1675 1673 1676 mdp->link = 0; 1674 1677 mdp->speed = 0; ··· 1706 1709 } 1707 1710 1708 1711 static int sh_eth_get_settings(struct net_device *ndev, 1709 - struct ethtool_cmd *ecmd) 1712 + struct ethtool_cmd *ecmd) 1710 1713 { 1711 1714 struct sh_eth_private *mdp = netdev_priv(ndev); 1712 1715 unsigned long flags; ··· 1720 1723 } 1721 1724 1722 1725 static int sh_eth_set_settings(struct net_device *ndev, 1723 - struct ethtool_cmd *ecmd) 1726 + struct ethtool_cmd *ecmd) 1724 1727 { 1725 1728 struct sh_eth_private *mdp = netdev_priv(ndev); 1726 1729 unsigned long flags; ··· 1796 1799 } 1797 1800 1798 1801 static void sh_eth_get_ethtool_stats(struct net_device *ndev, 1799 - struct ethtool_stats *stats, u64 *data) 1802 + struct ethtool_stats *stats, u64 *data) 1800 1803 { 1801 1804 struct sh_eth_private *mdp = netdev_priv(ndev); 1802 1805 int i = 0; ··· 1813 1816 switch (stringset) { 1814 1817 case ETH_SS_STATS: 1815 1818 memcpy(data, *sh_eth_gstrings_stats, 1816 - sizeof(sh_eth_gstrings_stats)); 1819 + sizeof(sh_eth_gstrings_stats)); 1817 1820 break; 1818 1821 } 1819 1822 } ··· 1948 1951 1949 1952 netif_stop_queue(ndev); 1950 1953 1951 - if (netif_msg_timer(mdp)) 1952 - dev_err(&ndev->dev, "%s: transmit timed out, status %8.8x," 1953 - " resetting...\n", ndev->name, (int)sh_eth_read(ndev, EESR)); 1954 + if (netif_msg_timer(mdp)) { 1955 + dev_err(&ndev->dev, "%s: transmit timed out, status %8.8x, resetting...\n", 1956 + ndev->name, (int)sh_eth_read(ndev, EESR)); 1957 + } 1954 1958 1955 1959 /* tx_errors count up */ 1956 1960 ndev->stats.tx_errors++; ··· 2084 2086 } 2085 2087 2086 2088 /* ioctl to device function */ 2087 - static int sh_eth_do_ioctl(struct net_device *ndev, struct ifreq *rq, 2088 - int cmd) 2089 + static int sh_eth_do_ioctl(struct net_device *ndev, struct ifreq *rq, int cmd) 2089 2090 { 2090 2091 struct sh_eth_private *mdp = netdev_priv(ndev); 2091 2092 struct phy_device *phydev = mdp->phydev; ··· 2339 2342 unsigned long flags; 2340 2343 2341 2344 spin_lock_irqsave(&mdp->lock, flags); 2342 - /* 2343 - * Initial condition is MCT = 1, PRM = 0. 2345 + /* Initial condition is MCT = 1, PRM = 0. 2344 2346 * Depending on ndev->flags, set PRM or clear MCT 2345 2347 */ 2346 2348 ecmr_bits = (sh_eth_read(ndev, ECMR) & ~ECMR_PRM) | ECMR_MCT; ··· 2405 2409 2406 2410 mdp->vlan_num_ids++; 2407 2411 2408 - /* 2409 - * The controller has one VLAN tag HW filter. So, if the filter is 2412 + /* The controller has one VLAN tag HW filter. So, if the filter is 2410 2413 * already enabled, the driver disables it and the filte 2411 2414 */ 2412 2415 if (mdp->vlan_num_ids > 1) { ··· 2521 2526 mdp->mii_bus->name = "sh_mii"; 2522 2527 mdp->mii_bus->parent = &ndev->dev; 2523 2528 snprintf(mdp->mii_bus->id, MII_BUS_ID_SIZE, "%s-%x", 2524 - mdp->pdev->name, id); 2529 + mdp->pdev->name, id); 2525 2530 2526 2531 /* PHY IRQ */ 2527 2532 mdp->mii_bus->irq = devm_kzalloc(&ndev->dev, ··· 2734 2739 2735 2740 /* print device information */ 2736 2741 pr_info("Base address at 0x%x, %pM, IRQ %d.\n", 2737 - (u32)ndev->base_addr, ndev->dev_addr, ndev->irq); 2742 + (u32)ndev->base_addr, ndev->dev_addr, ndev->irq); 2738 2743 2739 2744 platform_set_drvdata(pdev, ndev); 2740 2745 ··· 2772 2777 #ifdef CONFIG_PM 2773 2778 static int sh_eth_runtime_nop(struct device *dev) 2774 2779 { 2775 - /* 2776 - * Runtime PM callback shared between ->runtime_suspend() 2780 + /* Runtime PM callback shared between ->runtime_suspend() 2777 2781 * and ->runtime_resume(). Simply returns success. 2778 2782 * 2779 2783 * This driver re-initializes all registers after
+23 -30
drivers/net/ethernet/renesas/sh_eth.h
··· 1 - /* 2 - * SuperH Ethernet device driver 1 + /* SuperH Ethernet device driver 3 2 * 4 3 * Copyright (C) 2006-2012 Nobuhiro Iwamatsu 5 4 * Copyright (C) 2008-2012 Renesas Solutions Corp. ··· 11 12 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 12 13 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for 13 14 * more details. 14 - * You should have received a copy of the GNU General Public License along with 15 - * this program; if not, write to the Free Software Foundation, Inc., 16 - * 51 Franklin St - Fifth Floor, Boston, MA 02110-1301 USA. 17 15 * 18 16 * The full GNU General Public License is included in this distribution in 19 17 * the file called "COPYING". ··· 167 171 #define SH2_SH3_SKB_RX_ALIGN 2 168 172 #endif 169 173 170 - /* 171 - * Register's bits 174 + /* Register's bits 172 175 */ 173 176 /* EDSR : sh7734, sh7757, sh7763, and r8a7740 only */ 174 177 enum EDSR_BIT { ··· 194 199 EDTRR_TRNS_ETHER = 0x01, 195 200 }; 196 201 197 - /* EDRRR*/ 202 + /* EDRRR */ 198 203 enum EDRRR_R_BIT { 199 204 EDRRR_R = 0x01, 200 205 }; ··· 417 422 #define TSU_VTAG_ENABLE 0x80000000 418 423 #define TSU_VTAG_VID_MASK 0x00000fff 419 424 420 - /* 421 - * The sh ether Tx buffer descriptors. 425 + /* The sh ether Tx buffer descriptors. 422 426 * This structure should be 20 bytes. 423 427 */ 424 428 struct sh_eth_txdesc { ··· 431 437 #endif 432 438 u32 addr; /* TD2 */ 433 439 u32 pad1; /* padding data */ 434 - } __attribute__((aligned(2), packed)); 440 + } __aligned(2) __packed; 435 441 436 - /* 437 - * The sh ether Rx buffer descriptors. 442 + /* The sh ether Rx buffer descriptors. 438 443 * This structure should be 20 bytes. 439 444 */ 440 445 struct sh_eth_rxdesc { ··· 447 454 #endif 448 455 u32 addr; /* RD2 */ 449 456 u32 pad0; /* padding data */ 450 - } __attribute__((aligned(2), packed)); 457 + } __aligned(2) __packed; 451 458 452 459 /* This structure is used by each CPU dependency handling. */ 453 460 struct sh_eth_cpu_data { ··· 473 480 unsigned long eesr_err_check; 474 481 475 482 /* hardware features */ 476 - unsigned long irq_flags; /* IRQ configuration flags */ 477 - unsigned no_psr:1; /* EtherC DO NOT have PSR */ 478 - unsigned apr:1; /* EtherC have APR */ 479 - unsigned mpr:1; /* EtherC have MPR */ 480 - unsigned tpauser:1; /* EtherC have TPAUSER */ 481 - unsigned bculr:1; /* EtherC have BCULR */ 482 - unsigned tsu:1; /* EtherC have TSU */ 483 - unsigned hw_swap:1; /* E-DMAC have DE bit in EDMR */ 484 - unsigned rpadir:1; /* E-DMAC have RPADIR */ 485 - unsigned no_trimd:1; /* E-DMAC DO NOT have TRIMD */ 483 + unsigned long irq_flags; /* IRQ configuration flags */ 484 + unsigned no_psr:1; /* EtherC DO NOT have PSR */ 485 + unsigned apr:1; /* EtherC have APR */ 486 + unsigned mpr:1; /* EtherC have MPR */ 487 + unsigned tpauser:1; /* EtherC have TPAUSER */ 488 + unsigned bculr:1; /* EtherC have BCULR */ 489 + unsigned tsu:1; /* EtherC have TSU */ 490 + unsigned hw_swap:1; /* E-DMAC have DE bit in EDMR */ 491 + unsigned rpadir:1; /* E-DMAC have RPADIR */ 492 + unsigned no_trimd:1; /* E-DMAC DO NOT have TRIMD */ 486 493 unsigned no_ade:1; /* E-DMAC DO NOT have ADE bit in EESR */ 487 494 unsigned hw_crc:1; /* E-DMAC have CSMR */ 488 495 unsigned select_mii:1; /* EtherC have RMII_MII (MII select register) */ ··· 504 511 struct sh_eth_txdesc *tx_ring; 505 512 struct sk_buff **rx_skbuff; 506 513 struct sk_buff **tx_skbuff; 507 - spinlock_t lock; 508 - u32 cur_rx, dirty_rx; /* Producer/consumer ring indices */ 514 + spinlock_t lock; /* Register access lock */ 515 + u32 cur_rx, dirty_rx; /* Producer/consumer ring indices */ 509 516 u32 cur_tx, dirty_tx; 510 - u32 rx_buf_sz; /* Based on MTU+slack. */ 517 + u32 rx_buf_sz; /* Based on MTU+slack. */ 511 518 int edmac_endian; 512 519 struct napi_struct napi; 513 520 /* MII transceiver section. */ 514 - u32 phy_id; /* PHY ID */ 521 + u32 phy_id; /* PHY ID */ 515 522 struct mii_bus *mii_bus; /* MDIO bus control */ 516 523 struct phy_device *phydev; /* PHY device control */ 517 524 int link; ··· 519 526 int msg_enable; 520 527 int speed; 521 528 int duplex; 522 - int port; /* for TSU */ 523 - int vlan_num_ids; /* for VLAN tag filter */ 529 + int port; /* for TSU */ 530 + int vlan_num_ids; /* for VLAN tag filter */ 524 531 525 532 unsigned no_ether_link:1; 526 533 unsigned ether_link_active_low:1;