From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-5.3 required=3.0 tests=BAYES_00, HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,NICE_REPLY_A,SPF_HELO_NONE, SPF_PASS,USER_AGENT_SANE_1 autolearn=no autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 0E47AC433DB for ; Mon, 8 Mar 2021 03:58:14 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id C918E65147 for ; Mon, 8 Mar 2021 03:58:13 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232535AbhCHD5l (ORCPT ); Sun, 7 Mar 2021 22:57:41 -0500 Received: from szxga08-in.huawei.com ([45.249.212.255]:3293 "EHLO szxga08-in.huawei.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232429AbhCHD5Y (ORCPT ); Sun, 7 Mar 2021 22:57:24 -0500 Received: from dggeme758-chm.china.huawei.com (unknown [172.30.72.53]) by szxga08-in.huawei.com (SkyGuard) with ESMTP id 4Dv4GX4m1xz142kb; Mon, 8 Mar 2021 11:54:28 +0800 (CST) Received: from [127.0.0.1] (10.40.188.234) by dggeme758-chm.china.huawei.com (10.3.19.104) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256_P256) id 15.1.2106.2; Mon, 8 Mar 2021 11:57:18 +0800 Subject: Re: [PATCH] spi: Add HiSilicon SPI controller driver support To: Lukas Wunner CC: , , References: <1614599771-33629-1-git-send-email-f.fangjian@huawei.com> <20210307143636.GA10974@wunner.de> From: Jay Fang Message-ID: <331fa0f5-7052-0dac-e375-df25789c56b6@huawei.com> Date: Mon, 8 Mar 2021 11:57:17 +0800 User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:78.0) Gecko/20100101 Thunderbird/78.6.1 MIME-Version: 1.0 In-Reply-To: <20210307143636.GA10974@wunner.de> Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 7bit X-Originating-IP: [10.40.188.234] X-ClientProxiedBy: dggeme701-chm.china.huawei.com (10.1.199.97) To dggeme758-chm.china.huawei.com (10.3.19.104) X-CFilter-Loop: Reflected Precedence: bulk List-ID: X-Mailing-List: linux-spi@vger.kernel.org On 2021/3/7 22:36, Lukas Wunner wrote: > On Mon, Mar 01, 2021 at 07:56:11PM +0800, Jay Fang wrote: >> +static int hisi_spi_setup(struct spi_device *spi) >> +{ >> + struct hisi_spi *hs = spi_controller_get_devdata(spi->controller); >> + struct hisi_chip_data *chip; >> + >> + /* Only alloc on first setup */ >> + chip = spi_get_ctldata(spi); >> + if (!chip) { >> + chip = kzalloc(sizeof(*chip), GFP_KERNEL); >> + if (!chip) >> + return -ENOMEM; >> + spi_set_ctldata(spi, chip); >> + } > [...] >> + master = devm_spi_alloc_master(dev, 0); > > It would seem simpler to just pass "sizeof struct hisi_chip_data" > to devm_spi_alloc_master(), thus obviating the need to allocate > it on first incocation of the ->setup hook. > Hi Lukas, Thanks for your review. "struct hisi_chip_data" is the private data of per-spi device, not the spi controller. So I think this method is not suitable here. Maybe we can allocate "struct hisi_spi" in this way. Thanks Jay