[v3,2/4] soundwire: Provide build stubs for common functions
Commit Message
Provide stub functions when CONFIG_SOUNDWIRE is not set for functions
that are quite likely to be used from common code on devices supporting
multiple control buses.
Reviewed-by: Pierre-Louis Bossart <pierre-louis.bossart@linux.intel.com>
Signed-off-by: Charles Keepax <ckeepax@opensource.cirrus.com>
---
No changes since v2.
include/linux/soundwire/sdw.h | 92 +++++++++++++++++++++++++++++++----
1 file changed, 82 insertions(+), 10 deletions(-)
Comments
On 21-11-22, 14:14, Charles Keepax wrote:
> Provide stub functions when CONFIG_SOUNDWIRE is not set for functions
> that are quite likely to be used from common code on devices supporting
> multiple control buses.
>
> Reviewed-by: Pierre-Louis Bossart <pierre-louis.bossart@linux.intel.com>
> Signed-off-by: Charles Keepax <ckeepax@opensource.cirrus.com>
> ---
>
> No changes since v2.
>
> include/linux/soundwire/sdw.h | 92 +++++++++++++++++++++++++++++++----
> 1 file changed, 82 insertions(+), 10 deletions(-)
>
> diff --git a/include/linux/soundwire/sdw.h b/include/linux/soundwire/sdw.h
> index 902ed46f76c80..4f80cba898f11 100644
> --- a/include/linux/soundwire/sdw.h
> +++ b/include/linux/soundwire/sdw.h
> @@ -1021,15 +1021,8 @@ int sdw_stream_add_master(struct sdw_bus *bus,
> struct sdw_port_config *port_config,
> unsigned int num_ports,
> struct sdw_stream_runtime *stream);
> -int sdw_stream_add_slave(struct sdw_slave *slave,
> - struct sdw_stream_config *stream_config,
> - struct sdw_port_config *port_config,
> - unsigned int num_ports,
> - struct sdw_stream_runtime *stream);
> int sdw_stream_remove_master(struct sdw_bus *bus,
> struct sdw_stream_runtime *stream);
> -int sdw_stream_remove_slave(struct sdw_slave *slave,
> - struct sdw_stream_runtime *stream);
> int sdw_startup_stream(void *sdw_substream);
> int sdw_prepare_stream(struct sdw_stream_runtime *stream);
> int sdw_enable_stream(struct sdw_stream_runtime *stream);
> @@ -1040,8 +1033,20 @@ int sdw_bus_prep_clk_stop(struct sdw_bus *bus);
> int sdw_bus_clk_stop(struct sdw_bus *bus);
> int sdw_bus_exit_clk_stop(struct sdw_bus *bus);
>
> -/* messaging and data APIs */
> +int sdw_compare_devid(struct sdw_slave *slave, struct sdw_slave_id id);
> +void sdw_extract_slave_id(struct sdw_bus *bus, u64 addr, struct sdw_slave_id *id);
> +
> +#if IS_ENABLED(CONFIG_SOUNDWIRE)
>
> +int sdw_stream_add_slave(struct sdw_slave *slave,
> + struct sdw_stream_config *stream_config,
> + struct sdw_port_config *port_config,
> + unsigned int num_ports,
> + struct sdw_stream_runtime *stream);
> +int sdw_stream_remove_slave(struct sdw_slave *slave,
> + struct sdw_stream_runtime *stream);
> +
> +/* messaging and data APIs */
> int sdw_read(struct sdw_slave *slave, u32 addr);
> int sdw_write(struct sdw_slave *slave, u32 addr, u8 value);
> int sdw_write_no_pm(struct sdw_slave *slave, u32 addr, u8 value);
> @@ -1053,7 +1058,74 @@ int sdw_nwrite_no_pm(struct sdw_slave *slave, u32 addr, size_t count, const u8 *
> int sdw_update(struct sdw_slave *slave, u32 addr, u8 mask, u8 val);
> int sdw_update_no_pm(struct sdw_slave *slave, u32 addr, u8 mask, u8 val);
>
> -int sdw_compare_devid(struct sdw_slave *slave, struct sdw_slave_id id);
> -void sdw_extract_slave_id(struct sdw_bus *bus, u64 addr, struct sdw_slave_id *id);
> +#else
> +
> +static inline int sdw_stream_add_slave(struct sdw_slave *slave,
> + struct sdw_stream_config *stream_config,
> + struct sdw_port_config *port_config,
> + unsigned int num_ports,
> + struct sdw_stream_runtime *stream)
> +{
> + return 0;
Should this and other here not return error...? Indicating sdw is not
available..? Silently ignoring may not be very helpful in debugging
> +}
> +
> +static inline int sdw_stream_remove_slave(struct sdw_slave *slave,
> + struct sdw_stream_runtime *stream)
> +{
> + return 0;
> +}
> +
> +/* messaging and data APIs */
> +static inline int sdw_read(struct sdw_slave *slave, u32 addr)
> +{
> + return 0;
> +}
> +
> +static inline int sdw_write(struct sdw_slave *slave, u32 addr, u8 value)
> +{
> + return 0;
> +}
> +
> +static inline int sdw_write_no_pm(struct sdw_slave *slave, u32 addr, u8 value)
> +{
> + return 0;
> +}
> +
> +static inline int sdw_read_no_pm(struct sdw_slave *slave, u32 addr)
> +{
> + return 0;
> +}
> +
> +static inline int sdw_nread(struct sdw_slave *slave, u32 addr, size_t count, u8 *val)
> +{
> + return 0;
> +}
> +
> +static inline int sdw_nread_no_pm(struct sdw_slave *slave, u32 addr, size_t count, u8 *val)
> +{
> + return 0;
> +}
> +
> +static inline int sdw_nwrite(struct sdw_slave *slave, u32 addr, size_t count, const u8 *val)
> +{
> + return 0;
> +}
> +
> +static inline int sdw_nwrite_no_pm(struct sdw_slave *slave, u32 addr, size_t count, const u8 *val)
> +{
> + return 0;
> +}
> +
> +static inline int sdw_update(struct sdw_slave *slave, u32 addr, u8 mask, u8 val)
> +{
> + return 0;
> +}
> +
> +static inline int sdw_update_no_pm(struct sdw_slave *slave, u32 addr, u8 mask, u8 val)
> +{
> + return 0;
> +}
> +
> +#endif /* CONFIG_SOUNDWIRE */
>
> #endif /* __SOUNDWIRE_H */
> --
> 2.30.2
On Thu, Nov 24, 2022 at 10:21:32AM +0530, Vinod Koul wrote:
> On 21-11-22, 14:14, Charles Keepax wrote:
> > Provide stub functions when CONFIG_SOUNDWIRE is not set for functions
> > that are quite likely to be used from common code on devices supporting
> > multiple control buses.
> >
> > Reviewed-by: Pierre-Louis Bossart <pierre-louis.bossart@linux.intel.com>
> > Signed-off-by: Charles Keepax <ckeepax@opensource.cirrus.com>
> > ---
> > +static inline int sdw_stream_add_slave(struct sdw_slave *slave,
> > + struct sdw_stream_config *stream_config,
> > + struct sdw_port_config *port_config,
> > + unsigned int num_ports,
> > + struct sdw_stream_runtime *stream)
> > +{
> > + return 0;
>
> Should this and other here not return error...? Indicating sdw is not
> available..? Silently ignoring may not be very helpful in debugging
>
Yeah I was a little unsure which way to go on that, in the end I
opted for returning zero as it was more likely code would get
optimised out. But I am happy to switch to returning an error, it
would as you say making debugging misconfigurations easier.
-ENOSYS seems kinda reasonable I think.
Thanks,
Charles
On 24-11-22, 09:22, Charles Keepax wrote:
> On Thu, Nov 24, 2022 at 10:21:32AM +0530, Vinod Koul wrote:
> > On 21-11-22, 14:14, Charles Keepax wrote:
> > > Provide stub functions when CONFIG_SOUNDWIRE is not set for functions
> > > that are quite likely to be used from common code on devices supporting
> > > multiple control buses.
> > >
> > > Reviewed-by: Pierre-Louis Bossart <pierre-louis.bossart@linux.intel.com>
> > > Signed-off-by: Charles Keepax <ckeepax@opensource.cirrus.com>
> > > ---
> > > +static inline int sdw_stream_add_slave(struct sdw_slave *slave,
> > > + struct sdw_stream_config *stream_config,
> > > + struct sdw_port_config *port_config,
> > > + unsigned int num_ports,
> > > + struct sdw_stream_runtime *stream)
> > > +{
> > > + return 0;
> >
> > Should this and other here not return error...? Indicating sdw is not
> > available..? Silently ignoring may not be very helpful in debugging
> >
>
> Yeah I was a little unsure which way to go on that, in the end I
> opted for returning zero as it was more likely code would get
> optimised out. But I am happy to switch to returning an error, it
> would as you say making debugging misconfigurations easier.
> -ENOSYS seems kinda reasonable I think.
Right, -ENOSYS seems to be apt here
@@ -1021,15 +1021,8 @@ int sdw_stream_add_master(struct sdw_bus *bus,
struct sdw_port_config *port_config,
unsigned int num_ports,
struct sdw_stream_runtime *stream);
-int sdw_stream_add_slave(struct sdw_slave *slave,
- struct sdw_stream_config *stream_config,
- struct sdw_port_config *port_config,
- unsigned int num_ports,
- struct sdw_stream_runtime *stream);
int sdw_stream_remove_master(struct sdw_bus *bus,
struct sdw_stream_runtime *stream);
-int sdw_stream_remove_slave(struct sdw_slave *slave,
- struct sdw_stream_runtime *stream);
int sdw_startup_stream(void *sdw_substream);
int sdw_prepare_stream(struct sdw_stream_runtime *stream);
int sdw_enable_stream(struct sdw_stream_runtime *stream);
@@ -1040,8 +1033,20 @@ int sdw_bus_prep_clk_stop(struct sdw_bus *bus);
int sdw_bus_clk_stop(struct sdw_bus *bus);
int sdw_bus_exit_clk_stop(struct sdw_bus *bus);
-/* messaging and data APIs */
+int sdw_compare_devid(struct sdw_slave *slave, struct sdw_slave_id id);
+void sdw_extract_slave_id(struct sdw_bus *bus, u64 addr, struct sdw_slave_id *id);
+
+#if IS_ENABLED(CONFIG_SOUNDWIRE)
+int sdw_stream_add_slave(struct sdw_slave *slave,
+ struct sdw_stream_config *stream_config,
+ struct sdw_port_config *port_config,
+ unsigned int num_ports,
+ struct sdw_stream_runtime *stream);
+int sdw_stream_remove_slave(struct sdw_slave *slave,
+ struct sdw_stream_runtime *stream);
+
+/* messaging and data APIs */
int sdw_read(struct sdw_slave *slave, u32 addr);
int sdw_write(struct sdw_slave *slave, u32 addr, u8 value);
int sdw_write_no_pm(struct sdw_slave *slave, u32 addr, u8 value);
@@ -1053,7 +1058,74 @@ int sdw_nwrite_no_pm(struct sdw_slave *slave, u32 addr, size_t count, const u8 *
int sdw_update(struct sdw_slave *slave, u32 addr, u8 mask, u8 val);
int sdw_update_no_pm(struct sdw_slave *slave, u32 addr, u8 mask, u8 val);
-int sdw_compare_devid(struct sdw_slave *slave, struct sdw_slave_id id);
-void sdw_extract_slave_id(struct sdw_bus *bus, u64 addr, struct sdw_slave_id *id);
+#else
+
+static inline int sdw_stream_add_slave(struct sdw_slave *slave,
+ struct sdw_stream_config *stream_config,
+ struct sdw_port_config *port_config,
+ unsigned int num_ports,
+ struct sdw_stream_runtime *stream)
+{
+ return 0;
+}
+
+static inline int sdw_stream_remove_slave(struct sdw_slave *slave,
+ struct sdw_stream_runtime *stream)
+{
+ return 0;
+}
+
+/* messaging and data APIs */
+static inline int sdw_read(struct sdw_slave *slave, u32 addr)
+{
+ return 0;
+}
+
+static inline int sdw_write(struct sdw_slave *slave, u32 addr, u8 value)
+{
+ return 0;
+}
+
+static inline int sdw_write_no_pm(struct sdw_slave *slave, u32 addr, u8 value)
+{
+ return 0;
+}
+
+static inline int sdw_read_no_pm(struct sdw_slave *slave, u32 addr)
+{
+ return 0;
+}
+
+static inline int sdw_nread(struct sdw_slave *slave, u32 addr, size_t count, u8 *val)
+{
+ return 0;
+}
+
+static inline int sdw_nread_no_pm(struct sdw_slave *slave, u32 addr, size_t count, u8 *val)
+{
+ return 0;
+}
+
+static inline int sdw_nwrite(struct sdw_slave *slave, u32 addr, size_t count, const u8 *val)
+{
+ return 0;
+}
+
+static inline int sdw_nwrite_no_pm(struct sdw_slave *slave, u32 addr, size_t count, const u8 *val)
+{
+ return 0;
+}
+
+static inline int sdw_update(struct sdw_slave *slave, u32 addr, u8 mask, u8 val)
+{
+ return 0;
+}
+
+static inline int sdw_update_no_pm(struct sdw_slave *slave, u32 addr, u8 mask, u8 val)
+{
+ return 0;
+}
+
+#endif /* CONFIG_SOUNDWIRE */
#endif /* __SOUNDWIRE_H */