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.

PCI/pwrctrl: tc9563: Rename private struct and pointers for consistency

Previously the pwrseq, tc9563, and slot pwrctrl drivers used different
naming conventions for their private data structs and pointers to them,
which makes patches hard to read.

Rename struct and variables to be shorter and more specific:

struct tc9563_pwrctrl_ctx -> struct tc9563_pwrctrl
struct tc9563_pwrctrl_ctx *ctx -> struct tc9563_pwrctrl *tc9563

No functional change intended.

Signed-off-by: Bjorn Helgaas <bhelgaas@google.com>
Signed-off-by: Manivannan Sadhasivam <manivannan.sadhasivam@oss.qualcomm.com>
Reviewed-by: Bartosz Golaszewski <bartosz.golaszewski@oss.qualcomm.com>
Link: https://patch.msgid.link/20260115-pci-pwrctrl-rework-v5-6-9d26da3ce903@oss.qualcomm.com

+72 -71
+72 -71
drivers/pci/pwrctrl/pci-pwrctrl-tc9563.c
··· 105 105 "vddio18", 106 106 }; 107 107 108 - struct tc9563_pwrctrl_ctx { 108 + struct tc9563_pwrctrl { 109 + struct pci_pwrctrl pwrctrl; 109 110 struct regulator_bulk_data supplies[TC9563_PWRCTL_MAX_SUPPLY]; 110 111 struct tc9563_pwrctrl_cfg cfg[TC9563_MAX]; 111 112 struct gpio_desc *reset_gpio; 112 113 struct i2c_adapter *adapter; 113 114 struct i2c_client *client; 114 - struct pci_pwrctrl pwrctrl; 115 115 }; 116 116 117 117 /* ··· 231 231 return 0; 232 232 } 233 233 234 - static int tc9563_pwrctrl_disable_port(struct tc9563_pwrctrl_ctx *ctx, 234 + static int tc9563_pwrctrl_disable_port(struct tc9563_pwrctrl *tc9563, 235 235 enum tc9563_pwrctrl_ports port) 236 236 { 237 - struct tc9563_pwrctrl_cfg *cfg = &ctx->cfg[port]; 237 + struct tc9563_pwrctrl_cfg *cfg = &tc9563->cfg[port]; 238 238 const struct tc9563_pwrctrl_reg_setting *seq; 239 239 int ret, len; 240 240 ··· 249 249 len = ARRAY_SIZE(dsp2_pwroff_seq); 250 250 } 251 251 252 - ret = tc9563_pwrctrl_i2c_bulk_write(ctx->client, seq, len); 252 + ret = tc9563_pwrctrl_i2c_bulk_write(tc9563->client, seq, len); 253 253 if (ret) 254 254 return ret; 255 255 256 - return tc9563_pwrctrl_i2c_bulk_write(ctx->client, common_pwroff_seq, 256 + return tc9563_pwrctrl_i2c_bulk_write(tc9563->client, common_pwroff_seq, 257 257 ARRAY_SIZE(common_pwroff_seq)); 258 258 } 259 259 260 - static int tc9563_pwrctrl_set_l0s_l1_entry_delay(struct tc9563_pwrctrl_ctx *ctx, 260 + static int tc9563_pwrctrl_set_l0s_l1_entry_delay(struct tc9563_pwrctrl *tc9563, 261 261 enum tc9563_pwrctrl_ports port, 262 262 bool is_l1, u32 ns) 263 263 { ··· 271 271 units = ns / TC9563_L0S_L1_DELAY_UNIT_NS; 272 272 273 273 if (port == TC9563_ETHERNET) { 274 - ret = tc9563_pwrctrl_i2c_read(ctx->client, 274 + ret = tc9563_pwrctrl_i2c_read(tc9563->client, 275 275 TC9563_EMBEDDED_ETH_DELAY, 276 276 &rd_val); 277 277 if (ret) ··· 284 284 rd_val = u32_replace_bits(rd_val, units, 285 285 TC9563_ETH_L0S_DELAY_MASK); 286 286 287 - return tc9563_pwrctrl_i2c_write(ctx->client, 287 + return tc9563_pwrctrl_i2c_write(tc9563->client, 288 288 TC9563_EMBEDDED_ETH_DELAY, 289 289 rd_val); 290 290 } 291 291 292 - ret = tc9563_pwrctrl_i2c_write(ctx->client, TC9563_PORT_SELECT, 292 + ret = tc9563_pwrctrl_i2c_write(tc9563->client, TC9563_PORT_SELECT, 293 293 BIT(port)); 294 294 if (ret) 295 295 return ret; 296 296 297 - return tc9563_pwrctrl_i2c_write(ctx->client, 297 + return tc9563_pwrctrl_i2c_write(tc9563->client, 298 298 is_l1 ? TC9563_PORT_L1_DELAY : TC9563_PORT_L0S_DELAY, 299 299 units); 300 300 } 301 301 302 - static int tc9563_pwrctrl_set_tx_amplitude(struct tc9563_pwrctrl_ctx *ctx, 302 + static int tc9563_pwrctrl_set_tx_amplitude(struct tc9563_pwrctrl *tc9563, 303 303 enum tc9563_pwrctrl_ports port) 304 304 { 305 - u32 amp = ctx->cfg[port].tx_amp; 305 + u32 amp = tc9563->cfg[port].tx_amp; 306 306 int port_access; 307 307 308 308 if (amp < TC9563_TX_MARGIN_MIN_UA) ··· 331 331 {TC9563_TX_MARGIN, amp}, 332 332 }; 333 333 334 - return tc9563_pwrctrl_i2c_bulk_write(ctx->client, tx_amp_seq, 334 + return tc9563_pwrctrl_i2c_bulk_write(tc9563->client, tx_amp_seq, 335 335 ARRAY_SIZE(tx_amp_seq)); 336 336 } 337 337 338 - static int tc9563_pwrctrl_disable_dfe(struct tc9563_pwrctrl_ctx *ctx, 338 + static int tc9563_pwrctrl_disable_dfe(struct tc9563_pwrctrl *tc9563, 339 339 enum tc9563_pwrctrl_ports port) 340 340 { 341 - struct tc9563_pwrctrl_cfg *cfg = &ctx->cfg[port]; 341 + struct tc9563_pwrctrl_cfg *cfg = &tc9563->cfg[port]; 342 342 int port_access, lane_access = 0x3; 343 343 u32 phy_rate = 0x21; 344 344 ··· 375 375 {TC9563_PHY_RATE_CHANGE_OVERRIDE, 0x0}, 376 376 }; 377 377 378 - return tc9563_pwrctrl_i2c_bulk_write(ctx->client, disable_dfe_seq, 378 + return tc9563_pwrctrl_i2c_bulk_write(tc9563->client, disable_dfe_seq, 379 379 ARRAY_SIZE(disable_dfe_seq)); 380 380 } 381 381 382 - static int tc9563_pwrctrl_set_nfts(struct tc9563_pwrctrl_ctx *ctx, 382 + static int tc9563_pwrctrl_set_nfts(struct tc9563_pwrctrl *tc9563, 383 383 enum tc9563_pwrctrl_ports port) 384 384 { 385 - u8 *nfts = ctx->cfg[port].nfts; 385 + u8 *nfts = tc9563->cfg[port].nfts; 386 386 struct tc9563_pwrctrl_reg_setting nfts_seq[] = { 387 387 {TC9563_NFTS_2_5_GT, nfts[0]}, 388 388 {TC9563_NFTS_5_GT, nfts[1]}, ··· 392 392 if (!nfts[0]) 393 393 return 0; 394 394 395 - ret = tc9563_pwrctrl_i2c_write(ctx->client, TC9563_PORT_SELECT, 395 + ret = tc9563_pwrctrl_i2c_write(tc9563->client, TC9563_PORT_SELECT, 396 396 BIT(port)); 397 397 if (ret) 398 398 return ret; 399 399 400 - return tc9563_pwrctrl_i2c_bulk_write(ctx->client, nfts_seq, 400 + return tc9563_pwrctrl_i2c_bulk_write(tc9563->client, nfts_seq, 401 401 ARRAY_SIZE(nfts_seq)); 402 402 } 403 403 404 - static int tc9563_pwrctrl_assert_deassert_reset(struct tc9563_pwrctrl_ctx *ctx, 404 + static int tc9563_pwrctrl_assert_deassert_reset(struct tc9563_pwrctrl *tc9563, 405 405 bool deassert) 406 406 { 407 407 int ret, val; 408 408 409 - ret = tc9563_pwrctrl_i2c_write(ctx->client, TC9563_GPIO_CONFIG, 409 + ret = tc9563_pwrctrl_i2c_write(tc9563->client, TC9563_GPIO_CONFIG, 410 410 TC9563_GPIO_MASK); 411 411 if (ret) 412 412 return ret; 413 413 414 414 val = deassert ? TC9563_GPIO_DEASSERT_BITS : 0; 415 415 416 - return tc9563_pwrctrl_i2c_write(ctx->client, TC9563_RESET_GPIO, val); 416 + return tc9563_pwrctrl_i2c_write(tc9563->client, TC9563_RESET_GPIO, val); 417 417 } 418 418 419 - static int tc9563_pwrctrl_parse_device_dt(struct tc9563_pwrctrl_ctx *ctx, 419 + static int tc9563_pwrctrl_parse_device_dt(struct tc9563_pwrctrl *tc9563, 420 420 struct device_node *node, 421 421 enum tc9563_pwrctrl_ports port) 422 422 { 423 - struct tc9563_pwrctrl_cfg *cfg = &ctx->cfg[port]; 423 + struct tc9563_pwrctrl_cfg *cfg = &tc9563->cfg[port]; 424 424 int ret; 425 425 426 426 /* Disable port if the status of the port is disabled. */ ··· 450 450 return 0; 451 451 } 452 452 453 - static void tc9563_pwrctrl_power_off(struct tc9563_pwrctrl_ctx *ctx) 453 + static void tc9563_pwrctrl_power_off(struct tc9563_pwrctrl *tc9563) 454 454 { 455 - gpiod_set_value(ctx->reset_gpio, 1); 455 + gpiod_set_value(tc9563->reset_gpio, 1); 456 456 457 - regulator_bulk_disable(ARRAY_SIZE(ctx->supplies), ctx->supplies); 457 + regulator_bulk_disable(ARRAY_SIZE(tc9563->supplies), tc9563->supplies); 458 458 } 459 459 460 - static int tc9563_pwrctrl_bring_up(struct tc9563_pwrctrl_ctx *ctx) 460 + static int tc9563_pwrctrl_bring_up(struct tc9563_pwrctrl *tc9563) 461 461 { 462 - struct device *dev = ctx->pwrctrl.dev; 462 + struct device *dev = tc9563->pwrctrl.dev; 463 463 struct tc9563_pwrctrl_cfg *cfg; 464 464 int ret, i; 465 465 466 - ret = regulator_bulk_enable(ARRAY_SIZE(ctx->supplies), ctx->supplies); 466 + ret = regulator_bulk_enable(ARRAY_SIZE(tc9563->supplies), 467 + tc9563->supplies); 467 468 if (ret < 0) 468 469 return dev_err_probe(dev, ret, "cannot enable regulators\n"); 469 470 470 - gpiod_set_value(ctx->reset_gpio, 0); 471 + gpiod_set_value(tc9563->reset_gpio, 0); 471 472 472 473 fsleep(TC9563_OSC_STAB_DELAY_US); 473 474 474 - ret = tc9563_pwrctrl_assert_deassert_reset(ctx, false); 475 + ret = tc9563_pwrctrl_assert_deassert_reset(tc9563, false); 475 476 if (ret) 476 477 goto power_off; 477 478 478 479 for (i = 0; i < TC9563_MAX; i++) { 479 - cfg = &ctx->cfg[i]; 480 - ret = tc9563_pwrctrl_disable_port(ctx, i); 480 + cfg = &tc9563->cfg[i]; 481 + ret = tc9563_pwrctrl_disable_port(tc9563, i); 481 482 if (ret) { 482 483 dev_err(dev, "Disabling port failed\n"); 483 484 goto power_off; 484 485 } 485 486 486 - ret = tc9563_pwrctrl_set_l0s_l1_entry_delay(ctx, i, false, cfg->l0s_delay); 487 + ret = tc9563_pwrctrl_set_l0s_l1_entry_delay(tc9563, i, false, cfg->l0s_delay); 487 488 if (ret) { 488 489 dev_err(dev, "Setting L0s entry delay failed\n"); 489 490 goto power_off; 490 491 } 491 492 492 - ret = tc9563_pwrctrl_set_l0s_l1_entry_delay(ctx, i, true, cfg->l1_delay); 493 + ret = tc9563_pwrctrl_set_l0s_l1_entry_delay(tc9563, i, true, cfg->l1_delay); 493 494 if (ret) { 494 495 dev_err(dev, "Setting L1 entry delay failed\n"); 495 496 goto power_off; 496 497 } 497 498 498 - ret = tc9563_pwrctrl_set_tx_amplitude(ctx, i); 499 + ret = tc9563_pwrctrl_set_tx_amplitude(tc9563, i); 499 500 if (ret) { 500 501 dev_err(dev, "Setting Tx amplitude failed\n"); 501 502 goto power_off; 502 503 } 503 504 504 - ret = tc9563_pwrctrl_set_nfts(ctx, i); 505 + ret = tc9563_pwrctrl_set_nfts(tc9563, i); 505 506 if (ret) { 506 507 dev_err(dev, "Setting N_FTS failed\n"); 507 508 goto power_off; 508 509 } 509 510 510 - ret = tc9563_pwrctrl_disable_dfe(ctx, i); 511 + ret = tc9563_pwrctrl_disable_dfe(tc9563, i); 511 512 if (ret) { 512 513 dev_err(dev, "Disabling DFE failed\n"); 513 514 goto power_off; 514 515 } 515 516 } 516 517 517 - ret = tc9563_pwrctrl_assert_deassert_reset(ctx, true); 518 + ret = tc9563_pwrctrl_assert_deassert_reset(tc9563, true); 518 519 if (!ret) 519 520 return 0; 520 521 521 522 power_off: 522 - tc9563_pwrctrl_power_off(ctx); 523 + tc9563_pwrctrl_power_off(tc9563); 523 524 return ret; 524 525 } 525 526 ··· 531 530 struct pci_bus *bus = bridge->bus; 532 531 struct device *dev = &pdev->dev; 533 532 enum tc9563_pwrctrl_ports port; 534 - struct tc9563_pwrctrl_ctx *ctx; 533 + struct tc9563_pwrctrl *tc9563; 535 534 struct device_node *i2c_node; 536 535 int ret, addr; 537 536 538 - ctx = devm_kzalloc(dev, sizeof(*ctx), GFP_KERNEL); 539 - if (!ctx) 537 + tc9563 = devm_kzalloc(dev, sizeof(*tc9563), GFP_KERNEL); 538 + if (!tc9563) 540 539 return -ENOMEM; 541 540 542 541 ret = of_property_read_u32_index(node, "i2c-parent", 1, &addr); ··· 544 543 return dev_err_probe(dev, ret, "Failed to read i2c-parent property\n"); 545 544 546 545 i2c_node = of_parse_phandle(dev->of_node, "i2c-parent", 0); 547 - ctx->adapter = of_find_i2c_adapter_by_node(i2c_node); 546 + tc9563->adapter = of_find_i2c_adapter_by_node(i2c_node); 548 547 of_node_put(i2c_node); 549 - if (!ctx->adapter) 548 + if (!tc9563->adapter) 550 549 return dev_err_probe(dev, -EPROBE_DEFER, "Failed to find I2C adapter\n"); 551 550 552 - ctx->client = i2c_new_dummy_device(ctx->adapter, addr); 553 - if (IS_ERR(ctx->client)) { 551 + tc9563->client = i2c_new_dummy_device(tc9563->adapter, addr); 552 + if (IS_ERR(tc9563->client)) { 554 553 dev_err(dev, "Failed to create I2C client\n"); 555 - put_device(&ctx->adapter->dev); 556 - return PTR_ERR(ctx->client); 554 + put_device(&tc9563->adapter->dev); 555 + return PTR_ERR(tc9563->client); 557 556 } 558 557 559 558 for (int i = 0; i < ARRAY_SIZE(tc9563_supply_names); i++) 560 - ctx->supplies[i].supply = tc9563_supply_names[i]; 559 + tc9563->supplies[i].supply = tc9563_supply_names[i]; 561 560 562 561 ret = devm_regulator_bulk_get(dev, TC9563_PWRCTL_MAX_SUPPLY, 563 - ctx->supplies); 562 + tc9563->supplies); 564 563 if (ret) { 565 564 dev_err_probe(dev, ret, "failed to get supply regulator\n"); 566 565 goto remove_i2c; 567 566 } 568 567 569 - ctx->reset_gpio = devm_gpiod_get(dev, "resx", GPIOD_OUT_HIGH); 570 - if (IS_ERR(ctx->reset_gpio)) { 571 - ret = dev_err_probe(dev, PTR_ERR(ctx->reset_gpio), "failed to get resx GPIO\n"); 568 + tc9563->reset_gpio = devm_gpiod_get(dev, "resx", GPIOD_OUT_HIGH); 569 + if (IS_ERR(tc9563->reset_gpio)) { 570 + ret = dev_err_probe(dev, PTR_ERR(tc9563->reset_gpio), "failed to get resx GPIO\n"); 572 571 goto remove_i2c; 573 572 } 574 573 575 - pci_pwrctrl_init(&ctx->pwrctrl, dev); 574 + pci_pwrctrl_init(&tc9563->pwrctrl, dev); 576 575 577 576 port = TC9563_USP; 578 - ret = tc9563_pwrctrl_parse_device_dt(ctx, node, port); 577 + ret = tc9563_pwrctrl_parse_device_dt(tc9563, node, port); 579 578 if (ret) { 580 579 dev_err(dev, "failed to parse device tree properties: %d\n", ret); 581 580 goto remove_i2c; ··· 588 587 */ 589 588 for_each_child_of_node_scoped(node, child) { 590 589 port++; 591 - ret = tc9563_pwrctrl_parse_device_dt(ctx, child, port); 590 + ret = tc9563_pwrctrl_parse_device_dt(tc9563, child, port); 592 591 if (ret) 593 592 break; 594 593 /* Embedded ethernet device are under DSP3 */ 595 594 if (port == TC9563_DSP3) { 596 595 for_each_child_of_node_scoped(child, child1) { 597 596 port++; 598 - ret = tc9563_pwrctrl_parse_device_dt(ctx, 597 + ret = tc9563_pwrctrl_parse_device_dt(tc9563, 599 598 child1, port); 600 599 if (ret) 601 600 break; ··· 613 612 goto remove_i2c; 614 613 } 615 614 616 - ret = tc9563_pwrctrl_bring_up(ctx); 615 + ret = tc9563_pwrctrl_bring_up(tc9563); 617 616 if (ret) 618 617 goto remove_i2c; 619 618 ··· 623 622 goto power_off; 624 623 } 625 624 626 - ret = devm_pci_pwrctrl_device_set_ready(dev, &ctx->pwrctrl); 625 + ret = devm_pci_pwrctrl_device_set_ready(dev, &tc9563->pwrctrl); 627 626 if (ret) 628 627 goto power_off; 629 628 630 - platform_set_drvdata(pdev, ctx); 629 + platform_set_drvdata(pdev, tc9563); 631 630 632 631 return 0; 633 632 634 633 power_off: 635 - tc9563_pwrctrl_power_off(ctx); 634 + tc9563_pwrctrl_power_off(tc9563); 636 635 remove_i2c: 637 - i2c_unregister_device(ctx->client); 638 - put_device(&ctx->adapter->dev); 636 + i2c_unregister_device(tc9563->client); 637 + put_device(&tc9563->adapter->dev); 639 638 return ret; 640 639 } 641 640 642 641 static void tc9563_pwrctrl_remove(struct platform_device *pdev) 643 642 { 644 - struct tc9563_pwrctrl_ctx *ctx = platform_get_drvdata(pdev); 643 + struct tc9563_pwrctrl *tc9563 = platform_get_drvdata(pdev); 645 644 646 - tc9563_pwrctrl_power_off(ctx); 647 - i2c_unregister_device(ctx->client); 648 - put_device(&ctx->adapter->dev); 645 + tc9563_pwrctrl_power_off(tc9563); 646 + i2c_unregister_device(tc9563->client); 647 + put_device(&tc9563->adapter->dev); 649 648 } 650 649 651 650 static const struct of_device_id tc9563_pwrctrl_of_match[] = {