public inbox for linux-block@vger.kernel.org
 help / color / mirror / Atom feed
From: Omar Sandoval <osandov@osandov.com>
To: Johannes Thumshirn <jthumshirn@suse.de>
Cc: Linux Block Layer Mailinglist <linux-block@vger.kernel.org>
Subject: Re: [PATCH blktests 1/2] rc: add helpers to handle PCI test devices
Date: Mon, 26 Jun 2017 14:31:39 -0700	[thread overview]
Message-ID: <20170626213139.GH6710@vader.dhcp.thefacebook.com> (raw)
In-Reply-To: <20170623142951.17189-1-jthumshirn@suse.de>

On Fri, Jun 23, 2017 at 04:29:50PM +0200, Johannes Thumshirn wrote:
> Add two helpers to check whether a device is attached via PCI and to get the
> PCI device from a TEST_DEV
> 
> Signed-off-by: Johannes Thumshirn <jthumshirn@suse.de>
> ---
>  common/rc | 15 +++++++++++++++
>  1 file changed, 15 insertions(+)
> 
> diff --git a/common/rc b/common/rc
> index b01f936b878b..497cf81ec475 100644
> --- a/common/rc
> +++ b/common/rc
> @@ -120,3 +120,18 @@ _test_dev_queue_set() {
>  	fi
>  	echo "$2" >"${TEST_DEV_SYSFS}/queue/$1"
>  }
> +
> +_test_dev_is_pci() {
> +	if ! readlink -f "$TEST_DEV_SYSFS/device" | grep -q pci; then
> +		SKIP_REASON="$TEST_DEV is not a PCI device"
> +		return 1
> +	fi
> +	return 0
> +}
> +
> +_get_pci_dev_from_blkdev() {
> +	pdev="$(readlink -f "$TEST_DEV_SYSFS/device" | \
> +		grep -Eo '[0-9a-f]{4}:[0-9a-f]{2}:[0-9a-f]{2}\.[0-9a-f]')"
> +
> +	echo "$pdev"
> +}

No need to do pdev=$(blah) and then echo $pdev, you can just do

_get_pci_dev_from_blkdev() {
	readlink -f "$TEST_DEV_SYSFS/device" | grep -Eo '[0-9a-f]{4}:[0-9a-f]{2}:[0-9a-f]{2}\.[0-9a-f]'
}

I'll fix that up when I commit it. Looks good otherwise.

      parent reply	other threads:[~2017-06-26 21:31 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-06-23 14:29 [PATCH blktests 1/2] rc: add helpers to handle PCI test devices Johannes Thumshirn
2017-06-23 14:29 ` [PATCH blktests 2/2] block/011: Perform PCI reset while doing IO Johannes Thumshirn
2017-06-23 15:36   ` Jens Axboe
2017-06-26 14:06     ` Johannes Thumshirn
2017-06-26 14:25       ` Jens Axboe
2017-06-26 21:29         ` Omar Sandoval
2017-06-26 21:45           ` Jens Axboe
2017-06-26 21:27   ` Omar Sandoval
2017-06-27  6:49     ` Johannes Thumshirn
2017-06-26 21:31 ` Omar Sandoval [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=20170626213139.GH6710@vader.dhcp.thefacebook.com \
    --to=osandov@osandov.com \
    --cc=jthumshirn@suse.de \
    --cc=linux-block@vger.kernel.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox