From patchwork Tue Mar 11 11:28:55 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Shixiong Ou X-Patchwork-Id: 14011534 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 8086AC28B2E for ; Tue, 11 Mar 2025 11:29:38 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 0034110E153; Tue, 11 Mar 2025 11:29:35 +0000 (UTC) Authentication-Results: gabe.freedesktop.org; dkim=pass (1024-bit key; unprotected) header.d=163.com header.i=@163.com header.b="f1qEfRNR"; dkim-atps=neutral Received: from m16.mail.163.com (m16.mail.163.com [117.135.210.5]) by gabe.freedesktop.org (Postfix) with ESMTP id 0EE5310E153 for ; Tue, 11 Mar 2025 11:29:32 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=163.com; s=s110527; h=From:Subject:Date:Message-Id:MIME-Version; bh=OpVqw PZqQYS/kR7eqAKdqdgZQ7qL42uA6b+mtlz2PfA=; b=f1qEfRNRtu41fPPfnoGcU VCEgNkY/t5NIUZGwxVCECKtQnNBEjuWTp1jJxJ4EzgYH3fB4xcoODhZ5oCjmqh/a HnU3i7tBZglBFU2hJRfT75V8a/jJwpVCr6vcNx//H//Ml8qQEo58tlBIHU2e7/3B Bk8ne+PCcVP8/cnVZBtJ3Y= Received: from localhost.localdomain (unknown []) by gzga-smtp-mtada-g0-2 (Coremail) with SMTP id _____wCH0Ct6HtBna0J3Rw--.58446S2; Tue, 11 Mar 2025 19:29:00 +0800 (CST) From: oushixiong1025@163.com To: Simona Vetter Cc: Helge Deller , Thomas Zimmermann , Samuel Thibault , Zsolt Kajtar , linux-fbdev@vger.kernel.org, dri-devel@lists.freedesktop.org, linux-kernel@vger.kernel.org, Shixiong Ou Subject: [PATCH 1/2] fbcon: Register sysfs groups through device_add_group Date: Tue, 11 Mar 2025 19:28:55 +0800 Message-Id: <20250311112856.1020095-1-oushixiong1025@163.com> X-Mailer: git-send-email 2.25.1 MIME-Version: 1.0 X-CM-TRANSID: _____wCH0Ct6HtBna0J3Rw--.58446S2 X-Coremail-Antispam: 1Uf129KBjvJXoWxCFy7uF4fJFykZrWfXF1UWrg_yoW5KF4kpr 4DJa4YgFW5G3ZrWw43uw4DZ3sxWwn2k34fJws5Kw1fKFn7A3sIqa48JFyjya4rtF97GF1f Ja4qyry8AFWxWr7anT9S1TB71UUUUU7qnTZGkaVYY2UrUUUUjbIjqfuFe4nvWSU5nxnvy2 9KBjDUYxBIdaVFxhVjvjDU0xZFpf9x07jnID7UUUUU= X-Originating-IP: [116.128.244.169] X-CM-SenderInfo: xrxvxxx0lr0wirqskqqrwthudrp/1tbiXBgND2fQGIlhsAAAsx X-BeenThere: dri-devel@lists.freedesktop.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Direct Rendering Infrastructure - Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" From: Shixiong Ou Use device_add_group() to simplify creation and removal. Signed-off-by: Shixiong Ou --- drivers/video/fbdev/core/fbcon.c | 48 +++++++++++++++----------------- 1 file changed, 22 insertions(+), 26 deletions(-) diff --git a/drivers/video/fbdev/core/fbcon.c b/drivers/video/fbdev/core/fbcon.c index 07d127110ca4..51c3e8a5a092 100644 --- a/drivers/video/fbdev/core/fbcon.c +++ b/drivers/video/fbdev/core/fbcon.c @@ -3159,7 +3159,7 @@ static const struct consw fb_con = { .con_debug_leave = fbcon_debug_leave, }; -static ssize_t store_rotate(struct device *device, +static ssize_t rotate_store(struct device *device, struct device_attribute *attr, const char *buf, size_t count) { @@ -3181,7 +3181,7 @@ static ssize_t store_rotate(struct device *device, return count; } -static ssize_t store_rotate_all(struct device *device, +static ssize_t rotate_all_store(struct device *device, struct device_attribute *attr,const char *buf, size_t count) { @@ -3203,7 +3203,7 @@ static ssize_t store_rotate_all(struct device *device, return count; } -static ssize_t show_rotate(struct device *device, +static ssize_t rotate_show(struct device *device, struct device_attribute *attr,char *buf) { struct fb_info *info; @@ -3222,7 +3222,7 @@ static ssize_t show_rotate(struct device *device, return sysfs_emit(buf, "%d\n", rotate); } -static ssize_t show_cursor_blink(struct device *device, +static ssize_t cursor_blink_show(struct device *device, struct device_attribute *attr, char *buf) { struct fb_info *info; @@ -3247,7 +3247,7 @@ static ssize_t show_cursor_blink(struct device *device, return sysfs_emit(buf, "%d\n", blink); } -static ssize_t store_cursor_blink(struct device *device, +static ssize_t cursor_blink_store(struct device *device, struct device_attribute *attr, const char *buf, size_t count) { @@ -3281,32 +3281,30 @@ static ssize_t store_cursor_blink(struct device *device, return count; } -static struct device_attribute device_attrs[] = { - __ATTR(rotate, S_IRUGO|S_IWUSR, show_rotate, store_rotate), - __ATTR(rotate_all, S_IWUSR, NULL, store_rotate_all), - __ATTR(cursor_blink, S_IRUGO|S_IWUSR, show_cursor_blink, - store_cursor_blink), +static DEVICE_ATTR_RW(rotate); +static DEVICE_ATTR_WO(rotate_all); +static DEVICE_ATTR_RW(cursor_blink); + +static struct attribute *fbcon_device_attrs[] = { + &dev_attr_rotate.attr, + &dev_attr_rotate_all.attr, + &dev_attr_cursor_blink.attr, + NULL, +}; + +static const struct attribute_group fbcon_device_attr_group = { + .attrs = fbcon_device_attrs, }; static int fbcon_init_device(void) { - int i, error = 0; + int ret; fbcon_has_sysfs = 1; - for (i = 0; i < ARRAY_SIZE(device_attrs); i++) { - error = device_create_file(fbcon_device, &device_attrs[i]); - - if (error) - break; - } - - if (error) { - while (--i >= 0) - device_remove_file(fbcon_device, &device_attrs[i]); - + ret = device_add_group(fbcon_device, &fbcon_device_attr_group); + if (ret) fbcon_has_sysfs = 0; - } return 0; } @@ -3389,11 +3387,9 @@ void __init fb_console_init(void) static void __exit fbcon_deinit_device(void) { - int i; if (fbcon_has_sysfs) { - for (i = 0; i < ARRAY_SIZE(device_attrs); i++) - device_remove_file(fbcon_device, &device_attrs[i]); + device_remove_group(fb_info->dev, &fbcon_device_attr_group); fbcon_has_sysfs = 0; } From patchwork Tue Mar 11 11:28:56 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Shixiong Ou X-Patchwork-Id: 14011533 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 44AA9C282EC for ; Tue, 11 Mar 2025 11:29:36 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 7EC1E10E013; Tue, 11 Mar 2025 11:29:35 +0000 (UTC) Authentication-Results: gabe.freedesktop.org; dkim=pass (1024-bit key; unprotected) header.d=163.com header.i=@163.com header.b="oeO82pSr"; dkim-atps=neutral Received: from m16.mail.163.com (m16.mail.163.com [117.135.210.3]) by gabe.freedesktop.org (Postfix) with ESMTP id EAF3510E013 for ; Tue, 11 Mar 2025 11:29:32 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=163.com; s=s110527; h=From:Subject:Date:Message-Id:MIME-Version; bh=SM9Ub Ll72nXfMLjNLt6sWlifM6ckJcGNSdk6TeIigO4=; b=oeO82pSr0V+mkKe+cTj6F MtKUCbiTBEjXEhQ8WTR78xGJ2VyPl/i8KE96XN1VKpHEW/zeB3nNHa5BNbwZiejs dQkzRtzoWY5DumqMnCHJlGk/QYyJHXFiFmHfuENJ1b87RVICPqoBgY77Accxm50K RrYLHXluzk4EKo4TiTDgoM= Received: from localhost.localdomain (unknown []) by gzga-smtp-mtada-g0-2 (Coremail) with SMTP id _____wCH0Ct6HtBna0J3Rw--.58446S3; Tue, 11 Mar 2025 19:29:04 +0800 (CST) From: oushixiong1025@163.com To: Simona Vetter Cc: Helge Deller , Thomas Zimmermann , Samuel Thibault , Zsolt Kajtar , linux-fbdev@vger.kernel.org, dri-devel@lists.freedesktop.org, linux-kernel@vger.kernel.org, Shixiong Ou Subject: [PATCH 2/2] fbcon: Change return value type to void Date: Tue, 11 Mar 2025 19:28:56 +0800 Message-Id: <20250311112856.1020095-2-oushixiong1025@163.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20250311112856.1020095-1-oushixiong1025@163.com> References: <20250311112856.1020095-1-oushixiong1025@163.com> MIME-Version: 1.0 X-CM-TRANSID: _____wCH0Ct6HtBna0J3Rw--.58446S3 X-Coremail-Antispam: 1Uf129KBjvdXoWrZFWDurykCw4kAFyDAFyfXrb_yoWftrc_Cw 1DZr95XrykKry0kwnag3W3u3yYqa12qa1rGr1DtF95Ja47tryFqr4DZr1qqrWqgF18ArZ0 q3Zrtr4Ivw1rCjkaLaAFLSUrUUUUjb8apTn2vfkv8UJUUUU8Yxn0WfASr-VFAUDa7-sFnT 9fnUUvcSsGvfC2KfnxnUUI43ZEXa7IU0xOz7UUUUU== X-Originating-IP: [116.128.244.169] X-CM-SenderInfo: xrxvxxx0lr0wirqskqqrwthudrp/1tbiXBgND2fQGIlhsAABsw X-BeenThere: dri-devel@lists.freedesktop.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Direct Rendering Infrastructure - Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" From: Shixiong Ou fbcon_init_device() doesn't need to return a value. Signed-off-by: Shixiong Ou --- drivers/video/fbdev/core/fbcon.c | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/drivers/video/fbdev/core/fbcon.c b/drivers/video/fbdev/core/fbcon.c index 51c3e8a5a092..c1692b68f69e 100644 --- a/drivers/video/fbdev/core/fbcon.c +++ b/drivers/video/fbdev/core/fbcon.c @@ -3296,7 +3296,7 @@ static const struct attribute_group fbcon_device_attr_group = { .attrs = fbcon_device_attrs, }; -static int fbcon_init_device(void) +static void fbcon_init_device(void) { int ret; @@ -3305,8 +3305,6 @@ static int fbcon_init_device(void) ret = device_add_group(fbcon_device, &fbcon_device_attr_group); if (ret) fbcon_has_sysfs = 0; - - return 0; } #ifdef CONFIG_FRAMEBUFFER_CONSOLE_DEFERRED_TAKEOVER