From patchwork Fri Feb 28 15:11:17 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Jonathan_Neusch=C3=A4fer_via_B4_Relay?= X-Patchwork-Id: 869815 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 3C1DF1EF361; Fri, 28 Feb 2025 15:11:34 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1740755495; cv=none; b=gT8PYy7/GnzeXJxFzE1PFnLJef0Dw9ITC6bdXSWaCuRbfYI/O5Wzk/bzP9DSjAnaaRWpf939zW3C15CQJqfP1yhChY346A0cjMjm4Yv+XYFRXhWoLr00F4QhOktgsYq6p4F2E4t3tumR2c3LPJRH2iegmgm63P5FPJrJyh5lSMg= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1740755495; c=relaxed/simple; bh=bf3wlblmTinnWFniIp02mcMiY7kKvz+UH9UrgdVi1Yk=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=rsZbzvUSA9kCmm2ZAGwkq3eme0P1zUE28A7g9FloWsuEXtLxaPpaxLNZ0H42LTXDmM36dfZQ5cTz6w3hqvwojfa1irTH7t8hmu5jMaMIHORwlYD1/ogcQs2ciZe1yeokrxkvhyL46Ub5CiKSkPEruBHskdqKZJgJOqH4MEqIorg= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=Y11VSiuo; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="Y11VSiuo" Received: by smtp.kernel.org (Postfix) with ESMTPS id D002BC4CEE2; Fri, 28 Feb 2025 15:11:34 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1740755494; bh=bf3wlblmTinnWFniIp02mcMiY7kKvz+UH9UrgdVi1Yk=; h=From:Date:Subject:References:In-Reply-To:To:Cc:Reply-To:From; b=Y11VSiuosDDu4OvhcY+kGVxaTlIeV+imkEeXTsRvgfbIY8CQuKmcmWDLqUAY047JS JXG8AL7iT3bgIKhjYoIIsvU/80Q5eKcFSuMaxJsWs3x9oAIbdeaYNErEyeCB1G9El6 o7D00ezfyXbg03AHpnQ8ifkVor7C33a1CsEjChc/Sdt8QsrDw6jV4m+i2S0E/i+eaF YE5QYH8du3QRweSp9Orkm2jY5JuIAz6pieg9KeMNYz0yAI/cSkzVrwJAy+vUsvbnci K+dihqLkEcLpmfiufLANTU1Tg0IAiyuGMjO8y1/DFKEBd0PAYRqcXDOq69izu1DQ1b aBfXIUvysnCkw== Received: from aws-us-west-2-korg-lkml-1.web.codeaurora.org (localhost.localdomain [127.0.0.1]) by smtp.lore.kernel.org (Postfix) with ESMTP id C2ED7C282D0; Fri, 28 Feb 2025 15:11:34 +0000 (UTC) From: =?utf-8?q?Jonathan_Neusch=C3=A4fer_via_B4_Relay?= Date: Fri, 28 Feb 2025 16:11:17 +0100 Subject: [PATCH v3 2/9] usb: storage: transport: Use const for constant array Precedence: bulk X-Mailing-List: linux-usb@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Message-Id: <20250228-misc-const-v3-2-09b417ded9c4@posteo.net> References: <20250228-misc-const-v3-0-09b417ded9c4@posteo.net> In-Reply-To: <20250228-misc-const-v3-0-09b417ded9c4@posteo.net> To: Alan Stern , Greg Kroah-Hartman Cc: linux-usb@vger.kernel.org, usb-storage@lists.one-eyed-alien.net, linux-kernel@vger.kernel.org, =?utf-8?q?Jonathan_Neusch=C3=A4fer?= X-Mailer: b4 0.14.2 X-Developer-Signature: v=1; a=ed25519-sha256; t=1740755487; l=1083; i=j.ne@posteo.net; s=20240329; h=from:subject:message-id; bh=5QhhUgzLhqlm9TuqxkqZvu43pDK5vNdB37hr9QmYLe0=; b=Do+TFHXIzpuTMoqzCo0Tlwt1aL6JJT8DwkXkg/H3OvZYEdkDmwi2cv0YFHb/HTKnG0germ+oH 3FcQCQ4aPi4AYzYLjafm50iYjfGO2uOQK+QciXxn5RZ3CgOFtFWEsdV X-Developer-Key: i=j.ne@posteo.net; a=ed25519; pk=NIe0bK42wNaX/C4bi6ezm7NJK0IQE+8MKBm7igFMIS4= X-Endpoint-Received: by B4 Relay for j.ne@posteo.net/20240329 with auth_id=156 X-Original-From: =?utf-8?q?Jonathan_Neusch=C3=A4fer?= Reply-To: j.ne@posteo.net From: Jonathan Neuschäfer This array is only read, not modified. Declaring data as const makes it easier to see what's going on, and can prevent unintended writes through placement in a read-only section. Signed-off-by: Jonathan Neuschäfer --- V3: - elaborate why const is a good idea V2: - new patch --- drivers/usb/storage/transport.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/usb/storage/transport.c b/drivers/usb/storage/transport.c index e6bc8ecaecbb202714be69c6db6b0a4824de4855..1aa1bd26c81f2f9fbd508fdfed4465e6482bdef0 100644 --- a/drivers/usb/storage/transport.c +++ b/drivers/usb/storage/transport.c @@ -528,7 +528,7 @@ static void last_sector_hacks(struct us_data *us, struct scsi_cmnd *srb) u32 sector; /* To Report "Medium Error: Record Not Found */ - static unsigned char record_not_found[18] = { + static const unsigned char record_not_found[18] = { [0] = 0x70, /* current error */ [2] = MEDIUM_ERROR, /* = 0x03 */ [7] = 0x0a, /* additional length */ From patchwork Fri Feb 28 15:11:19 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Jonathan_Neusch=C3=A4fer_via_B4_Relay?= X-Patchwork-Id: 869814 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 580A71EF370; Fri, 28 Feb 2025 15:11:35 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1740755495; cv=none; b=U6shN7mcZZxyotl4epGNOP5UaN14vbP8EUwzW18D41FWcdeaXagzOB+iUMsayVt6UcC78IcTvZU4681pw30jA5MFiFT235gi6IS0Osc3mh3RwBGQaPMNwOS25UwgKW6Q/kdjIyGuPIje7h0JicpyFYcwJFkploYwrPUj4vSmjK8= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1740755495; c=relaxed/simple; bh=cdSuKnT2sd9mu09u9x2uroSHcOnXLi4YExIlWOzziOc=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=XJj0GEmSKD1zW7p0T8oRigW6sEDGWIFxY2gBG9hNS/tHL1mJTS+Pwrk+MMETlym0Y3YmD9rO1auWO8Jg2VTnIJEH38D9MHotj+tkB4FI4VK5jUewTUgSrYHOPDCuQZfMDxDrcacBFH2jGfTuJunucsELIjC4uf1Y6tbWlUuiA/I= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=HTNcsXp6; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="HTNcsXp6" Received: by smtp.kernel.org (Postfix) with ESMTPS id E628BC4CEE9; Fri, 28 Feb 2025 15:11:34 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1740755494; bh=cdSuKnT2sd9mu09u9x2uroSHcOnXLi4YExIlWOzziOc=; h=From:Date:Subject:References:In-Reply-To:To:Cc:Reply-To:From; b=HTNcsXp6J+YGrdD7hmDLy33HufXX/fo7Kn9p2OXZf5u98oGzEZFrcnVmMP37xlhPu FT0gqiCklBiWf9cbXrRLbD0aPZ18WLOfYnsbROUuaUxX6KEa7+orbvhSqfA73wswe/ KFXIWWshQOpJA8DBMaRRyuLFwpzxJKZR73EOg80VN4V/tvdc8H2sA13BcV4PplwWFg OLMPNzYLOxkV8FNnMlX9Wiq6qjAEJAItYRbISFmUwAHa66FU/9TVuRyi5/zJTQlNKM G/OMq+BQbI08AjxNZ8IZt5lCUWOmI6HU8HJZ5/DJG9kVRBrjDeEPS1w3VEvKJXpC7A HEHiYMi72ULEQ== Received: from aws-us-west-2-korg-lkml-1.web.codeaurora.org (localhost.localdomain [127.0.0.1]) by smtp.lore.kernel.org (Postfix) with ESMTP id DBBA7C282D1; Fri, 28 Feb 2025 15:11:34 +0000 (UTC) From: =?utf-8?q?Jonathan_Neusch=C3=A4fer_via_B4_Relay?= Date: Fri, 28 Feb 2025 16:11:19 +0100 Subject: [PATCH v3 4/9] usb: storage: datafab: Use const for constant arrays Precedence: bulk X-Mailing-List: linux-usb@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Message-Id: <20250228-misc-const-v3-4-09b417ded9c4@posteo.net> References: <20250228-misc-const-v3-0-09b417ded9c4@posteo.net> In-Reply-To: <20250228-misc-const-v3-0-09b417ded9c4@posteo.net> To: Alan Stern , Greg Kroah-Hartman Cc: linux-usb@vger.kernel.org, usb-storage@lists.one-eyed-alien.net, linux-kernel@vger.kernel.org, =?utf-8?q?Jonathan_Neusch=C3=A4fer?= X-Mailer: b4 0.14.2 X-Developer-Signature: v=1; a=ed25519-sha256; t=1740755487; l=2538; i=j.ne@posteo.net; s=20240329; h=from:subject:message-id; bh=yfxYfaF8Q7PIxOVWEnYYboHL7YcgLcujoqn0SQzuem4=; b=JbKx0x32ZLzV6QqtxmDJURu77gmnOpKmN1kohJvtrdILXcI6OtZbOs9C5+mjbgi2BQLx08CP4 Ovc0j/bPp/SCwW6sBmUDyP84ulfxo/kJP/4ih3aOhtHb9wpSKqz3BBY X-Developer-Key: i=j.ne@posteo.net; a=ed25519; pk=NIe0bK42wNaX/C4bi6ezm7NJK0IQE+8MKBm7igFMIS4= X-Endpoint-Received: by B4 Relay for j.ne@posteo.net/20240329 with auth_id=156 X-Original-From: =?utf-8?q?Jonathan_Neusch=C3=A4fer?= Reply-To: j.ne@posteo.net From: Jonathan Neuschäfer These arrays are only read, not modified. Declaring data as const makes it easier to see what's going on, and can prevent unintended writes through placement in a read-only section. Signed-off-by: Jonathan Neuschäfer --- V3: - elaborate why const is a good idea V2: - new patch --- drivers/usb/storage/datafab.c | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/drivers/usb/storage/datafab.c b/drivers/usb/storage/datafab.c index bbfa2398b17036f431c0692bbf794bdb01d68cdf..9ba369483c9b36c2f662749c32bf81b525ae897f 100644 --- a/drivers/usb/storage/datafab.c +++ b/drivers/usb/storage/datafab.c @@ -319,7 +319,7 @@ static int datafab_determine_lun(struct us_data *us, // // There might be a better way of doing this? - static unsigned char scommand[8] = { 0, 1, 0, 0, 0, 0xa0, 0xec, 1 }; + static const unsigned char scommand[8] = { 0, 1, 0, 0, 0, 0xa0, 0xec, 1 }; unsigned char *command = us->iobuf; unsigned char *buf; int count = 0, rc; @@ -384,7 +384,7 @@ static int datafab_id_device(struct us_data *us, // to the ATA spec, 'Sector Count' isn't used but the Windows driver // sets this bit so we do too... // - static unsigned char scommand[8] = { 0, 1, 0, 0, 0, 0xa0, 0xec, 1 }; + static const unsigned char scommand[8] = { 0, 1, 0, 0, 0, 0xa0, 0xec, 1 }; unsigned char *command = us->iobuf; unsigned char *reply; int rc; @@ -437,16 +437,16 @@ static int datafab_handle_mode_sense(struct us_data *us, struct scsi_cmnd * srb, int sense_6) { - static unsigned char rw_err_page[12] = { + static const unsigned char rw_err_page[12] = { 0x1, 0xA, 0x21, 1, 0, 0, 0, 0, 1, 0, 0, 0 }; - static unsigned char cache_page[12] = { + static const unsigned char cache_page[12] = { 0x8, 0xA, 0x1, 0, 0, 0, 0, 0, 0, 0, 0, 0 }; - static unsigned char rbac_page[12] = { + static const unsigned char rbac_page[12] = { 0x1B, 0xA, 0, 0x81, 0, 0, 0, 0, 0, 0, 0, 0 }; - static unsigned char timer_page[8] = { + static const unsigned char timer_page[8] = { 0x1C, 0x6, 0, 0, 0, 0 }; unsigned char pc, page_code; @@ -550,7 +550,7 @@ static int datafab_transport(struct scsi_cmnd *srb, struct us_data *us) int rc; unsigned long block, blocks; unsigned char *ptr = us->iobuf; - static unsigned char inquiry_reply[8] = { + static const unsigned char inquiry_reply[8] = { 0x00, 0x80, 0x00, 0x01, 0x1F, 0x00, 0x00, 0x00 }; From patchwork Fri Feb 28 15:11:22 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Jonathan_Neusch=C3=A4fer_via_B4_Relay?= X-Patchwork-Id: 869813 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 6A8951EF385; Fri, 28 Feb 2025 15:11:35 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1740755495; cv=none; b=uvYRDaEwsXblaA+S5z18vg5kOVjYo7lsocs92K/LxIl5dplbhGNAkD1InG7zCOJ7lX951BfTS72ox4Yjvo3O7iLHXteP5Ss31SFmZCn87C/Z3GxNbuKDK2zZZfORsbaeabIUPbXy2I6q6x9CEC7JcQUFhC4g7iuPIJLbYvQuf20= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1740755495; c=relaxed/simple; bh=Gq4AWL6AY/PqYXGSEP4IhXEpS+l4bIw3E4nTSJGtDgE=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=tQHE4K4bNJ0nhPGHuhv9T/bN9gZd8srL3Y0OV8+F7BnlxR64xZlF52lRd4zjePgSCF6ZnucbJvboDsMIhNB0ZaIC1zCTVnNOafN7wBMM/aJVpNp4qeRxJAzGvkCkBgqN3/5WG4LQr22VhgBO5ufhZmavNQKo6OE6Nl6ydB8Z8CU= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=AtM7GyPw; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="AtM7GyPw" Received: by smtp.kernel.org (Postfix) with ESMTPS id 16931C4CEEB; Fri, 28 Feb 2025 15:11:35 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1740755495; bh=Gq4AWL6AY/PqYXGSEP4IhXEpS+l4bIw3E4nTSJGtDgE=; h=From:Date:Subject:References:In-Reply-To:To:Cc:Reply-To:From; b=AtM7GyPw3HxmjuDvsKVmkYBvTJO3VGul0/t+ZmqwAjovV6kr+vbpSh/xQfUaB78hN K1yh9xsA5RYMu72YmVXGz73AjP1HodEDL9B+xgqu/N2Z4Eq+FY1sgp/jfX7kZxHyhZ 2huNwJQnglDgrizsZotiwRastFNjIXUb0Vwc7LsbOYwistl0coOlR9wv9k0h1Ia5wo xsOuPFD2jlLLDTc+uvh0Ucfzvt5wS/B3k2Hx0Ms393GQFatvhi9CtEA+KB11Wc67R3 nkf5dqUE0dsMVouvJPzMsI/LwjRmJ9Q0XKW5+Nd4d8coO70hDEiqUryIz6yr96kvbk NEYpEIYe99WZQ== Received: from aws-us-west-2-korg-lkml-1.web.codeaurora.org (localhost.localdomain [127.0.0.1]) by smtp.lore.kernel.org (Postfix) with ESMTP id 0FC97C282C1; Fri, 28 Feb 2025 15:11:35 +0000 (UTC) From: =?utf-8?q?Jonathan_Neusch=C3=A4fer_via_B4_Relay?= Date: Fri, 28 Feb 2025 16:11:22 +0100 Subject: [PATCH v3 7/9] usb: storage: sddr09: Use const for constant arrays Precedence: bulk X-Mailing-List: linux-usb@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Message-Id: <20250228-misc-const-v3-7-09b417ded9c4@posteo.net> References: <20250228-misc-const-v3-0-09b417ded9c4@posteo.net> In-Reply-To: <20250228-misc-const-v3-0-09b417ded9c4@posteo.net> To: Alan Stern , Greg Kroah-Hartman Cc: linux-usb@vger.kernel.org, usb-storage@lists.one-eyed-alien.net, linux-kernel@vger.kernel.org, =?utf-8?q?Jonathan_Neusch=C3=A4fer?= X-Mailer: b4 0.14.2 X-Developer-Signature: v=1; a=ed25519-sha256; t=1740755487; l=2527; i=j.ne@posteo.net; s=20240329; h=from:subject:message-id; bh=l+RAY2RPsx/JPY4RJUMnd+IPm3/INCAlkSXItxmAg4Q=; b=6WBB8ETU477ruMo1xN/6W31d5OrSbxNiYQANwHrc/DsmaKLwdBrF+DRVOFoMu9N0t3v79sAzw fcvHCUvcTgzCwytQJQ6Jy3SAAwJsxM9BFHnDSv5ViAJOp4K8plvf6Z9 X-Developer-Key: i=j.ne@posteo.net; a=ed25519; pk=NIe0bK42wNaX/C4bi6ezm7NJK0IQE+8MKBm7igFMIS4= X-Endpoint-Received: by B4 Relay for j.ne@posteo.net/20240329 with auth_id=156 X-Original-From: =?utf-8?q?Jonathan_Neusch=C3=A4fer?= Reply-To: j.ne@posteo.net From: Jonathan Neuschäfer The nand_flash_ids, inquiry_response, and mode_page_01 arrays are only read, not modified. Declaring data as const makes it easier to see what's going on, and can prevent unintended writes through placement in a read-only section. Signed-off-by: Jonathan Neuschäfer --- V3: - elaborate why const is a good idea V2: - new patch --- drivers/usb/storage/sddr09.c | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/drivers/usb/storage/sddr09.c b/drivers/usb/storage/sddr09.c index d21ce3466e25842757b3e278d522c55b7c1f19de..e66b920e99e25c90b581ff1f3eae16ed0cfd903c 100644 --- a/drivers/usb/storage/sddr09.c +++ b/drivers/usb/storage/sddr09.c @@ -144,7 +144,7 @@ static inline char *nand_flash_manufacturer(int manuf_id) { * 256 MB NAND flash has a 5-byte ID with 2nd byte 0xaa, 0xba, 0xca or 0xda. */ -static struct nand_flash_dev nand_flash_ids[] = { +static const struct nand_flash_dev nand_flash_ids[] = { /* NAND flash */ { 0x6e, 20, 8, 4, 8, 2}, /* 1 MB */ { 0xe8, 20, 8, 4, 8, 2}, /* 1 MB */ @@ -169,7 +169,7 @@ static struct nand_flash_dev nand_flash_ids[] = { { 0,} }; -static struct nand_flash_dev * +static const struct nand_flash_dev * nand_find_id(unsigned char id) { int i; @@ -1133,9 +1133,9 @@ sddr09_reset(struct us_data *us) { } #endif -static struct nand_flash_dev * +static const struct nand_flash_dev * sddr09_get_cardinfo(struct us_data *us, unsigned char flags) { - struct nand_flash_dev *cardinfo; + const struct nand_flash_dev *cardinfo; unsigned char deviceID[4]; char blurbtxt[256]; int result; @@ -1545,12 +1545,12 @@ static int sddr09_transport(struct scsi_cmnd *srb, struct us_data *us) struct sddr09_card_info *info; - static unsigned char inquiry_response[8] = { + static const unsigned char inquiry_response[8] = { 0x00, 0x80, 0x00, 0x02, 0x1F, 0x00, 0x00, 0x00 }; /* note: no block descriptor support */ - static unsigned char mode_page_01[19] = { + static const unsigned char mode_page_01[19] = { 0x00, 0x0F, 0x00, 0x0, 0x0, 0x0, 0x00, 0x01, 0x0A, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 @@ -1584,7 +1584,7 @@ static int sddr09_transport(struct scsi_cmnd *srb, struct us_data *us) } if (srb->cmnd[0] == READ_CAPACITY) { - struct nand_flash_dev *cardinfo; + const struct nand_flash_dev *cardinfo; sddr09_get_wp(us, info); /* read WP bit */ From patchwork Fri Feb 28 15:11:23 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Jonathan_Neusch=C3=A4fer_via_B4_Relay?= X-Patchwork-Id: 869811 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 81B681EF38B; Fri, 28 Feb 2025 15:11:35 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1740755495; cv=none; b=D4/55hxDpXXciPQoJmJnPi0/0trHCxE7Lx1vUqjpoF0QOtoli4lQdlPgtyQqkM60YBngZEimkzbiB4a9TtVyA3gizQEkBeXp1axw9IFF/rr/0Xku5cSTKZ/hEoGKtKjJ5ySUAN7E5u1hq6ucxGO2sUXIu+Rp8Q+Sim6NAZM1Azg= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1740755495; c=relaxed/simple; bh=9ZJqhfxxUVKNn9pQ4sEtXI4UMBqewViPBr/PTvTjPN4=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=OBS/ksDGdZiZTyWeAPyf2iRDWZkLmXDLXYGm93bNKas6iDzOIPJxrzmYb2NZYmFIR1DfbTSwa4zRjLq42O0PmD+tBZKVhDt5dTfitrVRYpp9SD6V8T5bXtud8eKuHRxTU13ho5Tyemc3Sl9nw/7XDqY0ES3Ykn8eKy6KXabO/D8= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=cCF8J9u1; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="cCF8J9u1" Received: by smtp.kernel.org (Postfix) with ESMTPS id 26C7AC4CEED; Fri, 28 Feb 2025 15:11:35 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1740755495; bh=9ZJqhfxxUVKNn9pQ4sEtXI4UMBqewViPBr/PTvTjPN4=; h=From:Date:Subject:References:In-Reply-To:To:Cc:Reply-To:From; b=cCF8J9u1MMhIxliRHBG9j3Ogm5sTJcKO6u/9GgChK0cvg5l7FLen9lBwWGPssBj53 y2fS0CB842jWuJmQoq0LRT7bOIAXom6LJ6hdrKCnEEiGMS1o6NljHl9jpd+Hg9xTt0 Exb4NnnXvzBjFidHpNmc5lJroDc2LYBi8wgUfsiWBvd2h/eKjcHFYJiiS7NeG2I1DN T4TNqGxA03Klhfr6YOIkJoRs58YmYtZa9ot4hI0Ou3DfCXcQ6QJA6svXPavyjL7tEw dqdb6qKP03fW9C+8gIuezxzYcyFHH+0U5WoqP9U5TSQkowUwnYX41e2aRW5vQ+nnRw oHPK0+Btj/AuA== Received: from aws-us-west-2-korg-lkml-1.web.codeaurora.org (localhost.localdomain [127.0.0.1]) by smtp.lore.kernel.org (Postfix) with ESMTP id 1FB20C282D0; Fri, 28 Feb 2025 15:11:35 +0000 (UTC) From: =?utf-8?q?Jonathan_Neusch=C3=A4fer_via_B4_Relay?= Date: Fri, 28 Feb 2025 16:11:23 +0100 Subject: [PATCH v3 8/9] usb: storage: sddr55: Use const for constant arrays Precedence: bulk X-Mailing-List: linux-usb@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Message-Id: <20250228-misc-const-v3-8-09b417ded9c4@posteo.net> References: <20250228-misc-const-v3-0-09b417ded9c4@posteo.net> In-Reply-To: <20250228-misc-const-v3-0-09b417ded9c4@posteo.net> To: Alan Stern , Greg Kroah-Hartman Cc: linux-usb@vger.kernel.org, usb-storage@lists.one-eyed-alien.net, linux-kernel@vger.kernel.org, =?utf-8?q?Jonathan_Neusch=C3=A4fer?= X-Mailer: b4 0.14.2 X-Developer-Signature: v=1; a=ed25519-sha256; t=1740755487; l=1301; i=j.ne@posteo.net; s=20240329; h=from:subject:message-id; bh=dyKVA5pPyRY7TuBL1KemWvR3umAVS5JkAQpDbS4Ydg8=; b=BA2AmNdIfge2Df+JYGIJv5vw589dHvWjgpw9g3g4XAmSw0hlylN9Cwos695Ecbek4xyDO25CK YPc4LO4ulNyCW2RrB7XQ6aT4rULx/eUV2vZE8BRKGz3BpojbZOU/8sn X-Developer-Key: i=j.ne@posteo.net; a=ed25519; pk=NIe0bK42wNaX/C4bi6ezm7NJK0IQE+8MKBm7igFMIS4= X-Endpoint-Received: by B4 Relay for j.ne@posteo.net/20240329 with auth_id=156 X-Original-From: =?utf-8?q?Jonathan_Neusch=C3=A4fer?= Reply-To: j.ne@posteo.net From: Jonathan Neuschäfer These arrays are only read, not modified. Declaring data as const makes it easier to see what's going on, and can prevent unintended writes through placement in a read-only section. Signed-off-by: Jonathan Neuschäfer --- V3: - elaborate why const is a good idea V2: - new patch --- drivers/usb/storage/sddr55.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/drivers/usb/storage/sddr55.c b/drivers/usb/storage/sddr55.c index d5cdff30f6f31f98d3d58ffcdd2426d7cd385cbb..b323f0a3626031905b946ce64ddf04539a6e3232 100644 --- a/drivers/usb/storage/sddr55.c +++ b/drivers/usb/storage/sddr55.c @@ -775,11 +775,11 @@ static void sddr55_card_info_destructor(void *extra) { static int sddr55_transport(struct scsi_cmnd *srb, struct us_data *us) { int result; - static unsigned char inquiry_response[8] = { + static const unsigned char inquiry_response[8] = { 0x00, 0x80, 0x00, 0x02, 0x1F, 0x00, 0x00, 0x00 }; // write-protected for now, no block descriptor support - static unsigned char mode_page_01[20] = { + static const unsigned char mode_page_01[20] = { 0x0, 0x12, 0x00, 0x80, 0x0, 0x0, 0x0, 0x0, 0x01, 0x0A, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 From patchwork Fri Feb 28 15:11:24 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Jonathan_Neusch=C3=A4fer_via_B4_Relay?= X-Patchwork-Id: 869812 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 7F2291EF389; Fri, 28 Feb 2025 15:11:35 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1740755495; cv=none; b=gQERpVjVh1t+yPoSIi3pKl0OrYtRHeiNWHGdq/xJvIJpDKFLlh6qXM3tJVpxAqHFLbjnvEJ945yH9f4/ESUfavjtaMSup7dXE3jOdll7FakP8ALAI65AgvTseKG08pBI6E7gVW8qO9idmH2jgUAmOSdElm88tFyWZvkqaM1n72g= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1740755495; c=relaxed/simple; bh=m9oCxP9/ETxoHFPO9KXHbJ6twMmsrtK7h4rb6GlG0uU=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=HQeAilQq3+jz9aCwolGEYlj44pfI7soRgzbClKgHo+6BPjowhk8qsCAUrZdM/+1m8cSyeDcK32VG1JLRMPEgt6AA3KqQzWjuh+wzMqFxiBy86soghDFyxt50DbNo9zQ8MA9WE9CNaMi5cM25QPZwXhEw7DrmzZR+uNm0w2ScOg8= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=YTBe2Pmw; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="YTBe2Pmw" Received: by smtp.kernel.org (Postfix) with ESMTPS id 33B6DC4CEEF; Fri, 28 Feb 2025 15:11:35 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1740755495; bh=m9oCxP9/ETxoHFPO9KXHbJ6twMmsrtK7h4rb6GlG0uU=; h=From:Date:Subject:References:In-Reply-To:To:Cc:Reply-To:From; b=YTBe2PmwYr1JJip8EUYvg4m7NXKGo+abx3iF04MVWqc/cAAxlHlhlGspJqOllAfrj jllQDyP/ouFz40egRxyUAk8mahQCWlgS240O4OuAu3qGVG9GHjnUIC8/FXbDS5S/v6 r4UUazYCfp+B05bRGpcCf3PjhIfQ5qWllw8/lHxADHljOUZ/DY+wCrrHBiSs5GbbQ5 n7RenSvA7885vmpwDsOXkqMQorkb2EUxW0YB5rvPFdp5vCl/y2CXr1iykC3LO+TeDA foC5Rj4zQGw0lyCN8oqUQTbsH23AkbrHiwpd/KBuVcvq1MoLXZfsDcoLC6g5LmIOeC 32sOuDy/9wqYA== Received: from aws-us-west-2-korg-lkml-1.web.codeaurora.org (localhost.localdomain [127.0.0.1]) by smtp.lore.kernel.org (Postfix) with ESMTP id 2C10EC282D1; Fri, 28 Feb 2025 15:11:35 +0000 (UTC) From: =?utf-8?q?Jonathan_Neusch=C3=A4fer_via_B4_Relay?= Date: Fri, 28 Feb 2025 16:11:24 +0100 Subject: [PATCH v3 9/9] usb: storage: shuttle_usbat: Use const for constant array Precedence: bulk X-Mailing-List: linux-usb@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Message-Id: <20250228-misc-const-v3-9-09b417ded9c4@posteo.net> References: <20250228-misc-const-v3-0-09b417ded9c4@posteo.net> In-Reply-To: <20250228-misc-const-v3-0-09b417ded9c4@posteo.net> To: Alan Stern , Greg Kroah-Hartman Cc: linux-usb@vger.kernel.org, usb-storage@lists.one-eyed-alien.net, linux-kernel@vger.kernel.org, =?utf-8?q?Jonathan_Neusch=C3=A4fer?= X-Mailer: b4 0.14.2 X-Developer-Signature: v=1; a=ed25519-sha256; t=1740755487; l=1113; i=j.ne@posteo.net; s=20240329; h=from:subject:message-id; bh=c3zFUpIiLQBTnxFuX58IYeC708hZ2OFipFj3XEiE89M=; b=17wwAL61o0Jxp0MpLVODKSR5Di1ZGuLePUAxm0dBAjg9XqlvS+dfhTNn3txurpA0eEvTR+bhD VBaqrrNEvXeAsyefhBm1t9roTEB21NVsLaiAcO0Rq7eMhdHhDVxA4eR X-Developer-Key: i=j.ne@posteo.net; a=ed25519; pk=NIe0bK42wNaX/C4bi6ezm7NJK0IQE+8MKBm7igFMIS4= X-Endpoint-Received: by B4 Relay for j.ne@posteo.net/20240329 with auth_id=156 X-Original-From: =?utf-8?q?Jonathan_Neusch=C3=A4fer?= Reply-To: j.ne@posteo.net From: Jonathan Neuschäfer This array is only read, not modified. Declaring data as const makes it easier to see what's going on, and can prevent unintended writes through placement in a read-only section. Signed-off-by: Jonathan Neuschäfer --- V3: - elaborate why const is a good idea V2: - new patch --- drivers/usb/storage/shuttle_usbat.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/usb/storage/shuttle_usbat.c b/drivers/usb/storage/shuttle_usbat.c index c33cbf177e6fcaa80e0d2639594d1314c59f4950..27faa0ead11d1b0ee9e45ba6a3ee5bade8a416e4 100644 --- a/drivers/usb/storage/shuttle_usbat.c +++ b/drivers/usb/storage/shuttle_usbat.c @@ -1683,7 +1683,7 @@ static int usbat_flash_transport(struct scsi_cmnd * srb, struct us_data *us) struct usbat_info *info = (struct usbat_info *) (us->extra); unsigned long block, blocks; unsigned char *ptr = us->iobuf; - static unsigned char inquiry_response[36] = { + static const unsigned char inquiry_response[36] = { 0x00, 0x80, 0x00, 0x01, 0x1F, 0x00, 0x00, 0x00 };