From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=subdimension.ro header.i=@subdimension.ro header.b="uLhAajAA" Received: from mail.subdimension.ro (skycaves.subdimension.ro [172.104.132.142]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id B0FEB94; Sat, 2 Dec 2023 08:01:59 -0800 (PST) Received: from sunspire (unknown [188.24.94.216]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange ECDHE (prime256v1) server-signature RSA-PSS (4096 bits) server-digest SHA256) (Client did not present a certificate) by mail.subdimension.ro (Postfix) with ESMTPSA id 1AE6628EE6F; Sat, 2 Dec 2023 16:01:57 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=subdimension.ro; s=skycaves; t=1701532917; bh=jB8oEC6mjeL2dllM2of5rXMFZjB7XW3eFIvJcBkpmWo=; h=Date:From:To:Cc:Subject:References:In-Reply-To; b=uLhAajAAo+TjG7a0Fh4VrOH3X3D00QY7UL9uAav0gJvvnLaWnpNacmHpqxFxUXsNE Frbs/MOfShNfXMJhQVRY7C+R6lxpcvjHqPbEgvS7fc+fTMUx6nw8y6HD1ASYgg3tru g2Q3f4/tJEmfJqzo9XwfRcH9tuoBlk7mqjnwWrWk= Date: Sat, 2 Dec 2023 18:01:55 +0200 From: Petre Rodan To: Jonathan Cameron Cc: Jonathan Cameron , linux-kernel@vger.kernel.org, linux-iio@vger.kernel.org, Lars-Peter Clausen , Andy Shevchenko , Angel Iglesias , Matti Vaittinen , Andreas Klinger , Rob Herring , Krzysztof Kozlowski Subject: Re: [PATCH v3 2/2] iio: pressure: driver for Honeywell HSC/SSC series pressure sensors Message-ID: References: <20231126102721.15322-1-petre.rodan@subdimension.ro> <20231126183334.625d2d8b@jic23-huawei> <20231201182453.00005673@Huawei.com> Precedence: bulk X-Mailing-List: linux-iio@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20231201182453.00005673@Huawei.com> Hello! On Fri, Dec 01, 2023 at 06:24:53PM +0000, Jonathan Cameron wrote: > > > > +static int hsc_spi_probe(struct spi_device *spi) > > > > +{ > > > > + struct iio_dev *indio_dev; > > > > + struct hsc_data *hsc; > > > > + struct device *dev = &spi->dev; > > > > + > > > > + indio_dev = devm_iio_device_alloc(dev, sizeof(*hsc)); > > > > + if (!indio_dev) > > > > + return -ENOMEM; > > > > + > > > > + hsc = iio_priv(indio_dev); > > > > + hsc->xfer = hsc_spi_xfer; > > > > > > Also, pass the callback and spi->dev into hsc probe. Easy to use > > > a container_of() to get back to the struct spi_device *spi > > > > I'd rather simply pass along the client struct. > > > > I don't like the fact it has to be a void * > > The core code has no idea what is in there. At least we constraint it > somewhat with a struct device. but ... that is the nice part. the core code never needs to know what exactly is behind that pointer, since it only gets used by the i2c/spi module that provided that pointer in the first place. I've never seen a better use of void * :) I could define a struct client_handle; in the .h, use a pointer to that that as function argument, do a lot of castings, but I feel like it's still a void * with extra steps. cheers, peter