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

[media] c8sectpfe: Rework firmware loading mechanism

c8sectpfe driver relied on CONFIG_FW_LOADER_USER_HELPER_FALLBACK option
for loading its xp70 firmware. A previous commit removed this Kconfig
option, as it is apparently harmful, but did not update the driver
code which relied on it.

This patch reworks the firmware loading into the start_feed callback.
At this point we can be sure the rootfs is present, thereby removing
the depedency on CONFIG_FW_LOADER_USER_HELPER_FALLBACK.

Fixes: 79f5b6ae960d ('[media] c8sectpfe: Remove select on CONFIG_FW_LOADER_USER_HELPER_FALLBACK')

Signed-off-by: Peter Griffin <peter.griffin@linaro.org>
Signed-off-by: Mauro Carvalho Chehab <mchehab@osg.samsung.com>

authored by

Peter Griffin and committed by
Mauro Carvalho Chehab
c23ac90f ee105cac

+22 -43
+22 -43
drivers/media/platform/sti/c8sectpfe/c8sectpfe-core.c
··· 49 49 #define PID_TABLE_SIZE 1024 50 50 #define POLL_MSECS 50 51 51 52 - static int load_c8sectpfe_fw_step1(struct c8sectpfei *fei); 52 + static int load_c8sectpfe_fw(struct c8sectpfei *fei); 53 53 54 54 #define TS_PKT_SIZE 188 55 55 #define HEADER_SIZE (4) ··· 141 141 struct channel_info *channel; 142 142 u32 tmp; 143 143 unsigned long *bitmap; 144 + int ret; 144 145 145 146 switch (dvbdmxfeed->type) { 146 147 case DMX_TYPE_TS: ··· 170 169 } 171 170 172 171 if (!atomic_read(&fei->fw_loaded)) { 173 - dev_err(fei->dev, "%s: c8sectpfe fw not loaded\n", __func__); 174 - return -EINVAL; 172 + ret = load_c8sectpfe_fw(fei); 173 + if (ret) 174 + return ret; 175 175 } 176 176 177 177 mutex_lock(&fei->lock); ··· 267 265 unsigned long *bitmap; 268 266 269 267 if (!atomic_read(&fei->fw_loaded)) { 270 - dev_err(fei->dev, "%s: c8sectpfe fw not loaded\n", __func__); 271 - return -EINVAL; 268 + ret = load_c8sectpfe_fw(fei); 269 + if (ret) 270 + return ret; 272 271 } 273 272 274 273 mutex_lock(&fei->lock); ··· 883 880 goto err_clk_disable; 884 881 } 885 882 886 - /* ensure all other init has been done before requesting firmware */ 887 - ret = load_c8sectpfe_fw_step1(fei); 888 - if (ret) { 889 - dev_err(dev, "Couldn't load slim core firmware\n"); 890 - goto err_clk_disable; 891 - } 892 - 893 883 c8sectpfe_debugfs_init(fei); 894 884 895 885 return 0; ··· 1087 1091 phdr->p_memsz - phdr->p_filesz); 1088 1092 } 1089 1093 1090 - static int load_slim_core_fw(const struct firmware *fw, void *context) 1094 + static int load_slim_core_fw(const struct firmware *fw, struct c8sectpfei *fei) 1091 1095 { 1092 - struct c8sectpfei *fei = context; 1093 1096 Elf32_Ehdr *ehdr; 1094 1097 Elf32_Phdr *phdr; 1095 1098 u8 __iomem *dst; 1096 1099 int err = 0, i; 1097 1100 1098 - if (!fw || !context) 1101 + if (!fw || !fei) 1099 1102 return -EINVAL; 1100 1103 1101 1104 ehdr = (Elf32_Ehdr *)fw->data; ··· 1146 1151 return err; 1147 1152 } 1148 1153 1149 - static void load_c8sectpfe_fw_cb(const struct firmware *fw, void *context) 1154 + static int load_c8sectpfe_fw(struct c8sectpfei *fei) 1150 1155 { 1151 - struct c8sectpfei *fei = context; 1156 + const struct firmware *fw; 1152 1157 int err; 1158 + 1159 + dev_info(fei->dev, "Loading firmware: %s\n", FIRMWARE_MEMDMA); 1160 + 1161 + err = request_firmware(&fw, FIRMWARE_MEMDMA, fei->dev); 1162 + if (err) 1163 + return err; 1153 1164 1154 1165 err = c8sectpfe_elf_sanity_check(fei, fw); 1155 1166 if (err) { 1156 1167 dev_err(fei->dev, "c8sectpfe_elf_sanity_check failed err=(%d)\n" 1157 1168 , err); 1158 - goto err; 1169 + return err; 1159 1170 } 1160 1171 1161 - err = load_slim_core_fw(fw, context); 1172 + err = load_slim_core_fw(fw, fei); 1162 1173 if (err) { 1163 1174 dev_err(fei->dev, "load_slim_core_fw failed err=(%d)\n", err); 1164 - goto err; 1175 + return err; 1165 1176 } 1166 1177 1167 1178 /* now the firmware is loaded configure the input blocks */ 1168 1179 err = configure_channels(fei); 1169 1180 if (err) { 1170 1181 dev_err(fei->dev, "configure_channels failed err=(%d)\n", err); 1171 - goto err; 1182 + return err; 1172 1183 } 1173 1184 1174 1185 /* ··· 1187 1186 writel(0x1, fei->io + DMA_CPU_RUN); 1188 1187 1189 1188 atomic_set(&fei->fw_loaded, 1); 1190 - err: 1191 - complete_all(&fei->fw_ack); 1192 - } 1193 - 1194 - static int load_c8sectpfe_fw_step1(struct c8sectpfei *fei) 1195 - { 1196 - int err; 1197 - 1198 - dev_info(fei->dev, "Loading firmware: %s\n", FIRMWARE_MEMDMA); 1199 - 1200 - init_completion(&fei->fw_ack); 1201 - atomic_set(&fei->fw_loaded, 0); 1202 - 1203 - err = request_firmware_nowait(THIS_MODULE, FW_ACTION_HOTPLUG, 1204 - FIRMWARE_MEMDMA, fei->dev, GFP_KERNEL, fei, 1205 - load_c8sectpfe_fw_cb); 1206 - 1207 - if (err) { 1208 - dev_err(fei->dev, "request_firmware_nowait err: %d.\n", err); 1209 - complete_all(&fei->fw_ack); 1210 - return err; 1211 - } 1212 1189 1213 1190 return 0; 1214 1191 }