On 11/10/2025 8:43 AM, Alexandre Courbot wrote:
>> +impl<'a> Iterator for GspSeqIter<'a> {
>> +    type Item = Result<GspSeqCmd>;
>> +
>> +    fn next(&mut self) -> Option<Self::Item> {
>> +        // Stop if we've processed all commands or reached the end of data.
>> +        if self.cmds_processed >= self.total_cmds || self.current_offset >= 
>> self.cmd_data.len() {
>> +            return None;
>> +        }
>> +
>> +        // Check if we have enough data for opcode.
>> +        let opcode_size = size_of::<fw::GSP_SEQ_BUF_OPCODE>();
>> +        if self.current_offset + opcode_size > self.cmd_data.len() {
[..]>> +        let offset = self.current_offset;
>> +
>> +        // Handle command creation based on available data,
>> +        // zero-pad if necessary (since last command may not be full size).
>> +        let mut buffer = [0u8; CMD_SIZE];
>> +        let copy_len = if offset + CMD_SIZE <= self.cmd_data.len() {
>> +            CMD_SIZE
>> +        } else {
>> +            self.cmd_data.len() - offset
>> +        };
>> +        buffer[..copy_len].copy_from_slice(&self.cmd_data[offset..offset + 
>> copy_len]);
>> +        let cmd_result = GspSeqCmd::new(&buffer, self.dev);
>> +
>> +        cmd_result.map_or_else(
>> +            |_err| {
>> +                dev_err!(self.dev, "Error parsing command at offset {}", 
>> offset);
>> +                None
>> +            },
>> This looks a bit redundant: we are processing errors here, but then we
> also have another error handler in the caller (the one that says "Error
> running command..."). I'm pretty sure there is room for simplification
> here.

No, "Error running command" is because of .run() failure. We won't even get
there if .next() fails. AFAICS, there is no other diagnostic other than this if
command parsing fails.

Thanks.

Reply via email to