Re: [libgpiod v2][PATCH V8 5/9] bindings: rust: Add libgpiod crate

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

 



On 02-11-22, 21:14, Kent Gibson wrote:
> > +    /// Get the file descriptor associated with the chip.
> > +    ///
> > +    /// The returned file descriptor must not be closed by the caller, else other methods for the
> > +    /// `struct Chip` may fail.
> > +    pub fn fd(&self) -> Result<u32> {
> > +        // SAFETY: `gpiod_chip` is guaranteed to be valid here.
> > +        let fd = unsafe { gpiod::gpiod_chip_get_fd(self.ichip.chip) };
> > +
> > +        if fd < 0 {
> > +            Err(Error::OperationFailed(
> > +                OperationType::ChipGetFd,
> > +                errno::errno(),
> > +            ))
> > +        } else {
> > +            Ok(fd as u32)
> > +        }
> > +    }
> 
> Impl AsRawFd, as per Request.

You suggested it for line request earlier and I fixed that.

My bad for not updating this one, I completely missed that we have fd
implementation here too :(

-- 
viresh



[Index of Archives]     [Linux SPI]     [Linux Kernel]     [Linux ARM (vger)]     [Linux ARM MSM]     [Linux Omap]     [Linux Arm]     [Linux Tegra]     [Fedora ARM]     [Linux for Samsung SOC]     [eCos]     [Linux Fastboot]     [Gcc Help]     [Git]     [DCCP]     [IETF Announce]     [Security]     [Linux MIPS]     [Yosemite Campsites]

  Powered by Linux