Merge tag 'char-misc-5.17-rc4' of git://git.kernel.org/pub/scm/linux/kernel/git/gregkh/char-misc

Pull char/misc driver fixes from Greg KH:
"Here are a small number of char/misc driver fixes for 5.17-rc4 for
reported issues. They contain:

- phy driver fixes

- iio driver fix

- eeprom driver fix

- speakup regression fix

- fastrpc fix

All of these have been in linux-next with no reported issues"

* tag 'char-misc-5.17-rc4' of git://git.kernel.org/pub/scm/linux/kernel/git/gregkh/char-misc:
iio: buffer: Fix file related error handling in IIO_BUFFER_GET_FD_IOCTL
speakup-dectlk: Restore pitch setting
bus: mhi: pci_generic: Add mru_default for Cinterion MV31-W
bus: mhi: pci_generic: Add mru_default for Foxconn SDX55
eeprom: ee1004: limit i2c reads to I2C_SMBUS_BLOCK_MAX
misc: fastrpc: avoid double fput() on failed usercopy
phy: dphy: Correct clk_pre parameter
phy: phy-mtk-tphy: Fix duplicated argument in phy-mtk-tphy
phy: stm32: fix a refcount leak in stm32_usbphyc_pll_enable()
phy: xilinx: zynqmp: Fix bus width setting for SGMII
phy: cadence: Sierra: fix error handling bugs in probe()
phy: ti: Fix missing sentinel for clk_div_table
phy: broadcom: Kconfig: Fix PHY_BRCM_USB config option
phy: usb: Leave some clocks running during suspend

+104 -37
+1
drivers/accessibility/speakup/speakup_dectlk.c
··· 44 44 { CAPS_START, .u.s = {"[:dv ap 160] " } }, 45 45 { CAPS_STOP, .u.s = {"[:dv ap 100 ] " } }, 46 46 { RATE, .u.n = {"[:ra %d] ", 180, 75, 650, 0, 0, NULL } }, 47 + { PITCH, .u.n = {"[:dv ap %d] ", 122, 50, 350, 0, 0, NULL } }, 47 48 { INFLECTION, .u.n = {"[:dv pr %d] ", 100, 0, 10000, 0, 0, NULL } }, 48 49 { VOL, .u.n = {"[:dv g5 %d] ", 86, 60, 86, 0, 0, NULL } }, 49 50 { PUNCT, .u.n = {"[:pu %c] ", 0, 0, 2, 0, 0, "nsa" } },
+2
drivers/bus/mhi/pci_generic.c
··· 366 366 .config = &modem_foxconn_sdx55_config, 367 367 .bar_num = MHI_PCI_DEFAULT_BAR_NUM, 368 368 .dma_data_width = 32, 369 + .mru_default = 32768, 369 370 .sideband_wake = false, 370 371 }; 371 372 ··· 402 401 .config = &modem_mv31_config, 403 402 .bar_num = MHI_PCI_DEFAULT_BAR_NUM, 404 403 .dma_data_width = 32, 404 + .mru_default = 32768, 405 405 }; 406 406 407 407 static const struct mhi_channel_config mhi_sierra_em919x_channels[] = {
+5 -7
drivers/gpu/drm/bridge/nwl-dsi.c
··· 7 7 */ 8 8 9 9 #include <linux/bitfield.h> 10 + #include <linux/bits.h> 10 11 #include <linux/clk.h> 11 12 #include <linux/irq.h> 12 13 #include <linux/math64.h> ··· 197 196 /* 198 197 * ui2bc - UI time periods to byte clock cycles 199 198 */ 200 - static u32 ui2bc(struct nwl_dsi *dsi, unsigned long long ui) 199 + static u32 ui2bc(unsigned int ui) 201 200 { 202 - u32 bpp = mipi_dsi_pixel_format_to_bpp(dsi->format); 203 - 204 - return DIV64_U64_ROUND_UP(ui * dsi->lanes, 205 - dsi->mode.clock * 1000 * bpp); 201 + return DIV_ROUND_UP(ui, BITS_PER_BYTE); 206 202 } 207 203 208 204 /* ··· 230 232 } 231 233 232 234 /* values in byte clock cycles */ 233 - cycles = ui2bc(dsi, cfg->clk_pre); 235 + cycles = ui2bc(cfg->clk_pre); 234 236 DRM_DEV_DEBUG_DRIVER(dsi->dev, "cfg_t_pre: 0x%x\n", cycles); 235 237 nwl_dsi_write(dsi, NWL_DSI_CFG_T_PRE, cycles); 236 238 cycles = ps2bc(dsi, cfg->lpx + cfg->clk_prepare + cfg->clk_zero); 237 239 DRM_DEV_DEBUG_DRIVER(dsi->dev, "cfg_tx_gap (pre): 0x%x\n", cycles); 238 - cycles += ui2bc(dsi, cfg->clk_pre); 240 + cycles += ui2bc(cfg->clk_pre); 239 241 DRM_DEV_DEBUG_DRIVER(dsi->dev, "cfg_t_post: 0x%x\n", cycles); 240 242 nwl_dsi_write(dsi, NWL_DSI_CFG_T_POST, cycles); 241 243 cycles = ps2bc(dsi, cfg->hs_exit);
+11 -3
drivers/iio/industrialio-buffer.c
··· 1569 1569 } 1570 1570 1571 1571 if (copy_to_user(ival, &fd, sizeof(fd))) { 1572 - put_unused_fd(fd); 1573 - ret = -EFAULT; 1574 - goto error_free_ib; 1572 + /* 1573 + * "Leak" the fd, as there's not much we can do about this 1574 + * anyway. 'fd' might have been closed already, as 1575 + * anon_inode_getfd() called fd_install() on it, which made 1576 + * it reachable by userland. 1577 + * 1578 + * Instead of allowing a malicious user to play tricks with 1579 + * us, rely on the process exit path to do any necessary 1580 + * cleanup, as in releasing the file, if still needed. 1581 + */ 1582 + return -EFAULT; 1575 1583 } 1576 1584 1577 1585 return 0;
+3
drivers/misc/eeprom/ee1004.c
··· 114 114 if (offset + count > EE1004_PAGE_SIZE) 115 115 count = EE1004_PAGE_SIZE - offset; 116 116 117 + if (count > I2C_SMBUS_BLOCK_MAX) 118 + count = I2C_SMBUS_BLOCK_MAX; 119 + 117 120 return i2c_smbus_read_i2c_block_data_or_emulated(client, offset, count, buf); 118 121 } 119 122
+8 -1
drivers/misc/fastrpc.c
··· 1288 1288 } 1289 1289 1290 1290 if (copy_to_user(argp, &bp, sizeof(bp))) { 1291 - dma_buf_put(buf->dmabuf); 1291 + /* 1292 + * The usercopy failed, but we can't do much about it, as 1293 + * dma_buf_fd() already called fd_install() and made the 1294 + * file descriptor accessible for the current process. It 1295 + * might already be closed and dmabuf no longer valid when 1296 + * we reach this point. Therefore "leak" the fd and rely on 1297 + * the process exit path to do any required cleanup. 1298 + */ 1292 1299 return -EFAULT; 1293 1300 } 1294 1301
+2 -1
drivers/phy/amlogic/phy-meson-axg-mipi-dphy.c
··· 9 9 10 10 #include <linux/bitfield.h> 11 11 #include <linux/bitops.h> 12 + #include <linux/bits.h> 12 13 #include <linux/clk.h> 13 14 #include <linux/delay.h> 14 15 #include <linux/io.h> ··· 251 250 (DIV_ROUND_UP(priv->config.clk_zero, temp) << 16) | 252 251 (DIV_ROUND_UP(priv->config.clk_prepare, temp) << 24)); 253 252 regmap_write(priv->regmap, MIPI_DSI_CLK_TIM1, 254 - DIV_ROUND_UP(priv->config.clk_pre, temp)); 253 + DIV_ROUND_UP(priv->config.clk_pre, BITS_PER_BYTE)); 255 254 256 255 regmap_write(priv->regmap, MIPI_DSI_HS_TIM, 257 256 DIV_ROUND_UP(priv->config.hs_exit, temp) |
+1 -2
drivers/phy/broadcom/Kconfig
··· 97 97 depends on OF 98 98 select GENERIC_PHY 99 99 select SOC_BRCMSTB if ARCH_BRCMSTB 100 - default ARCH_BCM4908 101 - default ARCH_BRCMSTB 100 + default ARCH_BCM4908 || ARCH_BRCMSTB 102 101 help 103 102 Enable this to support the Broadcom STB USB PHY. 104 103 This driver is required by the USB XHCI, EHCI and OHCI
+38
drivers/phy/broadcom/phy-brcm-usb.c
··· 18 18 #include <linux/soc/brcmstb/brcmstb.h> 19 19 #include <dt-bindings/phy/phy.h> 20 20 #include <linux/mfd/syscon.h> 21 + #include <linux/suspend.h> 21 22 22 23 #include "phy-brcm-usb-init.h" 23 24 ··· 71 70 int init_count; 72 71 int wake_irq; 73 72 struct brcm_usb_phy phys[BRCM_USB_PHY_ID_MAX]; 73 + struct notifier_block pm_notifier; 74 + bool pm_active; 74 75 }; 75 76 76 77 static s8 *node_reg_names[BRCM_REGS_MAX] = { 77 78 "crtl", "xhci_ec", "xhci_gbl", "usb_phy", "usb_mdio", "bdc_ec" 78 79 }; 80 + 81 + static int brcm_pm_notifier(struct notifier_block *notifier, 82 + unsigned long pm_event, 83 + void *unused) 84 + { 85 + struct brcm_usb_phy_data *priv = 86 + container_of(notifier, struct brcm_usb_phy_data, pm_notifier); 87 + 88 + switch (pm_event) { 89 + case PM_HIBERNATION_PREPARE: 90 + case PM_SUSPEND_PREPARE: 91 + priv->pm_active = true; 92 + break; 93 + case PM_POST_RESTORE: 94 + case PM_POST_HIBERNATION: 95 + case PM_POST_SUSPEND: 96 + priv->pm_active = false; 97 + break; 98 + } 99 + return NOTIFY_DONE; 100 + } 79 101 80 102 static irqreturn_t brcm_usb_phy_wake_isr(int irq, void *dev_id) 81 103 { ··· 114 90 struct brcm_usb_phy *phy = phy_get_drvdata(gphy); 115 91 struct brcm_usb_phy_data *priv = 116 92 container_of(phy, struct brcm_usb_phy_data, phys[phy->id]); 93 + 94 + if (priv->pm_active) 95 + return 0; 117 96 118 97 /* 119 98 * Use a lock to make sure a second caller waits until ··· 146 119 struct brcm_usb_phy *phy = phy_get_drvdata(gphy); 147 120 struct brcm_usb_phy_data *priv = 148 121 container_of(phy, struct brcm_usb_phy_data, phys[phy->id]); 122 + 123 + if (priv->pm_active) 124 + return 0; 149 125 150 126 dev_dbg(&gphy->dev, "EXIT\n"); 151 127 if (phy->id == BRCM_USB_PHY_2_0) ··· 518 488 if (err) 519 489 return err; 520 490 491 + priv->pm_notifier.notifier_call = brcm_pm_notifier; 492 + register_pm_notifier(&priv->pm_notifier); 493 + 521 494 mutex_init(&priv->mutex); 522 495 523 496 /* make sure invert settings are correct */ ··· 561 528 562 529 static int brcm_usb_phy_remove(struct platform_device *pdev) 563 530 { 531 + struct brcm_usb_phy_data *priv = dev_get_drvdata(&pdev->dev); 532 + 564 533 sysfs_remove_group(&pdev->dev.kobj, &brcm_usb_phy_group); 534 + unregister_pm_notifier(&priv->pm_notifier); 565 535 566 536 return 0; 567 537 } ··· 575 539 struct brcm_usb_phy_data *priv = dev_get_drvdata(dev); 576 540 577 541 if (priv->init_count) { 542 + dev_dbg(dev, "SUSPEND\n"); 578 543 priv->ini.wake_enabled = device_may_wakeup(dev); 579 544 if (priv->phys[BRCM_USB_PHY_3_0].inited) 580 545 brcm_usb_uninit_xhci(&priv->ini); ··· 615 578 * Uninitialize anything that wasn't previously initialized. 616 579 */ 617 580 if (priv->init_count) { 581 + dev_dbg(dev, "RESUME\n"); 618 582 if (priv->wake_irq >= 0) 619 583 disable_irq_wake(priv->wake_irq); 620 584 brcm_usb_init_common(&priv->ini);
+20 -13
drivers/phy/cadence/phy-cadence-sierra.c
··· 1338 1338 struct device *dev = &pdev->dev; 1339 1339 const struct cdns_sierra_data *data; 1340 1340 unsigned int id_value; 1341 - int i, ret, node = 0; 1341 + int ret, node = 0; 1342 1342 void __iomem *base; 1343 1343 struct device_node *dn = dev->of_node, *child; 1344 1344 ··· 1416 1416 dev_err(dev, "failed to get reset %s\n", 1417 1417 child->full_name); 1418 1418 ret = PTR_ERR(sp->phys[node].lnk_rst); 1419 - goto put_child2; 1419 + of_node_put(child); 1420 + goto put_control; 1420 1421 } 1421 1422 1422 1423 if (!sp->autoconf) { ··· 1425 1424 if (ret) { 1426 1425 dev_err(dev, "missing property in node %s\n", 1427 1426 child->name); 1428 - goto put_child; 1427 + of_node_put(child); 1428 + reset_control_put(sp->phys[node].lnk_rst); 1429 + goto put_control; 1429 1430 } 1430 1431 } 1431 1432 ··· 1437 1434 1438 1435 if (IS_ERR(gphy)) { 1439 1436 ret = PTR_ERR(gphy); 1440 - goto put_child; 1437 + of_node_put(child); 1438 + reset_control_put(sp->phys[node].lnk_rst); 1439 + goto put_control; 1441 1440 } 1442 1441 sp->phys[node].phy = gphy; 1443 1442 phy_set_drvdata(gphy, &sp->phys[node]); ··· 1451 1446 if (sp->num_lanes > SIERRA_MAX_LANES) { 1452 1447 ret = -EINVAL; 1453 1448 dev_err(dev, "Invalid lane configuration\n"); 1454 - goto put_child2; 1449 + goto put_control; 1455 1450 } 1456 1451 1457 1452 /* If more than one subnode, configure the PHY as multilink */ 1458 1453 if (!sp->autoconf && sp->nsubnodes > 1) { 1459 1454 ret = cdns_sierra_phy_configure_multilink(sp); 1460 1455 if (ret) 1461 - goto put_child2; 1456 + goto put_control; 1462 1457 } 1463 1458 1464 1459 pm_runtime_enable(dev); 1465 1460 phy_provider = devm_of_phy_provider_register(dev, of_phy_simple_xlate); 1466 - return PTR_ERR_OR_ZERO(phy_provider); 1461 + if (IS_ERR(phy_provider)) { 1462 + ret = PTR_ERR(phy_provider); 1463 + goto put_control; 1464 + } 1467 1465 1468 - put_child: 1469 - node++; 1470 - put_child2: 1471 - for (i = 0; i < node; i++) 1472 - reset_control_put(sp->phys[i].lnk_rst); 1473 - of_node_put(child); 1466 + return 0; 1467 + 1468 + put_control: 1469 + while (--node >= 0) 1470 + reset_control_put(sp->phys[node].lnk_rst); 1474 1471 clk_disable: 1475 1472 cdns_sierra_phy_disable_clocks(sp); 1476 1473 reset_control_assert(sp->apb_rst);
+1 -1
drivers/phy/mediatek/phy-mtk-tphy.c
··· 992 992 /* no efuse, ignore it */ 993 993 if (!instance->efuse_intr && 994 994 !instance->efuse_rx_imp && 995 - !instance->efuse_rx_imp) { 995 + !instance->efuse_tx_imp) { 996 996 dev_warn(dev, "no u3 intr efuse, but dts enable it\n"); 997 997 instance->efuse_sw_en = 0; 998 998 break;
+2 -2
drivers/phy/phy-core-mipi-dphy.c
··· 36 36 37 37 cfg->clk_miss = 0; 38 38 cfg->clk_post = 60000 + 52 * ui; 39 - cfg->clk_pre = 8000; 39 + cfg->clk_pre = 8; 40 40 cfg->clk_prepare = 38000; 41 41 cfg->clk_settle = 95000; 42 42 cfg->clk_term_en = 0; ··· 97 97 if (cfg->clk_post < (60000 + 52 * ui)) 98 98 return -EINVAL; 99 99 100 - if (cfg->clk_pre < 8000) 100 + if (cfg->clk_pre < 8) 101 101 return -EINVAL; 102 102 103 103 if (cfg->clk_prepare < 38000 || cfg->clk_prepare > 95000)
+2 -1
drivers/phy/rockchip/phy-rockchip-inno-dsidphy.c
··· 5 5 * Author: Wyon Bi <bivvy.bi@rock-chips.com> 6 6 */ 7 7 8 + #include <linux/bits.h> 8 9 #include <linux/kernel.h> 9 10 #include <linux/clk.h> 10 11 #include <linux/iopoll.h> ··· 365 364 * The value of counter for HS Tclk-pre 366 365 * Tclk-pre = Tpin_txbyteclkhs * value 367 366 */ 368 - clk_pre = DIV_ROUND_UP(cfg->clk_pre, t_txbyteclkhs); 367 + clk_pre = DIV_ROUND_UP(cfg->clk_pre, BITS_PER_BYTE); 369 368 370 369 /* 371 370 * The value of counter for HS Tlpx Time
+1 -1
drivers/phy/st/phy-stm32-usbphyc.c
··· 304 304 305 305 ret = __stm32_usbphyc_pll_disable(usbphyc); 306 306 if (ret) 307 - return ret; 307 + goto dec_n_pll_cons; 308 308 } 309 309 310 310 ret = stm32_usbphyc_regulators_enable(usbphyc);
+1
drivers/phy/ti/phy-j721e-wiz.c
··· 233 233 { .val = 1, .div = 2, }, 234 234 { .val = 2, .div = 4, }, 235 235 { .val = 3, .div = 8, }, 236 + { /* sentinel */ }, 236 237 }; 237 238 238 239 static const struct wiz_clk_div_sel clk_div_sel[] = {
+6 -5
drivers/phy/xilinx/phy-zynqmp.c
··· 134 134 #define PROT_BUS_WIDTH_10 0x0 135 135 #define PROT_BUS_WIDTH_20 0x1 136 136 #define PROT_BUS_WIDTH_40 0x2 137 - #define PROT_BUS_WIDTH_SHIFT 2 137 + #define PROT_BUS_WIDTH_SHIFT(n) ((n) * 2) 138 + #define PROT_BUS_WIDTH_MASK(n) GENMASK((n) * 2 + 1, (n) * 2) 138 139 139 140 /* Number of GT lanes */ 140 141 #define NUM_LANES 4 ··· 446 445 static void xpsgtr_phy_init_sgmii(struct xpsgtr_phy *gtr_phy) 447 446 { 448 447 struct xpsgtr_dev *gtr_dev = gtr_phy->dev; 448 + u32 mask = PROT_BUS_WIDTH_MASK(gtr_phy->lane); 449 + u32 val = PROT_BUS_WIDTH_10 << PROT_BUS_WIDTH_SHIFT(gtr_phy->lane); 449 450 450 451 /* Set SGMII protocol TX and RX bus width to 10 bits. */ 451 - xpsgtr_write(gtr_dev, TX_PROT_BUS_WIDTH, 452 - PROT_BUS_WIDTH_10 << (gtr_phy->lane * PROT_BUS_WIDTH_SHIFT)); 453 - xpsgtr_write(gtr_dev, RX_PROT_BUS_WIDTH, 454 - PROT_BUS_WIDTH_10 << (gtr_phy->lane * PROT_BUS_WIDTH_SHIFT)); 452 + xpsgtr_clr_set(gtr_dev, TX_PROT_BUS_WIDTH, mask, val); 453 + xpsgtr_clr_set(gtr_dev, RX_PROT_BUS_WIDTH, mask, val); 455 454 456 455 xpsgtr_bypass_scrambler_8b10b(gtr_phy); 457 456 }