From: John Garry <john.g.garry@oracle.com>
To: jejb@linux.ibm.com, martin.petersen@oracle.com
Cc: linux-scsi@vger.kernel.org, linux-kernel@vger.kernel.org,
dgilbert@interlog.com, John Garry <john.g.garry@oracle.com>
Subject: [PATCH 01/11] scsi: scsi_debug: Don't hold driver host struct pointer in host->hostdata[]
Date: Tue, 7 Mar 2023 10:55:45 +0000 [thread overview]
Message-ID: <20230307105555.3745277-2-john.g.garry@oracle.com> (raw)
In-Reply-To: <20230307105555.3745277-1-john.g.garry@oracle.com>
This driver stores just a pointer to the driver host structure in
host->hostdata[]. Most other drivers actually have the driver host
structure allocated in host->hostdata[], but this driver is different as
we allocate that memory separately.
However there is no need to allocate this memory only in host->hostdata[]
when we can already look up the driver host structure from shost->dma_dev.
Also remove a check for !sdbg_host in find_build_dev_info(), as this cannot
be true. Other similar checks will be later removed.
Signed-off-by: John Garry <john.g.garry@oracle.com>
---
drivers/scsi/scsi_debug.c | 16 +++++++---------
1 file changed, 7 insertions(+), 9 deletions(-)
diff --git a/drivers/scsi/scsi_debug.c b/drivers/scsi/scsi_debug.c
index 226139a8aaac..f713117a5f2e 100644
--- a/drivers/scsi/scsi_debug.c
+++ b/drivers/scsi/scsi_debug.c
@@ -327,6 +327,9 @@ struct sdeb_store_info {
#define to_sdebug_host(d) \
container_of(d, struct sdebug_host_info, dev)
+#define to_sdebug_host_from_shost(shost) \
+ to_sdebug_host(shost->dma_dev)
+
enum sdeb_defer_type {SDEB_DEFER_NONE = 0, SDEB_DEFER_HRT = 1,
SDEB_DEFER_WQ = 2, SDEB_DEFER_POLL = 3};
@@ -5168,11 +5171,7 @@ static struct sdebug_dev_info *find_build_dev_info(struct scsi_device *sdev)
struct sdebug_dev_info *open_devip = NULL;
struct sdebug_dev_info *devip;
- sdbg_host = *(struct sdebug_host_info **)shost_priv(sdev->host);
- if (!sdbg_host) {
- pr_err("Host info NULL\n");
- return NULL;
- }
+ sdbg_host = to_sdebug_host_from_shost(sdev->host);
list_for_each_entry(devip, &sdbg_host->dev_info_list, dev_list) {
if ((devip->used) && (devip->channel == sdev->channel) &&
@@ -5409,7 +5408,7 @@ static int scsi_debug_target_reset(struct scsi_cmnd *SCpnt)
hp = sdp->host;
if (!hp)
goto lie;
- sdbg_host = *(struct sdebug_host_info **)shost_priv(hp);
+ sdbg_host = to_sdebug_host_from_shost(hp);
if (sdbg_host) {
list_for_each_entry(devip,
&sdbg_host->dev_info_list,
@@ -5442,7 +5441,7 @@ static int scsi_debug_bus_reset(struct scsi_cmnd *SCpnt)
sdev_printk(KERN_INFO, sdp, "%s\n", __func__);
hp = sdp->host;
if (hp) {
- sdbg_host = *(struct sdebug_host_info **)shost_priv(hp);
+ sdbg_host = to_sdebug_host_from_shost(hp);
if (sdbg_host) {
list_for_each_entry(devip,
&sdbg_host->dev_info_list,
@@ -7821,7 +7820,7 @@ static int sdebug_driver_probe(struct device *dev)
if (!sdebug_clustering)
sdebug_driver_template.dma_boundary = PAGE_SIZE - 1;
- hpnt = scsi_host_alloc(&sdebug_driver_template, sizeof(sdbg_host));
+ hpnt = scsi_host_alloc(&sdebug_driver_template, 0);
if (NULL == hpnt) {
pr_err("scsi_host_alloc failed\n");
error = -ENODEV;
@@ -7864,7 +7863,6 @@ static int sdebug_driver_probe(struct device *dev)
hpnt->nr_maps = 3;
sdbg_host->shost = hpnt;
- *((struct sdebug_host_info **)hpnt->hostdata) = sdbg_host;
if ((hpnt->this_id >= 0) && (sdebug_num_tgts > hpnt->this_id))
hpnt->max_id = sdebug_num_tgts + 1;
else
--
2.35.3
next prev parent reply other threads:[~2023-03-07 10:57 UTC|newest]
Thread overview: 14+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-03-07 10:55 [PATCH 00/11] scsi_debug: Some minor improvements John Garry
2023-03-07 10:55 ` John Garry [this message]
2023-03-07 14:58 ` [PATCH 01/11] scsi: scsi_debug: Don't hold driver host struct pointer in host->hostdata[] Bart Van Assche
2023-03-07 15:12 ` John Garry
2023-03-07 10:55 ` [PATCH 02/11] scsi: scsi_debug: Stop setting devip->sdbg_host twice John Garry
2023-03-07 10:55 ` [PATCH 03/11] scsi: scsi_debug: Drop scsi_debug_abort() NULL pointer checks John Garry
2023-03-07 10:55 ` [PATCH 04/11] scsi: scsi_debug: Drop scsi_debug_device_reset() " John Garry
2023-03-07 10:55 ` [PATCH 05/11] scsi: scsi_debug: Drop scsi_debug_target_reset() " John Garry
2023-03-07 10:55 ` [PATCH 06/11] scsi: scsi_debug: Drop scsi_debug_bus_reset() " John Garry
2023-03-07 10:55 ` [PATCH 07/11] scsi: scsi_debug: Drop scsi_debug_host_reset() device NULL pointer check John Garry
2023-03-07 10:55 ` [PATCH 08/11] scsi: scsi_debug: Drop check for num_in_q exceeding queue depth John Garry
2023-03-07 10:55 ` [PATCH 09/11] scsi: scsi_debug: Drop sdebug_dev_info.num_in_q John Garry
2023-03-07 10:55 ` [PATCH 10/11] scsi: scsi_debug: Get command abort feature working again John Garry
2023-03-07 10:55 ` [PATCH 11/11] scsi: scsi_debug: Add poll mode deferred completions to statistics John Garry
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20230307105555.3745277-2-john.g.garry@oracle.com \
--to=john.g.garry@oracle.com \
--cc=dgilbert@interlog.com \
--cc=jejb@linux.ibm.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-scsi@vger.kernel.org \
--cc=martin.petersen@oracle.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®