From patchwork Tue Dec 19 13:34:46 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Greg KH X-Patchwork-Id: 180944 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:7300:24d3:b0:fb:cd0c:d3e with SMTP id r19csp1939484dyi; Tue, 19 Dec 2023 05:35:18 -0800 (PST) X-Google-Smtp-Source: AGHT+IGA6btWH6MOsOmSd2IrAF8e5o8pJhNNwodyah+teLa1jiclh2YxZJsjvRCx8LT3vu24Qg9F X-Received: by 2002:a17:902:f689:b0:1d3:b35e:7b0e with SMTP id l9-20020a170902f68900b001d3b35e7b0emr5140207plg.57.1702992918659; Tue, 19 Dec 2023 05:35:18 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1702992918; cv=none; d=google.com; s=arc-20160816; b=ubBFwH9fKCKiTQHUtFdWrDPpmWxWmC4QUtARJ8bRiC57zQas0PtyatZNKICJ4qChZd qVDwz5WIdtGvIAbvr70apCceNXNWTziU8oBdcFRFQu94kkEBoWw8mU6JoQAMrUgo+PWF HmkIIbc5oeHKNJU3GeYdgTLYY/YakNTCpqaYaXsXK6y1WUItgAZm38jJob0nGcmVWIqA A6srOAsg08PmOVIo3uL5M5/1OdJ3cxExKCbT8GPor4V0xO5Me433SDBbFD9EOGX/7hra iinyEPxASFZqvioWauo9n3mQdbxQJJZ57alMcmnITINhu6zKjH+Z3RJ+/sM7WVM22vAL CfiA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:lines:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:message-id:date:subject:cc:to :from:dkim-signature; bh=DXt3nV0hO2rfzvaZF0CuEXtkrARoLnBE68NO+SkbA3g=; fh=rGJpmjVY/uvn4rwm4TqoSQjbOFnGUCmUBu4bAc0o4Ks=; b=CKIGkdmlTZ7ZoJYIahFBkizVj+56kyWmjf5OYGzEN8YKGnCI5sW/Yz8mFHdPfB/lTf tsYSDNWhB+fG7yCPWWMsLBf6Hp9UwEtj1JwLvr0r9YL6TnH4lgANtw9v6nWjSQs6mkEm fIvcVz6+9Brr8a/hjKdNfW56gRy+Pp1fSL9MhLyLX9GVDx93rnSmMIBP8Faga8+3Pv5R hPEH7nlXIYuXzSAreogJ6Do0KOOlHV1TTs+q7wrq7zdruYhI7J2vjwAInMtko1+9HuA2 SYZ40qy2cJIrH4U+J6Q5o77sg5X9c1mk0L8df8lcC/Gy0j3/CbK9ar9q9BunPwsQoVIv GLUQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=Zxutq3kV; spf=pass (google.com: domain of linux-kernel+bounces-5266-ouuuleilei=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) smtp.mailfrom="linux-kernel+bounces-5266-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: from sv.mirrors.kernel.org (sv.mirrors.kernel.org. [139.178.88.99]) by mx.google.com with ESMTPS id jw2-20020a170903278200b001d3c45e0e3csi2727945plb.343.2023.12.19.05.35.18 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 19 Dec 2023 05:35:18 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-5266-ouuuleilei=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) client-ip=139.178.88.99; Authentication-Results: mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=Zxutq3kV; spf=pass (google.com: domain of linux-kernel+bounces-5266-ouuuleilei=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) smtp.mailfrom="linux-kernel+bounces-5266-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by sv.mirrors.kernel.org (Postfix) with ESMTPS id 71FD628121F for ; Tue, 19 Dec 2023 13:35:18 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 76FCE19BDE; Tue, 19 Dec 2023 13:34:56 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b="Zxutq3kV" X-Original-To: linux-kernel@vger.kernel.org Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 8678B1BDD5; Tue, 19 Dec 2023 13:34:53 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 58F42C433C8; Tue, 19 Dec 2023 13:34:52 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1702992892; bh=IRSSHnu68I519nHuE1LCsW+t+yzsh069i/48dm7XrHQ=; h=From:To:Cc:Subject:Date:From; b=Zxutq3kVVurVLsiVmh8WHxeIwJ8taDRvmjv6ieT3MwVqbFV56ys1kdij2jJC12ngr b6VmlvjFuVFcsXbpt8ngK1PKoUl5emAWZ3Fpk8XQnr7AXV1t8Zk+RFRVV1ehzGW0mn IkYPQt9ypkpoOudg0TaB/WWqGbaQHBZZx4Wddko4= From: Greg Kroah-Hartman To: tiwai@suse.com, perex@perex.cz Cc: linux-sound@vger.kernel.org, linux-kernel@vger.kernel.org, Greg Kroah-Hartman , Dawei Li , Yu Liao , "Rafael J. Wysocki" , Hans de Goede Subject: [PATCH] ALSA: mark all struct bus_type as const Date: Tue, 19 Dec 2023 14:34:46 +0100 Message-ID: <2023121945-immersion-budget-d0aa@gregkh> X-Mailer: git-send-email 2.43.0 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Lines: 92 X-Developer-Signature: v=1; a=openpgp-sha256; l=3244; i=gregkh@linuxfoundation.org; h=from:subject:message-id; bh=IRSSHnu68I519nHuE1LCsW+t+yzsh069i/48dm7XrHQ=; b=owGbwMvMwCRo6H6F97bub03G02pJDKmNs7+23U55/0hZacGkT5lTJp+JbBD/4LlqS98suQk/f NIUT7v5dsSyMAgyMciKKbJ82cZzdH/FIUUvQ9vTMHNYmUCGMHBxCsBEkgMZFsxPlt22Ufld58Io Pr6tV3Kb4tUENzDM4Xq+W2rd+r8Wy10Ovim+npd36+i3pQA= X-Developer-Key: i=gregkh@linuxfoundation.org; a=openpgp; fpr=F4B60CC5BF78C2214A313DCB3147D40DDB2DFB29 X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1785717502991740045 X-GMAIL-MSGID: 1785717502991740045 Now that the driver core can properly handle constant struct bus_type, move all of the sound subsystem struct bus_type structures as const, placing them into read-only memory which can not be modified at runtime. Note, this fixes a duplicate definition of ac97_bus_type, which somehow was declared extern in a .h file, and then static as a prototype in a .c file, and then properly later on in the same .c file. Amazing that no compiler warning ever showed up for this. Cc: Jaroslav Kysela Cc: Takashi Iwai Cc: Dawei Li Cc: Yu Liao Cc: "Rafael J. Wysocki" Cc: Hans de Goede Cc: linux-sound@vger.kernel.org Signed-off-by: Greg Kroah-Hartman --- include/sound/ac97_codec.h | 2 +- include/sound/hdaudio.h | 2 +- sound/ac97/bus.c | 2 -- sound/ac97_bus.c | 2 +- sound/hda/hda_bus_type.c | 2 +- 5 files changed, 4 insertions(+), 6 deletions(-) diff --git a/include/sound/ac97_codec.h b/include/sound/ac97_codec.h index c495c6d5fbe0..4bd3be3a3192 100644 --- a/include/sound/ac97_codec.h +++ b/include/sound/ac97_codec.h @@ -410,7 +410,7 @@ int snd_ac97_pcm_close(struct ac97_pcm *pcm); int snd_ac97_pcm_double_rate_rules(struct snd_pcm_runtime *runtime); /* ad hoc AC97 device driver access */ -extern struct bus_type ac97_bus_type; +extern const struct bus_type ac97_bus_type; /* AC97 platform_data adding function */ static inline void snd_ac97_dev_add_pdata(struct snd_ac97 *ac97, void *data) diff --git a/include/sound/hdaudio.h b/include/sound/hdaudio.h index dd7c87bbc613..1517d752f750 100644 --- a/include/sound/hdaudio.h +++ b/include/sound/hdaudio.h @@ -33,7 +33,7 @@ struct hda_device_id; /* * exported bus type */ -extern struct bus_type snd_hda_bus_type; +extern const struct bus_type snd_hda_bus_type; /* * generic arrays diff --git a/sound/ac97/bus.c b/sound/ac97/bus.c index 3173e9d98927..1dc7965eb14b 100644 --- a/sound/ac97/bus.c +++ b/sound/ac97/bus.c @@ -28,8 +28,6 @@ static DEFINE_MUTEX(ac97_controllers_mutex); static DEFINE_IDR(ac97_adapter_idr); static LIST_HEAD(ac97_controllers); -static struct bus_type ac97_bus_type; - static inline struct ac97_controller* to_ac97_controller(struct device *ac97_adapter) { diff --git a/sound/ac97_bus.c b/sound/ac97_bus.c index c7aee8c42c55..7ea274c55900 100644 --- a/sound/ac97_bus.c +++ b/sound/ac97_bus.c @@ -75,7 +75,7 @@ int snd_ac97_reset(struct snd_ac97 *ac97, bool try_warm, unsigned int id, } EXPORT_SYMBOL_GPL(snd_ac97_reset); -struct bus_type ac97_bus_type = { +const struct bus_type ac97_bus_type = { .name = "ac97", }; diff --git a/sound/hda/hda_bus_type.c b/sound/hda/hda_bus_type.c index 4cd94178df9f..cce2c30511a2 100644 --- a/sound/hda/hda_bus_type.c +++ b/sound/hda/hda_bus_type.c @@ -76,7 +76,7 @@ static int hda_uevent(const struct device *dev, struct kobj_uevent_env *env) return 0; } -struct bus_type snd_hda_bus_type = { +const struct bus_type snd_hda_bus_type = { .name = "hdaudio", .match = hda_bus_match, .uevent = hda_uevent,