[BACK]Return to gpio.c CVS log [TXT][DIR] Up to [cvs.NetBSD.org] / src / sys / dev / gpio

Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.

Diff for /src/sys/dev/gpio/gpio.c between version 1.26 and 1.27

version 1.26, 2009/08/17 12:44:44 version 1.27, 2009/08/21 12:53:42
Line 217  gpiobus_print(void *aux, const char *pnp
Line 217  gpiobus_print(void *aux, const char *pnp
         return UNCONF;          return UNCONF;
 }  }
   
   /* return 1 if all pins can be mapped, 0 if not */
   
   int
   gpio_pin_can_map(void *gpio, int offset, u_int32_t mask)
   {
           struct gpio_softc *sc = gpio;
           int npins, pin, i;
   
           npins = gpio_npins(mask);
           if (npins > sc->sc_npins)
                   return 0;
   
           for (npins = 0, i = 0; i < 32; i++)
                   if (mask & (1 << i)) {
                           pin = offset + i;
                           if (pin < 0 || pin >= sc->sc_npins)
                                   return 0;
                           if (sc->sc_pins[pin].pin_mapped)
                                   return 0;
                   }
   
           return 1;
   }
   
 int  int
 gpio_pin_map(void *gpio, int offset, u_int32_t mask, struct gpio_pinmap *map)  gpio_pin_map(void *gpio, int offset, u_int32_t mask, struct gpio_pinmap *map)
 {  {
Line 483  gpioioctl(dev_t dev, u_long cmd, void *d
Line 507  gpioioctl(dev_t dev, u_long cmd, void *d
                 if (kauth_authorize_device(cred, KAUTH_DEVICE_GPIO_PINSET,                  if (kauth_authorize_device(cred, KAUTH_DEVICE_GPIO_PINSET,
                     NULL, NULL, NULL, NULL))                      NULL, NULL, NULL, NULL))
                         return EPERM;                          return EPERM;
   
                 attach = (struct gpio_attach *)data;                  attach = (struct gpio_attach *)data;
   
                   /* do not try to attach if the pins are already mapped */
                   if (!gpio_pin_can_map(sc, attach->ga_offset, attach->ga_mask))
                           return EBUSY;
   
                 ga.ga_gpio = sc;                  ga.ga_gpio = sc;
                 ga.ga_dvname = attach->ga_dvname;                  ga.ga_dvname = attach->ga_dvname;
                 ga.ga_offset = attach->ga_offset;                  ga.ga_offset = attach->ga_offset;

Legend:
Removed from v.1.26  
changed lines
  Added in v.1.27

CVSweb <webmaster@jp.NetBSD.org>