Received: by 2002:a05:6358:16cc:b0:ea:6187:17c9 with SMTP id r12csp6182663rwl; Mon, 9 Jan 2023 05:22:35 -0800 (PST) X-Google-Smtp-Source: AMrXdXtEtyNWGtJ2rZtIVjCmXksATRx4DEz6LdLrI01m327XUL0igS4ip4xXZJ+eyh1VxmUBc3tP X-Received: by 2002:a05:6402:f17:b0:489:5852:fbb5 with SMTP id i23-20020a0564020f1700b004895852fbb5mr36848851eda.16.1673270555056; Mon, 09 Jan 2023 05:22:35 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1673270555; cv=none; d=google.com; s=arc-20160816; b=kaOObtr+LJFw+s1HNTCHNjvirDDeApy5xLlnb+tZGb6nS7zMQslt9biT6bcxnR5tSd BqoqR4b6QGiyOZkGP7oVB0PWFMyCdOMmSr+HsOZRvYOaV65UgotkQ3UCeW7Mn0dRX90C ylWZUtzkZPs8ufC+HcWsU5fY/d9QSPZjM9tlm+7qUMb2k/1RbF+9VAIV0GWEY2wVqQjj SeaTnq/v171iTxs3ZNCqTbcGNtmsOQReIWdA1AFoIMuDQNyDR+MI/KBSDnMNFjLyn/jE 4IKLMRPzJHZ6KTpB9/2W4Jmqe6AmshICvmOgFyRDUF/URIR9cIZmpNnp+UtSk7nYGNSO rA0w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:in-reply-to:from :references:cc:to:content-language:subject:user-agent:mime-version :date:message-id:dkim-signature; bh=s31wz7gB9QKrqom3h1UXOtdobd8v5s2tNWIgt27cLmg=; b=BnP1/CSnrVXVKU0DExmc5ROPUpcPnZgEXWT/E6xWBoXZ/odyI/a+gS+7e4BuQIQUs7 JU8UC6VOadibAcOvFtMH932KOkUwqZi0Td87UbuhcDHTMlLTsSwEJPWO31FGpKI1aaHZ t7lKbdIKZnKQKG1ItJtvzqitWKVw211GZUDb9BgfXROEIWdXbRLKQv9Xdfp+13PyY9hG JIsOm5kX1DNkfXSNq6XanCMG6OM0eGPZzdOO6L1vLPlJlv7kHBg2seMJSjAY/6L/QMgF +U3xt76gSWiVtunRp3DhLfYRKPGhXcFE1Kh8zA6Pxzwm82ULoSPB2tC3+oH9R28R0xlq pwOA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass (test mode) header.i=@ideasonboard.com header.s=mail header.b=KrH5T+by; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id t7-20020a50d707000000b00489df3c748csi9716089edi.154.2023.01.09.05.22.22; Mon, 09 Jan 2023 05:22:35 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass (test mode) header.i=@ideasonboard.com header.s=mail header.b=KrH5T+by; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233396AbjAINCh (ORCPT + 52 others); Mon, 9 Jan 2023 08:02:37 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:49530 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233331AbjAINCM (ORCPT ); Mon, 9 Jan 2023 08:02:12 -0500 Received: from perceval.ideasonboard.com (perceval.ideasonboard.com [IPv6:2001:4b98:dc2:55:216:3eff:fef7:d647]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id B4A991758A; Mon, 9 Jan 2023 04:59:21 -0800 (PST) Received: from [192.168.1.15] (91-154-32-225.elisa-laajakaista.fi [91.154.32.225]) by perceval.ideasonboard.com (Postfix) with ESMTPSA id 601AE6CF; Mon, 9 Jan 2023 13:59:04 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com; s=mail; t=1673269145; bh=b5YGXWGHoxTUNR2lz6oATrp9StnnDmiege+b+Kt/YnM=; h=Date:Subject:To:Cc:References:From:In-Reply-To:From; b=KrH5T+bybl6PE8El4Qq1rEpTueK/bkk15n6q/dYt+2CCW0oOYqStD7LHyJcRbxi6G 37+ZbEVMVSqdYp6qu+ZipXAK+VAB6FQ1ZIg+OKLPORNMFGVf2ZAJA/cD8WQF6/+7NP eAcl919tiZ4bUQDh7hlGbfP4FMT9mgdx8LhGVyPU= Message-ID: <5173a16a-83c5-5cfe-f6ce-03e1c90e8790@ideasonboard.com> Date: Mon, 9 Jan 2023 14:59:01 +0200 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:102.0) Gecko/20100101 Thunderbird/102.4.2 Subject: Re: [PATCH v6 7/8] media: i2c: add DS90UB913 driver Content-Language: en-US To: Andy Shevchenko , Laurent Pinchart Cc: linux-media@vger.kernel.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, linux-i2c@vger.kernel.org, Rob Herring , Krzysztof Kozlowski , Wolfram Sang , Luca Ceresoli , Matti Vaittinen , Mauro Carvalho Chehab , Peter Rosin , Liam Girdwood , Mark Brown , Sakari Ailus , Michael Tretter , Shawn Tu , Hans Verkuil , Mike Pagano , =?UTF-8?Q?Krzysztof_Ha=c5=82asa?= , Marek Vasut References: <20230105140307.272052-1-tomi.valkeinen@ideasonboard.com> <20230105140307.272052-8-tomi.valkeinen@ideasonboard.com> From: Tomi Valkeinen In-Reply-To: Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,NICE_REPLY_A,SPF_HELO_PASS, SPF_PASS autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 09/01/2023 13:07, Andy Shevchenko wrote: > On Sun, Jan 08, 2023 at 06:06:34AM +0200, Laurent Pinchart wrote: >> On Thu, Jan 05, 2023 at 04:03:06PM +0200, Tomi Valkeinen wrote: > > ... > >>> + scnprintf(priv->gpio_chip_name, sizeof(priv->gpio_chip_name), "%s", >>> + dev_name(dev)); >> >> I think you can use strscpy(). > > Actually I'm not sure we even need that variable. What is the lifetime of > the dev and gc? I believe they are the same or gc's one is shorter, hence > dev_name() can be used directly, no? I think this is a valid point, no need for the extra variable afaics. > ... > >>> + gc->of_node = priv->client->dev.of_node; > > We don't have of_node anymore in gc. And if the parent device is set, you can > drop this line (it will work with older and newer kernels. Otherwise, use > fwnode. What do you mean "we don't have of_node anymore"? > ... > >>> + ret = gpiochip_add_data(gc, priv); >>> + if (ret) { >>> + dev_err(dev, "Failed to add GPIOs: %d\n", ret); > >>> + return ret; >>> + } >>> + >>> + return 0; > > return ret; I'm not a fan of that style. I like my error handling ifs to return the error inside the if block, and a successful function ends in a "return 0". > ... > >>> + ep_node = of_graph_get_endpoint_by_regs(dev->of_node, 0, 0); > > Why this can't be fwnode_handle from day 1? I guess it can. It's an old driver and there has been no need to convert to fwnode, so we're still using OF. >>> + if (!ep_node) { >>> + dev_err(dev, "No graph endpoint\n"); >>> + return -ENODEV; >>> + } > > ... > >>> + ep_np = of_graph_get_endpoint_by_regs(np, 0, 0); >>> + if (!ep_np) { >>> + dev_err(dev, "OF: no endpoint\n"); >>> + return -ENOENT; >>> + } > > Ditto. > >>> + ret = of_property_read_u32(ep_np, "pclk-sample", &priv->pclk_polarity); >>> + >>> + of_node_put(ep_np); > > Ditto. > > ... > >>> + return ret; >>> + } >>> + >>> + return 0; > > return ret; > > ... > >>> + priv->plat_data = dev_get_platdata(&client->dev); >>> + if (!priv->plat_data) { >>> + dev_err(dev, "Platform data missing\n"); >>> + return -ENODEV; > > return dev_err_probe(...); ? Isn't the idea with dev_err_probe to use it where -EPROBE_DEFER might be the error? That's not the case here. Buuut reading the relevant docs a bit more shows that it's actually recommended to be used in this kind of cases too, so you're right. >>> + } > > ... > >>> + priv->regmap = devm_regmap_init_i2c(client, &ub913_regmap_config); >>> + if (IS_ERR(priv->regmap)) { >>> + dev_err(dev, "Failed to init regmap\n"); >>> + return PTR_ERR(priv->regmap); > > Ditto? > >>> + } > > ... > >>> +#ifdef CONFIG_OF >> >> The driver depends on CONFIG_OF so I would drop this, as well as the >> of_match_ptr(). > > Even if there is no OF dependency, these ugly ifdeffery with of_match_ptr() > are error prone (compilation wise). > > ... > >>> +static const struct of_device_id ub913_dt_ids[] = { >>> + { .compatible = "ti,ds90ub913a-q1", }, > > Inner comma is not needed. Ok. > >>> + {} >>> +}; > > ... > >>> +static struct i2c_driver ds90ub913_driver = { >>> + .probe_new = ub913_probe, >>> + .remove = ub913_remove, >>> + .id_table = ub913_id, >>> + .driver = { >>> + .name = "ds90ub913a", > >>> + .owner = THIS_MODULE, > > This is something like for 5+ years is not needed, as the below macro sets it > for you. Ok. >>> + .of_match_table = of_match_ptr(ub913_dt_ids), >>> + }, >>> +}; > >>> + > > Redundant blank line. > >>> +module_i2c_driver(ds90ub913_driver); > Tomi