All of lore.kernel.org
 help / color / mirror / Atom feed
From: "Ville Syrjälä" <ville.syrjala@linux.intel.com>
To: Chris Wilson <chris@chris-wilson.co.uk>, intel-gfx@lists.freedesktop.org
Subject: Re: [PATCH igt v3] lib: Add simple sysfs accessors
Date: Mon, 30 May 2016 17:45:16 +0300	[thread overview]
Message-ID: <20160530144516.GK4329@intel.com> (raw)
In-Reply-To: <20160527180727.GF19380@nuc-i3427.alporthouse.com>

On Fri, May 27, 2016 at 07:07:27PM +0100, Chris Wilson wrote:
> On Fri, May 27, 2016 at 08:46:14PM +0300, Ville Syrjälä wrote:
> > > +	for (int n = 0; n < 16; n++) {
> > > +		int len = sprintf(path, "/sys/class/drm/card%d", n);
> > > +		if (device[0]) {
> > > +			char tmp[80];
> > > +			int ret;
> > > +
> > > +			sprintf(path + len, "/dev");
> > > +			fd = open(path, O_RDONLY);
> > > +			if (fd == -1)
> > > +				continue;
> > > +
> > > +			ret = read(fd, tmp, sizeof(tmp-1));
> > > +			if (ret < 0)
> > > +				ret = 0;
> > > +			tmp[ret] = '\0';
> > > +			while (ret > 0 && tmp[ret-1] == '\n')
> > > +				tmp[--ret] = '\0';
> > > +			close(fd);
> > > +
> > > +			if (strcmp(tmp, device))
> > > +				continue;
> > 
> > fscanf?
> 
>                 if (fd != -1) {
>                         FILE *file;
>                         int ret, maj, min;
> 
>                         sprintf(path + len, "/dev");
>                         file = fopen(path, "r");
>                         if (!file)
>                                 continue;
> 
>                         ret = fscanf(file, "%d:%d", &maj, &min);
>                         fclose(file);
> 
>                         if (ret != 2 ||
>                             major(st.st_rdev) != maj ||
>                             minor(st.st_rdev) != min)
>                                 continue;

lgtm

-- 
Ville Syrjälä
Intel OTC
_______________________________________________
Intel-gfx mailing list
Intel-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/intel-gfx

      reply	other threads:[~2016-05-30 14:45 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-05-26 14:14 [PATCH igt 1/2] lib: Add simple sysfs accessors Chris Wilson
2016-05-26 14:14 ` [PATCH igt 2/2] lib: Override the connector status using the sysfs status attribute Chris Wilson
2016-05-26 14:39   ` Ville Syrjälä
2016-05-26 14:55     ` Chris Wilson
2016-05-26 14:36 ` [PATCH igt 1/2] lib: Add simple sysfs accessors Ville Syrjälä
2016-05-26 14:50   ` Chris Wilson
2016-05-26 15:07 ` [PATCH igt v2 " Chris Wilson
2016-05-26 15:07   ` [PATCH igt v2 2/2] lib: Override the connector status using the sysfs status attribute Chris Wilson
2016-05-26 16:19   ` [PATCH igt v3] lib: Add simple sysfs accessors Chris Wilson
2016-05-27 17:46     ` Ville Syrjälä
2016-05-27 18:07       ` Chris Wilson
2016-05-30 14:45         ` Ville Syrjälä [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20160530144516.GK4329@intel.com \
    --to=ville.syrjala@linux.intel.com \
    --cc=chris@chris-wilson.co.uk \
    --cc=intel-gfx@lists.freedesktop.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.