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 'ipa-device-pointer-access'

Alex Elder says:

====================
net: ipa: simplify device pointer access

This version of this patch series fixes the bugs in the first patch
(which were fixed in the second), where ipa_interrupt_config() had
two remaining spots that returned a pointer rather than an integer.

Outside of initialization, all uses of the platform device pointer
stored in the IPA structure determine the address of device
structure embedded within the platform device structure.

By changing some of the initialization functions to take a platform
device as argument we can simplify getting at the device structure
address by storing it (instead of the platform device pointer) in
the IPA structure.

The first two patches split the interrupt initialization code into
two parts--one done earlier than before. The next four patches
update some initialization functions to take a platform device
pointer as argument. And the last patch replaces the platform
device pointer with a device pointer, and converts all remaining
references to the &ipa->pdev->dev to use ipa->dev.
====================

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

+197 -143
+2 -3
drivers/net/ipa/ipa.h
··· 21 21 struct clk; 22 22 struct icc_path; 23 23 struct net_device; 24 - struct platform_device; 25 24 26 25 struct ipa_power; 27 26 struct ipa_smp2p; ··· 30 31 * struct ipa - IPA information 31 32 * @gsi: Embedded GSI structure 32 33 * @version: IPA hardware version 33 - * @pdev: Platform device 34 + * @dev: IPA device pointer 34 35 * @completion: Used to signal pipeline clear transfer complete 35 36 * @nb: Notifier block used for remoteproc SSR 36 37 * @notifier: Remoteproc SSR notifier ··· 78 79 struct ipa { 79 80 struct gsi gsi; 80 81 enum ipa_version version; 81 - struct platform_device *pdev; 82 + struct device *dev; 82 83 struct completion completion; 83 84 struct notifier_block nb; 84 85 void *notifier;
+3 -3
drivers/net/ipa/ipa_cmd.c
··· 174 174 u32 offset_max = field_max(IP_FLTRT_FLAGS_NHASH_ADDR_FMASK); 175 175 u32 size_max = field_max(IP_FLTRT_FLAGS_NHASH_SIZE_FMASK); 176 176 const char *table = route ? "route" : "filter"; 177 - struct device *dev = &ipa->pdev->dev; 177 + struct device *dev = ipa->dev; 178 178 u32 size; 179 179 180 180 size = route ? ipa->route_count : ipa->filter_count + 1; ··· 204 204 /* Validate the memory region that holds headers */ 205 205 static bool ipa_cmd_header_init_local_valid(struct ipa *ipa) 206 206 { 207 - struct device *dev = &ipa->pdev->dev; 207 + struct device *dev = ipa->dev; 208 208 const struct ipa_mem *mem; 209 209 u32 offset_max; 210 210 u32 size_max; ··· 256 256 const char *name, u32 offset) 257 257 { 258 258 struct ipa_cmd_register_write *payload; 259 - struct device *dev = &ipa->pdev->dev; 259 + struct device *dev = ipa->dev; 260 260 u32 offset_max; 261 261 u32 bit_count; 262 262
+14 -15
drivers/net/ipa/ipa_endpoint.c
··· 233 233 const struct ipa_gsi_endpoint_data *data) 234 234 { 235 235 const struct ipa_gsi_endpoint_data *other_data; 236 - struct device *dev = &ipa->pdev->dev; 237 236 enum ipa_endpoint_name other_name; 237 + struct device *dev = ipa->dev; 238 238 239 239 if (ipa_gsi_endpoint_data_empty(data)) 240 240 return true; ··· 388 388 const struct ipa_gsi_endpoint_data *data) 389 389 { 390 390 const struct ipa_gsi_endpoint_data *dp = data; 391 - struct device *dev = &ipa->pdev->dev; 391 + struct device *dev = ipa->dev; 392 392 enum ipa_endpoint_name name; 393 393 u32 max; 394 394 ··· 606 606 count = ipa->modem_tx_count + ipa_cmd_pipeline_clear_count(); 607 607 trans = ipa_cmd_trans_alloc(ipa, count); 608 608 if (!trans) { 609 - dev_err(&ipa->pdev->dev, 609 + dev_err(ipa->dev, 610 610 "no transaction to reset modem exception endpoints\n"); 611 611 return -EBUSY; 612 612 } ··· 1498 1498 if (endpoint_id == command_endpoint->endpoint_id) { 1499 1499 complete(&ipa->completion); 1500 1500 } else { 1501 - dev_err(&ipa->pdev->dev, 1502 - "unexpected tagged packet from endpoint %u\n", 1501 + dev_err(ipa->dev, "unexpected tagged packet from endpoint %u\n", 1503 1502 endpoint_id); 1504 1503 } 1505 1504 ··· 1535 1536 void *data = page_address(page) + NET_SKB_PAD; 1536 1537 u32 unused = buffer_size - total_len; 1537 1538 struct ipa *ipa = endpoint->ipa; 1539 + struct device *dev = ipa->dev; 1538 1540 u32 resid = total_len; 1539 1541 1540 1542 while (resid) { ··· 1544 1544 u32 len; 1545 1545 1546 1546 if (resid < IPA_STATUS_SIZE) { 1547 - dev_err(&endpoint->ipa->pdev->dev, 1547 + dev_err(dev, 1548 1548 "short message (%u bytes < %zu byte status)\n", 1549 1549 resid, IPA_STATUS_SIZE); 1550 1550 break; ··· 1666 1666 */ 1667 1667 static int ipa_endpoint_reset_rx_aggr(struct ipa_endpoint *endpoint) 1668 1668 { 1669 - struct device *dev = &endpoint->ipa->pdev->dev; 1670 1669 struct ipa *ipa = endpoint->ipa; 1670 + struct device *dev = ipa->dev; 1671 1671 struct gsi *gsi = &ipa->gsi; 1672 1672 bool suspended = false; 1673 1673 dma_addr_t addr; ··· 1769 1769 gsi_channel_reset(&ipa->gsi, channel_id, true); 1770 1770 1771 1771 if (ret) 1772 - dev_err(&ipa->pdev->dev, 1772 + dev_err(ipa->dev, 1773 1773 "error %d resetting channel %u for endpoint %u\n", 1774 1774 ret, endpoint->channel_id, endpoint->endpoint_id); 1775 1775 } ··· 1817 1817 1818 1818 ret = gsi_channel_start(gsi, endpoint->channel_id); 1819 1819 if (ret) { 1820 - dev_err(&ipa->pdev->dev, 1820 + dev_err(ipa->dev, 1821 1821 "error %d starting %cX channel %u for endpoint %u\n", 1822 1822 ret, endpoint->toward_ipa ? 'T' : 'R', 1823 1823 endpoint->channel_id, endpoint_id); ··· 1854 1854 /* Note that if stop fails, the channel's state is not well-defined */ 1855 1855 ret = gsi_channel_stop(gsi, endpoint->channel_id); 1856 1856 if (ret) 1857 - dev_err(&ipa->pdev->dev, 1858 - "error %d attempting to stop endpoint %u\n", ret, 1859 - endpoint_id); 1857 + dev_err(ipa->dev, "error %d attempting to stop endpoint %u\n", 1858 + ret, endpoint_id); 1860 1859 } 1861 1860 1862 1861 void ipa_endpoint_suspend_one(struct ipa_endpoint *endpoint) 1863 1862 { 1864 - struct device *dev = &endpoint->ipa->pdev->dev; 1863 + struct device *dev = endpoint->ipa->dev; 1865 1864 struct gsi *gsi = &endpoint->ipa->gsi; 1866 1865 int ret; 1867 1866 ··· 1880 1881 1881 1882 void ipa_endpoint_resume_one(struct ipa_endpoint *endpoint) 1882 1883 { 1883 - struct device *dev = &endpoint->ipa->pdev->dev; 1884 + struct device *dev = endpoint->ipa->dev; 1884 1885 struct gsi *gsi = &endpoint->ipa->gsi; 1885 1886 int ret; 1886 1887 ··· 1982 1983 1983 1984 int ipa_endpoint_config(struct ipa *ipa) 1984 1985 { 1985 - struct device *dev = &ipa->pdev->dev; 1986 + struct device *dev = ipa->dev; 1986 1987 const struct reg *reg; 1987 1988 u32 endpoint_id; 1988 1989 u32 hw_limit;
+45 -24
drivers/net/ipa/ipa_interrupt.c
··· 19 19 * time only these three are supported. 20 20 */ 21 21 22 + #include <linux/platform_device.h> 22 23 #include <linux/types.h> 23 24 #include <linux/interrupt.h> 24 25 #include <linux/pm_runtime.h> ··· 110 109 struct ipa_interrupt *interrupt = dev_id; 111 110 struct ipa *ipa = interrupt->ipa; 112 111 u32 enabled = interrupt->enabled; 112 + struct device *dev = ipa->dev; 113 113 const struct reg *reg; 114 - struct device *dev; 115 114 u32 pending; 116 115 u32 offset; 117 116 u32 mask; 118 117 int ret; 119 118 120 - dev = &ipa->pdev->dev; 121 119 ret = pm_runtime_get_sync(dev); 122 120 if (WARN_ON(ret < 0)) 123 121 goto out_power_put; ··· 236 236 } 237 237 238 238 /* Configure the IPA interrupt framework */ 239 - struct ipa_interrupt *ipa_interrupt_config(struct ipa *ipa) 239 + int ipa_interrupt_config(struct ipa *ipa) 240 240 { 241 - struct device *dev = &ipa->pdev->dev; 242 - struct ipa_interrupt *interrupt; 241 + struct ipa_interrupt *interrupt = ipa->interrupt; 242 + unsigned int irq = interrupt->irq; 243 + struct device *dev = ipa->dev; 243 244 const struct reg *reg; 244 - unsigned int irq; 245 245 int ret; 246 246 247 - ret = platform_get_irq_byname(ipa->pdev, "ipa"); 248 - if (ret <= 0) { 249 - dev_err(dev, "DT error %d getting \"ipa\" IRQ property\n", 250 - ret); 251 - return ERR_PTR(ret ? : -EINVAL); 252 - } 253 - irq = ret; 254 - 255 - interrupt = kzalloc(sizeof(*interrupt), GFP_KERNEL); 256 - if (!interrupt) 257 - return ERR_PTR(-ENOMEM); 258 247 interrupt->ipa = ipa; 259 - interrupt->irq = irq; 260 248 261 - /* Start with all IPA interrupts disabled */ 249 + /* Disable all IPA interrupt types */ 262 250 reg = ipa_reg(ipa, IPA_IRQ_EN); 263 251 iowrite32(0, ipa->reg_virt + reg_offset(reg)); 264 252 ··· 259 271 260 272 ret = dev_pm_set_wake_irq(dev, irq); 261 273 if (ret) { 262 - dev_err(dev, "error %d registering \"ipa\" IRQ as wakeirq\n", ret); 274 + dev_err(dev, "error %d registering \"ipa\" IRQ as wakeirq\n", 275 + ret); 263 276 goto err_free_irq; 264 277 } 265 278 266 - return interrupt; 279 + ipa->interrupt = interrupt; 280 + 281 + return 0; 267 282 268 283 err_free_irq: 269 284 free_irq(interrupt->irq, interrupt); 270 285 err_kfree: 271 286 kfree(interrupt); 272 287 273 - return ERR_PTR(ret); 288 + return ret; 274 289 } 275 290 276 291 /* Inverse of ipa_interrupt_config() */ 277 - void ipa_interrupt_deconfig(struct ipa_interrupt *interrupt) 292 + void ipa_interrupt_deconfig(struct ipa *ipa) 278 293 { 279 - struct device *dev = &interrupt->ipa->pdev->dev; 294 + struct ipa_interrupt *interrupt = ipa->interrupt; 295 + struct device *dev = ipa->dev; 296 + 297 + ipa->interrupt = NULL; 280 298 281 299 dev_pm_clear_wake_irq(dev); 282 300 free_irq(interrupt->irq, interrupt); 301 + } 302 + 303 + /* Initialize the IPA interrupt structure */ 304 + struct ipa_interrupt *ipa_interrupt_init(struct platform_device *pdev) 305 + { 306 + struct device *dev = &pdev->dev; 307 + struct ipa_interrupt *interrupt; 308 + int irq; 309 + 310 + irq = platform_get_irq_byname(pdev, "ipa"); 311 + if (irq <= 0) { 312 + dev_err(dev, "DT error %d getting \"ipa\" IRQ property\n", irq); 313 + 314 + return ERR_PTR(irq ? : -EINVAL); 315 + } 316 + 317 + interrupt = kzalloc(sizeof(*interrupt), GFP_KERNEL); 318 + if (!interrupt) 319 + return ERR_PTR(-ENOMEM); 320 + interrupt->irq = irq; 321 + 322 + return interrupt; 323 + } 324 + 325 + /* Inverse of ipa_interrupt_init() */ 326 + void ipa_interrupt_exit(struct ipa_interrupt *interrupt) 327 + { 283 328 kfree(interrupt); 284 329 }
+18 -4
drivers/net/ipa/ipa_interrupt.h
··· 76 76 void ipa_interrupt_irq_disable(struct ipa *ipa); 77 77 78 78 /** 79 - * ipa_interrupt_config() - Configure the IPA interrupt framework 79 + * ipa_interrupt_config() - Configure IPA interrupts 80 80 * @ipa: IPA pointer 81 81 * 82 - * Return: Pointer to IPA SMP2P info, or a pointer-coded error 82 + * Return: 0 if successful, or a negative error code 83 83 */ 84 - struct ipa_interrupt *ipa_interrupt_config(struct ipa *ipa); 84 + int ipa_interrupt_config(struct ipa *ipa); 85 85 86 86 /** 87 87 * ipa_interrupt_deconfig() - Inverse of ipa_interrupt_config() 88 + * @ipa: IPA pointer 89 + */ 90 + void ipa_interrupt_deconfig(struct ipa *ipa); 91 + 92 + /** 93 + * ipa_interrupt_init() - Initialize the IPA interrupt structure 94 + * @pdev: IPA platform device pointer 95 + * 96 + * Return: Pointer to an IPA interrupt structure, or a pointer-coded error 97 + */ 98 + struct ipa_interrupt *ipa_interrupt_init(struct platform_device *pdev); 99 + 100 + /** 101 + * ipa_interrupt_exit() - Inverse of ipa_interrupt_init() 88 102 * @interrupt: IPA interrupt structure 89 103 */ 90 - void ipa_interrupt_deconfig(struct ipa_interrupt *interrupt); 104 + void ipa_interrupt_exit(struct ipa_interrupt *interrupt); 91 105 92 106 #endif /* _IPA_INTERRUPT_H_ */
+38 -22
drivers/net/ipa/ipa_main.c
··· 7 7 #include <linux/types.h> 8 8 #include <linux/atomic.h> 9 9 #include <linux/bitfield.h> 10 - #include <linux/device.h> 11 10 #include <linux/bug.h> 12 11 #include <linux/io.h> 13 12 #include <linux/firmware.h> ··· 113 114 { 114 115 struct ipa_endpoint *exception_endpoint; 115 116 struct ipa_endpoint *command_endpoint; 116 - struct device *dev = &ipa->pdev->dev; 117 + struct device *dev = ipa->dev; 117 118 int ret; 118 119 119 120 ret = gsi_setup(&ipa->gsi); ··· 541 542 if (ret) 542 543 goto err_hardware_deconfig; 543 544 544 - ipa->interrupt = ipa_interrupt_config(ipa); 545 - if (IS_ERR(ipa->interrupt)) { 546 - ret = PTR_ERR(ipa->interrupt); 547 - ipa->interrupt = NULL; 545 + ret = ipa_interrupt_config(ipa); 546 + if (ret) 548 547 goto err_mem_deconfig; 549 - } 550 548 551 549 ipa_uc_config(ipa); 552 550 ··· 568 572 ipa_endpoint_deconfig(ipa); 569 573 err_uc_deconfig: 570 574 ipa_uc_deconfig(ipa); 571 - ipa_interrupt_deconfig(ipa->interrupt); 572 - ipa->interrupt = NULL; 575 + ipa_interrupt_deconfig(ipa); 573 576 err_mem_deconfig: 574 577 ipa_mem_deconfig(ipa); 575 578 err_hardware_deconfig: ··· 586 591 ipa_modem_deconfig(ipa); 587 592 ipa_endpoint_deconfig(ipa); 588 593 ipa_uc_deconfig(ipa); 589 - ipa_interrupt_deconfig(ipa->interrupt); 590 - ipa->interrupt = NULL; 594 + ipa_interrupt_deconfig(ipa); 591 595 ipa_mem_deconfig(ipa); 592 596 ipa_hardware_deconfig(ipa); 593 597 } ··· 802 808 static int ipa_probe(struct platform_device *pdev) 803 809 { 804 810 struct device *dev = &pdev->dev; 811 + struct ipa_interrupt *interrupt; 805 812 enum ipa_firmware_loader loader; 806 813 const struct ipa_data *data; 807 814 struct ipa_power *power; ··· 834 839 if (loader == IPA_LOADER_DEFER) 835 840 return -EPROBE_DEFER; 836 841 837 - /* The clock and interconnects might not be ready when we're 838 - * probed, so might return -EPROBE_DEFER. 842 + /* The IPA interrupt might not be ready when we're probed, so this 843 + * might return -EPROBE_DEFER. 844 + */ 845 + interrupt = ipa_interrupt_init(pdev); 846 + if (IS_ERR(interrupt)) 847 + return PTR_ERR(interrupt); 848 + 849 + /* The clock and interconnects might not be ready when we're probed, 850 + * so this might return -EPROBE_DEFER. 839 851 */ 840 852 power = ipa_power_init(dev, data->power_data); 841 - if (IS_ERR(power)) 842 - return PTR_ERR(power); 853 + if (IS_ERR(power)) { 854 + ret = PTR_ERR(power); 855 + goto err_interrupt_exit; 856 + } 843 857 844 858 /* No more EPROBE_DEFER. Allocate and initialize the IPA structure */ 845 859 ipa = kzalloc(sizeof(*ipa), GFP_KERNEL); ··· 857 853 goto err_power_exit; 858 854 } 859 855 860 - ipa->pdev = pdev; 856 + ipa->dev = dev; 861 857 dev_set_drvdata(dev, ipa); 858 + ipa->interrupt = interrupt; 862 859 ipa->power = power; 863 860 ipa->version = data->version; 864 861 ipa->modem_route_count = data->modem_route_count; 865 862 init_completion(&ipa->completion); 866 863 867 - ret = ipa_reg_init(ipa); 864 + ret = ipa_reg_init(ipa, pdev); 868 865 if (ret) 869 866 goto err_kfree_ipa; 870 867 871 - ret = ipa_mem_init(ipa, data->mem_data); 868 + ret = ipa_mem_init(ipa, pdev, data->mem_data); 872 869 if (ret) 873 870 goto err_reg_exit; 874 871 ··· 887 882 if (ret) 888 883 goto err_endpoint_exit; 889 884 890 - ret = ipa_smp2p_init(ipa, loader == IPA_LOADER_MODEM); 885 + ret = ipa_smp2p_init(ipa, pdev, loader == IPA_LOADER_MODEM); 891 886 if (ret) 892 887 goto err_table_exit; 893 888 ··· 944 939 kfree(ipa); 945 940 err_power_exit: 946 941 ipa_power_exit(power); 942 + err_interrupt_exit: 943 + ipa_interrupt_exit(interrupt); 947 944 948 945 return ret; 949 946 } 950 947 951 948 static void ipa_remove(struct platform_device *pdev) 952 949 { 953 - struct ipa *ipa = dev_get_drvdata(&pdev->dev); 954 - struct ipa_power *power = ipa->power; 955 - struct device *dev = &pdev->dev; 950 + struct ipa_interrupt *interrupt; 951 + struct ipa_power *power; 952 + struct device *dev; 953 + struct ipa *ipa; 956 954 int ret; 955 + 956 + ipa = dev_get_drvdata(&pdev->dev); 957 + dev = ipa->dev; 958 + WARN_ON(dev != &pdev->dev); 959 + 960 + power = ipa->power; 961 + interrupt = ipa->interrupt; 957 962 958 963 /* Prevent the modem from triggering a call to ipa_setup(). This 959 964 * also ensures a modem-initiated setup that's underway completes. ··· 1006 991 ipa_reg_exit(ipa); 1007 992 kfree(ipa); 1008 993 ipa_power_exit(power); 994 + ipa_interrupt_exit(interrupt); 1009 995 1010 996 dev_info(dev, "IPA driver removed"); 1011 997 }
+18 -19
drivers/net/ipa/ipa_mem.c
··· 9 9 #include <linux/bug.h> 10 10 #include <linux/dma-mapping.h> 11 11 #include <linux/iommu.h> 12 + #include <linux/platform_device.h> 12 13 #include <linux/io.h> 13 14 #include <linux/soc/qcom/smem.h> 14 15 ··· 76 75 int ipa_mem_setup(struct ipa *ipa) 77 76 { 78 77 dma_addr_t addr = ipa->zero_addr; 79 - const struct reg *reg; 80 78 const struct ipa_mem *mem; 81 79 struct gsi_trans *trans; 80 + const struct reg *reg; 82 81 u32 offset; 83 82 u16 size; 84 83 u32 val; ··· 88 87 */ 89 88 trans = ipa_cmd_trans_alloc(ipa, 4); 90 89 if (!trans) { 91 - dev_err(&ipa->pdev->dev, "no transaction for memory setup\n"); 90 + dev_err(ipa->dev, "no transaction for memory setup\n"); 92 91 return -EBUSY; 93 92 } 94 93 ··· 218 217 219 218 static bool ipa_mem_valid_one(struct ipa *ipa, const struct ipa_mem *mem) 220 219 { 221 - struct device *dev = &ipa->pdev->dev; 222 220 enum ipa_mem_id mem_id = mem->id; 221 + struct device *dev = ipa->dev; 223 222 u16 size_multiple; 224 223 225 224 /* Make sure the memory region is valid for this version of IPA */ ··· 255 254 static bool ipa_mem_valid(struct ipa *ipa, const struct ipa_mem_data *mem_data) 256 255 { 257 256 DECLARE_BITMAP(regions, IPA_MEM_COUNT) = { }; 258 - struct device *dev = &ipa->pdev->dev; 257 + struct device *dev = ipa->dev; 259 258 enum ipa_mem_id mem_id; 260 259 u32 i; 261 260 ··· 291 290 /* Do all memory regions fit within the IPA local memory? */ 292 291 static bool ipa_mem_size_valid(struct ipa *ipa) 293 292 { 294 - struct device *dev = &ipa->pdev->dev; 293 + struct device *dev = ipa->dev; 295 294 u32 limit = ipa->mem_size; 296 295 u32 i; 297 296 ··· 318 317 */ 319 318 int ipa_mem_config(struct ipa *ipa) 320 319 { 321 - struct device *dev = &ipa->pdev->dev; 320 + struct device *dev = ipa->dev; 322 321 const struct ipa_mem *mem; 323 322 const struct reg *reg; 324 323 dma_addr_t addr; ··· 394 393 /* Inverse of ipa_mem_config() */ 395 394 void ipa_mem_deconfig(struct ipa *ipa) 396 395 { 397 - struct device *dev = &ipa->pdev->dev; 396 + struct device *dev = ipa->dev; 398 397 399 398 dma_free_coherent(dev, ipa->zero_size, ipa->zero_virt, ipa->zero_addr); 400 399 ipa->zero_size = 0; ··· 421 420 */ 422 421 trans = ipa_cmd_trans_alloc(ipa, 3); 423 422 if (!trans) { 424 - dev_err(&ipa->pdev->dev, 425 - "no transaction to zero modem memory\n"); 423 + dev_err(ipa->dev, "no transaction to zero modem memory\n"); 426 424 return -EBUSY; 427 425 } 428 426 ··· 452 452 */ 453 453 static int ipa_imem_init(struct ipa *ipa, unsigned long addr, size_t size) 454 454 { 455 - struct device *dev = &ipa->pdev->dev; 455 + struct device *dev = ipa->dev; 456 456 struct iommu_domain *domain; 457 457 unsigned long iova; 458 458 phys_addr_t phys; ··· 485 485 486 486 static void ipa_imem_exit(struct ipa *ipa) 487 487 { 488 + struct device *dev = ipa->dev; 488 489 struct iommu_domain *domain; 489 - struct device *dev; 490 490 491 491 if (!ipa->imem_size) 492 492 return; 493 493 494 - dev = &ipa->pdev->dev; 495 494 domain = iommu_get_domain_for_dev(dev); 496 495 if (domain) { 497 496 size_t size; ··· 526 527 */ 527 528 static int ipa_smem_init(struct ipa *ipa, u32 item, size_t size) 528 529 { 529 - struct device *dev = &ipa->pdev->dev; 530 + struct device *dev = ipa->dev; 530 531 struct iommu_domain *domain; 531 532 unsigned long iova; 532 533 phys_addr_t phys; ··· 593 594 594 595 static void ipa_smem_exit(struct ipa *ipa) 595 596 { 596 - struct device *dev = &ipa->pdev->dev; 597 + struct device *dev = ipa->dev; 597 598 struct iommu_domain *domain; 598 599 599 600 domain = iommu_get_domain_for_dev(dev); ··· 614 615 } 615 616 616 617 /* Perform memory region-related initialization */ 617 - int ipa_mem_init(struct ipa *ipa, const struct ipa_mem_data *mem_data) 618 + int ipa_mem_init(struct ipa *ipa, struct platform_device *pdev, 619 + const struct ipa_mem_data *mem_data) 618 620 { 619 - struct device *dev = &ipa->pdev->dev; 621 + struct device *dev = &pdev->dev; 620 622 struct resource *res; 621 623 int ret; 622 624 ··· 634 634 if (!ipa_table_mem_valid(ipa, true)) 635 635 return -EINVAL; 636 636 637 - ret = dma_set_mask_and_coherent(&ipa->pdev->dev, DMA_BIT_MASK(64)); 637 + ret = dma_set_mask_and_coherent(dev, DMA_BIT_MASK(64)); 638 638 if (ret) { 639 639 dev_err(dev, "error %d setting DMA mask\n", ret); 640 640 return ret; 641 641 } 642 642 643 - res = platform_get_resource_byname(ipa->pdev, IORESOURCE_MEM, 644 - "ipa-shared"); 643 + res = platform_get_resource_byname(pdev, IORESOURCE_MEM, "ipa-shared"); 645 644 if (!res) { 646 645 dev_err(dev, 647 646 "DT error getting \"ipa-shared\" memory property\n");
+4 -1
drivers/net/ipa/ipa_mem.h
··· 6 6 #ifndef _IPA_MEM_H_ 7 7 #define _IPA_MEM_H_ 8 8 9 + struct platform_device; 10 + 9 11 struct ipa; 10 12 struct ipa_mem_data; 11 13 ··· 102 100 103 101 int ipa_mem_zero_modem(struct ipa *ipa); 104 102 105 - int ipa_mem_init(struct ipa *ipa, const struct ipa_mem_data *mem_data); 103 + int ipa_mem_init(struct ipa *ipa, struct platform_device *pdev, 104 + const struct ipa_mem_data *mem_data); 106 105 void ipa_mem_exit(struct ipa *ipa); 107 106 108 107 #endif /* _IPA_MEM_H_ */
+7 -7
drivers/net/ipa/ipa_modem.c
··· 58 58 struct device *dev; 59 59 int ret; 60 60 61 - dev = &ipa->pdev->dev; 61 + dev = ipa->dev; 62 62 ret = pm_runtime_get_sync(dev); 63 63 if (ret < 0) 64 64 goto err_power_put; ··· 94 94 struct device *dev; 95 95 int ret; 96 96 97 - dev = &ipa->pdev->dev; 97 + dev = ipa->dev; 98 98 ret = pm_runtime_get_sync(dev); 99 99 if (ret < 0) 100 100 goto out_power_put; ··· 158 158 */ 159 159 netif_stop_queue(netdev); 160 160 161 - dev = &ipa->pdev->dev; 161 + dev = ipa->dev; 162 162 ret = pm_runtime_get(dev); 163 163 if (ret < 1) { 164 164 /* If a resume won't happen, just drop the packet */ ··· 322 322 goto out_set_state; 323 323 } 324 324 325 - SET_NETDEV_DEV(netdev, &ipa->pdev->dev); 325 + SET_NETDEV_DEV(netdev, ipa->dev); 326 326 priv = netdev_priv(netdev); 327 327 priv->ipa = ipa; 328 328 priv->tx = ipa->name_map[IPA_ENDPOINT_AP_MODEM_TX]; ··· 396 396 /* Treat a "clean" modem stop the same as a crash */ 397 397 static void ipa_modem_crashed(struct ipa *ipa) 398 398 { 399 - struct device *dev = &ipa->pdev->dev; 399 + struct device *dev = ipa->dev; 400 400 int ret; 401 401 402 402 /* Prevent the modem from triggering a call to ipa_setup() */ ··· 443 443 { 444 444 struct ipa *ipa = container_of(nb, struct ipa, nb); 445 445 struct qcom_ssr_notify_data *notify_data = data; 446 - struct device *dev = &ipa->pdev->dev; 446 + struct device *dev = ipa->dev; 447 447 448 448 switch (action) { 449 449 case QCOM_SSR_BEFORE_POWERUP: ··· 492 492 493 493 void ipa_modem_deconfig(struct ipa *ipa) 494 494 { 495 - struct device *dev = &ipa->pdev->dev; 495 + struct device *dev = ipa->dev; 496 496 int ret; 497 497 498 498 ret = qcom_unregister_ssr_notifier(ipa->notifier, &ipa->nb);
+2 -2
drivers/net/ipa/ipa_power.c
··· 238 238 239 239 ipa_interrupt_enable(ipa, IPA_IRQ_TX_SUSPEND); 240 240 241 - ret = device_init_wakeup(&ipa->pdev->dev, true); 241 + ret = device_init_wakeup(ipa->dev, true); 242 242 if (ret) 243 243 ipa_interrupt_disable(ipa, IPA_IRQ_TX_SUSPEND); 244 244 ··· 247 247 248 248 void ipa_power_teardown(struct ipa *ipa) 249 249 { 250 - (void)device_init_wakeup(&ipa->pdev->dev, false); 250 + (void)device_init_wakeup(ipa->dev, false); 251 251 ipa_interrupt_disable(ipa, IPA_IRQ_TX_SUSPEND); 252 252 } 253 253
+5 -5
drivers/net/ipa/ipa_qmi.c
··· 96 96 IPA_QMI_INIT_COMPLETE_IND_SZ, 97 97 ipa_init_complete_ind_ei, &ind); 98 98 if (ret) 99 - dev_err(&ipa->pdev->dev, 99 + dev_err(ipa->dev, 100 100 "error %d sending init complete indication\n", ret); 101 101 else 102 102 ipa_qmi->indication_sent = true; ··· 148 148 ipa = container_of(ipa_qmi, struct ipa, qmi); 149 149 ret = ipa_modem_start(ipa); 150 150 if (ret) 151 - dev_err(&ipa->pdev->dev, "error %d starting modem\n", ret); 151 + dev_err(ipa->dev, "error %d starting modem\n", ret); 152 152 } 153 153 154 154 /* All QMI clients from the modem node are gone (modem shut down or crashed). */ ··· 199 199 ipa_qmi->indication_requested = true; 200 200 ipa_qmi_ready(ipa_qmi); /* We might be ready now */ 201 201 } else { 202 - dev_err(&ipa->pdev->dev, 202 + dev_err(ipa->dev, 203 203 "error %d sending register indication response\n", ret); 204 204 } 205 205 } ··· 228 228 ipa_qmi->uc_ready = true; 229 229 ipa_qmi_ready(ipa_qmi); /* We might be ready now */ 230 230 } else { 231 - dev_err(&ipa->pdev->dev, 231 + dev_err(ipa->dev, 232 232 "error %d sending init complete response\n", ret); 233 233 } 234 234 } ··· 417 417 qmi = &ipa_qmi->client_handle; 418 418 419 419 ipa = container_of(ipa_qmi, struct ipa, qmi); 420 - dev = &ipa->pdev->dev; 420 + dev = ipa->dev; 421 421 422 422 ret = qmi_txn_init(qmi, &txn, NULL, NULL); 423 423 if (ret < 0) {
+4 -4
drivers/net/ipa/ipa_reg.c
··· 4 4 * Copyright (C) 2019-2023 Linaro Ltd. 5 5 */ 6 6 7 + #include <linux/platform_device.h> 7 8 #include <linux/io.h> 8 9 9 10 #include "ipa.h" ··· 133 132 } 134 133 } 135 134 136 - int ipa_reg_init(struct ipa *ipa) 135 + int ipa_reg_init(struct ipa *ipa, struct platform_device *pdev) 137 136 { 138 - struct device *dev = &ipa->pdev->dev; 137 + struct device *dev = &pdev->dev; 139 138 const struct regs *regs; 140 139 struct resource *res; 141 140 ··· 147 146 return -EINVAL; 148 147 149 148 /* Setup IPA register memory */ 150 - res = platform_get_resource_byname(ipa->pdev, IORESOURCE_MEM, 151 - "ipa-reg"); 149 + res = platform_get_resource_byname(pdev, IORESOURCE_MEM, "ipa-reg"); 152 150 if (!res) { 153 151 dev_err(dev, "DT error getting \"ipa-reg\" memory property\n"); 154 152 return -ENODEV;
+3 -1
drivers/net/ipa/ipa_reg.h
··· 12 12 #include "ipa_version.h" 13 13 #include "reg.h" 14 14 15 + struct platform_device; 16 + 15 17 struct ipa; 16 18 17 19 /** ··· 645 643 646 644 const struct reg *ipa_reg(struct ipa *ipa, enum ipa_reg_id reg_id); 647 645 648 - int ipa_reg_init(struct ipa *ipa); 646 + int ipa_reg_init(struct ipa *ipa, struct platform_device *pdev); 649 647 void ipa_reg_exit(struct ipa *ipa); 650 648 651 649 #endif /* _IPA_REG_H_ */
+17 -16
drivers/net/ipa/ipa_smp2p.c
··· 5 5 */ 6 6 7 7 #include <linux/types.h> 8 - #include <linux/device.h> 8 + #include <linux/platform_device.h> 9 9 #include <linux/interrupt.h> 10 10 #include <linux/notifier.h> 11 11 #include <linux/panic_notifier.h> ··· 84 84 */ 85 85 static void ipa_smp2p_notify(struct ipa_smp2p *smp2p) 86 86 { 87 - struct device *dev; 88 87 u32 value; 89 88 u32 mask; 90 89 91 90 if (smp2p->notified) 92 91 return; 93 92 94 - dev = &smp2p->ipa->pdev->dev; 95 - smp2p->power_on = pm_runtime_get_if_active(dev, true) > 0; 93 + smp2p->power_on = pm_runtime_get_if_active(smp2p->ipa->dev, true) > 0; 96 94 97 95 /* Signal whether the IPA power is enabled */ 98 96 mask = BIT(smp2p->enabled_bit); ··· 150 152 static irqreturn_t ipa_smp2p_modem_setup_ready_isr(int irq, void *dev_id) 151 153 { 152 154 struct ipa_smp2p *smp2p = dev_id; 155 + struct ipa *ipa = smp2p->ipa; 153 156 struct device *dev; 154 157 int ret; 155 158 156 159 /* Ignore any (spurious) interrupts received after the first */ 157 - if (smp2p->ipa->setup_complete) 160 + if (ipa->setup_complete) 158 161 return IRQ_HANDLED; 159 162 160 163 /* Power needs to be active for setup */ 161 - dev = &smp2p->ipa->pdev->dev; 164 + dev = ipa->dev; 162 165 ret = pm_runtime_get_sync(dev); 163 166 if (ret < 0) { 164 167 dev_err(dev, "error %d getting power for setup\n", ret); ··· 167 168 } 168 169 169 170 /* An error here won't cause driver shutdown, so warn if one occurs */ 170 - ret = ipa_setup(smp2p->ipa); 171 + ret = ipa_setup(ipa); 171 172 WARN(ret != 0, "error %d from ipa_setup()\n", ret); 172 173 173 174 out_power_put: ··· 178 179 } 179 180 180 181 /* Initialize SMP2P interrupts */ 181 - static int ipa_smp2p_irq_init(struct ipa_smp2p *smp2p, const char *name, 182 - irq_handler_t handler) 182 + static int ipa_smp2p_irq_init(struct ipa_smp2p *smp2p, 183 + struct platform_device *pdev, 184 + const char *name, irq_handler_t handler) 183 185 { 184 - struct device *dev = &smp2p->ipa->pdev->dev; 186 + struct device *dev = &pdev->dev; 185 187 unsigned int irq; 186 188 int ret; 187 189 188 - ret = platform_get_irq_byname(smp2p->ipa->pdev, name); 190 + ret = platform_get_irq_byname(pdev, name); 189 191 if (ret <= 0) 190 192 return ret ? : -EINVAL; 191 193 irq = ret; ··· 208 208 /* Drop the power reference if it was taken in ipa_smp2p_notify() */ 209 209 static void ipa_smp2p_power_release(struct ipa *ipa) 210 210 { 211 - struct device *dev = &ipa->pdev->dev; 211 + struct device *dev = ipa->dev; 212 212 213 213 if (!ipa->smp2p->power_on) 214 214 return; ··· 219 219 } 220 220 221 221 /* Initialize the IPA SMP2P subsystem */ 222 - int ipa_smp2p_init(struct ipa *ipa, bool modem_init) 222 + int 223 + ipa_smp2p_init(struct ipa *ipa, struct platform_device *pdev, bool modem_init) 223 224 { 224 225 struct qcom_smem_state *enabled_state; 225 - struct device *dev = &ipa->pdev->dev; 226 + struct device *dev = &pdev->dev; 226 227 struct qcom_smem_state *valid_state; 227 228 struct ipa_smp2p *smp2p; 228 229 u32 enabled_bit; ··· 262 261 /* We have enough information saved to handle notifications */ 263 262 ipa->smp2p = smp2p; 264 263 265 - ret = ipa_smp2p_irq_init(smp2p, "ipa-clock-query", 264 + ret = ipa_smp2p_irq_init(smp2p, pdev, "ipa-clock-query", 266 265 ipa_smp2p_modem_clk_query_isr); 267 266 if (ret < 0) 268 267 goto err_null_smp2p; ··· 274 273 275 274 if (modem_init) { 276 275 /* Result will be non-zero (negative for error) */ 277 - ret = ipa_smp2p_irq_init(smp2p, "ipa-setup-ready", 276 + ret = ipa_smp2p_irq_init(smp2p, pdev, "ipa-setup-ready", 278 277 ipa_smp2p_modem_setup_ready_isr); 279 278 if (ret < 0) 280 279 goto err_notifier_unregister;
+5 -2
drivers/net/ipa/ipa_smp2p.h
··· 8 8 9 9 #include <linux/types.h> 10 10 11 + struct platform_device; 12 + 11 13 struct ipa; 12 14 13 15 /** 14 16 * ipa_smp2p_init() - Initialize the IPA SMP2P subsystem 15 17 * @ipa: IPA pointer 18 + * @pdev: Platform device pointer 16 19 * @modem_init: Whether the modem is responsible for GSI initialization 17 20 * 18 21 * Return: 0 if successful, or a negative error code 19 - * 20 22 */ 21 - int ipa_smp2p_init(struct ipa *ipa, bool modem_init); 23 + int ipa_smp2p_init(struct ipa *ipa, struct platform_device *pdev, 24 + bool modem_init); 22 25 23 26 /** 24 27 * ipa_smp2p_exit() - Inverse of ipa_smp2p_init()
+8 -10
drivers/net/ipa/ipa_table.c
··· 163 163 164 164 bool ipa_filtered_valid(struct ipa *ipa, u64 filtered) 165 165 { 166 - struct device *dev = &ipa->pdev->dev; 166 + struct device *dev = ipa->dev; 167 167 u32 count; 168 168 169 169 if (!filtered) { ··· 236 236 237 237 trans = ipa_cmd_trans_alloc(ipa, hweight64(ep_mask)); 238 238 if (!trans) { 239 - dev_err(&ipa->pdev->dev, 240 - "no transaction for %s filter reset\n", 239 + dev_err(ipa->dev, "no transaction for %s filter reset\n", 241 240 modem ? "modem" : "AP"); 242 241 return -EBUSY; 243 242 } ··· 297 298 298 299 trans = ipa_cmd_trans_alloc(ipa, hash_support ? 4 : 2); 299 300 if (!trans) { 300 - dev_err(&ipa->pdev->dev, 301 - "no transaction for %s route reset\n", 301 + dev_err(ipa->dev, "no transaction for %s route reset\n", 302 302 modem ? "modem" : "AP"); 303 303 return -EBUSY; 304 304 } ··· 325 327 326 328 void ipa_table_reset(struct ipa *ipa, bool modem) 327 329 { 328 - struct device *dev = &ipa->pdev->dev; 330 + struct device *dev = ipa->dev; 329 331 const char *ee_name; 330 332 int ret; 331 333 ··· 354 356 355 357 trans = ipa_cmd_trans_alloc(ipa, 1); 356 358 if (!trans) { 357 - dev_err(&ipa->pdev->dev, "no transaction for hash flush\n"); 359 + dev_err(ipa->dev, "no transaction for hash flush\n"); 358 360 return -EBUSY; 359 361 } 360 362 ··· 467 469 */ 468 470 trans = ipa_cmd_trans_alloc(ipa, 8); 469 471 if (!trans) { 470 - dev_err(&ipa->pdev->dev, "no transaction for table setup\n"); 472 + dev_err(ipa->dev, "no transaction for table setup\n"); 471 473 return -EBUSY; 472 474 } 473 475 ··· 711 713 */ 712 714 int ipa_table_init(struct ipa *ipa) 713 715 { 714 - struct device *dev = &ipa->pdev->dev; 716 + struct device *dev = ipa->dev; 715 717 dma_addr_t addr; 716 718 __le64 le_addr; 717 719 __le64 *virt; ··· 761 763 void ipa_table_exit(struct ipa *ipa) 762 764 { 763 765 u32 count = max_t(u32, 1 + ipa->filter_count, ipa->route_count); 764 - struct device *dev = &ipa->pdev->dev; 766 + struct device *dev = ipa->dev; 765 767 size_t size; 766 768 767 769 size = IPA_ZERO_RULE_SIZE + (1 + count) * sizeof(__le64);
+4 -5
drivers/net/ipa/ipa_uc.c
··· 127 127 static void ipa_uc_event_handler(struct ipa *ipa) 128 128 { 129 129 struct ipa_uc_mem_area *shared = ipa_uc_shared(ipa); 130 - struct device *dev = &ipa->pdev->dev; 130 + struct device *dev = ipa->dev; 131 131 132 132 if (shared->event == IPA_UC_EVENT_ERROR) 133 133 dev_err(dev, "microcontroller error event\n"); ··· 141 141 static void ipa_uc_response_hdlr(struct ipa *ipa) 142 142 { 143 143 struct ipa_uc_mem_area *shared = ipa_uc_shared(ipa); 144 - struct device *dev = &ipa->pdev->dev; 144 + struct device *dev = ipa->dev; 145 145 146 146 /* An INIT_COMPLETED response message is sent to the AP by the 147 147 * microcontroller when it is operational. Other than this, the AP ··· 191 191 /* Inverse of ipa_uc_config() */ 192 192 void ipa_uc_deconfig(struct ipa *ipa) 193 193 { 194 - struct device *dev = &ipa->pdev->dev; 194 + struct device *dev = ipa->dev; 195 195 196 196 ipa_interrupt_disable(ipa, IPA_IRQ_UC_1); 197 197 ipa_interrupt_disable(ipa, IPA_IRQ_UC_0); ··· 208 208 /* Take a proxy power reference for the microcontroller */ 209 209 void ipa_uc_power(struct ipa *ipa) 210 210 { 211 + struct device *dev = ipa->dev; 211 212 static bool already; 212 - struct device *dev; 213 213 int ret; 214 214 215 215 if (already) ··· 217 217 already = true; /* Only do this on first boot */ 218 218 219 219 /* This power reference dropped in ipa_uc_response_hdlr() above */ 220 - dev = &ipa->pdev->dev; 221 220 ret = pm_runtime_get_sync(dev); 222 221 if (ret < 0) { 223 222 pm_runtime_put_noidle(dev);