Received: by 2002:ab2:710b:0:b0:1ef:a325:1205 with SMTP id z11csp1092540lql; Tue, 12 Mar 2024 07:12:16 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCVEe9TkP3n8X+XKS2dL73mCUEntxvqNRTpuWiXL9sfNgE3D4mhD9HnEma2CC/la8X9Bg3rv4qc+JypFp/cEZWC+pEeGnWXu8W37Lc7qPA== X-Google-Smtp-Source: AGHT+IHgaAG3mu8+ZzxMrH7MwOzv0KM7QiGiiBzwK0u55KgW5d0BKReP6Qf1eW3Xlc1w2Vqu0Lxm X-Received: by 2002:a2e:9206:0:b0:2d3:c559:3a33 with SMTP id k6-20020a2e9206000000b002d3c5593a33mr6094499ljg.14.1710252736538; Tue, 12 Mar 2024 07:12:16 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1710252736; cv=pass; d=google.com; s=arc-20160816; b=x+a+XOJe6COfxg/Y6kwH4mqAb9j3J1K8Nncca4vdOtUUl6JkCb+tmVQWA3/UAOjfCG V9LE9VHC9XYAr86DNPyQy3uWiml6RFhzPkJCi6iwyTkLAg7J/bKW4rKErcREZbYbUDMo +F0Ni2ml5R6Nyf1XKJbjWQ5Kw2mGNiRzrSTW1aSRTZ6yORCuYgqdEEw0t0PQKVjbBWo9 8z7nVR8ZGgm4HJrJDQ9hF5ZBOC/fVsNYi5ChHedNCEuOTrQw/DmHb8UcNV1MEAPy3aGY 0LJ0ALhoOLSvsWbzSEXtro9FW6CPKTc8GERuhQMWsm5VS6/Z/f8rAjeLtyW9JVKcfAH2 wlzg== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=in-reply-to:content-disposition:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:references:message-id:subject:cc :to:from:date:dkim-signature; bh=5ruGwHsLfUwiCdhMOK9NbnqbyeXESLoq50ox4/jvQt4=; fh=ApyUzYITF0aU2ov6H5RYx3LBZOS5m+KK77M+XJ7VRzM=; b=Sv/kJ6rDQLXptxyF3ZXBgaqo6YG63ZLdMZUQws/Tibb7S02Uzx3eq5uQESW1U+RuXJ AESd0em+vXCFlgAB9zBInv6AVQ3+G/uQvJDht4AbOUDeiF17YMcQtlaJllNsPHxzZ5xZ sWrUwBCjgrL99/5qS50T/nXovT7jTQP/5DLPBlpdXjiGwcnol7XIIs6E6JH6Zrie2Omj vocThgAGZ2rEZ0rooWRf4tySjWNNDYFOIEp6g2MUp5SJXOT5Vsvy0+hhSrbKEf1aJf+l 3zTBZSVUd6eB5lUMPb+DxcXAOoQY6bMiuSFY/o/DwRzdNT7jIN+HyCznW+ymTREiAkPS 6H3A==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b="F3BSQa/l"; arc=pass (i=1 dkim=pass dkdomain=intel.com dmarc=pass fromdomain=linux.intel.com); spf=pass (google.com: domain of linux-kernel+bounces-100016-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) smtp.mailfrom="linux-kernel+bounces-100016-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com Return-Path: Received: from am.mirrors.kernel.org (am.mirrors.kernel.org. [2604:1380:4601:e00::3]) by mx.google.com with ESMTPS id m29-20020a50931d000000b00564432b527dsi3661019eda.551.2024.03.12.07.12.16 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 12 Mar 2024 07:12:16 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-100016-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) client-ip=2604:1380:4601:e00::3; Authentication-Results: mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b="F3BSQa/l"; arc=pass (i=1 dkim=pass dkdomain=intel.com dmarc=pass fromdomain=linux.intel.com); spf=pass (google.com: domain of linux-kernel+bounces-100016-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) smtp.mailfrom="linux-kernel+bounces-100016-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com 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 am.mirrors.kernel.org (Postfix) with ESMTPS id 01CB41F2573B for ; Tue, 12 Mar 2024 09:24:32 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 7F70979B90; Tue, 12 Mar 2024 09:19:22 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b="F3BSQa/l" Received: from mgamail.intel.com (mgamail.intel.com [192.198.163.18]) (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 0890A77F2C; Tue, 12 Mar 2024 09:19:19 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=192.198.163.18 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1710235161; cv=none; b=WRiO9jRBCVcntQ94Evjx53A95Rsx2ln+kaUJ9857/bof7Ib9jQMB9nb3uRxdfSN+oNfHGRkjshWVABNHGH9HmAk/FaA4S5aYPwu6CJJmBboYxSfUeJhBPjLdb/4OAyEl5ckPpbbcZ40FkDUPSJcC4Unl0cOY/J8bTZLg+GJQuRM= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1710235161; c=relaxed/simple; bh=8TtpUkIMGq597Pi0vWyKqN1BsRfaLDNjqAC1V4fg2xo=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=J16AC2HTRTCUlr68yhM2ZjFfoPim04//AoBbkiut3I9eYEdtL8vwTgCuVtLyoGsrKoPuLVgrQQiF6HHK0KHrYOUt5pDSPrJCqMyhyNXUWuQvnHF3uJs3K60VGSBYhxY5xGrzzfkP3eWHiCDVc4yJf79JJCtf9LhBC6Vmsf2mSd0= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.intel.com; spf=none smtp.mailfrom=linux.intel.com; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b=F3BSQa/l; arc=none smtp.client-ip=192.198.163.18 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.intel.com Authentication-Results: smtp.subspace.kernel.org; spf=none smtp.mailfrom=linux.intel.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1710235160; x=1741771160; h=date:from:to:cc:subject:message-id:references: mime-version:in-reply-to; bh=8TtpUkIMGq597Pi0vWyKqN1BsRfaLDNjqAC1V4fg2xo=; b=F3BSQa/lfbMOle5XCjPo2XIwytH75egiQG+MBidLxak8hANj5P8QDtCb CnzMlzYWxmsHuxJfYsGYXSw1f3LHACivky2HIlcH8G8UgLp2Ahwjgix31 oVk+cv7ZMexVfjsVM4ecDTGx5EZKM4yA/OberB/HXwuAaoPjKHqSG9icP OIS17h67D8aXpJprkQwtr2RmOdjWmjyMmBA06rZoJJY+5i4yhKdcoTiOK mSatYqbgEWfwU2k+3odusMV4YlfGxFAlWY5VwQGMgRzmaLs5t0XvAVl4g MLJmhk39Wb5uOcdvWoOTDHDtOcfv96ZQAoytuF3xSxXpeBMtvYTn1Fyap w==; X-IronPort-AV: E=McAfee;i="6600,9927,11010"; a="4784322" X-IronPort-AV: E=Sophos;i="6.07,119,1708416000"; d="scan'208";a="4784322" Received: from fmsmga001.fm.intel.com ([10.253.24.23]) by fmvoesa112.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 12 Mar 2024 02:19:19 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,11010"; a="937051558" X-IronPort-AV: E=Sophos;i="6.07,119,1708416000"; d="scan'208";a="937051558" Received: from kuha.fi.intel.com ([10.237.72.185]) by fmsmga001.fm.intel.com with SMTP; 12 Mar 2024 02:19:17 -0700 Received: by kuha.fi.intel.com (sSMTP sendmail emulation); Tue, 12 Mar 2024 11:19:16 +0200 Date: Tue, 12 Mar 2024 11:19:16 +0200 From: Heikki Krogerus To: "Ricardo B. Marliere" Cc: Greg Kroah-Hartman , linux-usb@vger.kernel.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH] usb: typec: constify struct class usage Message-ID: References: <20240301-class_cleanup-usb-v1-1-50309e325095@marliere.net> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20240301-class_cleanup-usb-v1-1-50309e325095@marliere.net> On Fri, Mar 01, 2024 at 06:19:28PM -0300, Ricardo B. Marliere wrote: > Since commit 43a7206b0963 ("driver core: class: make class_register() take > a const *"), the driver core allows for struct class to be in read-only > memory, so move the structures typec_mux_class, retimer_class and > typec_class to be declared at build time placing them into read-only > memory, instead of having to be dynamically allocated at boot time. > > Cc: Greg Kroah-Hartman > Suggested-by: Greg Kroah-Hartman > Signed-off-by: Ricardo B. Marliere Reviewed-by: Heikki Krogerus > --- > drivers/usb/typec/class.c | 2 +- > drivers/usb/typec/class.h | 6 +++--- > drivers/usb/typec/mux.c | 2 +- > drivers/usb/typec/retimer.c | 2 +- > 4 files changed, 6 insertions(+), 6 deletions(-) > > diff --git a/drivers/usb/typec/class.c b/drivers/usb/typec/class.c > index caea2b829980..389c7f0b8d93 100644 > --- a/drivers/usb/typec/class.c > +++ b/drivers/usb/typec/class.c > @@ -21,7 +21,7 @@ > > static DEFINE_IDA(typec_index_ida); > > -struct class typec_class = { > +const struct class typec_class = { > .name = "typec", > }; > > diff --git a/drivers/usb/typec/class.h b/drivers/usb/typec/class.h > index 759b98355eeb..7485cdb9dd20 100644 > --- a/drivers/usb/typec/class.h > +++ b/drivers/usb/typec/class.h > @@ -93,9 +93,9 @@ extern const struct device_type typec_port_dev_type; > #define is_typec_plug(dev) ((dev)->type == &typec_plug_dev_type) > #define is_typec_port(dev) ((dev)->type == &typec_port_dev_type) > > -extern struct class typec_mux_class; > -extern struct class retimer_class; > -extern struct class typec_class; > +extern const struct class typec_mux_class; > +extern const struct class retimer_class; > +extern const struct class typec_class; > > #if defined(CONFIG_ACPI) > int typec_link_ports(struct typec_port *connector); > diff --git a/drivers/usb/typec/mux.c b/drivers/usb/typec/mux.c > index 80dd91938d96..49926d6e72c7 100644 > --- a/drivers/usb/typec/mux.c > +++ b/drivers/usb/typec/mux.c > @@ -469,6 +469,6 @@ void *typec_mux_get_drvdata(struct typec_mux_dev *mux_dev) > } > EXPORT_SYMBOL_GPL(typec_mux_get_drvdata); > > -struct class typec_mux_class = { > +const struct class typec_mux_class = { > .name = "typec_mux", > }; > diff --git a/drivers/usb/typec/retimer.c b/drivers/usb/typec/retimer.c > index 4a7d1b5c4d86..b519fcf358ca 100644 > --- a/drivers/usb/typec/retimer.c > +++ b/drivers/usb/typec/retimer.c > @@ -155,6 +155,6 @@ void *typec_retimer_get_drvdata(struct typec_retimer *retimer) > } > EXPORT_SYMBOL_GPL(typec_retimer_get_drvdata); > > -struct class retimer_class = { > +const struct class retimer_class = { > .name = "retimer", > }; > > --- > base-commit: a560a5672826fc1e057068bda93b3d4c98d037a2 > change-id: 20240301-class_cleanup-usb-4c3cef5bb0ca > > Best regards, > -- > Ricardo B. Marliere -- heikki