[Intel-gfx] [PATCH igt 1/2] lib: Add simple sysfs accessors

Chris Wilson chris at chris-wilson.co.uk
Thu May 26 14:50:10 UTC 2016


On Thu, May 26, 2016 at 05:36:09PM +0300, Ville Syrjälä wrote:
> > +
> > +	for (int n = 0; n < 16; n++) {
> > +		int len = sprintf(path, "/sys/class/drm/card%d", n);
> > +		sprintf(path + len, "/error");
> 
> That's goint to limit this to i915. I was thinking we could pass
> the drm_fd here to find the correct minor for it.

Hah, I was rewriting it to avoid the i915 presumption. Using fstat and
comparing sysfs/cardN/dev is what I went with. Pretty much equivalent to
drmGetDeviceNameFromFd(), yes.

> > +bool igt_sysfs_set(const char *filename, const char *value)
> > +{
> > +	int sysfs = __igt_sysfs_singleton();
> > +	int fd, len, ret;
> > +
> > +	if (sysfs < 0)
> > +		return false;
> > +
> > +	fd = openat(sysfs, filename, O_WRONLY);
> > +	if (fd < 0)
> > +		return false;
> > +
> > +	len = strlen(value);
> > +	ret = write(fd, value, len);
> 
> EINTR?

Pesky signals.
-Chris

-- 
Chris Wilson, Intel Open Source Technology Centre


More information about the Intel-gfx mailing list