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

Merge tag 'linux-can-next-for-5.4-20190903' of git://git.kernel.org/pub/scm/linux/kernel/git/mkl/linux-can-next

Marc Kleine-Budde says:

====================
pull-request: can-next 2019-09-03

this is a pull request for net-next/master consisting of 15 patches.

The first patch is by Christer Beskow, targets the kvaser_pciefd driver
and fixes the PWM generator's frequency.

The next three patches are by Dan Murphy, the tcan4x5x is updated to use
a proper interrupts/interrupt-parent DT binding to specify the devices
IRQ line. Further the unneeded wake ups of the device is removed from
the driver.

A patch by me for the mcp25xx driver removes the deprecated board file
setup example. Three patches by Andy Shevchenko simplify clock handling,
update the driver from OF to device property API and simplify the
mcp251x_can_suspend() function.

The remaining 7 patches are by me and clean up checkpatch warnings in
the generic CAN device infrastructure.
====================

Signed-off-by: David S. Miller <davem@davemloft.net>

+97 -155
+5 -2
Documentation/devicetree/bindings/net/can/tcan4x5x.txt
··· 10 10 - #size-cells: 0 11 11 - spi-max-frequency: Maximum frequency of the SPI bus the chip can 12 12 operate at should be less than or equal to 18 MHz. 13 - - data-ready-gpios: Interrupt GPIO for data and error reporting. 14 13 - device-wake-gpios: Wake up GPIO to wake up the TCAN device. 14 + - interrupt-parent: the phandle to the interrupt controller which provides 15 + the interrupt. 16 + - interrupts: interrupt specification for data-ready. 15 17 16 18 See Documentation/devicetree/bindings/net/can/m_can.txt for additional 17 19 required property details. ··· 32 30 #size-cells = <1>; 33 31 spi-max-frequency = <10000000>; 34 32 bosch,mram-cfg = <0x0 0 0 32 0 0 1 1>; 35 - data-ready-gpios = <&gpio1 14 GPIO_ACTIVE_LOW>; 33 + interrupt-parent = <&gpio1>; 34 + interrupts = <14 GPIO_ACTIVE_LOW>; 36 35 device-state-gpios = <&gpio3 21 GPIO_ACTIVE_HIGH>; 37 36 device-wake-gpios = <&gpio1 15 GPIO_ACTIVE_HIGH>; 38 37 reset-gpios = <&gpio1 27 GPIO_ACTIVE_LOW>;
+56 -75
drivers/net/can/dev.c
··· 1 1 // SPDX-License-Identifier: GPL-2.0-only 2 - /* 3 - * Copyright (C) 2005 Marc Kleine-Budde, Pengutronix 2 + /* Copyright (C) 2005 Marc Kleine-Budde, Pengutronix 4 3 * Copyright (C) 2006 Andrey Volkov, Varma Electronics 5 4 * Copyright (C) 2008-2009 Wolfgang Grandegger <wg@grandegger.com> 6 5 */ ··· 61 62 #define CAN_CALC_MAX_ERROR 50 /* in one-tenth of a percent */ 62 63 #define CAN_CALC_SYNC_SEG 1 63 64 64 - /* 65 - * Bit-timing calculation derived from: 65 + /* Bit-timing calculation derived from: 66 66 * 67 67 * Code based on LinCAN sources and H8S2638 project 68 68 * Copyright 2004-2006 Pavel Pisa - DCE FELK CVUT cz ··· 73 75 * registers of the CAN controller. You can find more information 74 76 * in the header file linux/can/netlink.h. 75 77 */ 76 - static int can_update_sample_point(const struct can_bittiming_const *btc, 77 - unsigned int sample_point_nominal, unsigned int tseg, 78 - unsigned int *tseg1_ptr, unsigned int *tseg2_ptr, 79 - unsigned int *sample_point_error_ptr) 78 + static int 79 + can_update_sample_point(const struct can_bittiming_const *btc, 80 + unsigned int sample_point_nominal, unsigned int tseg, 81 + unsigned int *tseg1_ptr, unsigned int *tseg2_ptr, 82 + unsigned int *sample_point_error_ptr) 80 83 { 81 84 unsigned int sample_point_error, best_sample_point_error = UINT_MAX; 82 85 unsigned int sample_point, best_sample_point = 0; ··· 85 86 int i; 86 87 87 88 for (i = 0; i <= 1; i++) { 88 - tseg2 = tseg + CAN_CALC_SYNC_SEG - (sample_point_nominal * (tseg + CAN_CALC_SYNC_SEG)) / 1000 - i; 89 + tseg2 = tseg + CAN_CALC_SYNC_SEG - 90 + (sample_point_nominal * (tseg + CAN_CALC_SYNC_SEG)) / 91 + 1000 - i; 89 92 tseg2 = clamp(tseg2, btc->tseg2_min, btc->tseg2_max); 90 93 tseg1 = tseg - tseg2; 91 94 if (tseg1 > btc->tseg1_max) { ··· 95 94 tseg2 = tseg - tseg1; 96 95 } 97 96 98 - sample_point = 1000 * (tseg + CAN_CALC_SYNC_SEG - tseg2) / (tseg + CAN_CALC_SYNC_SEG); 97 + sample_point = 1000 * (tseg + CAN_CALC_SYNC_SEG - tseg2) / 98 + (tseg + CAN_CALC_SYNC_SEG); 99 99 sample_point_error = abs(sample_point_nominal - sample_point); 100 100 101 - if ((sample_point <= sample_point_nominal) && (sample_point_error < best_sample_point_error)) { 101 + if (sample_point <= sample_point_nominal && 102 + sample_point_error < best_sample_point_error) { 102 103 best_sample_point = sample_point; 103 104 best_sample_point_error = sample_point_error; 104 105 *tseg1_ptr = tseg1; ··· 151 148 152 149 /* choose brp step which is possible in system */ 153 150 brp = (brp / btc->brp_inc) * btc->brp_inc; 154 - if ((brp < btc->brp_min) || (brp > btc->brp_max)) 151 + if (brp < btc->brp_min || brp > btc->brp_max) 155 152 continue; 156 153 157 154 bitrate = priv->clock.freq / (brp * tsegall); ··· 165 162 if (bitrate_error < best_bitrate_error) 166 163 best_sample_point_error = UINT_MAX; 167 164 168 - can_update_sample_point(btc, sample_point_nominal, tseg / 2, &tseg1, &tseg2, &sample_point_error); 165 + can_update_sample_point(btc, sample_point_nominal, tseg / 2, 166 + &tseg1, &tseg2, &sample_point_error); 169 167 if (sample_point_error > best_sample_point_error) 170 168 continue; 171 169 ··· 195 191 } 196 192 197 193 /* real sample point */ 198 - bt->sample_point = can_update_sample_point(btc, sample_point_nominal, best_tseg, 199 - &tseg1, &tseg2, NULL); 194 + bt->sample_point = can_update_sample_point(btc, sample_point_nominal, 195 + best_tseg, &tseg1, &tseg2, 196 + NULL); 200 197 201 198 v64 = (u64)best_brp * 1000 * 1000 * 1000; 202 199 do_div(v64, priv->clock.freq); ··· 221 216 bt->brp = best_brp; 222 217 223 218 /* real bitrate */ 224 - bt->bitrate = priv->clock.freq / (bt->brp * (CAN_CALC_SYNC_SEG + tseg1 + tseg2)); 219 + bt->bitrate = priv->clock.freq / 220 + (bt->brp * (CAN_CALC_SYNC_SEG + tseg1 + tseg2)); 225 221 226 222 return 0; 227 223 } ··· 235 229 } 236 230 #endif /* CONFIG_CAN_CALC_BITTIMING */ 237 231 238 - /* 239 - * Checks the validity of the specified bit-timing parameters prop_seg, 232 + /* Checks the validity of the specified bit-timing parameters prop_seg, 240 233 * phase_seg1, phase_seg2 and sjw and tries to determine the bitrate 241 234 * prescaler value brp. You can find more information in the header 242 235 * file linux/can/netlink.h. ··· 275 270 } 276 271 277 272 /* Checks the validity of predefined bitrate settings */ 278 - static int can_validate_bitrate(struct net_device *dev, struct can_bittiming *bt, 279 - const u32 *bitrate_const, 280 - const unsigned int bitrate_const_cnt) 273 + static int 274 + can_validate_bitrate(struct net_device *dev, struct can_bittiming *bt, 275 + const u32 *bitrate_const, 276 + const unsigned int bitrate_const_cnt) 281 277 { 282 278 struct can_priv *priv = netdev_priv(dev); 283 279 unsigned int i; ··· 301 295 { 302 296 int err; 303 297 304 - /* 305 - * Depending on the given can_bittiming parameter structure the CAN 298 + /* Depending on the given can_bittiming parameter structure the CAN 306 299 * timing parameters are calculated based on the provided bitrate OR 307 300 * alternatively the CAN timing parameters (tq, prop_seg, etc.) are 308 301 * provided directly which are then checked and fixed up. ··· 402 397 } 403 398 EXPORT_SYMBOL_GPL(can_change_state); 404 399 405 - /* 406 - * Local echo of CAN messages 400 + /* Local echo of CAN messages 407 401 * 408 402 * CAN network devices *should* support a local echo functionality 409 403 * (see Documentation/networking/can.rst). To test the handling of CAN ··· 427 423 } 428 424 } 429 425 430 - /* 431 - * Put the skb on the stack to be looped backed locally lateron 426 + /* Put the skb on the stack to be looped backed locally lateron 432 427 * 433 428 * The function is typically called in the start_xmit function 434 429 * of the device driver. The driver must protect access to ··· 449 446 } 450 447 451 448 if (!priv->echo_skb[idx]) { 452 - 453 449 skb = can_create_echo_skb(skb); 454 450 if (!skb) 455 451 return; ··· 468 466 } 469 467 EXPORT_SYMBOL_GPL(can_put_echo_skb); 470 468 471 - struct sk_buff *__can_get_echo_skb(struct net_device *dev, unsigned int idx, u8 *len_ptr) 469 + struct sk_buff * 470 + __can_get_echo_skb(struct net_device *dev, unsigned int idx, u8 *len_ptr) 472 471 { 473 472 struct can_priv *priv = netdev_priv(dev); 474 473 ··· 496 493 return NULL; 497 494 } 498 495 499 - /* 500 - * Get the skb from the stack and loop it back locally 496 + /* Get the skb from the stack and loop it back locally 501 497 * 502 498 * The function is typically called when the TX done interrupt 503 499 * is handled in the device driver. The driver must protect ··· 517 515 } 518 516 EXPORT_SYMBOL_GPL(can_get_echo_skb); 519 517 520 - /* 521 - * Remove the skb from the stack and free it. 522 - * 523 - * The function is typically called when TX failed. 524 - */ 518 + /* Remove the skb from the stack and free it. 519 + * 520 + * The function is typically called when TX failed. 521 + */ 525 522 void can_free_echo_skb(struct net_device *dev, unsigned int idx) 526 523 { 527 524 struct can_priv *priv = netdev_priv(dev); ··· 534 533 } 535 534 EXPORT_SYMBOL_GPL(can_free_echo_skb); 536 535 537 - /* 538 - * CAN device restart for bus-off recovery 539 - */ 536 + /* CAN device restart for bus-off recovery */ 540 537 static void can_restart(struct net_device *dev) 541 538 { 542 539 struct can_priv *priv = netdev_priv(dev); ··· 545 546 546 547 BUG_ON(netif_carrier_ok(dev)); 547 548 548 - /* 549 - * No synchronization needed because the device is bus-off and 549 + /* No synchronization needed because the device is bus-off and 550 550 * no messages can come in or go out. 551 551 */ 552 552 can_flush_echo_skb(dev); 553 553 554 554 /* send restart message upstream */ 555 555 skb = alloc_can_err_skb(dev, &cf); 556 - if (skb == NULL) { 556 + if (!skb) { 557 557 err = -ENOMEM; 558 558 goto restart; 559 559 } ··· 578 580 static void can_restart_work(struct work_struct *work) 579 581 { 580 582 struct delayed_work *dwork = to_delayed_work(work); 581 - struct can_priv *priv = container_of(dwork, struct can_priv, restart_work); 583 + struct can_priv *priv = container_of(dwork, struct can_priv, 584 + restart_work); 582 585 583 586 can_restart(priv->dev); 584 587 } ··· 588 589 { 589 590 struct can_priv *priv = netdev_priv(dev); 590 591 591 - /* 592 - * A manual restart is only permitted if automatic restart is 592 + /* A manual restart is only permitted if automatic restart is 593 593 * disabled and the device is in the bus-off state 594 594 */ 595 595 if (priv->restart_ms) ··· 602 604 return 0; 603 605 } 604 606 605 - /* 606 - * CAN bus-off 607 + /* CAN bus-off 607 608 * 608 609 * This functions should be called when the device goes bus-off to 609 610 * tell the netif layer that no more packets can be sent or received. ··· 705 708 } 706 709 EXPORT_SYMBOL_GPL(alloc_can_err_skb); 707 710 708 - /* 709 - * Allocate and setup space for the CAN network device 710 - */ 711 + /* Allocate and setup space for the CAN network device */ 711 712 struct net_device *alloc_candev_mqs(int sizeof_priv, unsigned int echo_skb_max, 712 713 unsigned int txqs, unsigned int rxqs) 713 714 { ··· 741 746 } 742 747 EXPORT_SYMBOL_GPL(alloc_candev_mqs); 743 748 744 - /* 745 - * Free space of the CAN network device 746 - */ 749 + /* Free space of the CAN network device */ 747 750 void free_candev(struct net_device *dev) 748 751 { 749 752 free_netdev(dev); 750 753 } 751 754 EXPORT_SYMBOL_GPL(free_candev); 752 755 753 - /* 754 - * changing MTU and control mode for CAN/CANFD devices 755 - */ 756 + /* changing MTU and control mode for CAN/CANFD devices */ 756 757 int can_change_mtu(struct net_device *dev, int new_mtu) 757 758 { 758 759 struct can_priv *priv = netdev_priv(dev); ··· 785 794 } 786 795 EXPORT_SYMBOL_GPL(can_change_mtu); 787 796 788 - /* 789 - * Common open function when the device gets opened. 797 + /* Common open function when the device gets opened. 790 798 * 791 799 * This function should be called in the open function of the device 792 800 * driver. ··· 802 812 /* For CAN FD the data bitrate has to be >= the arbitration bitrate */ 803 813 if ((priv->ctrlmode & CAN_CTRLMODE_FD) && 804 814 (!priv->data_bittiming.bitrate || 805 - (priv->data_bittiming.bitrate < priv->bittiming.bitrate))) { 815 + priv->data_bittiming.bitrate < priv->bittiming.bitrate)) { 806 816 netdev_err(dev, "incorrect/missing data bit-timing\n"); 807 817 return -EINVAL; 808 818 } ··· 838 848 EXPORT_SYMBOL_GPL(of_can_transceiver); 839 849 #endif 840 850 841 - /* 842 - * Common close function for cleanup before the device gets closed. 851 + /* Common close function for cleanup before the device gets closed. 843 852 * 844 853 * This function should be called in the close function of the device 845 854 * driver. ··· 852 863 } 853 864 EXPORT_SYMBOL_GPL(close_candev); 854 865 855 - /* 856 - * CAN netlink interface 857 - */ 866 + /* CAN netlink interface */ 858 867 static const struct nla_policy can_policy[IFLA_CAN_MAX + 1] = { 859 868 [IFLA_CAN_STATE] = { .type = NLA_U32 }, 860 869 [IFLA_CAN_CTRLMODE] = { .len = sizeof(struct can_ctrlmode) }, ··· 1196 1209 1197 1210 static void can_dellink(struct net_device *dev, struct list_head *head) 1198 1211 { 1199 - return; 1200 1212 } 1201 1213 1202 1214 static struct rtnl_link_ops can_link_ops __read_mostly = { ··· 1213 1227 .fill_xstats = can_fill_xstats, 1214 1228 }; 1215 1229 1216 - /* 1217 - * Register the CAN network device 1218 - */ 1230 + /* Register the CAN network device */ 1219 1231 int register_candev(struct net_device *dev) 1220 1232 { 1221 1233 struct can_priv *priv = netdev_priv(dev); ··· 1239 1255 } 1240 1256 EXPORT_SYMBOL_GPL(register_candev); 1241 1257 1242 - /* 1243 - * Unregister the CAN network device 1244 - */ 1258 + /* Unregister the CAN network device */ 1245 1259 void unregister_candev(struct net_device *dev) 1246 1260 { 1247 1261 unregister_netdev(dev); 1248 1262 } 1249 1263 EXPORT_SYMBOL_GPL(unregister_candev); 1250 1264 1251 - /* 1252 - * Test if a network device is a candev based device 1265 + /* Test if a network device is a candev based device 1253 1266 * and return the can_priv* if so. 1254 1267 */ 1255 1268 struct can_priv *safe_candev_priv(struct net_device *dev) 1256 1269 { 1257 - if ((dev->type != ARPHRD_CAN) || (dev->rtnl_link_ops != &can_link_ops)) 1270 + if (dev->type != ARPHRD_CAN || dev->rtnl_link_ops != &can_link_ops) 1258 1271 return NULL; 1259 1272 1260 1273 return netdev_priv(dev); ··· 1266 1285 1267 1286 err = rtnl_link_register(&can_link_ops); 1268 1287 if (!err) 1269 - printk(KERN_INFO MOD_DESC "\n"); 1288 + pr_info(MOD_DESC "\n"); 1270 1289 1271 1290 return err; 1272 1291 }
+5 -1
drivers/net/can/kvaser_pciefd.c
··· 65 65 #define KVASER_PCIEFD_SYSID_BASE 0x1f020 66 66 #define KVASER_PCIEFD_SYSID_VERSION_REG (KVASER_PCIEFD_SYSID_BASE + 0x8) 67 67 #define KVASER_PCIEFD_SYSID_CANFREQ_REG (KVASER_PCIEFD_SYSID_BASE + 0xc) 68 + #define KVASER_PCIEFD_SYSID_BUSFREQ_REG (KVASER_PCIEFD_SYSID_BASE + 0x10) 68 69 #define KVASER_PCIEFD_SYSID_BUILD_REG (KVASER_PCIEFD_SYSID_BASE + 0x14) 69 70 /* Shared receive buffer registers */ 70 71 #define KVASER_PCIEFD_SRB_BASE 0x1f200 ··· 269 268 struct kvaser_pciefd_can *can[KVASER_PCIEFD_MAX_CAN_CHANNELS]; 270 269 void *dma_data[KVASER_PCIEFD_DMA_COUNT]; 271 270 u8 nr_channels; 271 + u32 bus_freq; 272 272 u32 freq; 273 273 u32 freq_to_ticks_div; 274 274 }; ··· 668 666 spin_lock_irqsave(&can->lock, irq); 669 667 670 668 /* Set frequency to 500 KHz*/ 671 - top = can->can.clock.freq / (2 * 500000) - 1; 669 + top = can->kv_pcie->bus_freq / (2 * 500000) - 1; 672 670 673 671 pwm_ctrl = top & 0xff; 674 672 pwm_ctrl |= (top & 0xff) << KVASER_PCIEFD_KCAN_PWM_TOP_SHIFT; ··· 1121 1119 return -ENODEV; 1122 1120 } 1123 1121 1122 + pcie->bus_freq = ioread32(pcie->reg_base + 1123 + KVASER_PCIEFD_SYSID_BUSFREQ_REG); 1124 1124 pcie->freq = ioread32(pcie->reg_base + KVASER_PCIEFD_SYSID_CANFREQ_REG); 1125 1125 pcie->freq_to_ticks_div = pcie->freq / 1000000; 1126 1126 if (pcie->freq_to_ticks_div == 0)
+1 -23
drivers/net/can/m_can/tcan4x5x.c
··· 117 117 struct m_can_classdev *mcan_dev; 118 118 119 119 struct gpio_desc *reset_gpio; 120 - struct gpio_desc *interrupt_gpio; 121 120 struct gpio_desc *device_wake_gpio; 122 121 struct gpio_desc *device_state_gpio; 123 122 struct regulator *power; ··· 235 236 struct tcan4x5x_priv *priv = cdev->device_data; 236 237 u32 val; 237 238 238 - tcan4x5x_check_wake(priv); 239 - 240 239 regmap_read(priv->regmap, priv->reg_offset + reg, &val); 241 240 242 241 return val; ··· 245 248 struct tcan4x5x_priv *priv = cdev->device_data; 246 249 u32 val; 247 250 248 - tcan4x5x_check_wake(priv); 249 - 250 251 regmap_read(priv->regmap, priv->mram_start + addr_offset, &val); 251 252 252 253 return val; ··· 254 259 { 255 260 struct tcan4x5x_priv *priv = cdev->device_data; 256 261 257 - tcan4x5x_check_wake(priv); 258 - 259 262 return regmap_write(priv->regmap, priv->reg_offset + reg, val); 260 263 } 261 264 ··· 261 268 int addr_offset, int val) 262 269 { 263 270 struct tcan4x5x_priv *priv = cdev->device_data; 264 - 265 - tcan4x5x_check_wake(priv); 266 271 267 272 return regmap_write(priv->regmap, priv->mram_start + addr_offset, val); 268 273 } ··· 281 290 { 282 291 struct tcan4x5x_priv *priv = cdev->device_data; 283 292 284 - tcan4x5x_check_wake(priv); 285 - 286 293 return regmap_write(priv->regmap, reg, val); 287 294 } 288 295 289 296 static int tcan4x5x_clear_interrupts(struct m_can_classdev *cdev) 290 297 { 291 - struct tcan4x5x_priv *tcan4x5x = cdev->device_data; 292 298 int ret; 293 - 294 - tcan4x5x_check_wake(tcan4x5x); 295 299 296 300 ret = tcan4x5x_write_tcan_reg(cdev, TCAN4X5X_STATUS, 297 301 TCAN4X5X_CLEAR_ALL_INT); ··· 342 356 { 343 357 struct tcan4x5x_priv *tcan4x5x = cdev->device_data; 344 358 345 - tcan4x5x->interrupt_gpio = devm_gpiod_get(cdev->dev, "data-ready", 346 - GPIOD_IN); 347 - if (IS_ERR(tcan4x5x->interrupt_gpio)) { 348 - dev_err(cdev->dev, "data-ready gpio not defined\n"); 349 - return -EINVAL; 350 - } 351 - 352 359 tcan4x5x->device_wake_gpio = devm_gpiod_get(cdev->dev, "device-wake", 353 360 GPIOD_OUT_HIGH); 354 361 if (IS_ERR(tcan4x5x->device_wake_gpio)) { ··· 359 380 GPIOD_IN); 360 381 if (IS_ERR(tcan4x5x->device_state_gpio)) 361 382 tcan4x5x->device_state_gpio = NULL; 362 - 363 - cdev->net->irq = gpiod_to_irq(tcan4x5x->interrupt_gpio); 364 383 365 384 tcan4x5x->power = devm_regulator_get_optional(cdev->dev, 366 385 "vsup"); ··· 424 447 mcan_class->is_peripheral = true; 425 448 mcan_class->bit_timing = &tcan4x5x_bittiming_const; 426 449 mcan_class->data_timing = &tcan4x5x_data_bittiming_const; 450 + mcan_class->net->irq = spi->irq; 427 451 428 452 spi_set_drvdata(spi, priv); 429 453
+19 -49
drivers/net/can/spi/mcp251x.c
··· 17 17 * - Sascha Hauer, Marc Kleine-Budde, Pengutronix 18 18 * - Simon Kallweit, intefo AG 19 19 * Copyright 2007 20 - * 21 - * Your platform definition file should specify something like: 22 - * 23 - * static struct mcp251x_platform_data mcp251x_info = { 24 - * .oscillator_frequency = 8000000, 25 - * }; 26 - * 27 - * static struct spi_board_info spi_board_info[] = { 28 - * { 29 - * .modalias = "mcp2510", 30 - * // "mcp2515" or "mcp25625" depending on your controller 31 - * .platform_data = &mcp251x_info, 32 - * .irq = IRQ_EINT13, 33 - * .max_speed_hz = 2*1000*1000, 34 - * .chip_select = 2, 35 - * }, 36 - * }; 37 - * 38 - * Please see mcp251x.h for a description of the fields in 39 - * struct mcp251x_platform_data. 40 20 */ 41 21 42 22 #include <linux/can/core.h> ··· 33 53 #include <linux/kernel.h> 34 54 #include <linux/module.h> 35 55 #include <linux/netdevice.h> 36 - #include <linux/of.h> 37 - #include <linux/of_device.h> 56 + #include <linux/property.h> 38 57 #include <linux/platform_device.h> 39 58 #include <linux/slab.h> 40 59 #include <linux/spi/spi.h> ··· 893 914 priv->tx_skb = NULL; 894 915 priv->tx_len = 0; 895 916 896 - if (!spi->dev.of_node) 917 + if (!dev_fwnode(&spi->dev)) 897 918 flags = IRQF_TRIGGER_FALLING; 898 919 899 920 ret = request_threaded_irq(spi->irq, NULL, mcp251x_can_ist, ··· 985 1006 986 1007 static int mcp251x_can_probe(struct spi_device *spi) 987 1008 { 988 - const struct of_device_id *of_id = of_match_device(mcp251x_of_match, 989 - &spi->dev); 1009 + const void *match = device_get_match_data(&spi->dev); 990 1010 struct mcp251x_platform_data *pdata = dev_get_platdata(&spi->dev); 991 1011 struct net_device *net; 992 1012 struct mcp251x_priv *priv; 993 1013 struct clk *clk; 994 1014 int freq, ret; 995 1015 996 - clk = devm_clk_get(&spi->dev, NULL); 997 - if (IS_ERR(clk)) { 998 - if (pdata) 999 - freq = pdata->oscillator_frequency; 1000 - else 1001 - return PTR_ERR(clk); 1002 - } else { 1003 - freq = clk_get_rate(clk); 1004 - } 1016 + clk = devm_clk_get_optional(&spi->dev, NULL); 1017 + if (IS_ERR(clk)) 1018 + return PTR_ERR(clk); 1019 + 1020 + freq = clk_get_rate(clk); 1021 + if (freq == 0 && pdata) 1022 + freq = pdata->oscillator_frequency; 1005 1023 1006 1024 /* Sanity check */ 1007 1025 if (freq < 1000000 || freq > 25000000) ··· 1009 1033 if (!net) 1010 1034 return -ENOMEM; 1011 1035 1012 - if (!IS_ERR(clk)) { 1013 - ret = clk_prepare_enable(clk); 1014 - if (ret) 1015 - goto out_free; 1016 - } 1036 + ret = clk_prepare_enable(clk); 1037 + if (ret) 1038 + goto out_free; 1017 1039 1018 1040 net->netdev_ops = &mcp251x_netdev_ops; 1019 1041 net->flags |= IFF_ECHO; ··· 1022 1048 priv->can.clock.freq = freq / 2; 1023 1049 priv->can.ctrlmode_supported = CAN_CTRLMODE_3_SAMPLES | 1024 1050 CAN_CTRLMODE_LOOPBACK | CAN_CTRLMODE_LISTENONLY; 1025 - if (of_id) 1026 - priv->model = (enum mcp251x_model)of_id->data; 1051 + if (match) 1052 + priv->model = (enum mcp251x_model)match; 1027 1053 else 1028 1054 priv->model = spi_get_device_id(spi)->driver_data; 1029 1055 priv->net = net; ··· 1096 1122 mcp251x_power_enable(priv->power, 0); 1097 1123 1098 1124 out_clk: 1099 - if (!IS_ERR(clk)) 1100 - clk_disable_unprepare(clk); 1125 + clk_disable_unprepare(clk); 1101 1126 1102 1127 out_free: 1103 1128 free_candev(net); ··· 1114 1141 1115 1142 mcp251x_power_enable(priv->power, 0); 1116 1143 1117 - if (!IS_ERR(priv->clk)) 1118 - clk_disable_unprepare(priv->clk); 1144 + clk_disable_unprepare(priv->clk); 1119 1145 1120 1146 free_candev(net); 1121 1147 ··· 1142 1170 priv->after_suspend = AFTER_SUSPEND_DOWN; 1143 1171 } 1144 1172 1145 - if (!IS_ERR_OR_NULL(priv->power)) { 1146 - regulator_disable(priv->power); 1147 - priv->after_suspend |= AFTER_SUSPEND_POWER; 1148 - } 1173 + mcp251x_power_enable(priv->power, 0); 1174 + priv->after_suspend |= AFTER_SUSPEND_POWER; 1149 1175 1150 1176 return 0; 1151 1177 }
+2 -1
include/linux/can/dev.h
··· 169 169 170 170 void can_put_echo_skb(struct sk_buff *skb, struct net_device *dev, 171 171 unsigned int idx); 172 - struct sk_buff *__can_get_echo_skb(struct net_device *dev, unsigned int idx, u8 *len_ptr); 172 + struct sk_buff *__can_get_echo_skb(struct net_device *dev, unsigned int idx, 173 + u8 *len_ptr); 173 174 unsigned int can_get_echo_skb(struct net_device *dev, unsigned int idx); 174 175 void can_free_echo_skb(struct net_device *dev, unsigned int idx); 175 176
+9 -4
include/linux/can/rx-offload.h
··· 15 15 struct can_rx_offload { 16 16 struct net_device *dev; 17 17 18 - unsigned int (*mailbox_read)(struct can_rx_offload *offload, struct can_frame *cf, 18 + unsigned int (*mailbox_read)(struct can_rx_offload *offload, 19 + struct can_frame *cf, 19 20 u32 *timestamp, unsigned int mb); 20 21 21 22 struct sk_buff_head skb_queue; ··· 30 29 bool inc; 31 30 }; 32 31 33 - int can_rx_offload_add_timestamp(struct net_device *dev, struct can_rx_offload *offload); 34 - int can_rx_offload_add_fifo(struct net_device *dev, struct can_rx_offload *offload, unsigned int weight); 35 - int can_rx_offload_irq_offload_timestamp(struct can_rx_offload *offload, u64 reg); 32 + int can_rx_offload_add_timestamp(struct net_device *dev, 33 + struct can_rx_offload *offload); 34 + int can_rx_offload_add_fifo(struct net_device *dev, 35 + struct can_rx_offload *offload, 36 + unsigned int weight); 37 + int can_rx_offload_irq_offload_timestamp(struct can_rx_offload *offload, 38 + u64 reg); 36 39 int can_rx_offload_irq_offload_fifo(struct can_rx_offload *offload); 37 40 int can_rx_offload_queue_sorted(struct can_rx_offload *offload, 38 41 struct sk_buff *skb, u32 timestamp);