sound/usb/6fire/chip.c
Source file repositories/reference/linux-study-clean/sound/usb/6fire/chip.c
File Facts
- System
- Linux kernel
- Corpus path
sound/usb/6fire/chip.c- Extension
.c- Size
- 5107 bytes
- Lines
- 208
- Domain
- Driver Families
- Bucket
- sound/usb
- Inferred role
- Driver Families: implementation source
- Status
- source implementation candidate
Why This File Exists
Repeatable hardware-adapter layer. Deep compatibility for every driver is out of scope; this atlas records patterns, probe lifecycles, bus glue, IRQ/DMA usage, and links back to core abstractions.
- Repeatable hardware-adapter layer. Deep compatibility for every driver is out of scope; this atlas records patterns, probe lifecycles, bus glue, IRQ/DMA usage, and links back to core abstractions.
- Defines or uses C structs; map object ownership, embedded links, reference counts, and lock ownership.
Dependency Surface
chip.hfirmware.hpcm.hcontrol.hcomm.hmidi.hlinux/moduleparam.hlinux/interrupt.hlinux/module.hlinux/init.hlinux/gfp.hsound/initval.h
Detected Declarations
function usb6fire_chip_abortfunction usb6fire_card_freefunction usb6fire_chip_probefunction usb6fire_chip_disconnect
Annotated Snippet
if (chips[i] && chips[i]->dev == device) {
chips[i]->intf_count++;
usb_set_intfdata(intf, chips[i]);
return 0;
} else if (!chips[i] && regidx < 0)
regidx = i;
}
if (regidx < 0) {
dev_err(&intf->dev, "too many cards registered.\n");
return -ENODEV;
}
/* check, if firmware is present on device, upload it if not */
ret = usb6fire_fw_init(intf);
if (ret < 0)
return ret;
else if (ret == FW_NOT_READY) /* firmware update performed */
return 0;
/* if we are here, card can be registered in alsa. */
if (usb_set_interface(device, 0, 0) != 0) {
dev_err(&intf->dev, "can't set first interface.\n");
return -EIO;
}
ret = snd_card_new(&intf->dev, index[regidx], id[regidx],
THIS_MODULE, sizeof(struct sfire_chip), &card);
if (ret < 0) {
dev_err(&intf->dev, "cannot create alsa card.\n");
return ret;
}
strscpy(card->driver, "6FireUSB");
strscpy(card->shortname, "TerraTec DMX6FireUSB");
sprintf(card->longname, "%s at %d:%d", card->shortname,
device->bus->busnum, device->devnum);
chip = card->private_data;
chip->dev = device;
chip->regidx = regidx;
chip->intf_count = 1;
chip->card = card;
card->private_free = usb6fire_card_free;
ret = usb6fire_comm_init(chip);
if (ret < 0)
goto destroy_chip;
ret = usb6fire_midi_init(chip);
if (ret < 0)
goto destroy_chip;
ret = usb6fire_pcm_init(chip);
if (ret < 0)
goto destroy_chip;
ret = usb6fire_control_init(chip);
if (ret < 0)
goto destroy_chip;
ret = snd_card_register(card);
if (ret < 0) {
dev_err(&intf->dev, "cannot register card.");
goto destroy_chip;
}
usb_set_intfdata(intf, chip);
chips[regidx] = chip;
return 0;
destroy_chip:
snd_card_free(card);
return ret;
}
static void usb6fire_chip_disconnect(struct usb_interface *intf)
{
struct sfire_chip *chip;
struct snd_card *card;
guard(mutex)(®ister_mutex);
chip = usb_get_intfdata(intf);
/* if !chip, fw upload has been performed */
if (!chip)
return;
chip->intf_count--;
if (chip->intf_count)
return;
chips[chip->regidx] = NULL;
Annotation
- Immediate include surface: `chip.h`, `firmware.h`, `pcm.h`, `control.h`, `comm.h`, `midi.h`, `linux/moduleparam.h`, `linux/interrupt.h`.
- Detected declarations: `function usb6fire_chip_abort`, `function usb6fire_card_free`, `function usb6fire_chip_probe`, `function usb6fire_chip_disconnect`.
- Atlas domain: Driver Families / sound/usb.
- Implementation status: source implementation candidate.
Implementation Notes
- This generated page is the file-by-file coverage layer; curated subsystem chapters should link here when they synthesize a multi-file control flow.
- Core OS pages should be promoted from atlas-only to deep-reviewed when they explain data structures, invariants, locking, lifecycle, and C implementation snippets.
- Driver-family pages are intentionally pattern-oriented unless they are part of the selected PCIe/NVMe representative device path.