Received: by 2002:a05:7412:b10a:b0:f3:1519:9f41 with SMTP id az10csp2600654rdb; Mon, 4 Dec 2023 02:05:50 -0800 (PST) X-Google-Smtp-Source: AGHT+IHVsvltvM1E/bAqCj+3uiDh58LMSwA0v8dAb2JLXR7c53EvwWAlfw6tGfec8X9j0DjdBFi2 X-Received: by 2002:a05:6358:e4a7:b0:170:7af:d1fc with SMTP id by39-20020a056358e4a700b0017007afd1fcmr4504778rwb.6.1701684349713; Mon, 04 Dec 2023 02:05:49 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1701684349; cv=none; d=google.com; s=arc-20160816; b=fJsWMPX0HT0lj6Zwv089ASY32eo4hHcT7mvMhY6hSaGCdEfk02he2tKa2uHTlAnPn8 2TKr1yakkzyKhNg5cRLdXAzHp5bXuxdjsY+wNphoxpD6TWStcGMXMofuLOSutNJ+Ujhw cVjFHEzKpvyT7Fxuw/afeODZP0hwVqsMbo3O+r9CJY1fbrOeam5qnMFST1whhYiSe9eH w0b6QdgAZLJBD/+sbkFEW64fD6UN/1IgFbLuywqcu6HHdOHgGPDUcnWOvnT0m10P1s28 /5znmRJQpClB/3fa6O6B7U9/GQHW4qt7nVguhR6qylMI86qiePCSA/rrCv1zfAWKgw1/ VZ9Q== 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=KXDx7AZ9C9zad9M5h18V7RpX00USpFjQkNaNARV4388=; fh=2nQBOaBKhnW+Uhdrbg+UgbquIOi0h7n5f/qQeD6NClQ=; b=x9ruxyZURMeZPVXZooGOFToeoQ7SY2eyZvGNBCmYnNja9656Xl4phR2NONPmkNlNtF 2wzh5UN0JzNU5bPNWFjM3nGJZ6ftJEGYCuqPrh4HxKHi4FqbNVQkk+HUFdUSLA8Lk3uO QE9V/3JQ38dlP0xIBnQxzb/RAxm+rCupEEE5yGBv/BldY0mgAphODOAyotsJGnepWfqx Mu4RoyomEILSHxY16bjh9yA1VGZfIoueLcCcQLEKGEw180TwJ1CHIgtTLo7qDolHs7e8 WUakZ6ozhGzN+m82APU9GXIwzu80TSojgABHJHExATOLTbEwCB8SoUY7EKeN+uUKoVyE Rwhg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=LCeo5emh; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.35 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 groat.vger.email (groat.vger.email. [23.128.96.35]) by mx.google.com with ESMTPS id w1-20020aa78581000000b006c0e3332534si3406903pfn.42.2023.12.04.02.05.49 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 04 Dec 2023 02:05:49 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.35 as permitted sender) client-ip=23.128.96.35; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=LCeo5emh; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.35 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 groat.vger.email (Postfix) with ESMTP id C02518078C83; Mon, 4 Dec 2023 02:05:41 -0800 (PST) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.11 at groat.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1343721AbjLDKFY (ORCPT + 99 others); Mon, 4 Dec 2023 05:05:24 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:33144 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235270AbjLDKFV (ORCPT ); Mon, 4 Dec 2023 05:05:21 -0500 Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 92726119 for ; Mon, 4 Dec 2023 02:05:27 -0800 (PST) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 33789C433C7; Mon, 4 Dec 2023 10:05:22 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1701684327; bh=TjbVpp0w/mr0UQlKAwP4FFpH3IWzsJ2Rxf+6614AKw4=; h=Date:From:To:Cc:Subject:In-Reply-To:References:From; b=LCeo5emhYBiylF4hn4+CLQjHs53oxcvqzN6JNW4byYOf8eYp9U98no67sD6bozjNo 5bdXsgeseUO4kEa6zkVHbKkI7rsY8QbHAj+xI8C0NPgjGJHi4ARMKiNyZin6vzPSOM cQ/9IjtcLf82phzN1tyCG6IYmyF3rcMa6xpdNUBkzmFInDyF2ovoAwtdQbMS+PPPq+ DFvxk2tG5Ll7GaA5StWiAF9g1W1PwG4tlKjfbHgu3PXVS8ZvzYtYpD2CYDRqKcWKt3 EcAg9hyL+mAXykW5rC5IHjO8lSHVEU4sJqzb7kQz+H1zH61AyrFd+7KZuzKt3tDqA3 ZEFenR3p1m8Dg== Date: Mon, 4 Dec 2023 10:05:17 +0000 From: Jonathan Cameron To: Anshul Dalal Cc: linux-kernel@vger.kernel.org, linux-iio@vger.kernel.org, devicetree@vger.kernel.org, Conor Dooley , Lars-Peter Clausen , Rob Herring , Krzysztof Kozlowski , linux-kernel-mentees@lists.linuxfoundation.org, Shuah Khan Subject: Re: [PATCH v2 2/2] iio: light: driver for Lite-On ltr390 Message-ID: <20231204100517.30df720e@jic23-huawei> In-Reply-To: References: <20231117074554.700970-1-anshulusr@gmail.com> <20231117074554.700970-2-anshulusr@gmail.com> <20231125140641.08284929@jic23-huawei> 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 groat.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 (groat.vger.email [0.0.0.0]); Mon, 04 Dec 2023 02:05:41 -0800 (PST) > >> +struct ltr390_data { > >> + struct regmap *regmap; > >> + struct i2c_client *client; > >> + struct mutex lock; > > > > All locks need a comment explaining the scope of data they protect. > > Note that regmap and the i2c bus will have their own locks by default > > so I'm not sure you need one here at all as I'm not seeing read modify write > > cycles or anything like that (I might be missing one though!) > > My goal with the mutex was to protect the sysfs though that might be > unnecessary. Ok. So, there is nothing stopping multiple parallel sysfs accesses, but what you'll actually be protecting is either device or driver state, not sysfs as such. > > >> +}; > >> + > >> +static const struct regmap_config ltr390_regmap_config = { > >> + .name = LTR390_DEVICE_NAME, > >> + .reg_bits = 8, > >> + .reg_stride = 1, > >> + .val_bits = 8, > >> +}; > >> + > >> +static int ltr390_probe(struct i2c_client *client) > >> +{ > >> + struct ltr390_data *data; > >> + struct iio_dev *indio_dev; > >> + int ret, part_number; > >> + > >> + indio_dev = devm_iio_device_alloc(&client->dev, sizeof(*data)); > >> + if (!indio_dev) > >> + return -ENOMEM; > >> + > >> + data = iio_priv(indio_dev); > >> + > >> + data->regmap = devm_regmap_init_i2c(client, <r390_regmap_config); > >> + if (IS_ERR(data->regmap)) > >> + return dev_err_probe(&client->dev, PTR_ERR(data->regmap), > > There are quite a few &client->dev in here. I'd introduce > > struct device *dev = &client->dev; > > as a local variable then use that to shorten all those lines a little. > > > >> + "regmap initialization failed\n"); > >> + > >> + data->client = client; > >> + i2c_set_clientdata(client, indio_dev); > > > > Why set this? I don' think you are using it. > > > > It seems to be necessary for regmap to work properly, I tested without > it and I get an EREMOTEIO(121) when reading the part id. That's weird given regmap will have no understanding of an iio_dev. If you can do some more debugging on where that error is coming from in regmap that would be great. I suspect it's coming from down in the bus master which should not be touching this at all. What is the i2c master in this case? Jonathan > > >> [..] > > Thanks for the review, > Best regards, > Anshul