From patchwork Mon Jan 30 17:10:59 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Greg KH X-Patchwork-Id: 50379 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:adf:eb09:0:0:0:0:0 with SMTP id s9csp2297094wrn; Mon, 30 Jan 2023 09:15:32 -0800 (PST) X-Google-Smtp-Source: AK7set91HSyT0BJRR8N9a2CjTT/pUzU7o8HCHqwYV4l8YuIgUddP2SWxEkEQYmvOzydIIlRO/0RL X-Received: by 2002:a50:ee0b:0:b0:4a0:e323:d59c with SMTP id g11-20020a50ee0b000000b004a0e323d59cmr16967577eds.20.1675098932649; Mon, 30 Jan 2023 09:15:32 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1675098932; cv=none; d=google.com; s=arc-20160816; b=nR3E6oUbCmZV9yrrncZNJMuF+LLxcrAY5gRWSFoLjAnFlgvhqK7nR7EboRoMCsNB5C Vgx8YRxPAqqAayG17KP9npkkFyGFSbZDXaxwfDg+iMmHmb/VWRN5GnOzdcJKd+wuewfz Xk0HhGTniyV1UlOsxiG0c2qtTr0cQ/vzTlPzHTeSt6sNpojyYVFnuWGSAihG4ltJEDoZ bxzSNODSDaVyJzin1810ph9H3HMDIgCq6LE3sGr4LorEqc8+GP8L1k5BTYx4pjjbqjEz 8JK4/dUHvGUGF/bjiLsVz+G7hkV8tdVJ/ay6aJ6fR1I5zvFNVrTILwwhwIk6Wo5oc1WU afaQ== 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:dkim-signature; bh=TPeh+fQUsg/FY+7TmNZaapGNxmwp0gj0no1f8rioPro=; b=E8FxQJ3UhNpFv7oYShLCyNz9KFT9tauY+5TV2GMX30hXLvf7GVhMRPvDCaIzQjLlcg HENIPWjvqJhP5ExbpExFV6TQHDM2yRU6tZ5/JTfz6s1MMsaLpYwrEaJBbfWAyWVrnYYy 5bfocHagOupm2I/PxxwPVMDi67TomhMALmDfUGUnlSCapyb9lP1JCcubE6YXku8E60VN 6Sa2yVB0cWW8RG5fczxL6qAihFQBKiFEipVCYBtoa9ZIBQzpAihXtbSUYjw3xFwZGi/x eHLWZUe3opha4cllvbKYMwDdwqUqtDObTb/6CcdcV6DkyU/CEEqz9CtACT5QMOeVqJlL i0mQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=BGosTPqD; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id c17-20020a50f611000000b004a08a5f9e49si15502403edn.48.2023.01.30.09.15.09; Mon, 30 Jan 2023 09:15:32 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=BGosTPqD; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S236703AbjA3RLL (ORCPT + 99 others); Mon, 30 Jan 2023 12:11:11 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:35760 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235055AbjA3RLH (ORCPT ); Mon, 30 Jan 2023 12:11:07 -0500 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 4A930402D3 for ; Mon, 30 Jan 2023 09:11:05 -0800 (PST) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id DAB30611F0 for ; Mon, 30 Jan 2023 17:11:04 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id EB732C4339B; Mon, 30 Jan 2023 17:11:03 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1675098664; bh=uPrZO2VVFrmuQntAv0HtD/x/u3arHKR1TJC+0KNfpe8=; h=From:To:Cc:Subject:Date:From; b=BGosTPqDXNPivlWS6lv6r22K/bJNkQaeDtCEnu5r29biygyn1kFkl6hAr9idKn2JG b0YlfYTTeT1H6gE6YQMeTTjo2mfqjYzOdzVvw6lNYQTP3iQLfTQRia4nnEH+kE6IGq kFNvXMo0f34e7ICwvgETsnG5nSWkr9TlCirUYa5I= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman Subject: [PATCH] driver core: soc: remove layering violation for the soc_bus Date: Mon, 30 Jan 2023 18:10:59 +0100 Message-Id: <20230130171059.1784057-1-gregkh@linuxfoundation.org> X-Mailer: git-send-email 2.39.1 MIME-Version: 1.0 X-Developer-Signature: v=1; a=openpgp-sha256; l=1434; i=gregkh@linuxfoundation.org; h=from:subject; bh=uPrZO2VVFrmuQntAv0HtD/x/u3arHKR1TJC+0KNfpe8=; b=owGbwMvMwCRo6H6F97bub03G02pJDMnXfynWLODJCyy6dexTdiLHc+tEnqiGqzk6zHb7fhupKNyv nevQEcvCIMjEICumyPJlG8/R/RWHFL0MbU/DzGFlAhnCwMUpABPhm8owv579VpOKb66af2S4yFy5Al ON7xN0GRZccvy/4OD5zIgQq/o01S8KN6X6rtoCAA== X-Developer-Key: i=gregkh@linuxfoundation.org; a=openpgp; fpr=F4B60CC5BF78C2214A313DCB3147D40DDB2DFB29 X-Spam-Status: No, score=-7.1 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_HI, SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1756468538183997342?= X-GMAIL-MSGID: =?utf-8?q?1756468538183997342?= The soc_bus code pokes around in the internal bus structures assuming that it "knows" if a field is not set that it has not been registered yet. That isn't a safe assumption, so just remove the layering violation entirely and keep track if the bus has been registered or not ourselves. Signed-off-by: Greg Kroah-Hartman Reviewed-by: Rafael J. Wysocki --- drivers/base/soc.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/drivers/base/soc.c b/drivers/base/soc.c index 22130b5f789d..0fb1d4ab9d8a 100644 --- a/drivers/base/soc.c +++ b/drivers/base/soc.c @@ -30,6 +30,7 @@ struct soc_device { static struct bus_type soc_bus_type = { .name = "soc", }; +static bool soc_bus_registered; static DEVICE_ATTR(machine, 0444, soc_info_show, NULL); static DEVICE_ATTR(family, 0444, soc_info_show, NULL); @@ -117,7 +118,7 @@ struct soc_device *soc_device_register(struct soc_device_attribute *soc_dev_attr const struct attribute_group **soc_attr_groups; int ret; - if (!soc_bus_type.p) { + if (!soc_bus_registered) { if (early_soc_dev_attr) return ERR_PTR(-EBUSY); early_soc_dev_attr = soc_dev_attr; @@ -183,6 +184,7 @@ static int __init soc_bus_register(void) ret = bus_register(&soc_bus_type); if (ret) return ret; + soc_bus_registered = true; if (early_soc_dev_attr) return PTR_ERR(soc_device_register(early_soc_dev_attr));