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=-3.8 required=3.0 tests=BAYES_00, HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS 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 DC26CC55179 for ; Wed, 4 Nov 2020 13:02:28 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 87DF02071A for ; Wed, 4 Nov 2020 13:02:28 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729750AbgKDNC0 (ORCPT ); Wed, 4 Nov 2020 08:02:26 -0500 Received: from vps0.lunn.ch ([185.16.172.187]:34590 "EHLO vps0.lunn.ch" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726350AbgKDNC0 (ORCPT ); Wed, 4 Nov 2020 08:02:26 -0500 Received: from andrew by vps0.lunn.ch with local (Exim 4.94) (envelope-from ) id 1kaIQW-005CkT-OD; Wed, 04 Nov 2020 14:02:12 +0100 Date: Wed, 4 Nov 2020 14:02:12 +0100 From: Andrew Lunn To: Lukasz Stelmach Cc: jim.cromie@gmail.com, Heiner Kallweit , "David S. Miller" , Jakub Kicinski , Rob Herring , Kukjin Kim , Krzysztof Kozlowski , Russell King , netdev@vger.kernel.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-samsung-soc@vger.kernel.org, Marek Szyprowski , =?utf-8?Q?Bart=C5=82omiej_=C5=BBolnierkiewicz?= Subject: Re: [PATCH v5 3/5] net: ax88796c: ASIX AX88796C SPI Ethernet Adapter Driver Message-ID: <20201104130212.GU933237@lunn.ch> References: <20201104024211.GS933237@lunn.ch> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org > >> +static int > >> +ax88796c_set_tunable(struct net_device *ndev, const struct ethtool_tunable *tuna, > >> + const void *data) > >> +{ > >> + struct ax88796c_device *ax_local = to_ax88796c_device(ndev); > >> + > >> + switch (tuna->id) { > >> + case ETHTOOL_SPI_COMPRESSION: > >> + if (netif_running(ndev)) > >> + return -EBUSY; > >> + ax_local->capabilities &= ~AX_CAP_COMP; > >> + ax_local->capabilities |= *(u32 *)data ? AX_CAP_COMP : 0; > > > > You should probably validate here that data is 0 or 1. That is what > > ax88796c_get_tunable() will return. > > > > It seems like this controls two hardware bits: > > > > SPICR_RCEN | SPICR_QCEN > > > > Maybe at some point it would make sense to allow these bits to be set > > individually? If you never validate the tunable, you cannot make use > > of other values to control the bits individually. > > Good point. What is your recommendation for the userland facing > interface, so that future changes will be least disruptive? I would KISS and just validate data is 0 or 1, and leave it at that. That then later gives you the option to have other values, if that is ever interesting. Andrew