Skip to content

[BUG] Bad I2S interface function signatures #19293

Description

@linguini1

Description / Steps to reproduce the issue

One example is the following part of the interface:

/****************************************************************************
 * Name: I2S_SETMCLKFREQUENCY
 *
 * Description:
 *   Set the master clock frequency. Usually, the MCLK is a multiple of the
 *   sample rate. Most of the audio codecs require setting specific MCLK
 *   frequency according to the sample rate. NOTE: this parameter may not
 *   be implemented on I2S driver. If not implemented, the I2S may set
 *   internally any value to the master clock (or even does not support it).
 *
 * Input Parameters:
 *   dev        - Device-specific state data
 *   frequency  - The I2S master clock's frequency
 *
 * Returned Value:
 *   Returns the resulting master clock or a negated errno value on failure.
 *
 ****************************************************************************/

#define I2S_SETMCLKFREQUENCY(d,f) \
  ((d)->ops->i2s_setmclkfrequency ? \
   (d)->ops->i2s_setmclkfrequency(d,f) : -ENOTTY)

The function i2s_setmclkfrequency should be capable of returning a negated error code. However, the function signature is as follows:

  /* Master Clock methods */

  CODE uint32_t (*i2s_getmclkfrequency)(FAR struct i2s_dev_s *dev);
  CODE uint32_t (*i2s_setmclkfrequency)(FAR struct i2s_dev_s *dev,
                                        uint32_t frequency);

A uint32_t is never capable of returning a negated error code.

On which OS does this issue occur?

[OS: Linux]

What is the version of your OS?

Arch Linux

NuttX Version

master

Issue Architecture

[Arch: all]

Issue Area

[Area: Drivers]

Host information

No response

Verification

  • I have verified before submitting the report.

Metadata

Metadata

Assignees

Labels

Arch: allIssues that apply to all architecturesArea: DriversDrivers issuesOS: LinuxIssues related to Linux (building system, etc)Type: BugSomething isn't working

Type

No type

Fields

No fields configured for issues without a type.

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions