Re: sys: use C99 struct init for struct audio_hw_if
On Tue, Oct 18, 2022 at 08:02:34PM +, Klemens Nanni wrote: > > Here's the actual complete diff that was tested as per above, > the previous did not include a bunch of files. > > I can also send/commit this in smaller per driver/arch/whatever chunks > if that's preferred. Your call ;-) ok ratchov
Re: sys: use C99 struct init for struct audio_hw_if
On Tue, Oct 18, 2022 at 02:17:54PM +, Klemens Nanni wrote: > audio(9) cleanup demands removing a member from this struct, which is > cumbersome in our current tree as drivers initialise it inconsistently, > i.e. a simple removal of ".member_name = driver_func," is not always > possible. > > Most drivers call their driver_*() functions like the member name, > - some vary slightly, e.g. ".allocm = driver_alloc," > - some read vague, e.g. ".round_buffersize = driver_round," where > .round_blocksize also exists > - some have the member name as comment, on both functions and NULL lines > - some use 0 not NULL > > Use C99 style everywhere for consistency and clarity, getting rid of all > annoying differences and allow for clear member removals/additions: > > - dont change current order of members > - no explicit NULL members > - no comments or blank lines > - trailing comma in last member line > > GENERIC.MP builds fine with this diff on arm64, amd64, i386 and sparc64. > I should be able to test macppc soon. > > Feedback? Objection? OK? > > NB: `git diff --word-diff --color' really helps seeing actual change. > 14 files changed, 228 insertions(+), 348 deletions(-) Here's the actual complete diff that was tested as per above, the previous did not include a bunch of files. I can also send/commit this in smaller per driver/arch/whatever chunks if that's preferred. --- sys/arch/hppa/gsc/harmony.c | 38 ++- sys/arch/luna88k/cbus/nec86.c | 5 -- sys/arch/macppc/dev/aoa.c | 36 ++ sys/arch/macppc/dev/awacs.c | 36 ++ sys/arch/macppc/dev/daca.c| 36 ++ sys/arch/macppc/dev/onyx.c| 36 ++ sys/arch/macppc/dev/snapper.c | 36 ++ sys/arch/macppc/dev/tumbler.c | 36 ++ sys/arch/sparc64/dev/ce4231.c | 37 ++ sys/dev/isa/ess.c | 76 - sys/dev/isa/gus.c | 91 +-- sys/dev/isa/pas.c | 38 ++- sys/dev/isa/sb.c | 38 ++- sys/dev/pci/auacer.c | 37 ++ sys/dev/pci/auglx.c | 37 ++ sys/dev/pci/auich.c | 37 ++ sys/dev/pci/auixp.c | 37 ++ sys/dev/pci/autri.c | 36 ++ sys/dev/pci/auvia.c | 37 ++ sys/dev/pci/azalia.c | 42 ++-- sys/dev/pci/cmpci.c | 37 ++ sys/dev/pci/cs4280.c | 36 ++ sys/dev/pci/cs4281.c | 37 ++ sys/dev/pci/eap.c | 72 +++ sys/dev/pci/emuxki.c | 37 ++ sys/dev/pci/envy.c| 36 ++ sys/dev/pci/esa.c | 38 ++- sys/dev/pci/eso.c | 37 ++ sys/dev/pci/fms.c | 36 ++ sys/dev/pci/maestro.c | 36 ++ sys/dev/pci/neo.c | 41 ++-- sys/dev/pci/sv.c | 38 ++- sys/dev/pci/yds.c | 37 ++ sys/dev/sbus/cs4231.c | 37 ++ sys/dev/tc/bba.c | 38 ++- sys/dev/usb/uaudio.c | 39 ++- sys/dev/usb/utvfu.c | 33 + 37 files changed, 580 insertions(+), 887 deletions(-) diff --git a/sys/arch/hppa/gsc/harmony.c b/sys/arch/hppa/gsc/harmony.c index ade991c17c2..6823cda936e 100644 --- a/sys/arch/hppa/gsc/harmony.c +++ b/sys/arch/hppa/gsc/harmony.c @@ -74,28 +74,22 @@ int harmony_trigger_input(void *, void *, void *, int, void (*intr)(void *), void *, struct audio_params *); const struct audio_hw_if harmony_sa_hw_if = { - harmony_open, - harmony_close, - harmony_set_params, - harmony_round_blocksize, - harmony_commit_settings, - NULL, - NULL, - NULL, - NULL, - harmony_halt_output, - harmony_halt_input, - NULL, - NULL, - harmony_set_port, - harmony_get_port, - harmony_query_devinfo, - harmony_allocm, - harmony_freem, - harmony_round_buffersize, - harmony_get_props, - harmony_trigger_output, - harmony_trigger_input + .open = harmony_open, + .close = harmony_close, + .set_params = harmony_set_params, + .round_blocksize = harmony_round_blocksize, + .commit_settings = harmony_commit_settings, + .halt_output = harmony_halt_output, + .halt_input = harmony_halt_input, + .set_port = harmony_set_port, + .get_port = harmony_get_port, + .query_devinfo = harmony_query_devinfo, + .allocm = harmony_allocm, + .freem = harmony_freem, + .round_buffersize = harmony_round_buffersize, + .get_props = harmony_get_props, + .trigger_output = harmony_trigger_output, + .trigger_input = harmony_trigger_input, }; int harmony_match(struct
Re: sys: use C99 struct init for struct audio_hw_if
On Tue, Oct 18, 2022 at 02:17:54PM +, Klemens Nanni wrote: > audio(9) cleanup demands removing a member from this struct, which is > cumbersome in our current tree as drivers initialise it inconsistently, > i.e. a simple removal of ".member_name = driver_func," is not always > possible. > > Most drivers call their driver_*() functions like the member name, > - some vary slightly, e.g. ".allocm = driver_alloc," > - some read vague, e.g. ".round_buffersize = driver_round," where > .round_blocksize also exists > - some have the member name as comment, on both functions and NULL lines > - some use 0 not NULL > > Use C99 style everywhere for consistency and clarity, getting rid of all > annoying differences and allow for clear member removals/additions: > > - dont change current order of members > - no explicit NULL members > - no comments or blank lines > - trailing comma in last member line > > GENERIC.MP builds fine with this diff on arm64, amd64, i386 and sparc64. > I should be able to test macppc soon. > > Feedback? Objection? OK? > AFAICS, this will make life easier and the diff looks good ok ratchov
sys: use C99 struct init for struct audio_hw_if
audio(9) cleanup demands removing a member from this struct, which is cumbersome in our current tree as drivers initialise it inconsistently, i.e. a simple removal of ".member_name = driver_func," is not always possible. Most drivers call their driver_*() functions like the member name, - some vary slightly, e.g. ".allocm = driver_alloc," - some read vague, e.g. ".round_buffersize = driver_round," where .round_blocksize also exists - some have the member name as comment, on both functions and NULL lines - some use 0 not NULL Use C99 style everywhere for consistency and clarity, getting rid of all annoying differences and allow for clear member removals/additions: - dont change current order of members - no explicit NULL members - no comments or blank lines - trailing comma in last member line GENERIC.MP builds fine with this diff on arm64, amd64, i386 and sparc64. I should be able to test macppc soon. Feedback? Objection? OK? NB: `git diff --word-diff --color' really helps seeing actual change. --- sys/arch/hppa/gsc/harmony.c | 38 ++- sys/arch/luna88k/cbus/nec86.c | 5 -- sys/arch/macppc/dev/aoa.c | 36 ++ sys/arch/macppc/dev/awacs.c | 36 ++ sys/arch/macppc/dev/daca.c| 36 ++ sys/arch/macppc/dev/onyx.c| 36 ++ sys/arch/macppc/dev/snapper.c | 36 ++ sys/arch/macppc/dev/tumbler.c | 36 ++ sys/arch/sparc64/dev/ce4231.c | 37 ++ sys/dev/isa/ess.c | 76 - sys/dev/isa/gus.c | 91 +-- sys/dev/isa/pas.c | 38 ++- sys/dev/isa/sb.c | 38 ++- sys/dev/pci/auacer.c | 37 ++ 14 files changed, 228 insertions(+), 348 deletions(-) diff --git a/sys/arch/hppa/gsc/harmony.c b/sys/arch/hppa/gsc/harmony.c index ade991c17c2..6823cda936e 100644 --- a/sys/arch/hppa/gsc/harmony.c +++ b/sys/arch/hppa/gsc/harmony.c @@ -74,28 +74,22 @@ int harmony_trigger_input(void *, void *, void *, int, void (*intr)(void *), void *, struct audio_params *); const struct audio_hw_if harmony_sa_hw_if = { - harmony_open, - harmony_close, - harmony_set_params, - harmony_round_blocksize, - harmony_commit_settings, - NULL, - NULL, - NULL, - NULL, - harmony_halt_output, - harmony_halt_input, - NULL, - NULL, - harmony_set_port, - harmony_get_port, - harmony_query_devinfo, - harmony_allocm, - harmony_freem, - harmony_round_buffersize, - harmony_get_props, - harmony_trigger_output, - harmony_trigger_input + .open = harmony_open, + .close = harmony_close, + .set_params = harmony_set_params, + .round_blocksize = harmony_round_blocksize, + .commit_settings = harmony_commit_settings, + .halt_output = harmony_halt_output, + .halt_input = harmony_halt_input, + .set_port = harmony_set_port, + .get_port = harmony_get_port, + .query_devinfo = harmony_query_devinfo, + .allocm = harmony_allocm, + .freem = harmony_freem, + .round_buffersize = harmony_round_buffersize, + .get_props = harmony_get_props, + .trigger_output = harmony_trigger_output, + .trigger_input = harmony_trigger_input, }; int harmony_match(struct device *, void *, void *); diff --git a/sys/arch/luna88k/cbus/nec86.c b/sys/arch/luna88k/cbus/nec86.c index eec75a8f4ac..2d2d965d1bc 100644 --- a/sys/arch/luna88k/cbus/nec86.c +++ b/sys/arch/luna88k/cbus/nec86.c @@ -84,12 +84,7 @@ const struct audio_hw_if nec86_hw_if = { .set_port = nec86hw_mixer_set_port, .get_port = nec86hw_mixer_get_port, .query_devinfo = nec86hw_mixer_query_devinfo, - .allocm = NULL, - .freem = NULL, - .round_buffersize = NULL, .get_props = nec86_get_props, - .trigger_output = NULL, - .trigger_input = NULL }; /* diff --git a/sys/arch/macppc/dev/aoa.c b/sys/arch/macppc/dev/aoa.c index f6372876a4d..39dfaa526c3 100644 --- a/sys/arch/macppc/dev/aoa.c +++ b/sys/arch/macppc/dev/aoa.c @@ -66,28 +66,20 @@ struct cfdriver aoa_cd = { }; const struct audio_hw_if aoa_hw_if = { - i2s_open, - i2s_close, - i2s_set_params, - i2s_round_blocksize, - NULL, - NULL, - NULL, - NULL, - NULL, - i2s_halt_output, - i2s_halt_input, - NULL, - NULL, - i2s_set_port, - i2s_get_port, - i2s_query_devinfo, - i2s_allocm, - NULL, - i2s_round_buffersize, - i2s_get_props, - i2s_trigger_output, - i2s_trigger_input + .open = i2s_open, + .close = i2s_close, + .set_params = i2s_set_params, + .round_blocksize = i2s_round_blocksize, + .halt_output = i2s_halt_output, + .halt_input =