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 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id B85DDC7EE2F for ; Tue, 30 May 2023 14:17:43 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230349AbjE3ORm convert rfc822-to-8bit (ORCPT ); Tue, 30 May 2023 10:17:42 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:59850 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229899AbjE3ORl (ORCPT ); Tue, 30 May 2023 10:17:41 -0400 Received: from frasgout.his.huawei.com (frasgout.his.huawei.com [185.176.79.56]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id A02C111B; Tue, 30 May 2023 07:17:09 -0700 (PDT) Received: from lhrpeml500005.china.huawei.com (unknown [172.18.147.201]) by frasgout.his.huawei.com (SkyGuard) with ESMTP id 4QVvYW0nc3z67mXG; Tue, 30 May 2023 22:15:11 +0800 (CST) Received: from localhost (10.202.227.76) by lhrpeml500005.china.huawei.com (7.191.163.240) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.23; Tue, 30 May 2023 15:16:49 +0100 Date: Tue, 30 May 2023 15:16:48 +0100 From: Jonathan Cameron To: Andy Shevchenko CC: , Wolfram Sang , Niyas Sait , Klaus Jensen , Andy Shevchenko , , Jeremy Kerr , Matt Johnston , Shesha Bhushan Sreenivasamurthy , , , "Viacheslav A . Dubeyko" Subject: Re: [RFC PATCH 3/6] i2c: aspeed: switch to generic fw properties. Message-ID: <20230530151648.00007d32@Huawei.com> In-Reply-To: References: <20230525152203.32190-1-Jonathan.Cameron@huawei.com> <20230525152203.32190-4-Jonathan.Cameron@huawei.com> Organization: Huawei Technologies Research and Development (UK) Ltd. X-Mailer: Claws Mail 4.1.0 (GTK 3.24.33; x86_64-w64-mingw32) MIME-Version: 1.0 Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: 8BIT X-Originating-IP: [10.202.227.76] X-ClientProxiedBy: lhrpeml100002.china.huawei.com (7.191.160.241) To lhrpeml500005.china.huawei.com (7.191.163.240) X-CFilter-Loop: Reflected Precedence: bulk List-ID: X-Mailing-List: linux-acpi@vger.kernel.org On Sat, 27 May 2023 00:11:09 +0300 Andy Shevchenko wrote: > On Thu, May 25, 2023 at 6:23 PM Jonathan Cameron > wrote: > > > > Not tested on device tree but works nicely for ACPI :) I was planning to abandon these as 'on list for anyone who cared' but now you've reviewed them I guess I better do an RFC v2 :) > > Needs a better commit message obviously :-) :) > > ... > > > - ret = of_property_read_u32(pdev->dev.of_node, > > + ret = device_property_read_u32(&pdev->dev, > > "bus-frequency", &bus->bus_frequency); > > Oh, please avoid double effort, i.e. go further and use I²C core APIs > for the timings. Oh, wait, do they use non-standard property?! yup :( Though it is documented as having a default of 100kHz in the devicetree binding so the original code shouldn't be calling dev_err() and should just do: bus->frequency = I2C_MAX_STANDARD_MODE_FREQ; device_property_read_u32(&pdev->dev, "bus-frequency, &bus->frequency); Fixing that is an unrelated change though. I'll do it for dt in a precusor patch then carry that forward to here. > > ... > > > + bus->get_clk_reg_val = (u32 (*)(struct device *, u32)) > > + device_get_match_data(&pdev->dev); > > Personally I prefer using pointers in driver_data so we can avoid > ambiguity for the 0/NULL value returned by this call. But if 0 value > is considered invalid here, it's probably fine. It is a pointer, just a function pointer rather than to a structure. I could wrap it up in a structure but that would be an unrelated driver change so at very least a separate patch. > > > + if (!bus->get_clk_reg_val) > > bus->get_clk_reg_val = aspeed_i2c_24xx_get_clk_reg_val; > > - else > > - bus->get_clk_reg_val = (u32 (*)(struct device *, u32)) > > - match->data; > >