Received: by 2002:a05:6a11:4021:0:0:0:0 with SMTP id ky33csp2944300pxb; Sun, 26 Sep 2021 00:17:45 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzLdNoEXv4IzigTrDKSwDXAKGBD2jyF4hbk/ubb85JVoo19o3v6rtWVTZgPMXLM6WPdDAi0 X-Received: by 2002:a05:6638:380f:: with SMTP id i15mr3197352jav.8.1632640665514; Sun, 26 Sep 2021 00:17:45 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1632640665; cv=none; d=google.com; s=arc-20160816; b=gdRvbtPaOH/HoUxyU4K2ryuy7CYbSboej31IOhdQZXnc64d/awzzopWaOy8xzGIii5 Myx6jiVwUwOtbJ/c3NPx/bp6INznrm/nqHUb88zIV729goGtuAgoDR5M8yj0uuBvAhAi 1P+K+V27KwCLNyUw0gsDZDgycHRXcpuQjtS4z1legsV4ahp7QO8NW7jtEBj6zQRF15RF kMmG+5Fb4EZVUxB1BQa91GeIHKCreZn3+U1DENShmfRDB5Gn67UFCVHtPYSPGOGZtucg CQQK3V+veCelIKpsbhQzmBG0OBdHvV1RQZ2GEoWh5ywC2GgEyttfBGe3G90PKxHg+RcW ZH3g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :message-id:date:subject:cc:to:from; bh=fme9h69zK593h9CIRwDOuhMVznkiprdDwzSR2H3i16U=; b=Uf8MxGKH8qQxtlgCIR+KXdvIYMKVJB09pYE85U5ufmTYmCheA3nDM7h1Og3Y9ycocg bRSdLY0ypthAbwqI+SAH/1eB75GggWo5sOUtqqVl6S9ggktcHIRiWCPzC80zrqukgns9 hkOI+POErjqBlZIn1odsqpCErCJtXOqse9E3Eq3/1VH/BQc3w2zUq+UnK9+Jd5S7ypfi TaRQ5xBbC17DYMNhbmg/lq64HSfoPnCOHHOE86RWv+cMTA++H8Udsby1CF7t7O3sV/Xe aULbmE40/A2LW97eAB4r8/RgT9ZbxLTGxLQZK0dbWRd+j9GqARWd/ddSpSBAuV0HG83i sULA== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id w8si15372129jaa.127.2021.09.26.00.17.34; Sun, 26 Sep 2021 00:17:45 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231185AbhIZHR2 (ORCPT + 99 others); Sun, 26 Sep 2021 03:17:28 -0400 Received: from mailgw.kylinos.cn ([123.150.8.42]:58471 "EHLO nksmu.kylinos.cn" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S230035AbhIZHR2 (ORCPT ); Sun, 26 Sep 2021 03:17:28 -0400 X-UUID: 9b0812a5c71b4ad6bae7ac3a6100c2eb-20210926 X-CPASD-INFO: c744725bb5a6427f8a56ed2deac424f9@rIduVGRkY5KOVaOCg3WCoFiSZWaVkFK zp5uDZGBkklmVhH5xTWJsXVKBfG5QZWNdYVN_eGpQYl9gZFB5i3-XblBgXoZgUZB3snluVGdgZQ== X-CPASD-FEATURE: 0.0 X-CLOUD-ID: c744725bb5a6427f8a56ed2deac424f9 X-CPASD-SUMMARY: SIP:-1,APTIP:-2.0,KEY:0.0,FROMBLOCK:1,EXT:0.0,OB:0.0,URL:-5,T VAL:196.0,ESV:0.0,ECOM:-5.0,ML:0.0,FD:0.0,CUTS:174.0,IP:-2.0,MAL:0.0,ATTNUM:0 .0,PHF:-5.0,PHC:-5.0,SPF:4.0,EDMS:-3,IPLABEL:4480.0,FROMTO:0,AD:0,FFOB:0.0,CF OB:0.0,SPC:0.0,SIG:-5,AUF:3,DUF:14612,ACD:53,DCD:155,SL:0,AG:0,CFC:0.644,CFSR :0.029,UAT:0,RAF:0,VERSION:2.3.4 X-CPASD-ID: 9b0812a5c71b4ad6bae7ac3a6100c2eb-20210926 X-CPASD-BLOCK: 1000 X-CPASD-STAGE: 1, 1 X-UUID: 9b0812a5c71b4ad6bae7ac3a6100c2eb-20210926 X-User: lizhenneng@kylinos.cn Received: from localhost.localdomain [(116.128.244.169)] by nksmu.kylinos.cn (envelope-from ) (Generic MTA) with ESMTP id 1290208314; Sun, 26 Sep 2021 15:12:58 +0800 From: Zhenneng Li To: Bjorn Helgaas Cc: linux-pci@vger.kernel.org, linux-kernel@vger.kernel.org, Zhenneng Li Subject: [PATCH] PCI/sysfs: add write attribute for boot_vga Date: Sun, 26 Sep 2021 15:15:39 +0800 Message-Id: <20210926071539.636644-1-lizhenneng@kylinos.cn> X-Mailer: git-send-email 2.25.1 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Add writing attribute for boot_vga sys node, so we can config default video display output dynamically when there are two video cards on a machine. Xorg server will determine running on which video card based on boot_vga node's value. Signed-off-by: Zhenneng Li --- drivers/pci/pci-sysfs.c | 24 +++++++++++++++++++++++- 1 file changed, 23 insertions(+), 1 deletion(-) diff --git a/drivers/pci/pci-sysfs.c b/drivers/pci/pci-sysfs.c index 7bbf2673c7f2..a6ba19ce7adb 100644 --- a/drivers/pci/pci-sysfs.c +++ b/drivers/pci/pci-sysfs.c @@ -664,7 +664,29 @@ static ssize_t boot_vga_show(struct device *dev, struct device_attribute *attr, !!(pdev->resource[PCI_ROM_RESOURCE].flags & IORESOURCE_ROM_SHADOW)); } -static DEVICE_ATTR_RO(boot_vga); + +static ssize_t boot_vga_store(struct device *dev, struct device_attribute *attr, + const char *buf, size_t count) +{ + unsigned long val; + struct pci_dev *pdev = to_pci_dev(dev); + struct pci_dev *vga_dev = vga_default_device(); + + if (kstrtoul(buf, 0, &val) < 0) + return -EINVAL; + + if (val != 1) + return -EINVAL; + + if (!capable(CAP_SYS_ADMIN)) + return -EPERM; + + if (pdev != vga_dev) + vga_set_default_device(pdev); + + return count; +} +static DEVICE_ATTR_RW(boot_vga); static ssize_t pci_read_config(struct file *filp, struct kobject *kobj, struct bin_attribute *bin_attr, char *buf, -- 2.25.1 No virus found Checked by Hillstone Network AntiVirus