Received: by 2002:a25:8b12:0:0:0:0:0 with SMTP id i18csp2149127ybl; Thu, 29 Aug 2019 04:21:52 -0700 (PDT) X-Google-Smtp-Source: APXvYqy0LoESSz5deZIwstXnVKqEaz7VoVi7AP8g5PSlj46uAIqmKKaAs494HDhwZ/j8T1D+SgPZ X-Received: by 2002:a17:902:12d:: with SMTP id 42mr9423492plb.125.1567077712850; Thu, 29 Aug 2019 04:21:52 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1567077712; cv=none; d=google.com; s=arc-20160816; b=gw54K0VJa7kozin+vRu1r3In08p3g5UdfZZ5mIAoRK9VFzCeDuHdPjlCQ7/c/khkb6 Gk3O2Jf+Qi2uZRGsQUGHu9nRC5FIIjXgEsbcUsKwDfeI2ppUyZO7VNVNF+DdxzTREWWm yezJd2gRQ++JjY/vGib//5OjWhPDiEhv4C5NX25G06XsQYJ0xuW8qmcX7MCnVRPcwkHs pfNj28L/I1RbkIz9fBVokGr0MOTxYpFCHUomW9syPZZ+kCSsCHUEzds7k1pkDJEINEDd cOkkVKHcl7vWiTIXm2L0KWSz+ZBcv7nDw/14mDLqNO+k4WXm8mUWCFud8j4SyfXvt9ew 3Ebw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from; bh=bGVOjHDh0Pi5GSp0ZuzJLyXzIAh7CDz47eF/32iM6Zs=; b=y6m06SXRSq9bmSMyOulDO00Mib1oWyc916rr92D5hGwLTtjvqscg7bqAk+k591D424 i/dUGTzXhoVEbfQ5/X6th5Z9wEpOibTcmcd4+8SvDhpN7drM4o5wE53LXhoG9K4RtG0I v1gzJYK6BI6fhUyU3WIYxEyWE3YEtayOpvT/EqkcoFudzZkGEFBiBSnhrN0h5vsJD8xQ yz+K3xsmM/t1yhz/VH3YyKeKPoW0J6NNLARUS+un58rJ9RHPbpka505OgEdszZ415378 TDJL6GsPfoeMbuxhsgcd36SmW8BvtSXSawvVekYQEwzcPIWAP0GvIe1pGH1pxr1bVEkh 6zTA== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=mellanox.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id x185si1825236pgb.161.2019.08.29.04.21.37; Thu, 29 Aug 2019 04:21:52 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=mellanox.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728433AbfH2LUE (ORCPT + 99 others); Thu, 29 Aug 2019 07:20:04 -0400 Received: from mail-il-dmz.mellanox.com ([193.47.165.129]:43768 "EHLO mellanox.co.il" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1728176AbfH2LTT (ORCPT ); Thu, 29 Aug 2019 07:19:19 -0400 Received: from Internal Mail-Server by MTLPINE1 (envelope-from parav@mellanox.com) with ESMTPS (AES256-SHA encrypted); 29 Aug 2019 14:19:17 +0300 Received: from sw-mtx-036.mtx.labs.mlnx (sw-mtx-036.mtx.labs.mlnx [10.12.150.149]) by labmailer.mlnx (8.13.8/8.13.8) with ESMTP id x7TBJ8v4020002; Thu, 29 Aug 2019 14:19:15 +0300 From: Parav Pandit To: alex.williamson@redhat.com, jiri@mellanox.com, kwankhede@nvidia.com, cohuck@redhat.com, davem@davemloft.net Cc: kvm@vger.kernel.org, linux-kernel@vger.kernel.org, netdev@vger.kernel.org, Parav Pandit Subject: [PATCH v2 3/6] mdev: Expose mdev alias in sysfs tree Date: Thu, 29 Aug 2019 06:19:01 -0500 Message-Id: <20190829111904.16042-4-parav@mellanox.com> X-Mailer: git-send-email 2.19.2 In-Reply-To: <20190829111904.16042-1-parav@mellanox.com> References: <20190826204119.54386-1-parav@mellanox.com> <20190829111904.16042-1-parav@mellanox.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Expose the optional alias for an mdev device as a sysfs attribute. This way, userspace tools such as udev may make use of the alias, for example to create a netdevice name for the mdev. Signed-off-by: Parav Pandit --- Changelog: v0->v1: - Addressed comments from Cornelia Huck - Updated commit description --- drivers/vfio/mdev/mdev_sysfs.c | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/drivers/vfio/mdev/mdev_sysfs.c b/drivers/vfio/mdev/mdev_sysfs.c index 43afe0e80b76..59f4e3cc5233 100644 --- a/drivers/vfio/mdev/mdev_sysfs.c +++ b/drivers/vfio/mdev/mdev_sysfs.c @@ -246,7 +246,20 @@ static ssize_t remove_store(struct device *dev, struct device_attribute *attr, static DEVICE_ATTR_WO(remove); +static ssize_t alias_show(struct device *device, + struct device_attribute *attr, char *buf) +{ + struct mdev_device *dev = mdev_from_dev(device); + + if (!dev->alias) + return -EOPNOTSUPP; + + return sprintf(buf, "%s\n", dev->alias); +} +static DEVICE_ATTR_RO(alias); + static const struct attribute *mdev_device_attrs[] = { + &dev_attr_alias.attr, &dev_attr_remove.attr, NULL, }; -- 2.19.2