Received: by 2002:a05:7412:6592:b0:d7:7d3a:4fe2 with SMTP id m18csp1002807rdg; Fri, 11 Aug 2023 07:00:30 -0700 (PDT) X-Google-Smtp-Source: AGHT+IHDQkCqr9miqUt8PY2nabTl7knS5pBEm2fktgTOGzjL142LdIK7vLsabSFfl7ZVsAKdE9Bg X-Received: by 2002:a05:6a20:938c:b0:135:110c:c6dd with SMTP id x12-20020a056a20938c00b00135110cc6ddmr2342391pzh.53.1691762429467; Fri, 11 Aug 2023 07:00:29 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1691762429; cv=pass; d=google.com; s=arc-20160816; b=WvTfcxfLMIBHAbAcNR32oiYjKzip7sB6Rrxe4u+NuHwRArh6VlcwIMtsYVbz+Bpo0B OmygDFFekqnJT5mCh9GTIsLoDKS3QljlTU0ckaicquDB1s/gbziH9I9Mah9GTKpcT2tP XSkijufAEPrT6QwRnPw48xJ8/YnvpCr9p1xWpmVeq4p6nsWhERA7mhJA/wZ7ezr+cItW cyaoend/Pg5e/mrclm6+HYyKhpP55I/IUxgme3VbZhG/t/fR+8e13nXqmHkfPhgoDVw3 fzhC2wRrXq0mKp7IR1r1C3Lq2kctPGNzYqqshbr5hCvfZi9m1bFIb2OFT/cAoApK/ws8 y4+A== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:mime-version:content-transfer-encoding :content-language:accept-language:in-reply-to:references:message-id :date:thread-index:thread-topic:subject:cc:to:from:dkim-signature; bh=9gtpcTtCzMiQLEyj/1SDw2V6U5+/qVV5EBzxifHbqcc=; fh=lDb83YZIJWXVidBVXnBKbNBmqE/xMQdzQ2gHi8smsHI=; b=GMH4ilZdlrHen61nbl3eLPXrutSQXOX3xRjRpBSkrBCXoASfUex80CKYB0CWWY9JRd SUPmaqgQDhkkX70WYL/inD+FCZa+NY/P3sAEULFRRtP84jrP5/wmLNmmEBohCrvWC3wK EgOBmr2sVaAg2jNNQ8OV2zyXOy7AgrfH+tgAZgo6+asjz0gMDDgc/lP71/xlRKMavpjI HhrEMHqxGvgsFXlXvjETkXaDKJTW4vJ5/4ceJ9tLPSTUyvElu3yDBmXhc1T4qqIbN0eX yQMJMyu7EnCgMoSbLaNlLDKJc6WpEjejoOELbB26oS7qXXJqsvscXOvwMcFE0hYMiNpK VoKw== ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@bp.renesas.com header.s=selector1 header.b=K7kDHr99; arc=pass (i=1 spf=pass spfdomain=bp.renesas.com dkim=pass dkdomain=bp.renesas.com dmarc=pass fromdomain=bp.renesas.com); 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=renesas.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id t186-20020a6381c3000000b0055beccf9921si3323236pgd.212.2023.08.11.07.00.15; Fri, 11 Aug 2023 07:00:29 -0700 (PDT) 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 header.i=@bp.renesas.com header.s=selector1 header.b=K7kDHr99; arc=pass (i=1 spf=pass spfdomain=bp.renesas.com dkim=pass dkdomain=bp.renesas.com dmarc=pass fromdomain=bp.renesas.com); 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=renesas.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S235574AbjHKN2A (ORCPT + 99 others); Fri, 11 Aug 2023 09:28:00 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:44724 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235733AbjHKN15 (ORCPT ); Fri, 11 Aug 2023 09:27:57 -0400 Received: from JPN01-OS0-obe.outbound.protection.outlook.com (mail-os0jpn01on2132.outbound.protection.outlook.com [40.107.113.132]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 72FE226A0; Fri, 11 Aug 2023 06:27:41 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=Mo56tVACYEQSupKnI4c1X3PckCNS/zFua+fQfLJ+jmezJXeyBQKIhzty8H6DeajLL/cKbt7twzp3NONLkgcM0vurMUHbjBqfacxRj0/Mjeeyz1pQscsTj1ZhajJN4pytEH+EXU1CK0VIvgVCDMHb3kDtrqv7jPjcY3sSsWZrUTjytHBenTetEZduBD+yTkjoAUxuM+7N3l0e6Vyw6ybol7RO66l+vfQ/3vT6H6MlIW6tMly/4ACRTRX3LnEcu7ws7H3UPZHFrXjqKBE4fdRjChlF/g8dTm4DrjXXIJB6dDevdpy19i9DNwmggV/czKIhcHwnk9N3FCrEZFMjEC/S9w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=9gtpcTtCzMiQLEyj/1SDw2V6U5+/qVV5EBzxifHbqcc=; b=ePReSbL0nQFjzA/xoG2i1raKfOJrSPBXOiMoypCIgEV8Y9VmZauTt42+jYcY0FK5H6fchhUfXOkZv9AHo6HykMoTClXXOyyx+ek6KWDvAThSqa2cS4QW9agMhCR5jtmc435NcABfKPDEGmv1xd0YfVpoHYqXL56GocDNqou/hTvYNmY/39wv0nz0YvDd4KlMZIYsSHu2NVrD6FcZJy173k07Uc02kTlZM/91y9m5X3GGhffdU1rc6SmEt5I2YHtMx56VUh1BJzvS8RukQWFqr4aqmHKI4jpvg3JmtlPBP1A65JVQz8tZVCDtDkiEPve0fHNvNQIS0nP6uGF4ptntHA== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=bp.renesas.com; dmarc=pass action=none header.from=bp.renesas.com; dkim=pass header.d=bp.renesas.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bp.renesas.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=9gtpcTtCzMiQLEyj/1SDw2V6U5+/qVV5EBzxifHbqcc=; b=K7kDHr99ktNJBhIXo8n1dKiO4yP2tkGVcUif8pr/fGuhtYFBq+KKgbgba3VpeAbb/DPROrYJyxgnnmIIJQm1JO+06yE4PK3/Q7hrAUWxITpe0/nLg7j8CubyGoY+SPGLhAA0pSAYWgEUDhzPzDv10YYFIN/CRqNlkOy/ZWIavnk= Received: from OS0PR01MB5922.jpnprd01.prod.outlook.com (2603:1096:604:bb::5) by TYCPR01MB11975.jpnprd01.prod.outlook.com (2603:1096:400:387::13) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6678.20; Fri, 11 Aug 2023 13:27:36 +0000 Received: from OS0PR01MB5922.jpnprd01.prod.outlook.com ([fe80::f4c1:5f6e:abd1:2bf9]) by OS0PR01MB5922.jpnprd01.prod.outlook.com ([fe80::f4c1:5f6e:abd1:2bf9%6]) with mapi id 15.20.6652.031; Fri, 11 Aug 2023 13:27:36 +0000 From: Biju Das To: Andy Shevchenko , Jonathan Cameron CC: "linux-kernel@vger.kernel.org" , Peter Rosin , Dmitry Torokhov , Daniel Scally , Heikki Krogerus , Sakari Ailus , Greg Kroah-Hartman , Alexandre Belloni , "Rafael J. Wysocki" , "linux-acpi@vger.kernel.org" , Andi Shyti , Wolfram Sang , Geert Uytterhoeven , "linux-rtc@vger.kernel.org" , "linux-iio@vger.kernel.org" , "linux-i2c@vger.kernel.org" , "linux-renesas-soc@vger.kernel.org" Subject: RE: [PATCH v7 0/4] Extend device_get_match_data() to struct bus_type Thread-Topic: [PATCH v7 0/4] Extend device_get_match_data() to struct bus_type Thread-Index: AQHZxu8xqdWpTKFxl0mrPmlP0GQCwa/b6UAAgAADvoCAAVlKAIABqeGAgABf2wCAAQcZAIAB6BqAgAED5pCAAGj8gIABdEDw Date: Fri, 11 Aug 2023 13:27:36 +0000 Message-ID: References: <20230804161728.394920-1-biju.das.jz@bp.renesas.com> <20230805174036.129ffbc2@jic23-huawei> <20230806142950.6c409600@jic23-huawei> <20230809182551.7eca502e@jic23-huawei> In-Reply-To: Accept-Language: en-GB, en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: authentication-results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=bp.renesas.com; x-ms-publictraffictype: Email x-ms-traffictypediagnostic: OS0PR01MB5922:EE_|TYCPR01MB11975:EE_ x-ms-office365-filtering-correlation-id: c2d3320d-5bca-44a5-9dca-08db9a6eba36 x-ms-exchange-senderadcheck: 1 x-ms-exchange-antispam-relay: 0 x-microsoft-antispam: BCL:0; x-microsoft-antispam-message-info: 237WtaiomMF89o/cM5LkxdTEEmkOLfblKi9Vy36ZhpdxNyinwsGeoSCL5HHAaYjCP3IZ1LP0JGcGvly/2GMvGlBkOTXYPBoWcleFa+kyt6YLasnIYuLaireIfawdh3FvbvlfXsvspjNN1V2+O+JnDIhbHkWWOugACKgt30bMNWv561zEoUOdPRq8qRkgGej5DGVLnjSyFa3bK1J3ojNv+rJiPBwT8H4uG1I0X5QxFAtRKiwcB7vmmbUNhzsrQKKga7jk8DZ/DR3qUEbQzl7Zr0yeZpI3hL/7rAvJvewYd9wm3Oj8+xQmqMoaSUqfJCZtAHyfxJac1IVTAHqjrU6qJ8XABW0avBw8yFEOCbODh+F4TbGie9uHAonaWAhGdUs+2zBQ6aBPtqFUTgtaqCIT5eY3rBpXnv0jSpVWmC2ihhKhcY+UKbt/RYz0fZFSkJSl461bf3OFpoC7klMhdZ5Uw6hLCPt0rrXGKNagFZTorUhR/jLW/UdmbzDo3EkT0BrWHE6Tlb331rhc/R+oKxUlBAIsVqCTkD6Wxw87vArGcFSEOtxDdYcw48IFt9oNUWsVPUtoHRy2fQQ7hA+GjLJVaCTUfc/CXffxq9J1nDePhcQKJjIpdE69GEaZQFOxGyey x-forefront-antispam-report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:OS0PR01MB5922.jpnprd01.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230028)(4636009)(376002)(346002)(39860400002)(136003)(396003)(366004)(451199021)(1800799006)(186006)(9686003)(26005)(41300700001)(7416002)(64756008)(66446008)(54906003)(66476007)(66556008)(66946007)(76116006)(2906002)(316002)(5660300002)(52536014)(4326008)(8676002)(8936002)(478600001)(6506007)(7696005)(71200400001)(110136005)(55016003)(122000001)(38070700005)(86362001)(33656002)(38100700002);DIR:OUT;SFP:1102; x-ms-exchange-antispam-messagedata-chunkcount: 1 x-ms-exchange-antispam-messagedata-0: =?us-ascii?Q?ojAI6R1ry3j/wOpcbRQBXJIwlhNtMJpZyPz+cZxlQ3V4ohVI1It226vJwvmw?= =?us-ascii?Q?dM/l9tS2ghowR1BIs0dWxmrI0qR5rLPbU5yYHLuRVLuXxO/TbNn2YwqvwMNa?= =?us-ascii?Q?e6Yn2fVyhZYSLDH2hVqoHK7rjUbPGDZ/SCR8XIXhWMAAGBLXb3etd2L/DU0c?= =?us-ascii?Q?e+eQAipI+/utt7zrVhj8fBnPojrg9mCfTo/re/jkHycBf0GB86Tm/i9BrfLI?= =?us-ascii?Q?Gy08lj3g54Ei9rqUOpB3VOmrNiW7NlPruMPw/H0w2PczoxHWJs5kVvLHZWCd?= =?us-ascii?Q?ctzNiToFYhAwZ1goqANcVtJrmU1BpmCGIblJl1zSM7VRXgNwRvX9i/eFMzwW?= =?us-ascii?Q?L5ezgNaNHAw1V6b/ZpBDLW5OXA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T2?= =?us-ascii?Q?/nJuNvw89LLbK2IonSnWY3cBmbCRFwoefMXBKmdrUdQ5Em/cBbxyt5wS1yCZ?= =?us-ascii?Q?o2v0Yw6uo7BTziqfeQGXWkLFscvF73WcLNSfDKVOqG8vyBPOly7QaYgI6qG7?= =?us-ascii?Q?cRKtaIM1Tfa1RzqLlKWnVE0id02aYrxNo/UOTgzkOTjGJLSBZFjEEytmyu/+?= =?us-ascii?Q?w/7/2VIjHzIjHHFcs3YuxEXQHbQUcMhYQbxCHIOfPtqUrzkB+5CR50rvVGaf?= =?us-ascii?Q?RVR+uohxbx/pc+zOLz2f5BIGqktNgcxSXqjV6qn1qwyY89gJt1Rs4IAbNnPK?= =?us-ascii?Q?FKR8RxvUTpgdWRdwb/5lOGyz2L/SskfhT2qsKvyo?= Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 X-OriginatorOrg: bp.renesas.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-AuthSource: OS0PR01MB5922.jpnprd01.prod.outlook.com X-MS-Exchange-CrossTenant-Network-Message-Id: c2d3320d-5bca-44a5-9dca-08db9a6eba36 X-MS-Exchange-CrossTenant-originalarrivaltime: 11 Aug 2023 13:27:36.3938 (UTC) X-MS-Exchange-CrossTenant-fromentityheader: Hosted X-MS-Exchange-CrossTenant-id: 53d82571-da19-47e4-9cb4-625a166a4a2a X-MS-Exchange-CrossTenant-mailboxtype: HOSTED X-MS-Exchange-CrossTenant-userprincipalname: BzOmHhPNGyWnJYaDQZzPtRtGGlOY3Iw8Vm/Wp5Z/BjcA1rFrS77gtndQp3e41c34R9ULOFJd6XXFhyASffcq9wbP19gyimFNWthMsEKR1xM= X-MS-Exchange-Transport-CrossTenantHeadersStamped: TYCPR01MB11975 X-Spam-Status: No, score=-2.0 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,RCVD_IN_DNSWL_NONE,RCVD_IN_MSPIKE_H2, SPF_HELO_PASS,SPF_PASS,URIBL_BLOCKED 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 Hi Andy Shevchenko, > Subject: Re: [PATCH v7 0/4] Extend device_get_match_data() to struct > bus_type >=20 > On Thu, Aug 10, 2023 at 09:05:10AM +0000, Biju Das wrote: > > > On Tue, 8 Aug 2023 15:18:52 +0300 > > > Andy Shevchenko wrote: > > > > On Mon, Aug 07, 2023 at 01:37:12PM -0700, Dmitry Torokhov wrote: > > > > > On Mon, Aug 07, 2023 at 05:54:07PM +0300, Andy Shevchenko wrote: >=20 > ... >=20 > > > > > So in legacy ID lookup path we can safely assume that values > > > > > below > > > > > 4096 are scalars and return NULL from the new > > > > > device_get_match_data(). This way current drivers using the > > > > > values as indices or doing direct comparisons against them can > > > > > continue doing manual look up and using them as they see fit. > > > > > And we can > > > convert the drivers at our leisure. > > > > > > > > It's a good idea, but I believe will be received as hack. > > > > But why not to try? We indeed have an error pointers for the last > > > > page and NULL (which is only up to 16 IIRC) and reserved space in > > > > the first page. To be more robust I would check all enums that are > > > > being used in I2C ID tables for maximum value and if that is less > > > > than 16, use > > > > ZERO_OR_NULL_PTR() instead of custom stuff. > > > > > > > See iio/adc/max1363 example that has 37ish. > > > > > > Could tidy that one up first and hopefully not find any others that > > > are in subsystems not keen on the move away from enums. > > > > If there is no objection, I can fix this using i2c_get_match_data() > > for > > iio/adc/max1363 and device_match_data() will return ZERO_OR_NULL_PTR() > > if max enum ID in the ID lookup table is less than 16. And the drivers > > that use legacy ID's will fallback to ID lookup. So that there won't > > be any regression. >=20 > I'm good with this approach, but make sure you checked the whole kernel > source tree for a such. Checking against 16 is too short I guess?? drivers/iio/imu/inv_mpu6050/inv_mpu_iio.h has 18 enums. /*device enum */ enum inv_devices { INV_MPU6050, INV_MPU6500, INV_MPU6515, INV_MPU6880, INV_MPU6000, INV_MPU9150, INV_MPU9250, INV_MPU9255, INV_ICM20608, INV_ICM20608D, INV_ICM20609, INV_ICM20689, INV_ICM20600, INV_ICM20602, INV_ICM20690, INV_IAM20680, INV_NUM_PARTS }; The new helper function +static bool i2c_is_client_uses_legacy_id_table(const struct i2c_driver *dr= iver) +{ + const struct i2c_device_id *id =3D driver->id_table; + kernel_ulong_t max_val =3D 0; + + if (!id) + return FALSE; + + while (id->name[0]) { + if (id->driver_data > max_val) + max_val =3D id->driver_data; + id++; + } + + return ZERO_OR_NULL_PTR(max_val); +} + Cheers, Biju