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 X-Spam-Level: X-Spam-Status: No, score=-6.7 required=3.0 tests=BAYES_00, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE, SPF_PASS,URIBL_BLOCKED autolearn=no autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 72022C4363A for ; Tue, 20 Oct 2020 22:58:41 +0000 (UTC) Received: from fraxinus.osuosl.org (smtp4.osuosl.org [140.211.166.137]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id CF1892225C for ; Tue, 20 Oct 2020 22:58:40 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org CF1892225C Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=ACULAB.COM Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=driverdev-devel-bounces@linuxdriverproject.org Received: from localhost (localhost [127.0.0.1]) by fraxinus.osuosl.org (Postfix) with ESMTP id 41030864CD; Tue, 20 Oct 2020 22:58:40 +0000 (UTC) X-Virus-Scanned: amavisd-new at osuosl.org Received: from fraxinus.osuosl.org ([127.0.0.1]) by localhost (.osuosl.org [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id XCKa6UWYCwuH; Tue, 20 Oct 2020 22:58:39 +0000 (UTC) Received: from ash.osuosl.org (ash.osuosl.org [140.211.166.34]) by fraxinus.osuosl.org (Postfix) with ESMTP id 80CAE86371; Tue, 20 Oct 2020 22:58:39 +0000 (UTC) Received: from silver.osuosl.org (smtp3.osuosl.org [140.211.166.136]) by ash.osuosl.org (Postfix) with ESMTP id 119901BF393 for ; Tue, 20 Oct 2020 22:58:39 +0000 (UTC) Received: from localhost (localhost [127.0.0.1]) by silver.osuosl.org (Postfix) with ESMTP id EDA0C2E8FC for ; Tue, 20 Oct 2020 22:58:38 +0000 (UTC) X-Virus-Scanned: amavisd-new at osuosl.org Received: from silver.osuosl.org ([127.0.0.1]) by localhost (.osuosl.org [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id NhP-ptOMQkyj for ; Tue, 20 Oct 2020 22:58:25 +0000 (UTC) X-Greylist: from auto-whitelisted by SQLgrey-1.7.6 Received: from eu-smtp-delivery-151.mimecast.com (eu-smtp-delivery-151.mimecast.com [185.58.86.151]) by silver.osuosl.org (Postfix) with ESMTPS id 47FA92E90A for ; Tue, 20 Oct 2020 21:53:10 +0000 (UTC) Received: from AcuMS.aculab.com (156.67.243.126 [156.67.243.126]) (Using TLS) by relay.mimecast.com with ESMTP id uk-mta-213-FDpc4XWSONmUnr5iOVCXlw-1; Tue, 20 Oct 2020 22:53:05 +0100 X-MC-Unique: FDpc4XWSONmUnr5iOVCXlw-1 Received: from AcuMS.Aculab.com (fd9f:af1c:a25b:0:43c:695e:880f:8750) by AcuMS.aculab.com (fd9f:af1c:a25b:0:43c:695e:880f:8750) with Microsoft SMTP Server (TLS) id 15.0.1347.2; Tue, 20 Oct 2020 22:53:04 +0100 Received: from AcuMS.Aculab.com ([fe80::43c:695e:880f:8750]) by AcuMS.aculab.com ([fe80::43c:695e:880f:8750%12]) with mapi id 15.00.1347.000; Tue, 20 Oct 2020 22:53:04 +0100 From: David Laight To: 'Dafna Hirschfeld' , 'Colin King' , Helen Koike , "Mauro Carvalho Chehab" , Greg Kroah-Hartman , "linux-media@vger.kernel.org" , "devel@driverdev.osuosl.org" Subject: RE: [PATCH] media: staging: rkisp1: rsz: make const array static, makes object smaller Thread-Topic: [PATCH] media: staging: rkisp1: rsz: make const array static, makes object smaller Thread-Index: AQHWpu/g1aA4z1vvvE6vSt76+nNaDamgnL6wgAAMVoCAAF2rAA== Date: Tue, 20 Oct 2020 21:53:04 +0000 Message-ID: References: <20201020144655.53251-1-colin.king@canonical.com> In-Reply-To: Accept-Language: en-GB, en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-ms-exchange-transport-fromentityheader: Hosted x-originating-ip: [10.202.205.107] MIME-Version: 1.0 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=C51A453 smtp.mailfrom=david.laight@aculab.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: aculab.com Content-Language: en-US X-BeenThere: driverdev-devel@linuxdriverproject.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Linux Driver Project Developer List List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: "kernel-janitors@vger.kernel.org" , "linux-kernel@vger.kernel.org" Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Errors-To: driverdev-devel-bounces@linuxdriverproject.org Sender: "devel" From: Dafna Hirschfeld > Sent: 20 October 2020 18:10 > > Am 20.10.20 um 17:29 schrieb David Laight: > > From: Colin King > >> Sent: 20 October 2020 15:47 > >> > >> From: Colin Ian King > >> ... > >> diff --git a/drivers/staging/media/rkisp1/rkisp1-resizer.c b/drivers/staging/media/rkisp1/rkisp1- > >> resizer.c > >> index 1687d82e6c68..7ca5b47c5bf5 100644 > >> --- a/drivers/staging/media/rkisp1/rkisp1-resizer.c > >> +++ b/drivers/staging/media/rkisp1/rkisp1-resizer.c > >> @@ -763,8 +763,10 @@ static void rkisp1_rsz_unregister(struct rkisp1_resizer *rsz) > >> > >> static int rkisp1_rsz_register(struct rkisp1_resizer *rsz) > >> { > >> - const char * const dev_names[] = {RKISP1_RSZ_MP_DEV_NAME, > >> - RKISP1_RSZ_SP_DEV_NAME}; > >> + static const char * const dev_names[] = { > >> + RKISP1_RSZ_MP_DEV_NAME, > >> + RKISP1_RSZ_SP_DEV_NAME > >> + }; > >> struct media_pad *pads = rsz->pads; > >> struct v4l2_subdev *sd = &rsz->sd; > >> int ret; > > > > Don't look at what that code is actually doing.... > > It is rather horrid. > > rkisp1_rsz_register() is called for each entry in an array (twice). > > The array index is written into rsz->id. > > The value is then used to select one of the two strings. > > But rsz->id is actually an enum type. > > Hi, > Is it that bad to use enum as an array index? > we use it in many places in the driver. You'd normally use a constant from the enum to size the array definition. In this case you've an enum, an array [2] and the dev_names[] all of which have to match 'by magic'. There is a loop that half implies you might add a third type. but then the following code only works for the two types. You've complex error recovery in case one of the calls to rkisp1_rsz_register() fails - but since there can only ever be two calls the code could be much simpler. David - Registered Address Lakeside, Bramley Road, Mount Farm, Milton Keynes, MK1 1PT, UK Registration No: 1397386 (Wales) _______________________________________________ devel mailing list devel@linuxdriverproject.org http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel