mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Tarang Raval <tarang.raval@siliconsignals.io>
To: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Cc: "sakari.ailus@linux.intel.com" <sakari.ailus@linux.intel.com>,
	"mchehab@kernel.org" <mchehab@kernel.org>,
	"linux-media@vger.kernel.org" <linux-media@vger.kernel.org>,
	"linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>
Subject: Re: [PATCH] media: mt9p031: Refactor format handling for different sensor models
Date: Fri, 25 Oct 2024 18:01:53 +0000	[thread overview]
Message-ID: <PN3P287MB1829F71AC066E73FF25FFA658B4F2@PN3P287MB1829.INDP287.PROD.OUTLOOK.COM> (raw)
In-Reply-To: <20241025161659.GD6519@pendragon.ideasonboard.com>

Hi Laurent,

Thanks for your suggestion.

>> +static const struct mt9p031_model_info mt9p031_models[] = {
>> +     {.code = MEDIA_BUS_FMT_SGRBG12_1X12}, /* mt9p006  */
>
>There should be spaces after { and before }

okay.

>> +     {.code = MEDIA_BUS_FMT_SGRBG12_1X12}, /* mt9p031  */
>
>You can use the same entry for both the MT9P006 and MT9P031 as they
>don't need to be deferentiated.

sure, will do 

>> +     {.code = MEDIA_BUS_FMT_Y12_1X12},     /* mt9p031m */
>> +};
>> +

[...]

>>  static const struct i2c_device_id mt9p031_id[] = {
>> -     { "mt9p006", MEDIA_BUS_FMT_SGRBG12_1X12 },
>> -     { "mt9p031", MEDIA_BUS_FMT_SGRBG12_1X12 },
>> -     { "mt9p031m", MEDIA_BUS_FMT_Y12_1X12 },
>> +     { "mt9p006", 0 },
>> +     { "mt9p031", 1 },
>> +     { "mt9p031m", 2 },
>>       { /* sentinel */ }
>>  };
>>  MODULE_DEVICE_TABLE(i2c, mt9p031_id);
>
>I think we can drop mt9p031_id. I'll send a patch series to do so.

okay 

>>  static const struct of_device_id mt9p031_of_match[] = {
>> -     { .compatible = "aptina,mt9p006", .data = (void *)MEDIA_BUS_FMT_SGRBG12_1X12 },
>> -     { .compatible = "aptina,mt9p031", .data = (void *)MEDIA_BUS_FMT_SGRBG12_1X12 },
>> -     { .compatible = "aptina,mt9p031m", .data = (void *)MEDIA_BUS_FMT_Y12_1X12 },
>> +     { .compatible = "aptina,mt9p006", .data = (void *)0 },
>> +     { .compatible = "aptina,mt9p031", .data = (void *)1 },
>> +     { .compatible = "aptina,mt9p031m", .data = (void *)2 },
>
>Let's avoid magic values. You can write
>
>       { .compatible = "aptina,mt9p006", .data = &mt9p031_models[0] },
>        { .compatible = "aptina,mt9p031", .data = &mt9p031_models[0] },
>       { .compatible = "aptina,mt9p031m", .data = &mt9p031_models[1] },
>
>but it may be even more readable to introduce a
>
>enum mt9p031_model {
>       MT9P031_MODEL_BAYER,
>        MT9P031_MODEL_MONO,
>};

makes sense.

>static const struct mt9p031_model_info mt9p031_models[] = {
>       [MT9P031_MODEL_BAYER] = {
>                .code = MEDIA_BUS_FMT_SGRBG12_1X12,
>        },
>        [MT9P031_MODEL_MONO] = {
>                .code = MEDIA_BUS_FMT_Y12_1X12,
>        },
>};
>
>static const struct of_device_id mt9p031_of_match[] = {
>        {
>                .compatible = "aptina,mt9p006",
>                .data = &mt9p031_models[MT9P031_MODEL_BAYER],
>       }, {
>                .compatible = "aptina,mt9p031",
>               .data = &mt9p031_models[MT9P031_MODEL_BAYER],
>        }, {
>                .compatible = "aptina,mt9p031m",
>                .data = &mt9p031_models[MEDIA_BUS_FMT_Y12_1X12],
>        },
>        { /* sentinel */ }
>};

I will update as per your suggestions and also drop mt9p031_id.

Best Regards,
Tarang

      reply	other threads:[~2024-10-25 18:01 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-10-25 13:02 Tarang Raval
2024-10-25 16:16 ` Laurent Pinchart
2024-10-25 18:01   ` Tarang Raval [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=PN3P287MB1829F71AC066E73FF25FFA658B4F2@PN3P287MB1829.INDP287.PROD.OUTLOOK.COM \
    --to=tarang.raval@siliconsignals.io \
    --cc=laurent.pinchart@ideasonboard.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-media@vger.kernel.org \
    --cc=mchehab@kernel.org \
    --cc=sakari.ailus@linux.intel.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®