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

Configure Feed

Select the types of activity you want to include in your feed.

Merge branch 'for-7.1/mcp2221' into for-linus

+23 -13
+23 -13
drivers/hid/hid-mcp2221.c
··· 19 19 #include <linux/gpio/driver.h> 20 20 #include <linux/iio/iio.h> 21 21 #include <linux/minmax.h> 22 + #include <linux/moduleparam.h> 22 23 #include "hid-ids.h" 24 + 25 + static bool gpio_mode_enforce; 26 + 27 + module_param(gpio_mode_enforce, bool, 0644); 28 + MODULE_PARM_DESC(gpio_mode_enforce, 29 + "Enforce GPIO mode for GP0 thru GP3 (default: false, will be used for IIO)"); 23 30 24 31 /* Commands codes in a raw output report */ 25 32 enum { ··· 543 536 if (ret) 544 537 goto exit; 545 538 546 - mcp->rxbuf_idx = 0; 547 - mcp->rxbuf = data->block; 548 - mcp->txbuf[0] = MCP2221_I2C_GET_DATA; 549 - ret = mcp_send_data_req_status(mcp, mcp->txbuf, 1); 539 + ret = mcp_i2c_smbus_read(mcp, NULL, 540 + MCP2221_I2C_RD_RPT_START, 541 + addr, data->block[0] + 1, 542 + data->block); 550 543 if (ret) 551 544 goto exit; 552 545 } else { ··· 562 555 case I2C_SMBUS_I2C_BLOCK_DATA: 563 556 if (read_write == I2C_SMBUS_READ) { 564 557 ret = mcp_smbus_write(mcp, addr, command, NULL, 565 - 0, MCP2221_I2C_WR_NO_STOP, 1); 558 + 0, MCP2221_I2C_WR_NO_STOP, 0); 566 559 if (ret) 567 560 goto exit; 568 561 569 - mcp->rxbuf_idx = 0; 570 - mcp->rxbuf = data->block; 571 - mcp->txbuf[0] = MCP2221_I2C_GET_DATA; 572 - ret = mcp_send_data_req_status(mcp, mcp->txbuf, 1); 562 + ret = mcp_i2c_smbus_read(mcp, NULL, 563 + MCP2221_I2C_RD_RPT_START, 564 + addr, data->block[0], 565 + &data->block[1]); 573 566 if (ret) 574 567 goto exit; 575 568 } else { ··· 657 650 int needgpiofix = 0; 658 651 int ret; 659 652 660 - if (IS_ENABLED(CONFIG_IIO)) 653 + if (IS_ENABLED(CONFIG_IIO) && !gpio_mode_enforce) 661 654 return 0; 662 655 663 656 ret = mcp_gpio_read_sram(mcp); ··· 1052 1045 #if IS_REACHABLE(CONFIG_IIO) 1053 1046 struct mcp2221 *mcp = hid_get_drvdata(hdev); 1054 1047 1055 - cancel_delayed_work_sync(&mcp->init_work); 1048 + if (!gpio_mode_enforce) 1049 + cancel_delayed_work_sync(&mcp->init_work); 1056 1050 #endif 1057 1051 } 1058 1052 ··· 1327 1319 #endif 1328 1320 1329 1321 #if IS_REACHABLE(CONFIG_IIO) 1330 - INIT_DELAYED_WORK(&mcp->init_work, mcp_init_work); 1331 - schedule_delayed_work(&mcp->init_work, msecs_to_jiffies(100)); 1322 + if (!gpio_mode_enforce) { 1323 + INIT_DELAYED_WORK(&mcp->init_work, mcp_init_work); 1324 + schedule_delayed_work(&mcp->init_work, msecs_to_jiffies(100)); 1325 + } 1332 1326 #endif 1333 1327 1334 1328 return 0;