mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Alexandre Belloni <alexandre.belloni@bootlin.com>
To: Claudius Heine <ch@denx.de>
Cc: Alessandro Zummo <a.zummo@towertech.it>,
	linux-rtc@vger.kernel.org, linux-kernel@vger.kernel.org,
	Henning Schild <henning.schild@siemens.com>,
	Johannes Hahn <johannes-hahn@siemens.com>
Subject: Re: [PATCH 1/2] rtc: rx6110: add i2c support
Date: Thu, 5 Nov 2020 23:19:24 +0100	[thread overview]
Message-ID: <20201105221924.GI1034841@piout.net> (raw)
In-Reply-To: <20201104102629.3422048-2-ch@denx.de>

On 04/11/2020 11:26:28+0100, Claudius Heine wrote:
> +static int rx6110_i2c_probe(struct i2c_client *client,
> +			    const struct i2c_device_id *id)
> +{
> +	struct i2c_adapter *adapter = to_i2c_adapter(client->dev.parent);
> +	struct rx6110_data *rx6110;
> +	int err;
> +
> +	if (!i2c_check_functionality(adapter, I2C_FUNC_SMBUS_BYTE_DATA
> +				| I2C_FUNC_SMBUS_I2C_BLOCK)) {
> +		dev_err(&adapter->dev,
> +			"doesn't support required functionality\n");
> +		return -EIO;
> +	}
> +
> +	rx6110 = devm_kzalloc(&client->dev, sizeof(*rx6110), GFP_KERNEL);
> +	if (!rx6110)
> +		return -ENOMEM;
> +
> +	rx6110->regmap = devm_regmap_init_i2c(client, &regmap_i2c_config);
> +	if (IS_ERR(rx6110->regmap)) {
> +		dev_err(&client->dev, "regmap init failed for rtc rx6110\n");
> +		return PTR_ERR(rx6110->regmap);
> +	}
> +
> +	i2c_set_clientdata(client, rx6110);
> +
> +	rx6110->rtc = devm_rtc_device_register(&client->dev,
> +					       client->name,
> +					       &rx6110_rtc_ops, THIS_MODULE);
> +
> +	if (IS_ERR(rx6110->rtc))
> +		return PTR_ERR(rx6110->rtc);
> +
> +	err = rx6110_init(rx6110);
> +	if (err)
> +		return err;
> +
> +	rx6110->rtc->max_user_freq = 1;
> +

I would prefer if you could have a common function doing the RTC
registration and init for both i2c and spi. It wouldn't do much yet but
ideally, it would set the RTC range too and it would be better to not
have to duplicate that.


-- 
Alexandre Belloni, Bootlin
Embedded Linux and Kernel engineering
https://bootlin.com

  reply	other threads:[~2020-11-05 22:19 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-11-04 10:26 [PATCH 0/2] Adding I2C support to RX6110 RTC Claudius Heine
2020-11-04 10:26 ` [PATCH 1/2] rtc: rx6110: add i2c support Claudius Heine
2020-11-05 22:19   ` Alexandre Belloni [this message]
2020-11-04 10:26 ` [PATCH 2/2] rtc: rx6110: add ACPI bindings to I2C Claudius Heine
2020-11-05 22:14 ` [PATCH 0/2] Adding I2C support to RX6110 RTC Alexandre Belloni
2020-11-06  7:40   ` Henning Schild
2020-11-06  7:59     ` Alexandre Belloni
2020-11-06  8:57       ` Henning Schild
2020-11-06  9:08         ` Alexandre Belloni
2020-11-06  7:51   ` Claudius Heine

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=20201105221924.GI1034841@piout.net \
    --to=alexandre.belloni@bootlin.com \
    --cc=a.zummo@towertech.it \
    --cc=ch@denx.de \
    --cc=henning.schild@siemens.com \
    --cc=johannes-hahn@siemens.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-rtc@vger.kernel.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

Powered by JetHome