linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: John Garry <john.garry@huawei.com>
To: "Ewan D. Milne" <emilne@redhat.com>,
	Krzysztof Kozlowski <krzysztof.kozlowski@linaro.org>,
	"James E.J. Bottomley" <jejb@linux.ibm.com>,
	"Martin K. Petersen" <martin.petersen@oracle.com>,
	"Alim Akhtar" <alim.akhtar@samsung.com>,
	Avri Altman <avri.altman@wdc.com>,
	"Doug Gilbert" <dgilbert@interlog.com>,
	<linux-scsi@vger.kernel.org>, <linux-kernel@vger.kernel.org>
Cc: <james.smart@broadcom.com>
Subject: Re: [PATCH 1/4] scsi: core: constify pointer to scsi_host_template
Date: Tue, 12 Apr 2022 08:57:39 +0100	[thread overview]
Message-ID: <b6af3fe8-db9a-b5dc-199f-21c05d7664a2@huawei.com> (raw)
In-Reply-To: <c121430b1b5c8f5816b2b42b9178d00889260c90.camel@redhat.com>

On 08/04/2022 20:31, Ewan D. Milne wrote:
> On Fri, 2022-04-08 at 13:57 +0100, John Garry wrote:
>> On 08/04/2022 13:32, Krzysztof Kozlowski wrote:
>>> On 08/04/2022 14:14, John Garry wrote:
>>>> On 08/04/2022 11:30, Krzysztof Kozlowski wrote:
>>>>> Several pointers to 'struct scsi_host_template' do not modify it, so
>>>>> made them const for safety.
>>>>>
>>>> Is this standard practice? What is so special here?
>>> This is standard practice and there is nothing special here. Pointers to
>>> const are preferred because:
>>> 1. They add safety if data is actually const. This is not yet the case,
>>> but scsi_host_template allocation could be made const with some effort.
> 
> This seems unlikely, because some drivers, e.g. vmw_pvscsi and scsi_debug,
> modify the scsi_host_template based on things like module parameters.
>

The standard flow is:

shost = scsi_host_alloc(sht, )

// modify shost, like
shost->cmd_per_lun = 5;

scsi_add_host(shost)

Is there some reason for which those two drivers can't follow that?

>>
>> To me this seems better, but I think that some drivers might modify
>> their scsi_host_template (so not possible)
> 
> Several drivers modify scsi_host_template, e.g. .can_queue, .cmd_per_lun
> 
> There is also code in lpfc_create_port() that initializes a scsi_host_template
> that is embedded in the lpfc_hba struct.  I don't think it gets modified after
> scsi_add_host() but it seems like driver maintainers might expect to be able
> to do so, in general.
> 

Even so, I don't see why other drivers cannot declare their 
scsi_host_template as const. C would have no problem with sht not be 
being const for this:

struct Scsi_Host *scsi_host_alloc(const struct scsi_host_template *sht, )

thanks,
John

  reply	other threads:[~2022-04-12  9:30 UTC|newest]

Thread overview: 24+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-04-08 10:30 [PATCH 1/4] scsi: core: constify pointer to scsi_host_template Krzysztof Kozlowski
2022-04-08 10:30 ` [PATCH 2/4] scsi: core: fix white-spaces Krzysztof Kozlowski
2022-05-04  8:47   ` Krzysztof Kozlowski
2022-04-08 10:30 ` [PATCH 3/4] scsi: ufs: ufshcd-pltfrm: constify pointed data Krzysztof Kozlowski
2022-04-08 10:30 ` [PATCH 4/4] scsi: ufs: ufshcd: " Krzysztof Kozlowski
2022-04-08 14:35   ` Bart Van Assche
2022-04-08 12:14 ` [PATCH 1/4] scsi: core: constify pointer to scsi_host_template John Garry
2022-04-08 12:32   ` Krzysztof Kozlowski
2022-04-08 12:57     ` John Garry
2022-04-08 19:31       ` Ewan D. Milne
2022-04-12  7:57         ` John Garry [this message]
2022-04-20  7:03           ` Christoph Hellwig
2022-04-25  8:58             ` John Garry
2022-04-25  9:22               ` Krzysztof Kozlowski
2022-04-25 13:04                 ` John Garry
2022-04-26  1:16                   ` Bart Van Assche
2022-04-26  1:54                     ` Douglas Gilbert
2022-04-26  4:13                       ` Bart Van Assche
2022-04-27  1:47                         ` Douglas Gilbert
2022-05-06 16:42                   ` Krzysztof Kozlowski
2022-05-09 11:28                     ` John Garry
2022-05-09 13:20                       ` Krzysztof Kozlowski
2022-05-09 14:50                         ` John Garry
2022-05-11  8:31                           ` Christoph Hellwig

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=b6af3fe8-db9a-b5dc-199f-21c05d7664a2@huawei.com \
    --to=john.garry@huawei.com \
    --cc=alim.akhtar@samsung.com \
    --cc=avri.altman@wdc.com \
    --cc=dgilbert@interlog.com \
    --cc=emilne@redhat.com \
    --cc=james.smart@broadcom.com \
    --cc=jejb@linux.ibm.com \
    --cc=krzysztof.kozlowski@linaro.org \
    --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;
as well as URLs for NNTP newsgroup(s).