Received: by 2002:a05:7412:b10a:b0:f3:1519:9f41 with SMTP id az10csp2646688rdb; Mon, 4 Dec 2023 03:46:52 -0800 (PST) X-Google-Smtp-Source: AGHT+IG9FezIPpPmzaqxFOgsVZPMCb5TLCxb2F1hJsaMYAQsu1aDNmBkK+9gUU6MHPL7TVFTMZha X-Received: by 2002:a17:903:246:b0:1d0:bcb2:b914 with SMTP id j6-20020a170903024600b001d0bcb2b914mr105458plh.129.1701690411946; Mon, 04 Dec 2023 03:46:51 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1701690411; cv=none; d=google.com; s=arc-20160816; b=F/Nz+pxQQ/5QvXSzFOGLmC2aRjPPHWInQTry0gS37sdysELwpk52uSYr/rF+vBSeQY GJ1Pwy5Os6qRD0/svq1Y9n7lbihJwZd/qlmbZn05c9IFk8f7losD2UjJ75FSMq8MfYrB 1y7huq5DfHUmpVALf4l5qlsMOyiE3zSVlWjQKytSHQNW9r4H5CeD7bGc1J1Dbf3oMZdQ knLrJkLdOwWuqV/2R6pCmgeUtIqrQDVZ8Lw0b25i4/zkz/SFeVCLCPt8idQ8x2dadXgE 3DsFqZa+1+/mvl+R+TR+3mNHp6773OAEKNezeL0qUmgToz2AVTFMCSPkFJbJTL6tw17K Xbhw== 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 :references:in-reply-to:message-id:subject:cc:to:from:date :dkim-signature; bh=6Pp9YgP06NBDQWBlKB7swjXQDc8/Q9zzxXP9QgKQMsA=; fh=acGZbngfzBHocZI97IolWcM3o6pPRKUNMvoZGKCrZ4Q=; b=YPvp5vO48qB2oGjDPpGO4MiMswthFP0ouneNIU3hGd2PeH2uuEHHGpA6hx2zQeNGTY LBt7xoDu3e0i2AHZrjIY3AIJXZirusYzUu4cHJSHJNn+1TdMPr9yXYwpgsPeRMou79WN H+xPqAtImJ53tu+V4Mi+4m2qO8DDF5zJp8UeGCqioiLlBpXM7Kx0w4mKWLkOtOkePC2k jDPuZ1w7HN+dbOJ50WkAeBxX3hLrIUCeSf7eizabk1OyP6nTS41zwjAyHXB/RJLfATop JaclJpOCSJ8RC9sCaJ8M9A1lA6VaXYbVTETBpWoa4IHfsUm4ua9LAaY1BCctzx/78skG 1K5A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=LYZOekNS; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:8 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from fry.vger.email (fry.vger.email. [2620:137:e000::3:8]) by mx.google.com with ESMTPS id l21-20020a170902d35500b001d0568f3a5asi2667588plk.609.2023.12.04.03.46.51 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 04 Dec 2023 03:46:51 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:8 as permitted sender) client-ip=2620:137:e000::3:8; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=LYZOekNS; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:8 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by fry.vger.email (Postfix) with ESMTP id 5B644807C6EC; Mon, 4 Dec 2023 03:46:49 -0800 (PST) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.11 at fry.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230163AbjLDLq2 (ORCPT + 99 others); Mon, 4 Dec 2023 06:46:28 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:44930 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229711AbjLDLq1 (ORCPT ); Mon, 4 Dec 2023 06:46:27 -0500 Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 6C6F2B0 for ; Mon, 4 Dec 2023 03:46:32 -0800 (PST) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 99456C433C8; Mon, 4 Dec 2023 11:46:28 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1701690391; bh=i1+VKeSNTBMfL+Jw9GhDsIITBUtuYP9Ee/ts7oDwFgg=; h=Date:From:To:Cc:Subject:In-Reply-To:References:From; b=LYZOekNSEYjZHt0q1vMfNanrbaTZwFa3bfc1jqH/fiIipmhRFHY14gN7d2UaeUqYR kFmE4PSCKESYlxK6Ze6RMrI+/P8eaVT0khlLEZkpqzVBn6lL58zjooUFS/uIj++YGJ sfFo884yHwHHXfkZDfNcdrcNgoB7Y1nkyB0NcsxM9rztyQHw/ylE4SM6CmK9+QVI7W Kwqgs8iKN6wGgJMqa+1YUa/g2dXrPqBJa+McF/UNmMDY8+3OABYdYctiN0A2DEaVce LJpLJB1f8JHUBDKKqtImQ+k1vnFcqt7aehSxnSl/FYyFQQI/BfvYBYB+ls9WaiDz6d OA5xATpMcvLGQ== Date: Mon, 4 Dec 2023 11:46:23 +0000 From: Jonathan Cameron To: Petre Rodan 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: <20231204114623.3aaa98d2@jic23-huawei> In-Reply-To: References: <20231126102721.15322-1-petre.rodan@subdimension.ro> <20231126183334.625d2d8b@jic23-huawei> <20231201182453.00005673@Huawei.com> X-Mailer: Claws Mail 4.1.1 (GTK 3.24.38; x86_64-pc-linux-gnu) MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit X-Spam-Status: No, score=-1.2 required=5.0 tests=DKIMWL_WL_HIGH,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,MAILING_LIST_MULTI, SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on fry.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 (fry.vger.email [0.0.0.0]); Mon, 04 Dec 2023 03:46:49 -0800 (PST) On Sat, 2 Dec 2023 18:01:55 +0200 Petre Rodan wrote: > 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. Usual trick for this is either use struct device and container_of or an anonymous union wrapped up in a struct. struct hsc_client_handle { union { struct i2c_client *i2c_client; struct spithingy *spi_client; }; }; Then assign appropriate element and pass the containing struct around. No casting needed. Aim is to define it as a constrained type that can only take one or the other of the types in the union. Jonathan > > cheers, > peter >