From patchwork Sat Mar 2 16:47:22 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Ricardo B. Marliere" X-Patchwork-Id: 13579560 Received: from mail-io1-f49.google.com (mail-io1-f49.google.com [209.85.166.49]) (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 1EBB222F14; Sat, 2 Mar 2024 16:47:31 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.166.49 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1709398053; cv=none; b=LVJKcvtkbu9oROr7PokWUqwoCMKMZ3BBA+wQrWHus+C20td9mQQIUp19e1TzSpM6u6nAsvFSS2QVFWNCIHCPaNDs9g5YhWStFUHYHa1Y8EGeIaEtln9uei0mnkJu85yUu73G0Hxa6y7GvSqyxMHDLd9ZYD1u2/M9thauy4nnDGI= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1709398053; c=relaxed/simple; bh=5fFFl+NQvKIKgg15BuOC5SNCW60DHjH9gv71w7SxkWk=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=aMob70jiD+wUvBJgQ0n3BeFBDNe7wC1Hg1KbPxTo5YmIY2Yo9uRSZrhddkQNnPwlrqvlYD3xOiGf0spmNEfGBGICpasNp1lrj/IMK6FlTtka3q5D7w8TG94Y9dEqsuRKUq5xzWCzW9VcZ3Lt8R14GoiedbiIwEkFXZCCGuQG5CQ= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=marliere.net; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=marliere.net header.i=@marliere.net header.b=Upd2qR4P; arc=none smtp.client-ip=209.85.166.49 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=marliere.net Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=marliere.net header.i=@marliere.net header.b="Upd2qR4P" Received: by mail-io1-f49.google.com with SMTP id ca18e2360f4ac-7c835b36e9dso16845139f.3; Sat, 02 Mar 2024 08:47:31 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1709398051; x=1710002851; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:dkim-signature:from:x-gm-message-state :from:to:cc:subject:date:message-id:reply-to; bh=VKp49xShFivIZ3FSVYH7CTAL/TfZjGtj5hihj2WnRpY=; b=UWLMp9nGZQYzpvdMM2zyrpkrh88U19TZuTxk0yFUgMj5sILuztkui34zbgg0IB/SgY p1JP2+OLgoiSGEnyIpNvfDsolPx2pkdKvcfuiTagQlF8uLLEwHXE98HDGumosyQUvllp IX7Jt4dNRJ5Az2sKLRAjmmaRH+c7OOyl7cEb148gNKkxEC8pWuC7QY4lHN7SyuvrtBXb jxwIvvOeTt3jtqMDnSrtDRr9xCLUcF6HRviKssYw7/PkRVMK00I8WZFSTb2Q/Tewgift 5x9aVfTJwiZ/g2Tri/fjrpUZ5VD7C/0Uxh2Tcu3tPwyeAfe8DlZ/cp4BbRIexOhCH9Uy E4Fg== X-Forwarded-Encrypted: i=1; AJvYcCW5meGs67klaA8A3kRy+eTnFtR61LAazBbXLzybeintVxp/quxtdpSbRgo0uxtw2W3+NLmuDXekfkF/PifqhuQLy8HK3gbhD4O32l93 X-Gm-Message-State: AOJu0YzHJLi2s0lfiLf7VnRtbVR1JvYVvGBY28QTaodD0KJRJKUPejrC Gx1U6ajZ1zZj/xxhk9KAxmQ2zwltGuj2SsdSWq1pZBEpiSnWn+iV X-Google-Smtp-Source: AGHT+IEp2RDU3Zd9t11xhj78W40lqahskTWojefoSXhk8+kyTEU8UOQRJGdPPdJy8RDxESofWyUcjA== X-Received: by 2002:a5e:c702:0:b0:7c8:2bb3:ebb4 with SMTP id f2-20020a5ec702000000b007c82bb3ebb4mr3145859iop.6.1709398051264; Sat, 02 Mar 2024 08:47:31 -0800 (PST) Received: from mail.marliere.net ([24.199.118.162]) by smtp.gmail.com with ESMTPSA id g10-20020a02b70a000000b00474558a20a3sm1385930jam.140.2024.03.02.08.47.30 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 02 Mar 2024 08:47:30 -0800 (PST) From: "Ricardo B. Marliere" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=marliere.net; s=2024; t=1709398049; h=from:from:reply-to:subject:subject: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; bh=VKp49xShFivIZ3FSVYH7CTAL/TfZjGtj5hihj2WnRpY=; b=Upd2qR4Pnm++Aph61tfJnBVo5fGiwg5YIqJqx+nygIMq2XZlIGT7HHyUKX/6BPfTaywNNR MqpdPzIGwPHCi+mRGFMtdtnuFR2SFSDq5iGla+YzDcnukgQRlKv950pbHLJsR7LA/No6QP jFJJL2iavDe/DvHMSuGkGrRspFOmCljLMAEstqoK5/4vwpWPssbL1KdVJkdCikYnvQu0Ay ZX1MAK5FEMoliNEOzOcBo/xyyNGlI0mwJ7WST+hwnYu5vsdnTIcHXJypJSQmijWiv7D9xS mURMKfnDKEAEEc3mFgL6h4eF8IhFxWlyDtd8W57W4WdIi+jSAcs5kF9mrabN9g== Authentication-Results: ORIGINATING; auth=pass smtp.auth=ricardo@marliere.net smtp.mailfrom=ricardo@marliere.net Date: Sat, 02 Mar 2024 13:47:22 -0300 Subject: [PATCH 1/5] scsi: sg: make sg_sysfs_class constant Precedence: bulk X-Mailing-List: linux-scsi@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Message-Id: <20240302-class_cleanup-scsi-v1-1-b9096b990e27@marliere.net> References: <20240302-class_cleanup-scsi-v1-0-b9096b990e27@marliere.net> In-Reply-To: <20240302-class_cleanup-scsi-v1-0-b9096b990e27@marliere.net> To: Doug Gilbert , "James E.J. Bottomley" , "Martin K. Petersen" , "Manoj N. Kumar" , "Matthew R. Ochs" , Uma Krishnan , =?utf-8?q?Kai_M=C3=A4kisara?= Cc: linux-scsi@vger.kernel.org, linux-kernel@vger.kernel.org, Greg Kroah-Hartman , "Ricardo B. Marliere" X-Developer-Signature: v=1; a=openpgp-sha256; l=2750; i=ricardo@marliere.net; h=from:subject:message-id; bh=5fFFl+NQvKIKgg15BuOC5SNCW60DHjH9gv71w7SxkWk=; b=owEBbQKS/ZANAwAKAckLinxjhlimAcsmYgBl41gcO4omM5O9dpvOdRQNcf0ToXQGw1Slh668i 1BBGJ1CLI+JAjMEAAEKAB0WIQQDCo6eQk7jwGVXh+HJC4p8Y4ZYpgUCZeNYHAAKCRDJC4p8Y4ZY pkfFEACCudsWo/MlDFnP2LfTWScW1Wxiezy5M1HYiFJB72XHRkqW9Ih8+tJdSV0q3G/aNhFtDlL nYjrXoxe/dwTMZbMZq8ryWsy4S1B7ubqN8OlfyWMe/agHgguYY/NiuGBaZGFaOeINChw1oJo+2/ t/Gk4ki7BYwfHh5TYuJPYxkjNyJsszsZiU/uNNg0itso0u4I46AqU3tnqJYCz051k+wcuylxEiN 4YnSVUc3tezYRscFAhmKgZo6uOQev/h/V82teVD7eShaIiifMetP6IrxjRfkIgl6dEsD+yzWsVB mfR+tEIWZa/rZqCp5BXeXMLB4TV4A/jpH26Q5z/N/XMuMxuidZePw8Nv/k1Ja+PGGS2eZJpUipi g7opERg54T02As/Rqjb0mK6GiqWUj3MOa/vfYLx5raPBpSEzQsNItqpPBDgytSXsWTyFQGm4Kqv RcNIkXcmUIKhs8wbx8C9YMU43liBagiTHicukYgr2WkjKs2tk91f6MvVLSirq6EsS71+vsxKa2J MxzfLRInj5j6c8UeMMhCOIlKFd3a28593zLZO7lbWd5xDoFHlWeqqsIGHZFPcZko86CpUk3myhg GZmPb5JTxAOSrGoOqbd1bgU6IgFcUfZBOzushN8tylwA0I5lcrUQHfBLQkWe8x+Jc8kA3pVSTkk I323B26ftPh/ZYQ== X-Developer-Key: i=ricardo@marliere.net; a=openpgp; fpr=030A8E9E424EE3C0655787E1C90B8A7C638658A6 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 sg_sysfs_class structure to be declared at build time placing it 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 --- drivers/scsi/sg.c | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/drivers/scsi/sg.c b/drivers/scsi/sg.c index 86210e4dd0d3..6ef6256246df 100644 --- a/drivers/scsi/sg.c +++ b/drivers/scsi/sg.c @@ -1424,7 +1424,9 @@ static const struct file_operations sg_fops = { .llseek = no_llseek, }; -static struct class *sg_sysfs_class; +static const struct class sg_sysfs_class = { + .name = "scsi_generic" +}; static int sg_sysfs_valid = 0; @@ -1526,7 +1528,7 @@ sg_add_device(struct device *cl_dev) if (sg_sysfs_valid) { struct device *sg_class_member; - sg_class_member = device_create(sg_sysfs_class, cl_dev->parent, + sg_class_member = device_create(&sg_sysfs_class, cl_dev->parent, MKDEV(SCSI_GENERIC_MAJOR, sdp->index), sdp, "%s", sdp->name); @@ -1616,7 +1618,7 @@ sg_remove_device(struct device *cl_dev) read_unlock_irqrestore(&sdp->sfd_lock, iflags); sysfs_remove_link(&scsidp->sdev_gendev.kobj, "generic"); - device_destroy(sg_sysfs_class, MKDEV(SCSI_GENERIC_MAJOR, sdp->index)); + device_destroy(&sg_sysfs_class, MKDEV(SCSI_GENERIC_MAJOR, sdp->index)); cdev_del(sdp->cdev); sdp->cdev = NULL; @@ -1687,11 +1689,9 @@ init_sg(void) SG_MAX_DEVS, "sg"); if (rc) return rc; - sg_sysfs_class = class_create("scsi_generic"); - if ( IS_ERR(sg_sysfs_class) ) { - rc = PTR_ERR(sg_sysfs_class); + rc = class_register(&sg_sysfs_class); + if (rc) goto err_out; - } sg_sysfs_valid = 1; rc = scsi_register_interface(&sg_interface); if (0 == rc) { @@ -1700,7 +1700,7 @@ init_sg(void) #endif /* CONFIG_SCSI_PROC_FS */ return 0; } - class_destroy(sg_sysfs_class); + class_unregister(&sg_sysfs_class); register_sg_sysctls(); err_out: unregister_chrdev_region(MKDEV(SCSI_GENERIC_MAJOR, 0), SG_MAX_DEVS); @@ -1715,7 +1715,7 @@ exit_sg(void) remove_proc_subtree("scsi/sg", NULL); #endif /* CONFIG_SCSI_PROC_FS */ scsi_unregister_interface(&sg_interface); - class_destroy(sg_sysfs_class); + class_unregister(&sg_sysfs_class); sg_sysfs_valid = 0; unregister_chrdev_region(MKDEV(SCSI_GENERIC_MAJOR, 0), SG_MAX_DEVS); From patchwork Sat Mar 2 16:47:23 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Ricardo B. Marliere" X-Patchwork-Id: 13579561 Received: from mail-io1-f43.google.com (mail-io1-f43.google.com [209.85.166.43]) (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 438B02BB1A; Sat, 2 Mar 2024 16:47:35 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.166.43 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1709398057; cv=none; b=CsllGP8C5NXPsTvXOOCS4ArfPCBnU561+u3LBGx+Dzgmx7p7ubLSn6MEOqw6RamzbwCQUtllJF/T1aGf8vKW0ZcK7e4qqS/QOonvpP4D/5F7KrkAczWJU5cVDg5xS00Jotz614eYGkLqMcpojTr+NwvzOBP3Xwwbw8Q3O/SQBj4= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1709398057; c=relaxed/simple; bh=rlc4uufc3PtM/hoEPL10OKjaFHgvMNuVTywDQZGsyvw=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=hoJXdVhOq0eKVPILS+x//6Ih3LH4plWXOWSS2YlWkK6c1H25gx61tbELw6zuczOSsDLVzwt9/DJXAHgrqz4TDVQz1fLc6uZZK0B6SGx75JNk23GDxvgmzL61ZUJg8T0D+EJgLbxIblToOYRxemM4RtrY9CIapfYdxaErnT1pSc8= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=marliere.net; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=marliere.net header.i=@marliere.net header.b=mL8nYeAD; arc=none smtp.client-ip=209.85.166.43 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=marliere.net Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=marliere.net header.i=@marliere.net header.b="mL8nYeAD" Received: by mail-io1-f43.google.com with SMTP id ca18e2360f4ac-7c403dbf3adso205795739f.1; Sat, 02 Mar 2024 08:47:35 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1709398054; x=1710002854; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:dkim-signature:from:x-gm-message-state :from:to:cc:subject:date:message-id:reply-to; bh=EIxIH/dP4WE4ZSIoHocSg2tr9v1M7GINqI1t7vtWcKE=; b=d6ir/tAOBC47VfehtTMX68EF3vVPN6zZe2yQW4FbUdsvcv2NKR5FuJ5w2drLun/mSH 8a98u0e2mtsDQP0p9X7q53a+AJgRZqN/TmdWcFLEHXDMeHnrAoUgxbbs+BIm2t67/4M7 WtucJpnuHt2Tf7YvylK4G8B0KpPWXdbIL2IsU0PpSJRQaxfa7mMOsXVDgi/+mQT5zPo/ QsXrWABmonnaPtKeYyjlGapaGcbOY53I0j4mWroaGw8kDZ/u3C+1/C8Eo3agB0/4L7xT fcYGqH5G99CrplVlmF4yLJgHQf4kI+zTVg94B+yO1IYFFNIEqj7TsfFw/VYHP0NlJNSi U8Yg== X-Forwarded-Encrypted: i=1; AJvYcCVRkfkEnRujhJK1RxUjmGAoAzvnfG70D4LW77BU+dDyeweh3HtS4Bf7KomWoN+0zPdEerpCPbYKrHdc9Zo9+fdNFweMH38mzSNvfUHl X-Gm-Message-State: AOJu0Yz6moZTcxhouTmErbU5FJnOGkf8M8RRNzHcSCwHN736PjSXFyYJ 6odCZGYFiap0g9ydpw0o4HsalTqe9VuwRdY+yShQ5cO8BsFNcLhS X-Google-Smtp-Source: AGHT+IH9A/LZfckMTPIlJHjoSAVFm8QxA4sruNR8pQW+9pmfexs502P6vVARjfmQPDf0tlLTRRlUXQ== X-Received: by 2002:a05:6602:3705:b0:7c8:298:8c88 with SMTP id bh5-20020a056602370500b007c802988c88mr6063659iob.7.1709398054386; Sat, 02 Mar 2024 08:47:34 -0800 (PST) Received: from mail.marliere.net ([24.199.118.162]) by smtp.gmail.com with ESMTPSA id f22-20020a056638023600b00474506c900esm1397545jaq.145.2024.03.02.08.47.33 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 02 Mar 2024 08:47:33 -0800 (PST) From: "Ricardo B. Marliere" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=marliere.net; s=2024; t=1709398052; h=from:from:reply-to:subject:subject: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; bh=EIxIH/dP4WE4ZSIoHocSg2tr9v1M7GINqI1t7vtWcKE=; b=mL8nYeAD2lk6N2ClmmOSOaO4aZy95VvHRavTznymRQsiG96lU7C/YkC8l9VPEjqI46nCVG DTSQ6ydWsj3Cq74fkuHbaKQqLcdWcavwwRV2E0AZhQXwhO9uYJIQ24OK98ozKF/3ILRJT5 Zbxe4i3q07OoHyEyoX17m80cfZ20eEr/SM6nHLwWPUj5OEsUGHpFffdLKXm9SDUFd+BlfM aXsYxgR3UXiE4f5ecXjuA2NIEkbODNyBmI4WbKZzysAmVd8Z47+2NrosvJAHup1LmV9YjY zU9wfG/Rl1xJfbbUriQIWPQ7Su1TnB7nJsg5p0LZSNFgeA9zxN+OurPAsQk2EA== Authentication-Results: ORIGINATING; auth=pass smtp.auth=ricardo@marliere.net smtp.mailfrom=ricardo@marliere.net Date: Sat, 02 Mar 2024 13:47:23 -0300 Subject: [PATCH 2/5] scsi: pmcraid: make pmcraid_class constant Precedence: bulk X-Mailing-List: linux-scsi@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Message-Id: <20240302-class_cleanup-scsi-v1-2-b9096b990e27@marliere.net> References: <20240302-class_cleanup-scsi-v1-0-b9096b990e27@marliere.net> In-Reply-To: <20240302-class_cleanup-scsi-v1-0-b9096b990e27@marliere.net> To: Doug Gilbert , "James E.J. Bottomley" , "Martin K. Petersen" , "Manoj N. Kumar" , "Matthew R. Ochs" , Uma Krishnan , =?utf-8?q?Kai_M=C3=A4kisara?= Cc: linux-scsi@vger.kernel.org, linux-kernel@vger.kernel.org, Greg Kroah-Hartman , "Ricardo B. Marliere" X-Developer-Signature: v=1; a=openpgp-sha256; l=3047; i=ricardo@marliere.net; h=from:subject:message-id; bh=rlc4uufc3PtM/hoEPL10OKjaFHgvMNuVTywDQZGsyvw=; b=owEBbQKS/ZANAwAKAckLinxjhlimAcsmYgBl41gcgcXPauwcMwcivousgucxCY3RKlSytTHfr WJeH+nqr1KJAjMEAAEKAB0WIQQDCo6eQk7jwGVXh+HJC4p8Y4ZYpgUCZeNYHAAKCRDJC4p8Y4ZY pnPWEACTmPuE8CaT+BVJaxp20vvGyFmz+woXDXlRcLmwZQFBfigeYCJZfDiEgy7opaqrPKVSLkd j9bCQ3p58rGUmFOWIiYyRhnrx63JN7wBtgFOVsas+IGEBz9cF4Manuv0e+DXaa7tvEBHcpYEu+h r8o6/bVuSIHq1a9XWDhUtlurep1BhI5BzH+I9i7Cewz6Yie4eYNJqeoxvzxxT7aVfJU69RgxAy2 3jIOjfuX370sAOXXb+Y9YaKr+DBfPtF0w1hZWW3NvUVjo6IysGgr2WLoxOFGTNU2fNicKLI5bMb dyqQscsnCPm18gKOZZ81dVy3hfdicuw9R3z6x43gwuUk753M0cnVXYqCkfI5g3PkSQhfK+XlgUr 65UStiHtAvLqyeRLrDJXZS0aToKbIwhiGUxx1sQgHSDb/nhCl4Aim/XN0imc3HFTxNxmvIBjR3j OLKmn8TyLoHcUymKgMStQlvFoOuDpIHDTHm5jgX5Bjmp8Wr1fwwr44luVMjd+56eDnVVuATQXJp qp5ZxlvdTM8yeF1Q36ZrkTGgYZ6J1KfD5OzR4UxD1pDgQLer+pCHy77k5k82LKfyM23ydJF1cmX 1kgcGZiYjujKQqAVkAedaRLpog2wyRuOdZGrwvc36nOJRIJMzdric8fCuKvishjTlyfLl5HncFt MlZ3fzF3qXKTDHw== X-Developer-Key: i=ricardo@marliere.net; a=openpgp; fpr=030A8E9E424EE3C0655787E1C90B8A7C638658A6 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 pmcraid_class structure to be declared at build time placing it 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 --- drivers/scsi/pmcraid.c | 20 +++++++++++--------- 1 file changed, 11 insertions(+), 9 deletions(-) diff --git a/drivers/scsi/pmcraid.c b/drivers/scsi/pmcraid.c index e8bcc3a88732..0614b7e366b7 100644 --- a/drivers/scsi/pmcraid.c +++ b/drivers/scsi/pmcraid.c @@ -61,7 +61,9 @@ static atomic_t pmcraid_adapter_count = ATOMIC_INIT(0); * pmcraid_minor - minor number(s) to use */ static unsigned int pmcraid_major; -static struct class *pmcraid_class; +static const struct class pmcraid_class = { + .name = PMCRAID_DEVFILE, +}; static DECLARE_BITMAP(pmcraid_minor, PMCRAID_MAX_ADAPTERS); /* @@ -4723,7 +4725,7 @@ static int pmcraid_setup_chrdev(struct pmcraid_instance *pinstance) if (error) pmcraid_release_minor(minor); else - device_create(pmcraid_class, NULL, MKDEV(pmcraid_major, minor), + device_create(&pmcraid_class, NULL, MKDEV(pmcraid_major, minor), NULL, "%s%u", PMCRAID_DEVFILE, minor); return error; } @@ -4739,7 +4741,7 @@ static int pmcraid_setup_chrdev(struct pmcraid_instance *pinstance) static void pmcraid_release_chrdev(struct pmcraid_instance *pinstance) { pmcraid_release_minor(MINOR(pinstance->cdev.dev)); - device_destroy(pmcraid_class, + device_destroy(&pmcraid_class, MKDEV(pmcraid_major, MINOR(pinstance->cdev.dev))); cdev_del(&pinstance->cdev); } @@ -5390,10 +5392,10 @@ static int __init pmcraid_init(void) } pmcraid_major = MAJOR(dev); - pmcraid_class = class_create(PMCRAID_DEVFILE); - if (IS_ERR(pmcraid_class)) { - error = PTR_ERR(pmcraid_class); + error = class_register(&pmcraid_class); + + if (error) { pmcraid_err("failed to register with sysfs, error = %x\n", error); goto out_unreg_chrdev; @@ -5402,7 +5404,7 @@ static int __init pmcraid_init(void) error = pmcraid_netlink_init(); if (error) { - class_destroy(pmcraid_class); + class_unregister(&pmcraid_class); goto out_unreg_chrdev; } @@ -5413,7 +5415,7 @@ static int __init pmcraid_init(void) pmcraid_err("failed to register pmcraid driver, error = %x\n", error); - class_destroy(pmcraid_class); + class_unregister(&pmcraid_class); pmcraid_netlink_release(); out_unreg_chrdev: @@ -5432,7 +5434,7 @@ static void __exit pmcraid_exit(void) unregister_chrdev_region(MKDEV(pmcraid_major, 0), PMCRAID_MAX_ADAPTERS); pci_unregister_driver(&pmcraid_driver); - class_destroy(pmcraid_class); + class_unregister(&pmcraid_class); } module_init(pmcraid_init); From patchwork Sat Mar 2 16:47:24 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Ricardo B. Marliere" X-Patchwork-Id: 13579562 Received: from mail-io1-f42.google.com (mail-io1-f42.google.com [209.85.166.42]) (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 89D8F36AE5; Sat, 2 Mar 2024 16:47:38 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.166.42 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1709398060; cv=none; b=buDwW7uM3gnFdXoROFbmYkP//diclh4LLJqGMqiXPpgfNxWJs4IIg6B72OdOkUkAg6hRaW4A0wG6E15M9bM2KhGMup8rHuY7TwuUS3Xy6ifj0qxjrPkp4nPNu6abn04ATbUfqNiVNtgtJXZLH3zHMY0tLqX7hosCxnaejc9o6n8= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1709398060; c=relaxed/simple; bh=Ur7tQ/GmafWahw88FheukE1dyb8cRyzWLMsnOBV0c+c=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=ND+bhf1gZGcQOVi2J9U2WgHsWpOHYF+zGNRt50QuGyExkxQAiBDNYt/stni6jH2bRUmHClPH8ivzRK2RSYmwQH5szGllrxppAuHlHgNJTmWnOzmvy77A2Me4CMO5SNSfmy7/lFIaEcFzG1rydi7jywSVYov61P9EvVzFetZ7lSI= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=marliere.net; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=marliere.net header.i=@marliere.net header.b=HDZjU+up; arc=none smtp.client-ip=209.85.166.42 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=marliere.net Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=marliere.net header.i=@marliere.net header.b="HDZjU+up" Received: by mail-io1-f42.google.com with SMTP id ca18e2360f4ac-7c7b8fb8ba6so193741839f.2; Sat, 02 Mar 2024 08:47:38 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1709398057; x=1710002857; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:dkim-signature:from:x-gm-message-state :from:to:cc:subject:date:message-id:reply-to; bh=/gjT/vbcRZfQ0R+BHS46IvecEsU2yDNeF1+wwArqnYU=; b=sbQ5nIjE2sSOlckGZdOc77ffrO8K2yHqG65TOmdqCebiKhPL/k0YCZQe+QOCyElnbY ZbnU4dyKJZLfphHio9tB3J9G1aK5mNGdRGQNkBxjZWMB7MHuzEZwJ+PuUVodrb3BmqS4 FiCRfWrRAWzTc4nKPW/5fulhwp+H2zrRWqYz7L4faD1PD5jkAZxnf8Y+hzSr2ndbmo7v nq2k2hWOxz/GCVQKWY/E9gyLorLGbjJGBhAIj1bi4lyjA1EWlG/vSGUSbhPe0CuHG96M w8ua90WJ3ouTMFsyvtn78l442VdEgD8B5txNykXocq2JgjDxsZZAGmPRZRyk7dNxspnB hpfg== X-Forwarded-Encrypted: i=1; AJvYcCW2RMKY9Gur4idX+PGKMRO52qgReh8qsz3sdggWzQVgVVceFwuzjDk32c+liTSdO1V7EHntEyBdcgT1vt8Z7KUtBbCipLRKQUlZZfMr X-Gm-Message-State: AOJu0YwOjmQE0r8NJ2JG9d5tjDBkElJ/AVySvXssgbyiKS3mBARxnWyk kCH/kOE4pHJhOqXcp0M6K9hFln1EqCzOFBu+Syxesbdc1w+vKREe X-Google-Smtp-Source: AGHT+IHY+ZsHcoT9iAkG9eZBjYef8sBy1HHG+JjNBVR2iiFcOT0AsNsY2fqVAukH6t4GEPK339+CBA== X-Received: by 2002:a5e:9516:0:b0:7c8:3027:7685 with SMTP id r22-20020a5e9516000000b007c830277685mr2760816ioj.11.1709398057601; Sat, 02 Mar 2024 08:47:37 -0800 (PST) Received: from mail.marliere.net ([24.199.118.162]) by smtp.gmail.com with ESMTPSA id i20-20020a02cc54000000b00474d40f8381sm689845jaq.122.2024.03.02.08.47.36 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 02 Mar 2024 08:47:37 -0800 (PST) From: "Ricardo B. Marliere" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=marliere.net; s=2024; t=1709398056; h=from:from:reply-to:subject:subject: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; bh=/gjT/vbcRZfQ0R+BHS46IvecEsU2yDNeF1+wwArqnYU=; b=HDZjU+upECGkrm0g3EuHD57+MUWzSqGDqaJGL3ZLjg022f99gKfrCHBqFXm5SfOb3Fvn5K e9N2l4hTy6nGAArpBiy0Po0u3IihBMxgst8qpOOprcos1ld9/ArdxBA0Q2GWktqeoQIDuk mXoj3KhG+A1n+GRY4q86+NzZNcPVbgYh/xw0ymEpAxU6Dsx0LGXavx9ir4TwUZT8qi4yuW cz1xYT4riMkUHdDeR3jXz8dbuNMiv3xSPj2fHO1M4sHrbKp6NxqLY63p1R2vE5h5W/AYZC W25tpo3Zs5qSoo+BBcFdgRlORFBDWtIaoQvwhkbm1eGWMt63A+eEwUnkR7lgUA== Authentication-Results: ORIGINATING; auth=pass smtp.auth=ricardo@marliere.net smtp.mailfrom=ricardo@marliere.net Date: Sat, 02 Mar 2024 13:47:24 -0300 Subject: [PATCH 3/5] scsi: cxlflash: make cxlflash_class constant Precedence: bulk X-Mailing-List: linux-scsi@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Message-Id: <20240302-class_cleanup-scsi-v1-3-b9096b990e27@marliere.net> References: <20240302-class_cleanup-scsi-v1-0-b9096b990e27@marliere.net> In-Reply-To: <20240302-class_cleanup-scsi-v1-0-b9096b990e27@marliere.net> To: Doug Gilbert , "James E.J. Bottomley" , "Martin K. Petersen" , "Manoj N. Kumar" , "Matthew R. Ochs" , Uma Krishnan , =?utf-8?q?Kai_M=C3=A4kisara?= Cc: linux-scsi@vger.kernel.org, linux-kernel@vger.kernel.org, Greg Kroah-Hartman , "Ricardo B. Marliere" X-Developer-Signature: v=1; a=openpgp-sha256; l=2323; i=ricardo@marliere.net; h=from:subject:message-id; bh=Ur7tQ/GmafWahw88FheukE1dyb8cRyzWLMsnOBV0c+c=; b=owEBbQKS/ZANAwAKAckLinxjhlimAcsmYgBl41gd9rGrGXv5gTfccBoR92QdvsC7Zi6Yz55xg ktLqyzdf52JAjMEAAEKAB0WIQQDCo6eQk7jwGVXh+HJC4p8Y4ZYpgUCZeNYHQAKCRDJC4p8Y4ZY pv3pD/97WhbNloatg2mHaT3Ut8S1i2zJXNCWY5nwWRz1QnpZE6kJDNKriPsoOS8c7Ielbp5nifP FuvWPkkBZQXIfRGvCXT+iHB1hVeJtvFmcW0cpOFOb7HHybn4j6g/O1fLztMNSd1eC0kE6G2XkZD ywVh2QlUUFmYXxAGf8iWBwJnAlsisEAKtTEHiDfMH2ePdGN20USAkt4g5kq9q6zUMNm0YourEok nLjwtYYoz7z93089gWs8JfZsr3k4oGRh2+0SFXBjEYgbqslvxP7X46HGDorGBs+zwQ6G6amc+Ob lb2UymWVBcAnbKXtRB9fr8c/FGycRELhyB543eheOYNWoE31kGYIhY2uGwX2TQTLb4wix4XaOdN XorAXAkPGW6fLIvdmpkKBZH7fUxmV+isekpxricQiLCJlr14r/Hwq4AzD4qAwJK5rS/duduenq8 1IT5W90mUjOqmwTYtdkb+1P9/Y5qXKJShjv48trjnq0lX5knLusHTtYuAwwmM9kIv721OzqkRAs jaPLQW5p0MN4SLqU3ANXCi2Q0DQxSBpElfJvG9/1OAvbSectAUkT2KYuUyHj1VhnBtLJMVtGIXc KWVWKlo42/CMBco9bwRusTvg0xzC3RCvBlfxSTziZCjHMVNUCoiHdsc5vJVd8O2ADGAGrTI88ms 4y1Jf16bBYoxq+Q== X-Developer-Key: i=ricardo@marliere.net; a=openpgp; fpr=030A8E9E424EE3C0655787E1C90B8A7C638658A6 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 cxlflash_class structure to be declared at build time placing it 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 --- drivers/scsi/cxlflash/main.c | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) diff --git a/drivers/scsi/cxlflash/main.c b/drivers/scsi/cxlflash/main.c index debd36974119..e8382cc5cf23 100644 --- a/drivers/scsi/cxlflash/main.c +++ b/drivers/scsi/cxlflash/main.c @@ -28,7 +28,12 @@ MODULE_AUTHOR("Manoj N. Kumar "); MODULE_AUTHOR("Matthew R. Ochs "); MODULE_LICENSE("GPL"); -static struct class *cxlflash_class; +static char *cxlflash_devnode(const struct device *dev, umode_t *mode); +static const struct class cxlflash_class = { + .name = "cxlflash", + .devnode = cxlflash_devnode, +}; + static u32 cxlflash_major; static DECLARE_BITMAP(cxlflash_minor, CXLFLASH_MAX_ADAPTERS); @@ -3602,7 +3607,7 @@ static int init_chrdev(struct cxlflash_cfg *cfg) goto err1; } - char_dev = device_create(cxlflash_class, NULL, devno, + char_dev = device_create(&cxlflash_class, NULL, devno, NULL, "cxlflash%d", minor); if (IS_ERR(char_dev)) { rc = PTR_ERR(char_dev); @@ -3880,14 +3885,12 @@ static int cxlflash_class_init(void) cxlflash_major = MAJOR(devno); - cxlflash_class = class_create("cxlflash"); - if (IS_ERR(cxlflash_class)) { - rc = PTR_ERR(cxlflash_class); + rc = class_register(&cxlflash_class); + if (rc) { pr_err("%s: class_create failed rc=%d\n", __func__, rc); goto err; } - cxlflash_class->devnode = cxlflash_devnode; out: pr_debug("%s: returning rc=%d\n", __func__, rc); return rc; @@ -3903,7 +3906,7 @@ static void cxlflash_class_exit(void) { dev_t devno = MKDEV(cxlflash_major, 0); - class_destroy(cxlflash_class); + class_unregister(&cxlflash_class); unregister_chrdev_region(devno, CXLFLASH_MAX_ADAPTERS); } From patchwork Sat Mar 2 16:47:25 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Ricardo B. Marliere" X-Patchwork-Id: 13579563 Received: from mail-io1-f54.google.com (mail-io1-f54.google.com [209.85.166.54]) (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 9C5A8374F6; Sat, 2 Mar 2024 16:47:41 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.166.54 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1709398063; cv=none; b=P8IYB7LdYrYqT9KTrFaOh0flmEzkKN442WTepzyCFNNLpfVbmQrqZW6OR2Y3z6NBBrSC6hIXDf8PyYsz5vcgYw8FJJxsR+c4rjuIAyNiu78KWkOg+hqCtTiFcDZVeuzXfZo9CTi+0+4ylWGegIyEuFT6CxZvb6hHns6Gq8qjXIs= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1709398063; c=relaxed/simple; bh=OFw+SoUq0xk7W6nH4RuzhazAI/0hRJvdMx9LIMtpX3E=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=FSmslWHMh7lpvmghlJyJik7ruu8ox6zOXGPwNCoaKvLrWF/B97c+gqB1q3o57E/Tcj88PBCKZ2sIXKr7bn23TtbFZEv8SdB/yDJyFkQFFqg/sZLh2IOnAyTnPUV5ftHqBMP36OFlP47FPy4/h20Xm4rcoKM2jueOk73ch33cNVk= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=marliere.net; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=marliere.net header.i=@marliere.net header.b=Rn6zPuYd; arc=none smtp.client-ip=209.85.166.54 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=marliere.net Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=marliere.net header.i=@marliere.net header.b="Rn6zPuYd" Received: by mail-io1-f54.google.com with SMTP id ca18e2360f4ac-7c7b8fb8ba6so193743839f.2; Sat, 02 Mar 2024 08:47:41 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1709398061; x=1710002861; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:dkim-signature:from:x-gm-message-state :from:to:cc:subject:date:message-id:reply-to; bh=io+X3piu28ZGp7fEkiX94HlMuyoRpBle34GT2h5igCM=; b=dEhkRZ5Em3Owp4e95X5tGprH44ZEQS7JlT5LIuXZK/+Gw1AMY6eoW1H82kpnjA3Sq2 /Oildon2Txs5oBxj7gTSw8y3IyQ5dX13DHTb9TDVSr38llrQEowHZDWAlmm/tMYMRJA7 +E2F5f6f1vwiaXfm2VrfhBSPwwm/ekuEC2VSpoWWyjrDRhz1GNsUbuok1d9DchAtu87k 0SGp9f3PRxyYo95m7sPDDq8//HtKsFAGxtXJClDVOFHc64DurGygnsoJUUrrSV/+xUhP J7MNgmeYvsixapVYw6wcIHL+VvQkcdernFSh9DC1I7Ye5F3mHhqCrgV3pd04zK9jDCJt QoRA== X-Forwarded-Encrypted: i=1; AJvYcCVRVv1m0AWjdfGHeJePdr14xipDHniJ1DaHieKqqFHikuYZzUatvsuFfNjp+LVMgh7MLe5yjV+0nkMFexqiCFpS/zw1TLj0lJ8Vb5zs X-Gm-Message-State: AOJu0YzxgvZlaZGI6Ay05QQydxAlAij++pjUMtKJ1oFdNgrNPGjkyr2e ZThcF+dg/iVJubKhRXBTJVnzJs9bDujiVGTEHFlGoyPrkzAwCEOC X-Google-Smtp-Source: AGHT+IGwhI7z0oc0j3g/9SiNMz0DnhCN3lRVafp+YkKuc9V5wkG/aMG1CZgmqdEIgAuWQ8gbVmg/6w== X-Received: by 2002:a05:6e02:2141:b0:365:b56f:ff8 with SMTP id d1-20020a056e02214100b00365b56f0ff8mr6001241ilv.15.1709398060828; Sat, 02 Mar 2024 08:47:40 -0800 (PST) Received: from mail.marliere.net ([24.199.118.162]) by smtp.gmail.com with ESMTPSA id k6-20020a92c9c6000000b0036577f79570sm1542618ilq.54.2024.03.02.08.47.40 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 02 Mar 2024 08:47:40 -0800 (PST) From: "Ricardo B. Marliere" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=marliere.net; s=2024; t=1709398059; h=from:from:reply-to:subject:subject: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; bh=io+X3piu28ZGp7fEkiX94HlMuyoRpBle34GT2h5igCM=; b=Rn6zPuYdvHA1i4lJ2avKHDE5h2+mTSUlwl2b3iNINkvtj+zB3OqJP9ot2hWU3TNkj0IN+/ 8r/i7EnAF0626UmHUqxnE0Cg6mcE11F0a1nAXUHczfT4RSdk5eRy1mqGXy4SMayZsQCDQ2 6nQV4gy0o66iZgFAHqF/nqsOgJBjPyZCZAe4SUJt0hiLSAB5FjQskxvdLEIe8fQ3//VZro NQQ/yHuk5EwUDn4/xruCnLgIEPa8OGk1JHap6iA0iHbIte7c87O+1zFsOemH5/PryLs5Uh wMji25k273VZSUME111nT+xc4uwN2rku6pcTaivcOAnpVZ7cCTGr28vmAPwDsg== Authentication-Results: ORIGINATING; auth=pass smtp.auth=ricardo@marliere.net smtp.mailfrom=ricardo@marliere.net Date: Sat, 02 Mar 2024 13:47:25 -0300 Subject: [PATCH 4/5] scsi: ch: make ch_sysfs_class constant Precedence: bulk X-Mailing-List: linux-scsi@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Message-Id: <20240302-class_cleanup-scsi-v1-4-b9096b990e27@marliere.net> References: <20240302-class_cleanup-scsi-v1-0-b9096b990e27@marliere.net> In-Reply-To: <20240302-class_cleanup-scsi-v1-0-b9096b990e27@marliere.net> To: Doug Gilbert , "James E.J. Bottomley" , "Martin K. Petersen" , "Manoj N. Kumar" , "Matthew R. Ochs" , Uma Krishnan , =?utf-8?q?Kai_M=C3=A4kisara?= Cc: linux-scsi@vger.kernel.org, linux-kernel@vger.kernel.org, Greg Kroah-Hartman , "Ricardo B. Marliere" X-Developer-Signature: v=1; a=openpgp-sha256; l=2964; i=ricardo@marliere.net; h=from:subject:message-id; bh=OFw+SoUq0xk7W6nH4RuzhazAI/0hRJvdMx9LIMtpX3E=; b=owEBbQKS/ZANAwAKAckLinxjhlimAcsmYgBl41gdug7CFvW2hatyKdoEGu0YCP9JqtLPIRH4X A+So7602CSJAjMEAAEKAB0WIQQDCo6eQk7jwGVXh+HJC4p8Y4ZYpgUCZeNYHQAKCRDJC4p8Y4ZY puZfD/9fEO0jnMv3Bq1JgyMfUPJQT8aSKLEJMf7Pbcb9RI5jFHpKC6fTxzB50/Nxhqlnx75nslI ro1ssoH+LIWkdtLtX8Kw2FUBbsR7dCaeTUYu8bljk/ab4mLFRXbTvj8rbre08eBILS6i264z5Kf HhyJgYRzcnD7B0pxoBnWmAvoFrSUhzPEzss0sF5YjvkM2QSP4cvvHfV0Ve1TdcCnfOPP2CW3aXB 9K/JptuL+lvWbnyOmofkzKMqXwuwbOzJn9Os4igSvAg38h+tr/4nsj8qCFaUCwvZIpgWJSYR/Zi 7xtCBoDroJAABSXkHlWKxJ+/uQ+VcQlk1yEZ2HzO8G5O6FDruL/W+lquJmZvVTJNasZw1IBWrEn pxjNNH/wp4GR/IjbZBLEyoPmEPTHfPQgOT5DDhL5SmvNTMIEp9+4geGlfQ6g0ysO4CSFp/jlw2h CaPCxkn8sIQIz2kyRHo0zNOpxAt/iBpYvZ8hKfqFDY2ZZBoaY/nkn6sr2HY98OBtrr5UuDk9up0 n3KIKrhW53SnZ36qK5E4oHZlndvQb0zW2tyzeQ5/9vdXZxLKMvUtyjry5Xo2RUKZh3mDbnznmQG TeTiP/66M5xIRGEtAjKAXwfN4jODl4jNTMrFkeN039qgdP7cGdumloTOVEfmn4cd7Un/onVJU1G D6NOAVOCk+WWDBQ== X-Developer-Key: i=ricardo@marliere.net; a=openpgp; fpr=030A8E9E424EE3C0655787E1C90B8A7C638658A6 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 ch_sysfs_class structure to be declared at build time placing it 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 --- drivers/scsi/ch.c | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/drivers/scsi/ch.c b/drivers/scsi/ch.c index 1befcd5b2a0f..fa07a6f54003 100644 --- a/drivers/scsi/ch.c +++ b/drivers/scsi/ch.c @@ -102,7 +102,9 @@ do { \ #define MAX_RETRIES 1 -static struct class * ch_sysfs_class; +static const struct class ch_sysfs_class = { + .name = "scsi_changer", +}; typedef struct { struct kref ref; @@ -930,7 +932,7 @@ static int ch_probe(struct device *dev) mutex_init(&ch->lock); kref_init(&ch->ref); ch->device = sd; - class_dev = device_create(ch_sysfs_class, dev, + class_dev = device_create(&ch_sysfs_class, dev, MKDEV(SCSI_CHANGER_MAJOR, ch->minor), ch, "s%s", ch->name); if (IS_ERR(class_dev)) { @@ -955,7 +957,7 @@ static int ch_probe(struct device *dev) return 0; destroy_dev: - device_destroy(ch_sysfs_class, MKDEV(SCSI_CHANGER_MAJOR, ch->minor)); + device_destroy(&ch_sysfs_class, MKDEV(SCSI_CHANGER_MAJOR, ch->minor)); put_device: scsi_device_put(sd); remove_idr: @@ -974,7 +976,7 @@ static int ch_remove(struct device *dev) dev_set_drvdata(dev, NULL); spin_unlock(&ch_index_lock); - device_destroy(ch_sysfs_class, MKDEV(SCSI_CHANGER_MAJOR,ch->minor)); + device_destroy(&ch_sysfs_class, MKDEV(SCSI_CHANGER_MAJOR, ch->minor)); scsi_device_put(ch->device); kref_put(&ch->ref, ch_destroy); return 0; @@ -1003,11 +1005,9 @@ static int __init init_ch_module(void) int rc; printk(KERN_INFO "SCSI Media Changer driver v" VERSION " \n"); - ch_sysfs_class = class_create("scsi_changer"); - if (IS_ERR(ch_sysfs_class)) { - rc = PTR_ERR(ch_sysfs_class); + rc = class_register(&ch_sysfs_class); + if (rc) return rc; - } rc = register_chrdev(SCSI_CHANGER_MAJOR,"ch",&changer_fops); if (rc < 0) { printk("Unable to get major %d for SCSI-Changer\n", @@ -1022,7 +1022,7 @@ static int __init init_ch_module(void) fail2: unregister_chrdev(SCSI_CHANGER_MAJOR, "ch"); fail1: - class_destroy(ch_sysfs_class); + class_unregister(&ch_sysfs_class); return rc; } @@ -1030,7 +1030,7 @@ static void __exit exit_ch_module(void) { scsi_unregister_driver(&ch_template.gendrv); unregister_chrdev(SCSI_CHANGER_MAJOR, "ch"); - class_destroy(ch_sysfs_class); + class_unregister(&ch_sysfs_class); idr_destroy(&ch_index_idr); } From patchwork Sat Mar 2 16:47:26 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Ricardo B. Marliere" X-Patchwork-Id: 13579564 Received: from mail-io1-f42.google.com (mail-io1-f42.google.com [209.85.166.42]) (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 9E1D5381DF; Sat, 2 Mar 2024 16:47:44 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.166.42 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1709398066; cv=none; b=Z7dvevCgohGdHvRdrlVMf4doOMIgGr7Rs+jF7fg2JjWPZh2xk1ie7xKtvuLvwrcPP4Q00wvtDthrBDPM7T8GodadER+IjL9J3/+f4odHEKicKlL12HXlb+SzMolL6fe+4eiPS1VjnpwDF3P4hmZutRY43r7nUpKKIQnVtR/B6ds= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1709398066; c=relaxed/simple; bh=wgMOE+sj1rZMMKNVOYVSq6l1jWjszymXD7/64j1vfoU=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=F5oT/hLO2oPJArc9acXtnv/8tCM5G0pQyRMZERjGbucPkBxB9h8Qoyoz795czp1xcYra6EHqLZ/9VJIQrBEN+prGGQoftoYt00DhZxQlF/sOgufu81ZjUzDJWKYDwXsZu7kk6dwk2M+6NqXpXNuQbqMP8izk0FIfKJJeXIMvJZc= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=marliere.net; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=marliere.net header.i=@marliere.net header.b=pm6WQ1M6; arc=none smtp.client-ip=209.85.166.42 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=marliere.net Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=marliere.net header.i=@marliere.net header.b="pm6WQ1M6" Received: by mail-io1-f42.google.com with SMTP id ca18e2360f4ac-7c788332976so113600939f.3; Sat, 02 Mar 2024 08:47:44 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1709398064; x=1710002864; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:dkim-signature:from:x-gm-message-state :from:to:cc:subject:date:message-id:reply-to; bh=j7hW65oxQqWdEt3THXuCSWMMi03uiOaUApU8DRpHvpU=; b=AFi0X61nkay5AMsve4CWvLSE0pFjXCtT+gdZwXLhGJaBFlVtLMdSi6OUk18zyiHUkr r1PfYB6hPc1yl5GdDV61p6F4azsf27BvUJYEvLJxc2svaQ4xW4AWdXarTwe3rh8KxJ6A uVEKMrNmgG9SWqdOk/EHwU/ITWaFUFexOHNk1HWQQUQEISLtgoqjkQmjYefUDAS4kE+D MHkmS62+S6gHwcHlwWM3kDZ5RS9tX2/asKhL3wnZZAvZRKUhBOZ92iMAQ0qdUOkiRG6g Dhx1KieiqRmfsNvQ5Gpt/b+HJmRysWV2QfHqFwybIoI585pxzNO08dtdw5ITQd70k1/t YT/Q== X-Forwarded-Encrypted: i=1; AJvYcCWkC5+ZCUGekHTyR4cNB9asLboGBR3UDdX8VXLEkcwXUaFZQY2Hti3tMWydeizVtTU1//+Q4BHGWZvxXcRYG6VhVRw/SVO7EnbwfBqq X-Gm-Message-State: AOJu0YyCEG6fpkDYtOJrYlNQsvOCa/2PYvYpONxhJ6sTMl6HyZtblFyB V+ren6bVua5z6RJ/6wPucLyNV66gLwMYoVkMg+AGvaTVc1K+PzKE X-Google-Smtp-Source: AGHT+IGf6K75ayQ2r8t2fX7p1HE9LDce/6YMZWF1q0NkpobfGP7wyqQ7FM2j+fwYP3f3TbK81fDdig== X-Received: by 2002:a5e:a714:0:b0:7c8:34b1:e446 with SMTP id b20-20020a5ea714000000b007c834b1e446mr1702514iod.12.1709398063964; Sat, 02 Mar 2024 08:47:43 -0800 (PST) Received: from mail.marliere.net ([24.199.118.162]) by smtp.gmail.com with ESMTPSA id c26-20020a02331a000000b004747a1063a8sm1408697jae.131.2024.03.02.08.47.43 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 02 Mar 2024 08:47:43 -0800 (PST) From: "Ricardo B. Marliere" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=marliere.net; s=2024; t=1709398062; h=from:from:reply-to:subject:subject: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; bh=j7hW65oxQqWdEt3THXuCSWMMi03uiOaUApU8DRpHvpU=; b=pm6WQ1M6R/3bjn1NS37kgHPToUBEwsSBuZlIyfJQNXqR+JNkqHxAXpR9ukRB9VTQHM6Y42 UFTTOq41bZfgFbz69gp886lHNFLbJgYCX9qVng5oAG2IQGSGLxLw2MsRB9nuUlLAq1WK22 8tfVabluKpCxc+ABXsB/pW2VC3H39qcGh/aqpU2QRwwtD9dXiiDAxLrsheu4kYkmwjbGgb /VfIXQuv62r4jjs7gLy8LRsVByScv1YPmjTCXpB3nnMxo4ykaM6PQDsAD5uVqTQN5pnFT4 aF5Rc4YiE6TyyHQr3kv26e9aLCRN3VNJaBS7gQkRTobd8zsZR3CgUh1MhdDW3Q== Authentication-Results: ORIGINATING; auth=pass smtp.auth=ricardo@marliere.net smtp.mailfrom=ricardo@marliere.net Date: Sat, 02 Mar 2024 13:47:26 -0300 Subject: [PATCH 5/5] scsi: st: make st_sysfs_class constant Precedence: bulk X-Mailing-List: linux-scsi@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Message-Id: <20240302-class_cleanup-scsi-v1-5-b9096b990e27@marliere.net> References: <20240302-class_cleanup-scsi-v1-0-b9096b990e27@marliere.net> In-Reply-To: <20240302-class_cleanup-scsi-v1-0-b9096b990e27@marliere.net> To: Doug Gilbert , "James E.J. Bottomley" , "Martin K. Petersen" , "Manoj N. Kumar" , "Matthew R. Ochs" , Uma Krishnan , =?utf-8?q?Kai_M=C3=A4kisara?= Cc: linux-scsi@vger.kernel.org, linux-kernel@vger.kernel.org, Greg Kroah-Hartman , "Ricardo B. Marliere" X-Developer-Signature: v=1; a=openpgp-sha256; l=1276; i=ricardo@marliere.net; h=from:subject:message-id; bh=wgMOE+sj1rZMMKNVOYVSq6l1jWjszymXD7/64j1vfoU=; b=owEBbQKS/ZANAwAKAckLinxjhlimAcsmYgBl41gdrdY8AIXuL43RwAEgLGNcwfXsIpXkoNK07 11TPBPcZsmJAjMEAAEKAB0WIQQDCo6eQk7jwGVXh+HJC4p8Y4ZYpgUCZeNYHQAKCRDJC4p8Y4ZY prxZEACAWAb5qsXTFpr+gGnR8tbrrhJDYQ3w6UCspd7HwVEPiUM8tAgUaYUeV466ossJzPlrA59 TarCIT/T3o7iuik70h7X1SLVXN7gaDmNxVXMnCtQ8V8PXxB1dEuEe4Tfx2ljAIrJFAfndTos4P6 cpsbVAeJ3yLGSKa7k6HjDps+l4R5vBEgY5h11yG6phHG5XawC5wjr0U26VQ+mL3yuhRQsTNrsW7 Jn83hQIuq9ETka1rDL2wR6FQkIRRQK5x84LuB/VEmxybvDZzTZ8FWsFdhVDOwqY31AlKF142eAq Pv6/2sMSo6wo+sOXIt/+pTuBFwd6F6ZxRvs3N8VfnG2u6rLPJbPHWBKgPgYVKk6+8UBH76ifQHe KxoMYCv64KkPkoskCypHNpMj4jBpzvS9anCTenKngcHjS1fo7CE6iQatExR6WOBgeoNfwXFte06 jqqEQrX7DZ0N3pbEX9fQ7h2iQ3iBqbt/O08VlaYY3Hk5G0agx7JoFdfEbnQwfRocxxf0sI0+f5W BHyN2fgj7M/WJOwT8oxm4+LUE87KKKlmPJFRaz840uwpzh1imurWIRKiJdkcqQj5Uy3s2Vyhu7u LCUxNC+POMPh9JkvF/opee9vsZd0WfZWN2omwPOIkANEA0mC5Zunjr+BMOR4N2buUtw3O5IaGz1 6rb/KhFy9NunR5g== X-Developer-Key: i=ricardo@marliere.net; a=openpgp; fpr=030A8E9E424EE3C0655787E1C90B8A7C638658A6 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 st_sysfs_class structure to be declared at build time placing it 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 --- drivers/scsi/st.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/drivers/scsi/st.c b/drivers/scsi/st.c index 338aa8c42968..5a9bcf8e0792 100644 --- a/drivers/scsi/st.c +++ b/drivers/scsi/st.c @@ -87,7 +87,7 @@ static int try_rdio = 1; static int try_wdio = 1; static int debug_flag; -static struct class st_sysfs_class; +static const struct class st_sysfs_class; static const struct attribute_group *st_dev_groups[]; static const struct attribute_group *st_drv_groups[]; @@ -4438,7 +4438,7 @@ static void scsi_tape_release(struct kref *kref) return; } -static struct class st_sysfs_class = { +static const struct class st_sysfs_class = { .name = "scsi_tape", .dev_groups = st_dev_groups, };