Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src/sys/dev/pad Style fixes. No functional changes intended.



details:   https://anonhg.NetBSD.org/src/rev/5650f8e018c4
branches:  trunk
changeset: 452288:5650f8e018c4
user:      isaki <isaki%NetBSD.org@localhost>
date:      Wed Jun 26 11:53:15 2019 +0000

description:
Style fixes.  No functional changes intended.
- Rename some functions for consistency.
- Rearrange some functions for readability.
- Unify to struct pad_softc.

diffstat:

 sys/dev/pad/pad.c    |  284 ++++++++++++++++++++++++++------------------------
 sys/dev/pad/padvar.h |    6 +-
 2 files changed, 151 insertions(+), 139 deletions(-)

diffs (truncated from 572 to 300 lines):

diff -r 45ade74bcb22 -r 5650f8e018c4 sys/dev/pad/pad.c
--- a/sys/dev/pad/pad.c Wed Jun 26 11:47:54 2019 +0000
+++ b/sys/dev/pad/pad.c Wed Jun 26 11:53:15 2019 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: pad.c,v 1.61 2019/06/19 12:52:41 isaki Exp $ */
+/* $NetBSD: pad.c,v 1.62 2019/06/26 11:53:15 isaki Exp $ */
 
 /*-
  * Copyright (c) 2007 Jared D. McNeill <jmcneill%invisible.ca@localhost>
@@ -27,7 +27,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: pad.c,v 1.61 2019/06/19 12:52:41 isaki Exp $");
+__KERNEL_RCSID(0, "$NetBSD: pad.c,v 1.62 2019/06/26 11:53:15 isaki Exp $");
 
 #include <sys/types.h>
 #include <sys/param.h>
@@ -93,9 +93,9 @@
                    const audio_params_t *, const audio_params_t *,
                    audio_filter_reg_t *, audio_filter_reg_t *);
 static int     pad_start_output(void *, void *, int,
-                                   void (*)(void *), void *);
+                   void (*)(void *), void *);
 static int     pad_start_input(void *, void *, int,
-                                  void (*)(void *), void *);
+                   void (*)(void *), void *);
 static int     pad_halt_output(void *);
 static int     pad_halt_input(void *);
 static int     pad_getdev(void *, struct audio_device *);
@@ -108,32 +108,35 @@
 static void    pad_done_output(void *);
 static void    pad_swvol_codec(audio_filter_arg_t *);
 
-static int pad_close(struct pad_softc *);
-static int pad_read(struct pad_softc *, off_t *, struct uio *, kauth_cred_t, int);
+static int     pad_close(struct pad_softc *);
+static int     pad_read(struct pad_softc *, off_t *, struct uio *,
+                   kauth_cred_t, int);
 
-static int fops_pad_close(struct file *);
-static int fops_pad_read(struct file *, off_t *, struct uio *, kauth_cred_t, int);
-static int pad_write(struct file *, off_t *, struct uio *, kauth_cred_t, int);
-static int pad_ioctl(struct file *, u_long, void *);
-static int pad_kqfilter(struct file *, struct knote *);
-static int pad_poll(struct file *, int);
-static int pad_stat(struct file *, struct stat *);
-static int pad_mmap(struct file *, off_t *, size_t, int, int *, int *,
-                          struct uvm_object **, int *);
+static int     fops_pad_close(struct file *);
+static int     fops_pad_read(struct file *, off_t *, struct uio *,
+                   kauth_cred_t, int);
+static int     fops_pad_write(struct file *, off_t *, struct uio *,
+                   kauth_cred_t, int);
+static int     fops_pad_ioctl(struct file *, u_long, void *);
+static int     fops_pad_kqfilter(struct file *, struct knote *);
+static int     fops_pad_poll(struct file *, int);
+static int     fops_pad_stat(struct file *, struct stat *);
+static int     fops_pad_mmap(struct file *, off_t *, size_t, int, int *, int *,
+                   struct uvm_object **, int *);
 
 static const struct audio_hw_if pad_hw_if = {
-       .query_format = pad_query_format,
-       .set_format = pad_set_format,
-       .start_output = pad_start_output,
-       .start_input = pad_start_input,
-       .halt_output = pad_halt_output,
-       .halt_input = pad_halt_input,
-       .getdev = pad_getdev,
-       .set_port = pad_set_port,
-       .get_port = pad_get_port,
-       .query_devinfo = pad_query_devinfo,
-       .get_props = pad_get_props,
-       .get_locks = pad_get_locks,
+       .query_format   = pad_query_format,
+       .set_format     = pad_set_format,
+       .start_output   = pad_start_output,
+       .start_input    = pad_start_input,
+       .halt_output    = pad_halt_output,
+       .halt_input     = pad_halt_input,
+       .getdev         = pad_getdev,
+       .set_port       = pad_set_port,
+       .get_port       = pad_get_port,
+       .query_devinfo  = pad_query_devinfo,
+       .get_props      = pad_get_props,
+       .get_locks      = pad_get_locks,
 };
 
 #define PAD_NFORMATS   1
@@ -152,43 +155,44 @@
 
 extern void    padattach(int);
 
-static int     pad_add_block(pad_softc_t *, uint8_t *, int);
-static int     pad_get_block(pad_softc_t *, pad_block_t *, int);
+static int     pad_add_block(struct pad_softc *, uint8_t *, int);
+static int     pad_get_block(struct pad_softc *, pad_block_t *, int);
 
-dev_type_open(pad_open);
+dev_type_open(cdev_pad_open);
 dev_type_close(cdev_pad_close);
 dev_type_read(cdev_pad_read);
 
 const struct cdevsw pad_cdevsw = {
-       .d_open = pad_open,
-       .d_close = cdev_pad_close,
-       .d_read = cdev_pad_read,
-       .d_write = nowrite,
-       .d_ioctl = noioctl,
-       .d_stop = nostop,
-       .d_tty = notty,
-       .d_poll = nopoll,
-       .d_mmap = nommap,
-       .d_kqfilter = nokqfilter,
-       .d_discard = nodiscard,
-       .d_flag = D_OTHER | D_MPSAFE,
+       .d_open         = cdev_pad_open,
+       .d_close        = cdev_pad_close,
+       .d_read         = cdev_pad_read,
+       .d_write        = nowrite,
+       .d_ioctl        = noioctl,
+       .d_stop         = nostop,
+       .d_tty          = notty,
+       .d_poll         = nopoll,
+       .d_mmap         = nommap,
+       .d_kqfilter     = nokqfilter,
+       .d_discard      = nodiscard,
+       .d_flag         = D_OTHER | D_MPSAFE,
 };
 
 const struct fileops pad_fileops = {
-       .fo_name = "pad",
-       .fo_read = fops_pad_read,
-       .fo_write = pad_write,
-       .fo_ioctl = pad_ioctl,
-       .fo_fcntl = fnullop_fcntl,
-       .fo_stat = pad_stat,
-       .fo_poll = pad_poll,
-       .fo_close = fops_pad_close,
-       .fo_mmap = pad_mmap,
-       .fo_kqfilter = pad_kqfilter,
-       .fo_restart = fnullop_restart
+       .fo_name        = "pad",
+       .fo_read        = fops_pad_read,
+       .fo_write       = fops_pad_write,
+       .fo_ioctl       = fops_pad_ioctl,
+       .fo_fcntl       = fnullop_fcntl,
+       .fo_stat        = fops_pad_stat,
+       .fo_poll        = fops_pad_poll,
+       .fo_close       = fops_pad_close,
+       .fo_mmap        = fops_pad_mmap,
+       .fo_kqfilter    = fops_pad_kqfilter,
+       .fo_restart     = fnullop_restart
 };
 
-CFATTACH_DECL2_NEW(pad, sizeof(pad_softc_t), pad_match, pad_attach, pad_detach,
+CFATTACH_DECL2_NEW(pad, sizeof(struct pad_softc),
+    pad_match, pad_attach, pad_detach,
     NULL, NULL, pad_childdet);
 
 void
@@ -209,7 +213,44 @@
 }
 
 static int
-pad_add_block(pad_softc_t *sc, uint8_t *blk, int blksize)
+pad_match(device_t parent, cfdata_t data, void *opaque)
+{
+
+       return 1;
+}
+
+static void
+pad_attach(device_t parent, device_t self, void *opaque)
+{
+
+       aprint_normal_dev(self, "outputs: 44100Hz, 16-bit, stereo\n");
+}
+
+static int
+pad_detach(device_t self, int flags)
+{
+       struct pad_softc *sc;
+       int cmaj, mn;
+
+       sc = device_private(self);
+       cmaj = cdevsw_lookup_major(&pad_cdevsw);
+       mn = device_unit(sc->sc_dev);
+       if (!sc->sc_dying)
+               vdevgone(cmaj, mn, mn, VCHR);
+
+       return 0;
+}
+
+static void
+pad_childdet(device_t self, device_t child)
+{
+       struct pad_softc *sc = device_private(self);
+
+       sc->sc_audiodev = NULL;
+}
+
+static int
+pad_add_block(struct pad_softc *sc, uint8_t *blk, int blksize)
 {
        int l;
 
@@ -234,7 +275,7 @@
 }
 
 static int
-pad_get_block(pad_softc_t *sc, pad_block_t *pb, int blksize)
+pad_get_block(struct pad_softc *sc, pad_block_t *pb, int blksize)
 {
        int l;
 
@@ -254,48 +295,10 @@
        return 0;
 }
 
-static int
-pad_match(device_t parent, cfdata_t data, void *opaque)
-{
-
-       return 1;
-}
-
-static void
-pad_childdet(device_t self, device_t child)
-{
-       pad_softc_t *sc = device_private(self);
-
-       sc->sc_audiodev = NULL;
-}
-
-static void
-pad_attach(device_t parent, device_t self, void *opaque)
+int
+cdev_pad_open(dev_t dev, int flags, int fmt, struct lwp *l)
 {
-       aprint_normal_dev(self, "outputs: 44100Hz, 16-bit, stereo\n");
-
-       return;
-}
-
-static int
-pad_detach(device_t self, int flags)
-{
-       pad_softc_t *sc;
-       int cmaj, mn;
-
-       sc = device_private(self);
-       cmaj = cdevsw_lookup_major(&pad_cdevsw);
-       mn = device_unit(sc->sc_dev);
-       if (!sc->sc_dying)
-               vdevgone(cmaj, mn, mn, VCHR);
-
-       return 0;
-}
-
-int
-pad_open(dev_t dev, int flags, int fmt, struct lwp *l)
-{
-       pad_softc_t *sc;
+       struct pad_softc *sc;
        struct file *fp;
        device_t paddev;
        cfdata_t cf;
@@ -366,7 +369,8 @@
        sc->sc_audiodev = audio_attach_mi(&pad_hw_if, sc, sc->sc_dev);
 
        if (!pmf_device_register(sc->sc_dev, NULL, NULL))
-               aprint_error_dev(sc->sc_dev, "couldn't establish power handler\n");
+               aprint_error_dev(sc->sc_dev,
+                   "couldn't establish power handler\n");
 
        if (PADUNIT(dev) == PADCLONER) {
                error = fd_clone(fp, fd, flags, &pad_fileops, sc);
@@ -423,7 +427,7 @@
 static int
 fops_pad_close(struct file *fp)
 {
-       pad_softc_t *sc;
+       struct pad_softc *sc;
        int error;
 
        sc = fp->f_pad;
@@ -439,20 +443,21 @@
 int
 cdev_pad_close(dev_t dev, int flags, int ifmt, struct lwp *l)
 {
-       pad_softc_t *sc;
+       struct pad_softc *sc;
        sc = device_private(device_lookup(&pad_cd, PADUNIT(dev)));
 
        return pad_close(sc);
 }
 
 static int
-pad_poll(struct file *fp, int events)



Home | Main Index | Thread Index | Old Index