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.

i3c: dw: Simplify xfer cleanup with __free(kfree)

Convert dw-i3c-master to use __free(kfree) guards for struct dw_i3c_xfer
allocations. This frees xfer objects automatically on scope exit, and
removes the now-unused dw_i3c_master_free_xfer() helper.

Signed-off-by: Felix Gu <ustc.gu@gmail.com>
Reviewed-by: Frank Li <Frank.Li@nxp.com>
Link: https://patch.msgid.link/20260404-dw-i3c-2-v3-2-8f7d146549c1@gmail.com
Signed-off-by: Alexandre Belloni <alexandre.belloni@bootlin.com>

authored by

Felix Gu and committed by
Alexandre Belloni
6105f491 256cc1f1

+7 -26
+7 -26
drivers/i3c/master/dw-i3c-master.c
··· 394 394 return xfer; 395 395 } 396 396 397 - static void dw_i3c_master_free_xfer(struct dw_i3c_xfer *xfer) 398 - { 399 - kfree(xfer); 400 - } 401 - 402 397 static void dw_i3c_master_start_xfer_locked(struct dw_i3c_master *master) 403 398 { 404 399 struct dw_i3c_xfer *xfer = master->xferqueue.cur; ··· 711 716 static int dw_i3c_ccc_set(struct dw_i3c_master *master, 712 717 struct i3c_ccc_cmd *ccc) 713 718 { 714 - struct dw_i3c_xfer *xfer; 715 719 struct dw_i3c_cmd *cmd; 716 720 int ret, pos = 0; 717 721 ··· 720 726 return pos; 721 727 } 722 728 723 - xfer = dw_i3c_master_alloc_xfer(master, 1); 729 + struct dw_i3c_xfer *xfer __free(kfree) = dw_i3c_master_alloc_xfer(master, 1); 724 730 if (!xfer) 725 731 return -ENOMEM; 726 732 ··· 745 751 if (xfer->cmds[0].error == RESPONSE_ERROR_IBA_NACK) 746 752 ccc->err = I3C_ERROR_M2; 747 753 748 - dw_i3c_master_free_xfer(xfer); 749 - 750 754 return ret; 751 755 } 752 756 753 757 static int dw_i3c_ccc_get(struct dw_i3c_master *master, struct i3c_ccc_cmd *ccc) 754 758 { 755 - struct dw_i3c_xfer *xfer; 756 759 struct dw_i3c_cmd *cmd; 757 760 int ret, pos; 758 761 ··· 757 766 if (pos < 0) 758 767 return pos; 759 768 760 - xfer = dw_i3c_master_alloc_xfer(master, 1); 769 + struct dw_i3c_xfer *xfer __free(kfree) = dw_i3c_master_alloc_xfer(master, 1); 761 770 if (!xfer) 762 771 return -ENOMEM; 763 772 ··· 782 791 ret = xfer->ret; 783 792 if (xfer->cmds[0].error == RESPONSE_ERROR_IBA_NACK) 784 793 ccc->err = I3C_ERROR_M2; 785 - dw_i3c_master_free_xfer(xfer); 786 794 787 795 return ret; 788 796 } ··· 828 838 static int dw_i3c_master_daa(struct i3c_master_controller *m) 829 839 { 830 840 struct dw_i3c_master *master = to_dw_i3c_master(m); 831 - struct dw_i3c_xfer *xfer; 832 841 struct dw_i3c_cmd *cmd; 833 842 u32 olddevs, newdevs; 834 843 u8 last_addr = 0; 835 844 int ret, pos; 845 + 846 + struct dw_i3c_xfer *xfer __free(kfree) = dw_i3c_master_alloc_xfer(master, 1); 847 + if (!xfer) 848 + return -ENOMEM; 836 849 837 850 ret = pm_runtime_resume_and_get(master->dev); 838 851 if (ret < 0) { ··· 870 877 ret = 0; 871 878 } 872 879 873 - xfer = dw_i3c_master_alloc_xfer(master, 1); 874 - if (!xfer) { 875 - ret = -ENOMEM; 876 - goto rpm_out; 877 - } 878 - 879 880 pos = dw_i3c_master_get_free_pos(master); 880 881 if (pos < 0) { 881 - dw_i3c_master_free_xfer(xfer); 882 882 ret = pos; 883 883 goto rpm_out; 884 884 } ··· 895 909 if (newdevs & BIT(pos)) 896 910 i3c_master_add_i3c_dev_locked(m, master->devs[pos].addr); 897 911 } 898 - 899 - dw_i3c_master_free_xfer(xfer); 900 912 901 913 rpm_out: 902 914 pm_runtime_put_autosuspend(master->dev); ··· 1067 1083 struct i3c_master_controller *m = i2c_dev_get_master(dev); 1068 1084 struct dw_i3c_master *master = to_dw_i3c_master(m); 1069 1085 unsigned int nrxwords = 0, ntxwords = 0; 1070 - struct dw_i3c_xfer *xfer; 1071 1086 int i, ret = 0; 1072 1087 1073 1088 if (!i2c_nxfers) ··· 1086 1103 nrxwords > master->caps.datafifodepth) 1087 1104 return -EOPNOTSUPP; 1088 1105 1089 - xfer = dw_i3c_master_alloc_xfer(master, i2c_nxfers); 1106 + struct dw_i3c_xfer *xfer __free(kfree) = dw_i3c_master_alloc_xfer(master, i2c_nxfers); 1090 1107 if (!xfer) 1091 1108 return -ENOMEM; 1092 1109 ··· 1095 1112 dev_err(master->dev, 1096 1113 "<%s> cannot resume i3c bus master, err: %d\n", 1097 1114 __func__, ret); 1098 - dw_i3c_master_free_xfer(xfer); 1099 1115 return ret; 1100 1116 } 1101 1117 ··· 1126 1144 dw_i3c_master_dequeue_xfer(master, xfer); 1127 1145 1128 1146 ret = xfer->ret; 1129 - dw_i3c_master_free_xfer(xfer); 1130 1147 1131 1148 pm_runtime_put_autosuspend(master->dev); 1132 1149 return ret;