linux-input.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Neil Armstrong <neil.armstrong@linaro.org>
To: Jeff LaBundy <jeff@labundy.com>
Cc: Dmitry Torokhov <dmitry.torokhov@gmail.com>,
	Rob Herring <robh+dt@kernel.org>,
	Krzysztof Kozlowski <krzysztof.kozlowski+dt@linaro.org>,
	Conor Dooley <conor+dt@kernel.org>,
	Bastien Nocera <hadess@hadess.net>,
	Hans de Goede <hdegoede@redhat.com>,
	Henrik Rydberg <rydberg@bitmath.org>,
	linux-input@vger.kernel.org, linux-arm-msm@vger.kernel.org,
	devicetree@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCH v3 4/4] input: touchscreen: add SPI support for Goodix Berlin Touchscreen IC
Date: Mon, 26 Jun 2023 15:20:35 +0200	[thread overview]
Message-ID: <94e80a49-11ae-e5b0-7eea-6ed4ec6d2ac8@linaro.org> (raw)
In-Reply-To: <ZJmMJxXxLrC9Xevi@nixie71>

Hi,

On 26/06/2023 15:01, Jeff LaBundy wrote:
> Hi Neil,
> 
> On Mon, Jun 26, 2023 at 09:02:16AM +0200, Neil Armstrong wrote:
> 
> [...]
> 
>>>> +static int goodix_berlin_spi_probe(struct spi_device *spi)
>>>> +{
>>>> +	struct regmap_config *regmap_config;
>>>> +	struct regmap *regmap;
>>>> +	size_t max_size;
>>>> +	int error = 0;
>>>> +
>>>> +	regmap_config = devm_kmemdup(&spi->dev, &goodix_berlin_spi_regmap_conf,
>>>> +				     sizeof(*regmap_config), GFP_KERNEL);
>>>> +	if (!regmap_config)
>>>> +		return -ENOMEM;
>>>
>>> Is there any reason we cannot simply pass goodix_berlin_spi_regmap_conf to
>>> devm_regmap_init() below? Why to duplicate and pass the copy?
>>>
>>> For reference, BMP280 in IIO is a similar example of a device with regmap
>>> sitting atop a bespoke SPI protocol; it does not seem to take this extra
>>> step.
>>
>> The goodix_berlin_spi_regmap_conf copy is modified after with the correct
>> max raw read/write size, and I'm not a fan of modifying a global structure
>> that could be use for multiple probes, I can make a copy in a stack variable
>> if it feels simpler.
> 
> Ah, that makes sense; in that case, the existing implementation seems fine
> to me. No changes necessary.
> 
> Correct me if I'm wrong, but the stack variable method wouldn't work since
> that memory is gone after goodix_berlin_spi_probe() returns.

The config is only needed for the devm_regmap_init() duration, so keeping
the memory allocated for the whole lifetime of the device seems useless.

Neil

> 
> Kind regards,
> Jeff LaBundy


  reply	other threads:[~2023-06-26 13:20 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-06-22 14:28 [PATCH v3 0/4] input: touchscreen: add initial support for Goodix Berlin touchscreen IC Neil Armstrong
2023-06-22 14:28 ` [PATCH v3 1/4] dt-bindings: input: document Goodix Berlin Touchscreen IC Neil Armstrong
2023-06-22 14:29 ` [PATCH v3 2/4] input: touchscreen: add core support for " Neil Armstrong
2023-06-25 19:14   ` Jeff LaBundy
2023-06-26  6:57     ` Neil Armstrong
2023-06-22 14:29 ` [PATCH v3 3/4] input: touchscreen: add I2C " Neil Armstrong
2023-06-25 19:17   ` Jeff LaBundy
2023-06-26  6:58     ` Neil Armstrong
2023-06-22 14:29 ` [PATCH v3 4/4] input: touchscreen: add SPI " Neil Armstrong
2023-06-25 19:38   ` Jeff LaBundy
2023-06-26  7:02     ` Neil Armstrong
2023-06-26 13:01       ` Jeff LaBundy
2023-06-26 13:20         ` Neil Armstrong [this message]
2023-06-26 21:17           ` Jeff LaBundy

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=94e80a49-11ae-e5b0-7eea-6ed4ec6d2ac8@linaro.org \
    --to=neil.armstrong@linaro.org \
    --cc=conor+dt@kernel.org \
    --cc=devicetree@vger.kernel.org \
    --cc=dmitry.torokhov@gmail.com \
    --cc=hadess@hadess.net \
    --cc=hdegoede@redhat.com \
    --cc=jeff@labundy.com \
    --cc=krzysztof.kozlowski+dt@linaro.org \
    --cc=linux-arm-msm@vger.kernel.org \
    --cc=linux-input@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=robh+dt@kernel.org \
    --cc=rydberg@bitmath.org \
    /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;
as well as URLs for NNTP newsgroup(s).