From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from smtp-out1.suse.de (smtp-out1.suse.de [195.135.223.130]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 7AB9E19B586 for ; Fri, 14 Mar 2025 08:17:01 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=195.135.223.130 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1741940223; cv=none; b=j3IQaC21sNsKBNv8M0fH47k1S7z0DqSWRo5+DT/xMjiFLVWwcEuVbusFmjucMtO/ouja9f88CsSzc9PeWAXbN6p9HUn8LBLuKQNDse1BFCE4ROZVJbe8CJ3Ue/AV9pKY91Sk+kV2Nux0DbgR3vBkOPzRhtwWB3TPt2kct9U52zU= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1741940223; c=relaxed/simple; bh=t5tY7oaiRw3G0ZF0sdPZeJxd1vz4nIpjBRbEQWZrp9I=; h=Message-ID:Date:MIME-Version:Subject:To:Cc:References:From: In-Reply-To:Content-Type; b=AvAsUNbvi6ma0xpRYtR9zsOIQtfq0ndKjUao2jd+9DImQzCu5PqbhqMlLC3ow7GMmj1Boo1MU9RPi5F+CUjs9sOJaDosMGWeQ013mgmiu31lwt0VZ7eSGa+7nku/t4WMvYsvFseYrZZ2hrhAkLj5Gf4uK7TWjNbrPclDpVqJVqc= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=suse.de; spf=pass smtp.mailfrom=suse.de; dkim=pass (1024-bit key) header.d=suse.de header.i=@suse.de header.b=kohQ+7J5; dkim=permerror (0-bit key) header.d=suse.de header.i=@suse.de header.b=04mBK/3L; dkim=pass (1024-bit key) header.d=suse.de header.i=@suse.de header.b=kohQ+7J5; dkim=permerror (0-bit key) header.d=suse.de header.i=@suse.de header.b=04mBK/3L; arc=none smtp.client-ip=195.135.223.130 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=suse.de Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=suse.de Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=suse.de header.i=@suse.de header.b="kohQ+7J5"; dkim=permerror (0-bit key) header.d=suse.de header.i=@suse.de header.b="04mBK/3L"; dkim=pass (1024-bit key) header.d=suse.de header.i=@suse.de header.b="kohQ+7J5"; dkim=permerror (0-bit key) header.d=suse.de header.i=@suse.de header.b="04mBK/3L" Received: from imap1.dmz-prg2.suse.org (unknown [10.150.64.97]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by smtp-out1.suse.de (Postfix) with ESMTPS id 9C3D02118D; Fri, 14 Mar 2025 08:16:59 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1741940219; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:autocrypt:autocrypt; bh=jm5lLsffcQZ17Q+pZxQSahI6cj+Ai4SV4uR5ebuFUWU=; b=kohQ+7J5muFu9/YSN19E6VDjab99l6NF7m15RSgi6rtKtbJah4ExCZe3JOFhwWLZrd6z/h cCq/bKeBAytMBAh92Ps7ehiR7hfdKaYjcsX7Cwr8GHSvp34G35qiONtBOHrXriVWMzNW1/ U3c4dedBVqohtqalWw+zx94rfb8EXgc= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1741940219; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:autocrypt:autocrypt; bh=jm5lLsffcQZ17Q+pZxQSahI6cj+Ai4SV4uR5ebuFUWU=; b=04mBK/3LIAHPZGXX4OpQ6RE0KC+fzTTlq6FzHsPTJH6mwO7DhjW4+bpGE1l9+w1+YaN9qB e8sdmkpAqOcFitCg== Authentication-Results: smtp-out1.suse.de; none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1741940219; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:autocrypt:autocrypt; bh=jm5lLsffcQZ17Q+pZxQSahI6cj+Ai4SV4uR5ebuFUWU=; b=kohQ+7J5muFu9/YSN19E6VDjab99l6NF7m15RSgi6rtKtbJah4ExCZe3JOFhwWLZrd6z/h cCq/bKeBAytMBAh92Ps7ehiR7hfdKaYjcsX7Cwr8GHSvp34G35qiONtBOHrXriVWMzNW1/ U3c4dedBVqohtqalWw+zx94rfb8EXgc= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1741940219; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:autocrypt:autocrypt; bh=jm5lLsffcQZ17Q+pZxQSahI6cj+Ai4SV4uR5ebuFUWU=; b=04mBK/3LIAHPZGXX4OpQ6RE0KC+fzTTlq6FzHsPTJH6mwO7DhjW4+bpGE1l9+w1+YaN9qB e8sdmkpAqOcFitCg== Received: from imap1.dmz-prg2.suse.org (localhost [127.0.0.1]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by imap1.dmz-prg2.suse.org (Postfix) with ESMTPS id 59F7113A31; Fri, 14 Mar 2025 08:16:59 +0000 (UTC) Received: from dovecot-director2.suse.de ([2a07:de40:b281:106:10:150:64:167]) by imap1.dmz-prg2.suse.org with ESMTPSA id tRmsFPvl02eWOgAAD6G6ig (envelope-from ); Fri, 14 Mar 2025 08:16:59 +0000 Message-ID: <9aec4ef1-7428-4630-a4af-d7448a023a60@suse.de> Date: Fri, 14 Mar 2025 09:16:58 +0100 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: [PATCH v2] fbcon: Use static attribute groups for sysfs entries To: oushixiong1025@163.com, Simona Vetter Cc: Helge Deller , Samuel Thibault , Zsolt Kajtar , =?UTF-8?Q?Thomas_Wei=C3=9Fschuh?= , linux-fbdev@vger.kernel.org, dri-devel@lists.freedesktop.org, linux-kernel@vger.kernel.org, Shixiong Ou References: <20250314060941.160048-1-oushixiong1025@163.com> Content-Language: en-US From: Thomas Zimmermann Autocrypt: addr=tzimmermann@suse.de; keydata= xsBNBFs50uABCADEHPidWt974CaxBVbrIBwqcq/WURinJ3+2WlIrKWspiP83vfZKaXhFYsdg XH47fDVbPPj+d6tQrw5lPQCyqjwrCPYnq3WlIBnGPJ4/jreTL6V+qfKRDlGLWFjZcsrPJGE0 BeB5BbqP5erN1qylK9i3gPoQjXGhpBpQYwRrEyQyjuvk+Ev0K1Jc5tVDeJAuau3TGNgah4Yc hdHm3bkPjz9EErV85RwvImQ1dptvx6s7xzwXTgGAsaYZsL8WCwDaTuqFa1d1jjlaxg6+tZsB 9GluwvIhSezPgnEmimZDkGnZRRSFiGP8yjqTjjWuf0bSj5rUnTGiyLyRZRNGcXmu6hjlABEB AAHNJ1Rob21hcyBaaW1tZXJtYW5uIDx0emltbWVybWFubkBzdXNlLmRlPsLAjgQTAQgAOAIb AwULCQgHAgYVCgkICwIEFgIDAQIeAQIXgBYhBHIX+6yM6c9jRKFo5WgNwR1TC3ojBQJftODH AAoJEGgNwR1TC3ojx1wH/0hKGWugiqDgLNXLRD/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MevcGdt38H4KSVXAylqyQOW5zvPc4/sq9c= In-Reply-To: <20250314060941.160048-1-oushixiong1025@163.com> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit X-Spam-Level: X-Spamd-Result: default: False [-4.30 / 50.00]; BAYES_HAM(-3.00)[100.00%]; NEURAL_HAM_LONG(-1.00)[-1.000]; NEURAL_HAM_SHORT(-0.20)[-1.000]; MIME_GOOD(-0.10)[text/plain]; RCVD_TLS_ALL(0.00)[]; FREEMAIL_TO(0.00)[163.com,ffwll.ch]; FREEMAIL_ENVRCPT(0.00)[163.com,gmx.de]; RCVD_VIA_SMTP_AUTH(0.00)[]; ARC_NA(0.00)[]; TO_DN_SOME(0.00)[]; MIME_TRACE(0.00)[0:+]; RCPT_COUNT_SEVEN(0.00)[10]; MID_RHS_MATCH_FROM(0.00)[]; FUZZY_BLOCKED(0.00)[rspamd.com]; FROM_HAS_DN(0.00)[]; FREEMAIL_CC(0.00)[gmx.de,ens-lyon.org,c64.rulez.org,linutronix.de,vger.kernel.org,lists.freedesktop.org,kylinos.cn]; DKIM_SIGNED(0.00)[suse.de:s=susede2_rsa,suse.de:s=susede2_ed25519]; FROM_EQ_ENVFROM(0.00)[]; TO_MATCH_ENVRCPT_ALL(0.00)[]; RCVD_COUNT_TWO(0.00)[2]; DBL_BLOCKED_OPENRESOLVER(0.00)[imap1.dmz-prg2.suse.org:helo] X-Spam-Score: -4.30 X-Spam-Flag: NO Hi Am 14.03.25 um 07:09 schrieb oushixiong1025@163.com: > From: Shixiong Ou > > Using device_create_with_groups() to simplify creation and removal. > Same as commit 1083a7be4504 ("tty: Use static attribute groups for > sysfs entries"). > > Signed-off-by: Shixiong Ou Acked-by: Thomas Zimmermann with minor comments below > --- > drivers/video/fbdev/core/fbcon.c | 69 +++++++++----------------------- > 1 file changed, 19 insertions(+), 50 deletions(-) > > diff --git a/drivers/video/fbdev/core/fbcon.c b/drivers/video/fbdev/core/fbcon.c > index 07d127110ca4..1d792bd11063 100644 > --- a/drivers/video/fbdev/core/fbcon.c > +++ b/drivers/video/fbdev/core/fbcon.c > @@ -160,7 +160,6 @@ static int info_idx = -1; > > /* console rotation */ > static int initial_rotation = -1; > -static int fbcon_has_sysfs; > static int margin_color; > > static const struct consw fb_con; > @@ -3159,7 +3158,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 +3180,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 +3202,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 +3221,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 +3246,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,35 +3280,18 @@ 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 int fbcon_init_device(void) > -{ > - int i, error = 0; > +static DEVICE_ATTR_RW(rotate); > +static DEVICE_ATTR_WO(rotate_all); > +static DEVICE_ATTR_RW(cursor_blink); Since you're changing it anyway, could you please sort these attributes alphabetically. So cursor blink should go first. It's easier to read then. > > - 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]); > - > - fbcon_has_sysfs = 0; > - } > +static struct attribute *fbcon_device_attrs[] = { > + &dev_attr_rotate.attr, > + &dev_attr_rotate_all.attr, > + &dev_attr_cursor_blink.attr, > + NULL Alphabetical sorting here as well. Best regards Thomas > +}; > > - return 0; > -} > +ATTRIBUTE_GROUPS(fbcon_device); > > #ifdef CONFIG_FRAMEBUFFER_CONSOLE_DEFERRED_TAKEOVER > static void fbcon_register_existing_fbs(struct work_struct *work) > @@ -3367,16 +3349,16 @@ void __init fb_console_init(void) > int i; > > console_lock(); > - fbcon_device = device_create(fb_class, NULL, MKDEV(0, 0), NULL, > - "fbcon"); > + fbcon_device = device_create_with_groups(fb_class, NULL, > + MKDEV(0, 0), NULL, > + fbcon_device_groups, "fbcon"); > > if (IS_ERR(fbcon_device)) { > printk(KERN_WARNING "Unable to create device " > "for fbcon; errno = %ld\n", > PTR_ERR(fbcon_device)); > fbcon_device = NULL; > - } else > - fbcon_init_device(); > + } > > for (i = 0; i < MAX_NR_CONSOLES; i++) > con2fb_map[i] = -1; > @@ -3387,18 +3369,6 @@ void __init fb_console_init(void) > > #ifdef MODULE > > -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]); > - > - fbcon_has_sysfs = 0; > - } > -} > - > void __exit fb_console_exit(void) > { > #ifdef CONFIG_FRAMEBUFFER_CONSOLE_DEFERRED_TAKEOVER > @@ -3411,7 +3381,6 @@ void __exit fb_console_exit(void) > #endif > > console_lock(); > - fbcon_deinit_device(); > device_destroy(fb_class, MKDEV(0, 0)); > > do_unregister_con_driver(&fb_con); -- -- Thomas Zimmermann Graphics Driver Developer SUSE Software Solutions Germany GmbH Frankenstrasse 146, 90461 Nuernberg, Germany GF: Ivo Totev, Andrew Myers, Andrew McDonald, Boudien Moerman HRB 36809 (AG Nuernberg)