On Wed, Aug 29, 2018 at 09:53:59AM +1000, David Gwynne wrote:
> this has autoconf(9) allocatethe todr struct thing as part of a softc
> instead of allocting it separately during attach.
> 
> no functional change, just a shuffling of the deck chairs.
> 
> ok?
> 

ok mlarkin

> Index: prtc.c
> ===================================================================
> RCS file: /cvs/src/sys/arch/sparc64/dev/prtc.c,v
> retrieving revision 1.4
> diff -u -p -r1.4 prtc.c
> --- prtc.c    28 Aug 2018 00:00:42 -0000      1.4
> +++ prtc.c    28 Aug 2018 23:52:40 -0000
> @@ -35,11 +35,17 @@
>  
>  extern todr_chip_handle_t todr_handle;
>  
> +struct prtc_softc {
> +     struct device   sc_dev;
> +     struct todr_chip_handle
> +                     sc_todr_chip;
> +};
> +
>  int  prtc_match(struct device *, void *, void *);
>  void prtc_attach(struct device *, struct device *, void *);
>  
>  struct cfattach prtc_ca = {
> -     sizeof(struct device), prtc_match, prtc_attach
> +     sizeof(struct prtc_softc), prtc_match, prtc_attach
>  };
>  
>  struct cfdriver prtc_cd = {
> @@ -66,7 +72,8 @@ prtc_match(struct device *parent, void *
>  void
>  prtc_attach(struct device *parent, struct device *self, void *aux)
>  {
> -     todr_chip_handle_t handle;
> +     struct prtc_softc *sc = (struct prtc_softc *)self;
> +     todr_chip_handle_t handle = &sc->sc_todr_chip;
>       char buf[32];
>       int opl;
>  
> @@ -78,11 +85,7 @@ prtc_attach(struct device *parent, struc
>  
>       printf("\n");
>  
> -     handle = malloc(sizeof(struct todr_chip_handle), M_DEVBUF, M_NOWAIT);
> -     if (handle == NULL)
> -             panic("couldn't allocate todr_handle");
> -
> -     handle->cookie = self;
> +     handle->cookie = sc;
>       if (opl) {
>               handle->todr_gettime = prtc_opl_gettime;
>               handle->todr_settime = prtc_opl_settime;
> 

Reply via email to