Received: by 2002:a05:7412:37c9:b0:e2:908c:2ebd with SMTP id jz9csp875038rdb; Tue, 19 Sep 2023 12:48:42 -0700 (PDT) X-Google-Smtp-Source: AGHT+IHNo7PppEPGPLMtU1t3BQARD8RlskJKnxYVhyC0d8CQeQWOoAcEyvVctuMhvR7kcWWnYBH8 X-Received: by 2002:a05:6a21:3d85:b0:155:5c28:ea67 with SMTP id bj5-20020a056a213d8500b001555c28ea67mr470959pzc.38.1695152922391; Tue, 19 Sep 2023 12:48:42 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1695152922; cv=none; d=google.com; s=arc-20160816; b=SudEXmJ7MWsZqZw5/Ik8RO4N/stvuvd5sI5lUO3sczINtMCJkwQ7FjS5hIcxuZOD1m 6P6fB5Slde3dsJfZEr6q7WJIk9TYjAFwgmTzfBTLWLge+NedNwHF3LrhVawyqjhGTXvW QsQoPPSZTUbkPxTkJM/FYRCM8g4H+CmpamF9fX7Ak24jPLQvNKkX/xom0dNwJeCgmE26 gK2IZLBsPKok0Ty0Yh3bdVDjLz8I3/DqIULwEpYhu1m8bERyepP1wx3mLrKf14ToL/RZ k3auBYaZSOIbPjfznQ0PXPf2o8x3BvOy3NvwdbSmcYiAfcQzy+FYry9VZvAhDIhBE1CD QMFQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-disposition:mime-version :references:message-id:subject:cc:to:from:date:dkim-signature; bh=XYVo0DIlVrsGyb15YB580Gp7jA08wMao19ef99+f2co=; fh=IySK1NIJxFwSBQYGQ2CFWH64uB2XfVAq41B6jTCSVbQ=; b=rGBfbHwmmB1ZYr3pyCKHyyrPul75E2/6eXjqCpnEDZaD5MJwrD79ljWskOqjJkiMZ1 4uj3A+MOazKxk1dkUSA54cKuxIGXBXEOqjIg12CHPe5d/Gj2yYLOI0HaAMK8zMo8B53R 0myqDQnYezOniQvggkaNIfkWh+TMKFkuNId3yaHPi7cRiQQdka7YcHSDTn5XRFy6+jFv R+M/7bsoXmKYt6v/MRLPI1vtrVhZCR5d6UKxcnUxWksSVxT3ZxcfwRmzonHnZeP8QFCp +p4UMmm57ym6IV2QOChiQZWD8QQT6HlBKetUex8c3w6L68+kV5fP7eFROBH28oIvmTti 5lwQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@lunn.ch header.s=20171124 header.b=51K66dbV; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:3 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=lunn.ch Return-Path: Received: from lipwig.vger.email (lipwig.vger.email. [2620:137:e000::3:3]) by mx.google.com with ESMTPS id r20-20020a6560d4000000b00565dd3fbfdfsi9746123pgv.214.2023.09.19.12.48.41 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 19 Sep 2023 12:48:42 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:3 as permitted sender) client-ip=2620:137:e000::3:3; Authentication-Results: mx.google.com; dkim=pass header.i=@lunn.ch header.s=20171124 header.b=51K66dbV; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:3 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=lunn.ch Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by lipwig.vger.email (Postfix) with ESMTP id 2A9C1804C231; Tue, 19 Sep 2023 08:13:53 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at lipwig.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233001AbjISPNr (ORCPT + 99 others); Tue, 19 Sep 2023 11:13:47 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:34858 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232490AbjISPNq (ORCPT ); Tue, 19 Sep 2023 11:13:46 -0400 Received: from vps0.lunn.ch (vps0.lunn.ch [156.67.10.101]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 6ABC394; Tue, 19 Sep 2023 08:13:40 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lunn.ch; s=20171124; h=In-Reply-To:Content-Disposition:Content-Type:MIME-Version: References:Message-ID:Subject:Cc:To:From:Date:From:Sender:Reply-To:Subject: Date:Message-ID:To:Cc:MIME-Version:Content-Type:Content-Transfer-Encoding: Content-ID:Content-Description:Content-Disposition:In-Reply-To:References; bh=XYVo0DIlVrsGyb15YB580Gp7jA08wMao19ef99+f2co=; b=51K66dbVjhEQD1mTpJSuIag79U zndzKI2iEruUJ/3n8QYNfH8NLcaB8qykpb/y9TnDc2CPLOIFbcM9gHjvIFzuejWZVJ8GNGgdaspv2 xepuIuKyu8Adx9j15wU8aJtu46n9h2wm1I0aXrO2v5nRVxXspBk2+2qESEJcHhctlerk=; Received: from andrew by vps0.lunn.ch with local (Exim 4.94.2) (envelope-from ) id 1qicPn-006vKZ-CJ; Tue, 19 Sep 2023 17:13:27 +0200 Date: Tue, 19 Sep 2023 17:13:27 +0200 From: Andrew Lunn To: Parthiban.Veerasooran@microchip.com Cc: davem@davemloft.net, edumazet@google.com, kuba@kernel.org, pabeni@redhat.com, robh+dt@kernel.org, krzysztof.kozlowski+dt@linaro.org, conor+dt@kernel.org, corbet@lwn.net, Steen.Hegelund@microchip.com, rdunlap@infradead.org, horms@kernel.org, casper.casan@gmail.com, netdev@vger.kernel.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, linux-doc@vger.kernel.org, Horatiu.Vultur@microchip.com, Woojung.Huh@microchip.com, Nicolas.Ferre@microchip.com, UNGLinuxDriver@microchip.com, Thorsten.Kummermehr@microchip.com Subject: Re: [RFC PATCH net-next 1/6] net: ethernet: implement OPEN Alliance control transaction interface Message-ID: References: <20230908142919.14849-1-Parthiban.Veerasooran@microchip.com> <20230908142919.14849-2-Parthiban.Veerasooran@microchip.com> <14c089d7-4d34-9cd5-7f77-55c80815e003@microchip.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <14c089d7-4d34-9cd5-7f77-55c80815e003@microchip.com> X-Spam-Status: No, score=-0.9 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI, SPF_HELO_NONE,SPF_PASS autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lipwig.vger.email Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (lipwig.vger.email [0.0.0.0]); Tue, 19 Sep 2023 08:13:53 -0700 (PDT) > >> +static void oa_tc6_prepare_ctrl_buf(struct oa_tc6 *tc6, u32 addr, u32 val[], > >> + u8 len, bool wnr, u8 *buf, bool ctrl_prot) > >> +{ > >> + u32 hdr; > >> + > >> + /* Prepare the control header with the required details */ > >> + hdr = FIELD_PREP(CTRL_HDR_DNC, 0) | > >> + FIELD_PREP(CTRL_HDR_WNR, wnr) | > >> + FIELD_PREP(CTRL_HDR_AID, 0) | > >> + FIELD_PREP(CTRL_HDR_MMS, addr >> 16) | > >> + FIELD_PREP(CTRL_HDR_ADDR, addr) | > >> + FIELD_PREP(CTRL_HDR_LEN, len - 1); > >> + hdr |= FIELD_PREP(CTRL_HDR_P, oa_tc6_get_parity(hdr)); > >> + *(u32 *)buf = cpu_to_be32(hdr); > >> + > >> + if (wnr) { > > > > What does wnr mean? Maybe give it a more meaningful name, unless it is > > actually something in the standard. Kerneldoc would also help. > Ah, it is "write not read". Shall I name it as "write_not_read" ? You might want to describe the high level concept as well in this file. What i _think_ this is about is that SPI is sort of a full duplex bus. While you are sending data to the SPI device, the device could also be sending a data to the CPU? And 'write not read' here means ignore what we receive from the device? > Ok, as per OA spec, up to 128 consecutive registers read or write can be > possible. So the maximum possible size would be 1032. As you suggested > will allocate this size of memory in the startup. Yes, 1032 bytes it not huge, so allocate it once and keep it for the lifetime of the device. > >> +void oa_tc6_deinit(struct oa_tc6 *tc6) > >> +{ > >> + kfree(tc6); > >> +} > >> +EXPORT_SYMBOL_GPL(oa_tc6_deinit); > > > > Maybe consider a devm_ API to make the MAC driver simpler. > Sorry I don't get your point. Could you please explain bit more? At least at this stage in the patch series, all you are doing is allocating memory. You add more code later, which might invalidate my point. But if all you are doing is allocating memory, you could use devm_kmalloc(). The driver core will then take care of releasing the memory when the driver is unloaded, or probe fails. That makes cleanup simpler and memory leaks less likely. There are a lot of devm_ helpers, see if you can use them. Andrew