Received: by 2002:a25:8b12:0:0:0:0:0 with SMTP id i18csp5967408ybl; Tue, 27 Aug 2019 12:19:19 -0700 (PDT) X-Google-Smtp-Source: APXvYqz3OCqFjyLIrNwmi5ZTd/jHvU4X0ABDy8DXMxy4yTY7e0UEWrDDU+q8v8WJ0fzqpKZg1sIn X-Received: by 2002:a62:24a:: with SMTP id 71mr11843pfc.148.1566933559442; Tue, 27 Aug 2019 12:19:19 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1566933559; cv=none; d=google.com; s=arc-20160816; b=QXyjMcUvTTXv17DGWGJiy2dhHJMb2O9vIm+NQ6tEznwBN1ktearrfEz4urhygkEJ4k 4Vi2MZUfd/2T0UF80FCkWvOS4zWnr49Nmm6sGiILMHyMQJoczCKXnMJGsIjckVc9ybKz nJDQvqIn/OHpayX8tSrjEzIk0MzsNKI/UzZkX/uIPKCsK/xRwjqJO9xg4nxujQzra9sG GakI0F14G9UJjqaR/aQTHV0ircRWiiaPZG60ZBrZEEPtk052LbnvtuCMd3S/Ui9SKTFo c6oABj8lbx3g8hRxDtXNSZKTxleHHNu/TnyOdno8T4O1z1mJESGbJnOD2wmVHbBodu9K vMTQ== 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=WQquJf3ipSDEW8B9OdQlPBMHFCJq8lA6pK0tfpRZ63Ktiojk0HU/gV86cSMAV7SY+k 3CM6QQApjImOwsCjXpHzWlrAjlvNhMSEDbiI04DZqBTomP+qifXXhxzLha2wE88iRYgA mbwN/HH0XzMjo8bbG0JEe+I9cGLbMd6ZSDVHGo5JqLyWxQYXY3m8jc68tr/AjB+3U4na JS3eFIpJkim+DEprxZJZTaKJzvPfclCpVuTormI8g4KUIgEIsoKsD7ikaKsrI/NtQHV4 qHtHqAUisJlSZESzuTQZV7j3KK2TImASsWNGrB3K4Jd2NG0Zax/iQ6+VaPyjHGmtMpnc dLpQ== 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 f9si9371804plo.306.2019.08.27.12.19.04; Tue, 27 Aug 2019 12:19:19 -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 S1731028AbfH0TRJ (ORCPT + 99 others); Tue, 27 Aug 2019 15:17:09 -0400 Received: from mail-il-dmz.mellanox.com ([193.47.165.129]:38883 "EHLO mellanox.co.il" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1730962AbfH0TRI (ORCPT ); Tue, 27 Aug 2019 15:17:08 -0400 Received: from Internal Mail-Server by MTLPINE1 (envelope-from parav@mellanox.com) with ESMTPS (AES256-SHA encrypted); 27 Aug 2019 22:17:05 +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 x7RJGuGt026842; Tue, 27 Aug 2019 22:17:03 +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 v1 3/5] mdev: Expose mdev alias in sysfs tree Date: Tue, 27 Aug 2019 14:16:52 -0500 Message-Id: <20190827191654.41161-4-parav@mellanox.com> X-Mailer: git-send-email 2.19.2 In-Reply-To: <20190827191654.41161-1-parav@mellanox.com> References: <20190826204119.54386-1-parav@mellanox.com> <20190827191654.41161-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