Received: by 2002:a05:7412:bc1a:b0:d7:7d3a:4fe2 with SMTP id ki26csp467372rdb; Sat, 19 Aug 2023 08:50:38 -0700 (PDT) X-Google-Smtp-Source: AGHT+IF/OwiALFiAqrec7OXOp/ORBFvGkZbSW1GPjG5Pqcm9QJ37JzXgM4c79A+uFSOEzcF2uxBE X-Received: by 2002:a17:902:e5c4:b0:1b1:9272:55e2 with SMTP id u4-20020a170902e5c400b001b1927255e2mr2760859plf.3.1692460237845; Sat, 19 Aug 2023 08:50:37 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1692460237; cv=pass; d=google.com; s=arc-20160816; b=fRWx5Cwh+FoiqVEomIVpEn2gH8dnpDUMSbGIuBcT2k3ClvZ0PI7QAJ3PBdddC9XlN8 rndg6KjUeqtiamcBqmDD7xlotMYFM4zL6U4dnXN+TKFyB4humaeZsBhnqG1bZw/5vJhs 8AeKWCHMOXLfJ4sPIsxWx0/lrVw2fQ2CzSJkK3L/S+dKU3b1Qkk2lsclBt0iv9DACXja UPiEuN9Y/YXIKdQ0SJQNvfCc+B9pUJ723HIMKFj7d///SWuoPzreLjlpk5b45553Gpkk Z1W9+KGxqDJtH50qvgPbGcb+4kT405w5kFS6kD8ygsFnf4GRJY8TAoLGDA/2ygCxM0RQ Ftrw== 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=enIiOwoMPpZWCX1g0GVpGG6HkB8PTm/E7rUF5UZs/Ps=; fh=e5ZWjT/+NF7YwUEyELKJR6HyYahtimlI5bNeqM++wSg=; b=X50rat95zALCCrZ7w3g6ydBMNKGK7DaMwj/VD11Np0HXue/fwy9/GM0+cvzy//4cXN 6aFLcoSJXDdsPBCFibsTPM7qN2WZ+fSpziesFfFtsUEKfD3+xA6a9EdoBLkIgSzMTai0 goES77zjQS/88FXU/7ADSs7NKtM5W4X10mM3iBY4fvT3jLSYf2vyLArkWnc0i73KTpRC x/zY3GEw6tQ8MhHuoi7Ej9REoNFiBFfIeQabATmK4WwpN9uXHxb9JtHrWJZ8Q71vy0xq 6rv2ebLCblhdHe1nSvkujV6OXcThnQCCsO9M7UFdNEeb30PWvul47xYwGjCz2OYIUval VMPA== ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@bp.renesas.com header.s=selector1 header.b=NE7MJzto; 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:18 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 lindbergh.monkeyblade.net (lindbergh.monkeyblade.net. [2620:137:e000::1:18]) by mx.google.com with ESMTPS id c5-20020a170902f30500b001bef0877fc1si3392594ple.476.2023.08.19.08.50.37 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 19 Aug 2023 08:50:37 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:18 as permitted sender) client-ip=2620:137:e000::1:18; Authentication-Results: mx.google.com; dkim=pass header.i=@bp.renesas.com header.s=selector1 header.b=NE7MJzto; 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:18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=renesas.com Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 542F6F4DBC; Sat, 19 Aug 2023 01:48:54 -0700 (PDT) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S235324AbjHOG7O (ORCPT + 99 others); Tue, 15 Aug 2023 02:59:14 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:41792 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235338AbjHOG6s (ORCPT ); Tue, 15 Aug 2023 02:58:48 -0400 Received: from JPN01-OS0-obe.outbound.protection.outlook.com (mail-os0jpn01on2099.outbound.protection.outlook.com [40.107.113.99]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id D5DA210F0; Mon, 14 Aug 2023 23:58:43 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=b49TTgEHpCs8mLtgwxBNil2lMqeRWejf32s3u8v+JO18gp6A69LqUmHbfStxnRJtx9Y/tzboK6gAHBsAnMU0Cg3LrznGKSPffx6OgozaZEs9TSnt1zA3XMLKk3J2dpP5WuutIsppVmcXNmpoKsckvWJGP0RL5qLraa8Qa2LxwWrYRp+rQIuLZxRGXzVGxinC99zDBWdnJp+iuqNDXbUlC+R1EObaTSRNPMZXGF2FhLZG7dpq/tp8KE/Eqxdv5gMLfINcGKJSR3z7r8V9/FJBssqI9IfbszploRgGB1wdtMUq1cW1WcV0qpThLd3KGLd5NLtqIEoq4t9x250RXa9ljA== 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=enIiOwoMPpZWCX1g0GVpGG6HkB8PTm/E7rUF5UZs/Ps=; b=K6wPVVyzYODC1DJ4BPi7FSKxMNTlHhv1XjxJkI07NQdZ1pD6BPG2P/s2PzjmZGskQsSfA1y0FokNHyo6FtAjrosdsYuFkvZJZDN61XABA8S7Y1Tumx6ImhzUtpL1bvQ3V6iSZntITm/5v42UyzGQtPCznoawq9MkUBV/K9QmP/y/usTl1ZPQaj0AV6KFmWDjdQOCU77u/h6rKLAx0WyXoMbOjIjzTyrzKXqsvlfuva/EPUtANsfr/z8Xd40WfV9+zTFfUtNGCwsEVZcZPHypjE3J1vNUBORTKuIXlLJIa7n7ClE2DQID1eueqdrXZXPhgDYO6tqw2khcKXqiunBuSA== 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=enIiOwoMPpZWCX1g0GVpGG6HkB8PTm/E7rUF5UZs/Ps=; b=NE7MJztov44dkfWU0Rbyh5Emu+0K3I9RhzYRALILL7IIOBeGoBn6KHuMHTaKeFnOh8lI/KiDzpbDUFDLAkY+mNfuYh1GYNxQkBAsa6jyGQx6fDjjrEH/1YRi3nU3M7xxyWoNyGl0IRdKH0xlICwfKgz3hqQPr05AakWHp6YadzU= Received: from OS0PR01MB5922.jpnprd01.prod.outlook.com (2603:1096:604:bb::5) by OS3PR01MB8507.jpnprd01.prod.outlook.com (2603:1096:604:199::13) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6678.26; Tue, 15 Aug 2023 06:58:41 +0000 Received: from OS0PR01MB5922.jpnprd01.prod.outlook.com ([fe80::2168:623e:e186:4cf0]) by OS0PR01MB5922.jpnprd01.prod.outlook.com ([fe80::2168:623e:e186:4cf0%6]) with mapi id 15.20.6678.025; Tue, 15 Aug 2023 06:58:41 +0000 From: Biju Das To: Andy Shevchenko CC: Jonathan Cameron , "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/b6UAAgAADvoCAAVlKAIABqeGAgABf2wCAAQcZAIAB6BqAgAED5pCAAGj8gIABdEDwgAASZ4CAAALG8IAFxH+AgAADBNA= Date: Tue, 15 Aug 2023 06:58:41 +0000 Message-ID: References: <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_|OS3PR01MB8507:EE_ x-ms-office365-filtering-correlation-id: d447ebc4-f482-417e-3d1b-08db9d5d0ef3 x-ms-exchange-senderadcheck: 1 x-ms-exchange-antispam-relay: 0 x-microsoft-antispam: BCL:0; x-microsoft-antispam-message-info: 7X7pJwzCDlkp3aS2lJnHx/t1M/bLlp3EB1b/sB1XS5V4dc+ysoNjOQRzo43A04JhE8eaIvOgBfU98JTbk7vOui/XqMwuxUIAx361mOVvVISbBao4pzkxcCPrEQAfXsnhNK3NfvPULIuKhpjVnCDrZxlKSQ5hboFQO1FwdxodlTU1H19wEaivKQhdIHtfSBMskEk8rK9Ep1LAVNQk17RtRLeYKQNk5J4UTu4fgDyK45RL62kIq24QQA+0i3EP0UnJT8tTzsd8EsPE6FnuMIyh2x/ZUoVUw045grr3HdlAae+ssOKxshfEa8SrJKC+ht0E2cDxcTu3OEm8g7iCnerzGw84BxOGIObAUYYDB/xqfF9ZcNc8kh8Mxjc5pkLHcWDoU9jKQimVehpPrifUCu9uDjkcIoa38/yNm46+3K4Lo4BZJMY21M6Wmsa3wEzDmW1T0DoYN5jDv9dpQghtjdjCY+wQBP+/u79NLTaYNuZMBLMum1AS9XF41T0FXDsBPn2981FqRdjfb7l1yJ37fUxpiz9Ou5n6L6ex3jE8X5IJI75v9oOcY58n590elMBc18fe10valwVjknbbxeMj4smWp1lrRfGKRA5+rT60rIc0pEl8SmxtuWMfH3Rp7uaCnBxb 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)(346002)(376002)(366004)(39860400002)(396003)(136003)(451199021)(1800799006)(186006)(2906002)(6506007)(26005)(55016003)(38100700002)(478600001)(38070700005)(41300700001)(52536014)(5660300002)(7696005)(8936002)(8676002)(71200400001)(33656002)(54906003)(86362001)(316002)(9686003)(66946007)(66446008)(66556008)(66476007)(64756008)(76116006)(4326008)(6916009)(122000001)(7416002);DIR:OUT;SFP:1102; x-ms-exchange-antispam-messagedata-chunkcount: 1 x-ms-exchange-antispam-messagedata-0: =?us-ascii?Q?r9C3sXTKkO79yOmUBfYCpQ/4CLV2x7UfKMcdNCURiy7I3GNtKh0tjS/8OQke?= =?us-ascii?Q?ozUAT82zrxEo9JScFgA6Yo+8vLUUnEfDBcHRRN59BMtbeV3481riqcq0jWQP?= =?us-ascii?Q?LqovxMEOkfDjf3GcYX/GBOy8p4pXwAhvT4XEmoNZxNs32yz9fs87124Pifma?= =?us-ascii?Q?oy79W9Ifjl47+6iqlh2mocsk2zIoSAIfJS7ceDufh7e0PmLpdm+lnI2t7FhT?= =?us-ascii?Q?v13DsRXh9CXUxI2OJpy5u7bQ/7Y3SoZRwx665OvEs7bPsjMSVRCCmGFNFx6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sY5lsttOssFdP7uGs9Wst/o4IShZmtIH9VKT?= =?us-ascii?Q?8TwPYhdYdXAhDIBoYhuIL/tARRoEFiY8/lyCz7gDYBvgH1VV7O6ymfnIbeMM?= =?us-ascii?Q?CLgLt18nd2mgKoSJk3xa89QBbtc6JgRJeymRefv0g1sI27bKRLOqY8Y90YxO?= =?us-ascii?Q?5biNavxYMy1mGx3VnZuPeoxUNWNyq9XV02gbhbQk+5LWqo7OEHCzcpCgM8Sw?= =?us-ascii?Q?gBK1Hcad5LMA8ALTXIwi5zmqCjDk9ybKXq4XXqFEaX7BsYeU1ucXJj2RK2Jc?= =?us-ascii?Q?wcIp6Uf0KrBVB44F+0r1YRnUvIQju6d+iUDriev9xk2X7YIkoTnOpI6DI/ll?= =?us-ascii?Q?jXdmZwadr6vUfKfma+MjhNIRiYX19MlS/cQNiKaFHseIC7CNB/H4N8QyKtAE?= =?us-ascii?Q?8hJ2xGd12/u8haDthEBMUrskE/Ycqrs0kr7rxyYE?= 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: d447ebc4-f482-417e-3d1b-08db9d5d0ef3 X-MS-Exchange-CrossTenant-originalarrivaltime: 15 Aug 2023 06:58:41.0936 (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: 9Flyw+i9AGCzRYF9+3sndhbLm8f4NjbQpZf6w7sVE5eQnfqe3A4tn5fC0Htr0Q87dcpmT0TlWEauFSQe2Q80a/amF+2mX4/sjI1K+dy1YDc= X-MS-Exchange-Transport-CrossTenantHeadersStamped: OS3PR01MB8507 X-Spam-Status: No, score=-2.0 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,RCVD_IN_DNSWL_BLOCKED,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, Thanks for the feedback. > Subject: Re: [PATCH v7 0/4] Extend device_get_match_data() to struct > bus_type >=20 > On Fri, Aug 11, 2023 at 02:46:10PM +0000, Biju Das wrote: > > > Subject: Re: [PATCH v7 0/4] Extend device_get_match_data() to struct > > > bus_type On Fri, Aug 11, 2023 at 01:27:36PM +0000, Biju Das wrote: > > > > > On Thu, Aug 10, 2023 at 09:05:10AM +0000, Biju Das wrote: >=20 > ... >=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. > > > > > > So, what does prevent us from moving that tables to use pointers? > > > > I think that will lead to ABI breakage(client->name vs id->name) > > > > match =3D device_get_match_data(&client->dev); > > if (match) { > > chip_type =3D (uintptr_t)match; > > name =3D client->name; > > } else if (id) { > > chip_type =3D (enum inv_devices) > > id->driver_data; > > name =3D id->name; > > } else { > > return -ENOSYS; > > } >=20 >=20 > It's easy to work around (may be better fix can be found, haven't checked= , > just what first comes to my mind): >=20 > match ... > name =3D match->name; The device_get_match_data()API returns matched data, so we cannot use that = one here. Maybe?? /* If enumerated via ID lookup, fix the ABI */ if (!dev_fwnode()) name =3D id->name; Cheers, Biju >=20 > /* If enumerated via firmware node, fix the ABI */ > if (dev_fwnode()) > client->name >=20 > > > > /*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 > > > > > > You mean for debugging? We don't need that in production. > > > > That is sample code for iterating through id table to find max enum > > and check against ZERO_OR_NULL_PTR >=20 > Much better with a coccinelle. You will find all or almost all occurrence= s > without too much effort done. >=20 > > > I think what you need is a coccinelle script to find these. > > > > I need to explore using coccinelle script as I have n't tried before. >=20 > -- > With Best Regards, > Andy Shevchenko >=20