Message ID | 20241203154635.2512-1-liujing@cmss.chinamobile.com (mailing list archive) |
---|---|
State | New |
Headers | show |
Series | ALSA: asihpi: Delete redundant judgments | expand |
On Tue, 03 Dec 2024 16:46:35 +0100, liujing wrote: > > Since HPI6205_TIMEOUT is a constant, time_out is always true, > so unneeded judgments are removed. > > Signed-off-by: liujing <liujing@cmss.chinamobile.com> Keeping it allows to remove the time_out for experiments, and compiler would optimize things in anyway, so there must be no code difference in the end. Since this doesn't improve things so significantly, I'd rather leave as is. And you mixed different fixes (the conversion of printf format) in a single patch without explanation, too. Please split, if any. thanks, Takashi > > diff --git a/sound/pci/asihpi/hpi6205.c b/sound/pci/asihpi/hpi6205.c > index c7d7eff86727..391cce428a11 100644 > --- a/sound/pci/asihpi/hpi6205.c > +++ b/sound/pci/asihpi/hpi6205.c > @@ -2127,22 +2127,20 @@ static u16 message_response_sequence(struct hpi_adapter_obj *pao, > time_out = HPI6205_TIMEOUT; > > /* read the result */ > - if (time_out) { > - if (interface->u.response_buffer.response.size <= phr->size) > - memcpy(phr, &interface->u.response_buffer, > - interface->u.response_buffer.response.size); > - else { > - HPI_DEBUG_LOG(ERROR, > + if (interface->u.response_buffer.response.size <= phr->size) > + memcpy(phr, &interface->u.response_buffer, > + interface->u.response_buffer.response.size); > + else { > + HPI_DEBUG_LOG(ERROR, > "response len %d too big for buffer %d\n", > interface->u.response_buffer.response.size, > phr->size); > - memcpy(phr, &interface->u.response_buffer, > + memcpy(phr, &interface->u.response_buffer, > sizeof(struct hpi_response_header)); > - phr->error = HPI_ERROR_RESPONSE_BUFFER_TOO_SMALL; > - phr->specific_error = > - interface->u.response_buffer.response.size; > - phr->size = sizeof(struct hpi_response_header); > - } > + phr->error = HPI_ERROR_RESPONSE_BUFFER_TOO_SMALL; > + phr->specific_error = > + interface->u.response_buffer.response.size; > + phr->size = sizeof(struct hpi_response_header); > } > /* set interface back to idle */ > send_dsp_command(phw, H620_HIF_IDLE); > diff --git a/sound/pci/mixart/mixart.c b/sound/pci/mixart/mixart.c > index 7ceaf6a7a77e..cac5fcaef08b 100644 > --- a/sound/pci/mixart/mixart.c > +++ b/sound/pci/mixart/mixart.c > @@ -1320,12 +1320,12 @@ static int snd_mixart_probe(struct pci_dev *pci, > idx = index[dev]; > else > idx = index[dev] + i; > - snprintf(tmpid, sizeof(tmpid), "%s-%d", id[dev] ? id[dev] : "MIXART", i); > + snprintf(tmpid, sizeof(tmpid), "%s-%u", id[dev] ? id[dev] : "MIXART", i); > err = snd_card_new(&pci->dev, idx, tmpid, THIS_MODULE, > 0, &card); > > if (err < 0) { > - dev_err(&pci->dev, "cannot allocate the card %d\n", i); > + dev_err(&pci->dev, "cannot allocate the card %u\n", i); > snd_mixart_free(mgr); > return err; > } > @@ -1334,7 +1334,7 @@ static int snd_mixart_probe(struct pci_dev *pci, > snprintf(card->shortname, sizeof(card->shortname), > "Digigram miXart [PCM #%d]", i); > snprintf(card->longname, sizeof(card->longname), > - "Digigram miXart at 0x%lx & 0x%lx, irq %i [PCM #%d]", > + "Digigram miXart at 0x%lx & 0x%lx, irq %i [PCM #%u]", > mgr->mem[0].phys, mgr->mem[1].phys, mgr->irq, i); > > err = snd_mixart_create(mgr, card, i); > -- > 2.27.0 > > >
diff --git a/sound/pci/asihpi/hpi6205.c b/sound/pci/asihpi/hpi6205.c index c7d7eff86727..391cce428a11 100644 --- a/sound/pci/asihpi/hpi6205.c +++ b/sound/pci/asihpi/hpi6205.c @@ -2127,22 +2127,20 @@ static u16 message_response_sequence(struct hpi_adapter_obj *pao, time_out = HPI6205_TIMEOUT; /* read the result */ - if (time_out) { - if (interface->u.response_buffer.response.size <= phr->size) - memcpy(phr, &interface->u.response_buffer, - interface->u.response_buffer.response.size); - else { - HPI_DEBUG_LOG(ERROR, + if (interface->u.response_buffer.response.size <= phr->size) + memcpy(phr, &interface->u.response_buffer, + interface->u.response_buffer.response.size); + else { + HPI_DEBUG_LOG(ERROR, "response len %d too big for buffer %d\n", interface->u.response_buffer.response.size, phr->size); - memcpy(phr, &interface->u.response_buffer, + memcpy(phr, &interface->u.response_buffer, sizeof(struct hpi_response_header)); - phr->error = HPI_ERROR_RESPONSE_BUFFER_TOO_SMALL; - phr->specific_error = - interface->u.response_buffer.response.size; - phr->size = sizeof(struct hpi_response_header); - } + phr->error = HPI_ERROR_RESPONSE_BUFFER_TOO_SMALL; + phr->specific_error = + interface->u.response_buffer.response.size; + phr->size = sizeof(struct hpi_response_header); } /* set interface back to idle */ send_dsp_command(phw, H620_HIF_IDLE); diff --git a/sound/pci/mixart/mixart.c b/sound/pci/mixart/mixart.c index 7ceaf6a7a77e..cac5fcaef08b 100644 --- a/sound/pci/mixart/mixart.c +++ b/sound/pci/mixart/mixart.c @@ -1320,12 +1320,12 @@ static int snd_mixart_probe(struct pci_dev *pci, idx = index[dev]; else idx = index[dev] + i; - snprintf(tmpid, sizeof(tmpid), "%s-%d", id[dev] ? id[dev] : "MIXART", i); + snprintf(tmpid, sizeof(tmpid), "%s-%u", id[dev] ? id[dev] : "MIXART", i); err = snd_card_new(&pci->dev, idx, tmpid, THIS_MODULE, 0, &card); if (err < 0) { - dev_err(&pci->dev, "cannot allocate the card %d\n", i); + dev_err(&pci->dev, "cannot allocate the card %u\n", i); snd_mixart_free(mgr); return err; } @@ -1334,7 +1334,7 @@ static int snd_mixart_probe(struct pci_dev *pci, snprintf(card->shortname, sizeof(card->shortname), "Digigram miXart [PCM #%d]", i); snprintf(card->longname, sizeof(card->longname), - "Digigram miXart at 0x%lx & 0x%lx, irq %i [PCM #%d]", + "Digigram miXart at 0x%lx & 0x%lx, irq %i [PCM #%u]", mgr->mem[0].phys, mgr->mem[1].phys, mgr->irq, i); err = snd_mixart_create(mgr, card, i);
Since HPI6205_TIMEOUT is a constant, time_out is always true, so unneeded judgments are removed. Signed-off-by: liujing <liujing@cmss.chinamobile.com>