Re: [PATCH v4 5/6] scsi: core: Protect host state changes with the host lock

John Garry <[email protected]> Mon, 3 Aug 2026 18:01:02 +0100
Newsgroups org.kernel.vger.linux-scsi
Organization Oracle Corporation
Message-ID <[email protected]>
On 31/07/2026 22:52, Bart Van Assche wrote:
> @@ -411,8 +413,8 @@ struct Scsi_Host *scsi_host_alloc(const struct scsi_host_template *sht, int priv
>   		return NULL;
>   
>   	shost->host_lock = &shost->default_lock;
> -	spin_lock_init(shost->host_lock);
> -	shost->shost_state = SHOST_CREATED;
> +	scoped_guard(spinlock_init, shost->host_lock)

Please forgive my ignorance, but what does spinlock_init do here in 
relation to setting shost->shost_state?

Elsewhere we have scoped_guard(spinlock_irq, shost->host_lock) for 
protecting setting shost->shost_state and this makes sense to me. 
However I am curious what scoped_guard(spinlock_init, ...) does.

> +		shost->shost_state = SHOST_CREATED;