Commit fa6e1cb66e2f9d2d4703e7bd7dd50839bb10e4c3

Authored by David Woodhouse
Committed by David Woodhouse
1 parent c63e87e90a

maestro3: treat firmware data as const

The maestro3 driver is byte-swapping its firmware to be host-endian in
advance, when it doesn't seem to be necessary -- we could just use
le16_to_cpu() as we load it.

Doing that means that we need to switch the in-tree firmware to be
little-endian too.

Take the least intrusive way of doing this, which is to switch the
existing snd_m3_convert_from_le() function to convert _to_ little-endian
instead, and use it on the in-tree firmware instead of the loaded
firmware. It's a bit suboptimal but doesn't matter much right now
because we're about to remove the special cases for the in-tree version
anyway.

Signed-off-by: David Woodhouse <dwmw2@infradead.org>

Showing 1 changed file with 15 additions and 14 deletions Side-by-side Diff

sound/pci/maestro3.c
... ... @@ -2240,18 +2240,16 @@
2240 2240 .size = sizeof assp_minisrc_image
2241 2241 };
2242 2242  
2243   -#else /* CONFIG_SND_MAESTRO3_FIRMWARE_IN_KERNEL */
2244   -
2245 2243 #ifdef __LITTLE_ENDIAN
2246   -static inline void snd_m3_convert_from_le(const struct firmware *fw) { }
  2244 +static inline void snd_m3_convert_to_le(const struct firmware *fw) { }
2247 2245 #else
2248   -static void snd_m3_convert_from_le(const struct firmware *fw)
  2246 +static void snd_m3_convert_to_le(const struct firmware *fw)
2249 2247 {
2250 2248 int i;
2251 2249 u16 *data = (u16 *)fw->data;
2252 2250  
2253 2251 for (i = 0; i < fw->size / 2; ++i)
2254   - le16_to_cpus(&data[i]);
  2252 + cpu_to_le16s(&data[i]);
2255 2253 }
2256 2254 #endif
2257 2255  
... ... @@ -2271,7 +2269,7 @@
2271 2269 static void snd_m3_assp_init(struct snd_m3 *chip)
2272 2270 {
2273 2271 unsigned int i;
2274   - u16 *data;
  2272 + const u16 *data;
2275 2273  
2276 2274 /* zero kernel data */
2277 2275 for (i = 0; i < (REV_B_DATA_MEMORY_UNIT_LENGTH * NUM_UNITS_KERNEL_DATA) / 2; i++)
2278 2276  
... ... @@ -2289,10 +2287,11 @@
2289 2287 KDATA_DMA_XFER0);
2290 2288  
2291 2289 /* write kernel into code memory.. */
2292   - data = (u16 *)chip->assp_kernel_image->data;
  2290 + data = (const u16 *)chip->assp_kernel_image->data;
2293 2291 for (i = 0 ; i * 2 < chip->assp_kernel_image->size; i++) {
2294 2292 snd_m3_assp_write(chip, MEMTYPE_INTERNAL_CODE,
2295   - REV_B_CODE_MEMORY_BEGIN + i, data[i]);
  2293 + REV_B_CODE_MEMORY_BEGIN + i,
  2294 + le16_to_cpu(data[i]));
2296 2295 }
2297 2296  
2298 2297 /*
2299 2298  
... ... @@ -2301,10 +2300,10 @@
2301 2300 * drop it there. It seems that the minisrc doesn't
2302 2301 * need vectors, so we won't bother with them..
2303 2302 */
2304   - data = (u16 *)chip->assp_minisrc_image->data;
  2303 + data = (const u16 *)chip->assp_minisrc_image->data;
2305 2304 for (i = 0; i * 2 < chip->assp_minisrc_image->size; i++) {
2306 2305 snd_m3_assp_write(chip, MEMTYPE_INTERNAL_CODE,
2307   - 0x400 + i, data[i]);
  2306 + 0x400 + i, le16_to_cpu(data[i]));
2308 2307 }
2309 2308  
2310 2309 /*
... ... @@ -2749,8 +2748,7 @@
2749 2748 if (err < 0) {
2750 2749 snd_m3_free(chip);
2751 2750 return err;
2752   - } else
2753   - snd_m3_convert_from_le(chip->assp_kernel_image);
  2751 + }
2754 2752 #endif
2755 2753  
2756 2754 #ifdef CONFIG_SND_MAESTRO3_FIRMWARE_IN_KERNEL
... ... @@ -2761,8 +2759,7 @@
2761 2759 if (err < 0) {
2762 2760 snd_m3_free(chip);
2763 2761 return err;
2764   - } else
2765   - snd_m3_convert_from_le(chip->assp_minisrc_image);
  2762 + }
2766 2763 #endif
2767 2764  
2768 2765 if ((err = pci_request_regions(pci, card->driver)) < 0) {
... ... @@ -2915,6 +2912,10 @@
2915 2912  
2916 2913 static int __init alsa_card_m3_init(void)
2917 2914 {
  2915 +#ifdef CONFIG_SND_MAESTRO3_FIRMWARE_IN_KERNEL
  2916 + snd_m3_convert_to_le(&assp_kernel);
  2917 + snd_m3_convert_to_le(&assp_minisrc);
  2918 +#endif
2918 2919 return pci_register_driver(&driver);
2919 2920 }
2920 2921