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

net: ipa: get rid of empty IPA functions

There are place holder functions in the IPA code that do nothing.
For the most part these are inverse functions, for example, once the
routing or filter tables are set up there is no need to perform any
matching teardown activity at shutdown, or in the case of an error.

These can be safely removed, resulting in some code simplification.
Add comments in these spots making it explicit that there is no
inverse.

Signed-off-by: Alex Elder <elder@linaro.org>
Signed-off-by: Jakub Kicinski <kuba@kernel.org>

authored by

Alex Elder and committed by
Jakub Kicinski
74858b63 077e770f

+24 -77
+9 -20
drivers/net/ipa/ipa_main.c
··· 147 147 if (ret) 148 148 goto err_endpoint_teardown; 149 149 150 - ret = ipa_mem_setup(ipa); 150 + ret = ipa_mem_setup(ipa); /* No matching teardown required */ 151 151 if (ret) 152 152 goto err_command_disable; 153 153 154 - ret = ipa_table_setup(ipa); 154 + ret = ipa_table_setup(ipa); /* No matching teardown required */ 155 155 if (ret) 156 - goto err_mem_teardown; 156 + goto err_command_disable; 157 157 158 158 /* Enable the exception handling endpoint, and tell the hardware 159 159 * to use it by default. ··· 161 161 exception_endpoint = ipa->name_map[IPA_ENDPOINT_AP_LAN_RX]; 162 162 ret = ipa_endpoint_enable_one(exception_endpoint); 163 163 if (ret) 164 - goto err_table_teardown; 164 + goto err_command_disable; 165 165 166 166 ipa_endpoint_default_route_set(ipa, exception_endpoint->endpoint_id); 167 167 ··· 179 179 err_default_route_clear: 180 180 ipa_endpoint_default_route_clear(ipa); 181 181 ipa_endpoint_disable_one(exception_endpoint); 182 - err_table_teardown: 183 - ipa_table_teardown(ipa); 184 - err_mem_teardown: 185 - ipa_mem_teardown(ipa); 186 182 err_command_disable: 187 183 ipa_endpoint_disable_one(command_endpoint); 188 184 err_endpoint_teardown: ··· 207 211 ipa_endpoint_default_route_clear(ipa); 208 212 exception_endpoint = ipa->name_map[IPA_ENDPOINT_AP_LAN_RX]; 209 213 ipa_endpoint_disable_one(exception_endpoint); 210 - ipa_table_teardown(ipa); 211 - ipa_mem_teardown(ipa); 212 214 command_endpoint = ipa->name_map[IPA_ENDPOINT_AP_COMMAND_TX]; 213 215 ipa_endpoint_disable_one(command_endpoint); 214 216 ipa_endpoint_teardown(ipa); ··· 474 480 if (ret) 475 481 goto err_endpoint_deconfig; 476 482 477 - ipa_table_config(ipa); 483 + ipa_table_config(ipa); /* No deconfig required */ 478 484 479 - /* Assign resource limitation to each group */ 485 + /* Assign resource limitation to each group; no deconfig required */ 480 486 ret = ipa_resource_config(ipa, data->resource_data); 481 487 if (ret) 482 - goto err_table_deconfig; 488 + goto err_mem_deconfig; 483 489 484 490 ret = ipa_modem_config(ipa); 485 491 if (ret) 486 - goto err_resource_deconfig; 492 + goto err_mem_deconfig; 487 493 488 494 return 0; 489 495 490 - err_resource_deconfig: 491 - ipa_resource_deconfig(ipa); 492 - err_table_deconfig: 493 - ipa_table_deconfig(ipa); 496 + err_mem_deconfig: 494 497 ipa_mem_deconfig(ipa); 495 498 err_endpoint_deconfig: 496 499 ipa_endpoint_deconfig(ipa); ··· 505 514 static void ipa_deconfig(struct ipa *ipa) 506 515 { 507 516 ipa_modem_deconfig(ipa); 508 - ipa_resource_deconfig(ipa); 509 - ipa_table_deconfig(ipa); 510 517 ipa_mem_deconfig(ipa); 511 518 ipa_endpoint_deconfig(ipa); 512 519 ipa_hardware_deconfig(ipa);
+3 -6
drivers/net/ipa/ipa_mem.c
··· 1 1 // SPDX-License-Identifier: GPL-2.0 2 2 3 3 /* Copyright (c) 2012-2018, The Linux Foundation. All rights reserved. 4 - * Copyright (C) 2019-2020 Linaro Ltd. 4 + * Copyright (C) 2019-2021 Linaro Ltd. 5 5 */ 6 6 7 7 #include <linux/types.h> ··· 53 53 * The AP informs the modem where its portions of memory are located 54 54 * in a QMI exchange that occurs at modem startup. 55 55 * 56 + * There is no need for a matching ipa_mem_teardown() function. 57 + * 56 58 * Return: 0 if successful, or a negative error code 57 59 */ 58 60 int ipa_mem_setup(struct ipa *ipa) ··· 97 95 iowrite32(val, ipa->reg_virt + IPA_REG_LOCAL_PKT_PROC_CNTXT_OFFSET); 98 96 99 97 return 0; 100 - } 101 - 102 - void ipa_mem_teardown(struct ipa *ipa) 103 - { 104 - /* Nothing to do */ 105 98 } 106 99 107 100 #ifdef IPA_VALIDATE
+2 -3
drivers/net/ipa/ipa_mem.h
··· 1 1 /* SPDX-License-Identifier: GPL-2.0 */ 2 2 3 3 /* Copyright (c) 2012-2018, The Linux Foundation. All rights reserved. 4 - * Copyright (C) 2019-2020 Linaro Ltd. 4 + * Copyright (C) 2019-2021 Linaro Ltd. 5 5 */ 6 6 #ifndef _IPA_MEM_H_ 7 7 #define _IPA_MEM_H_ ··· 88 88 int ipa_mem_config(struct ipa *ipa); 89 89 void ipa_mem_deconfig(struct ipa *ipa); 90 90 91 - int ipa_mem_setup(struct ipa *ipa); 92 - void ipa_mem_teardown(struct ipa *ipa); 91 + int ipa_mem_setup(struct ipa *ipa); /* No ipa_mem_teardown() needed */ 93 92 94 93 int ipa_mem_zero_modem(struct ipa *ipa); 95 94
+1 -7
drivers/net/ipa/ipa_resource.c
··· 158 158 ipa_resource_config_common(ipa, offset, &resource->limits[6], ylimits); 159 159 } 160 160 161 - /* Configure resources */ 161 + /* Configure resources; there is no ipa_resource_deconfig() */ 162 162 int ipa_resource_config(struct ipa *ipa, const struct ipa_resource_data *data) 163 163 { 164 164 u32 i; ··· 173 173 ipa_resource_config_dst(ipa, i, data); 174 174 175 175 return 0; 176 - } 177 - 178 - /* Inverse of ipa_resource_config() */ 179 - void ipa_resource_deconfig(struct ipa *ipa) 180 - { 181 - /* Nothing to do */ 182 176 }
+2 -6
drivers/net/ipa/ipa_resource.h
··· 14 14 * @ipa: IPA pointer 15 15 * @data: IPA resource configuration data 16 16 * 17 + * There is no need for a matching ipa_resource_deconfig() function. 18 + * 17 19 * Return: true if all regions are valid, false otherwise 18 20 */ 19 21 int ipa_resource_config(struct ipa *ipa, const struct ipa_resource_data *data); 20 - 21 - /** 22 - * ipa_resource_deconfig() - Inverse of ipa_resource_config() 23 - * @ipa: IPA pointer 24 - */ 25 - void ipa_resource_deconfig(struct ipa *ipa); 26 22 27 23 #endif /* _IPA_RESOURCE_H_ */
+3 -23
drivers/net/ipa/ipa_table.c
··· 497 497 return 0; 498 498 } 499 499 500 - void ipa_table_teardown(struct ipa *ipa) 501 - { 502 - /* Nothing to do */ /* XXX Maybe reset the tables? */ 503 - } 504 - 505 500 /** 506 501 * ipa_filter_tuple_zero() - Zero an endpoint's hashed filter tuple 507 502 * @endpoint: Endpoint whose filter hash tuple should be zeroed ··· 520 525 iowrite32(val, endpoint->ipa->reg_virt + offset); 521 526 } 522 527 528 + /* Configure a hashed filter table; there is no ipa_filter_deconfig() */ 523 529 static void ipa_filter_config(struct ipa *ipa, bool modem) 524 530 { 525 531 enum gsi_ee_id ee_id = modem ? GSI_EE_MODEM : GSI_EE_AP; ··· 539 543 if (endpoint->ee_id == ee_id) 540 544 ipa_filter_tuple_zero(endpoint); 541 545 } 542 - } 543 - 544 - static void ipa_filter_deconfig(struct ipa *ipa, bool modem) 545 - { 546 - /* Nothing to do */ 547 546 } 548 547 549 548 static bool ipa_route_id_modem(u32 route_id) ··· 567 576 iowrite32(val, ipa->reg_virt + offset); 568 577 } 569 578 579 + /* Configure a hashed route table; there is no ipa_route_deconfig() */ 570 580 static void ipa_route_config(struct ipa *ipa, bool modem) 571 581 { 572 582 u32 route_id; ··· 580 588 ipa_route_tuple_zero(ipa, route_id); 581 589 } 582 590 583 - static void ipa_route_deconfig(struct ipa *ipa, bool modem) 584 - { 585 - /* Nothing to do */ 586 - } 587 - 591 + /* Configure a filter and route tables; there is no ipa_table_deconfig() */ 588 592 void ipa_table_config(struct ipa *ipa) 589 593 { 590 594 ipa_filter_config(ipa, false); 591 595 ipa_filter_config(ipa, true); 592 596 ipa_route_config(ipa, false); 593 597 ipa_route_config(ipa, true); 594 - } 595 - 596 - void ipa_table_deconfig(struct ipa *ipa) 597 - { 598 - ipa_route_deconfig(ipa, true); 599 - ipa_route_deconfig(ipa, false); 600 - ipa_filter_deconfig(ipa, true); 601 - ipa_filter_deconfig(ipa, false); 602 598 } 603 599 604 600 /*
+4 -12
drivers/net/ipa/ipa_table.h
··· 74 74 /** 75 75 * ipa_table_setup() - Set up filter and route tables 76 76 * @ipa: IPA pointer 77 + * 78 + * There is no need for a matching ipa_table_teardown() function. 77 79 */ 78 80 int ipa_table_setup(struct ipa *ipa); 79 81 80 82 /** 81 - * ipa_table_teardown() - Inverse of ipa_table_setup() 82 - * @ipa: IPA pointer 83 - */ 84 - void ipa_table_teardown(struct ipa *ipa); 85 - 86 - /** 87 83 * ipa_table_config() - Configure filter and route tables 88 84 * @ipa: IPA pointer 85 + * 86 + * There is no need for a matching ipa_table_deconfig() function. 89 87 */ 90 88 void ipa_table_config(struct ipa *ipa); 91 - 92 - /** 93 - * ipa_table_deconfig() - Inverse of ipa_table_config() 94 - * @ipa: IPA pointer 95 - */ 96 - void ipa_table_deconfig(struct ipa *ipa); 97 89 98 90 /** 99 91 * ipa_table_init() - Do early initialization of filter and route tables