Received: by 2002:a05:6a10:144:0:0:0:0 with SMTP id 4csp941357pxw; Sat, 9 Apr 2022 06:00:41 -0700 (PDT) X-Google-Smtp-Source: ABdhPJy6teImVlYRWbDcWOY+Um+6mVnLEUOoM1UFpiDECXMvVhwYj1P6j/hOiJ1JYHPyCB2SCKQH X-Received: by 2002:a17:90a:6c21:b0:1cb:7154:14a0 with SMTP id x30-20020a17090a6c2100b001cb715414a0mr1045360pjj.6.1649509240731; Sat, 09 Apr 2022 06:00:40 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1649509240; cv=none; d=google.com; s=arc-20160816; b=oZlU6dojbYXed02Znxx61LpNpV8+2M9pXRM1voCo4DFBLXFQohV4TT7Aj60TJ0lTVd k0DdefREUtYfGPmUxjmEWicg1IkFAH4jz6mc92ccnBNrnPyJXsEVFmx+KyX9bwOCdFPu 6qDZ98OmIRGzOf8n6qVk6QwfclRixyCTIWDIjuByYKCQraH+v7cSuOojgA/Xue/0/9sn WtkAiYLaMC4r3ljJ0eg1OuVMnYBZIV9R5sYt9v3r8nEUdeo6BcsPcgRQzbyuZYStKaRt wo4umv0yvQwBlynixR0uRK1s+of8S7oGhAeF4mjEH30JUgt5IweO45De3KvTFH2s1MoH WV1w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:date:cc:to:from:subject :message-id:dkim-signature; bh=J/4FS6QgJbYZUbVh33aTHwESfnBXpb7C9e5m+pOdZFI=; b=eYa4ezOlCzQpHFyV/mUetZilHSahKg5VJl4hRxLVgH8JX6dH0iIlUZZYcuhz1gXwN0 2nb6oLoV8fz7CO9Npsr8tpAMfvYa7snnw+ibQs7NsGx7lZ/X3IPc7cTom52t6cg0Zoa2 QgUMaWvmnHMJs6d7hmER3krku2nl19G3odzMo1TTtHo10XgtS1CHDPJebJ8dmFgW71pG 70itgfO8dfwlJK0HdIFGM7HKPuphWgXoaP8KZf0jwCK2UnA3hN4HWrrCzlsb91cuBrze y0Fiz8CSP0Up4Hnc26QoP5rHU8cRpivrGQPW9Uqd61oDjS3mKTHTWL3q5XObVcJHXuRz hXeA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=Tu30R8NZ; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id m127-20020a632685000000b003822f3c787bsi3882396pgm.374.2022.04.09.06.00.20; Sat, 09 Apr 2022 06:00:40 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=Tu30R8NZ; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233785AbiDHTds (ORCPT + 99 others); Fri, 8 Apr 2022 15:33:48 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:48946 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229457AbiDHTdq (ORCPT ); Fri, 8 Apr 2022 15:33:46 -0400 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id AF5342B260 for ; Fri, 8 Apr 2022 12:31:41 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1649446300; 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=J/4FS6QgJbYZUbVh33aTHwESfnBXpb7C9e5m+pOdZFI=; b=Tu30R8NZip4K2SmpzPSvfm9YXChGAYwvAztUfY3zSgq37ZqCLDoNLGDrXoH/cJXbv7+n9X Hfujf5fs+T2eDSqmufcNxVziYm1zBRZVD3BuXL8tsjExDZL3v9GTGdfrI8EdArF/pPQ+8V 51WiEtWyfWxaBMkoDR66Pg/2IRiwtgk= Received: from mail-qv1-f70.google.com (mail-qv1-f70.google.com [209.85.219.70]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-182-tw_CLlFuMmqYreCtsYiu4Q-1; Fri, 08 Apr 2022 15:31:39 -0400 X-MC-Unique: tw_CLlFuMmqYreCtsYiu4Q-1 Received: by mail-qv1-f70.google.com with SMTP id 7-20020a0562140dc700b004442d23d2d8so730990qvt.2 for ; Fri, 08 Apr 2022 12:31:39 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:message-id:subject:from:to:cc:date:in-reply-to :references:user-agent:mime-version:content-transfer-encoding; bh=J/4FS6QgJbYZUbVh33aTHwESfnBXpb7C9e5m+pOdZFI=; b=WUYXb4I9c14Kfdv5INz7AMbwHd6GLuPeZgBIzZrbd5qZC86X1WhgyDYRmZg8ccm1tU +RNvE6GWpiCOndDnXjMBc5cyWS0xjD7Yvyh1PD+jYqfsc933EedUBRado6hF+wi5I6OS QnVWURquKc17dAgunl2b5RQP+hU1rRL/QQXQvRC2TDAxyH7+aSrCNawhYL5XiB27N7pM iGaK3scBrT9RhbB5fLd77HWPG1eLhld5J3EW24AX+IXmVHHwFDJChNfD7n2U0oeIlMN6 Zr0Od8KNP0eaDrpnDTVzCG/Z8luiiQ6MQtZ1ThmnL41Qp4y1tWahXqBHcFlCn/xJ1fb3 i/3A== X-Gm-Message-State: AOAM531xsflKTQGEvai6rraE3projwGMYQXHpl0/ngw9O6gGlK1LFNGI om8g+moKifHGvKZVW1iGmuVIfrwRhWNGS9AQOqr3aIVks24jwq0l92t55CxMvFWbbqn3xmbda+t 0ZRYiLHOOgpxjkfy9PKiFxilb X-Received: by 2002:a0c:a942:0:b0:443:a395:cc1f with SMTP id z2-20020a0ca942000000b00443a395cc1fmr17508597qva.68.1649446298777; Fri, 08 Apr 2022 12:31:38 -0700 (PDT) X-Received: by 2002:a0c:a942:0:b0:443:a395:cc1f with SMTP id z2-20020a0ca942000000b00443a395cc1fmr17508574qva.68.1649446298496; Fri, 08 Apr 2022 12:31:38 -0700 (PDT) Received: from emilne (nat-pool-bos-t.redhat.com. [66.187.233.206]) by smtp.gmail.com with ESMTPSA id u129-20020a376087000000b0067e401d7177sm14788983qkb.3.2022.04.08.12.31.36 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 08 Apr 2022 12:31:37 -0700 (PDT) Message-ID: Subject: Re: [PATCH 1/4] scsi: core: constify pointer to scsi_host_template From: "Ewan D. Milne" To: John Garry , Krzysztof Kozlowski , "James E.J. Bottomley" , "Martin K. Petersen" , Alim Akhtar , Avri Altman , Doug Gilbert , linux-scsi@vger.kernel.org, linux-kernel@vger.kernel.org Cc: james.smart@broadcom.com Date: Fri, 08 Apr 2022 15:31:35 -0400 In-Reply-To: <7b3885e3-dbae-ff0b-21dc-c28d635d950b@huawei.com> References: <20220408103027.311624-1-krzysztof.kozlowski@linaro.org> <2a88a992-641a-b3ff-fe39-7a61fff87cb6@huawei.com> <4c3be5b6-50ef-9e9a-6cee-9642df943342@linaro.org> <7b3885e3-dbae-ff0b-21dc-c28d635d950b@huawei.com> Content-Type: text/plain; charset="UTF-8" User-Agent: Evolution 3.30.5 (3.30.5-1.fc29) MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Spam-Status: No, score=-2.8 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_LOW, RCVD_IN_MSPIKE_H5,RCVD_IN_MSPIKE_WL,SPF_HELO_NONE,SPF_NONE, T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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. > > 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. -Ewan > > > 2. The more const variables, the easier function contents and its impact > > is to understand. This is actually the biggest benefit when dealing with > > code touching different structures. > > > > In general, constifying is a common practice everywhere in the kernel. > > Thanks, > John >