All of lore.kernel.org
 help / color / mirror / Atom feed
From: Alexandre Belloni <alexandre.belloni@free-electrons.com>
To: Akinobu Mita <akinobu.mita@gmail.com>
Cc: rtc-linux@googlegroups.com,
	Alessandro Zummo <a.zummo@towertech.it>,
	Renaud Cerrato <r.cerrato@til-technologies.fr>
Subject: [rtc-linux] Re: [PATCH 1/3] rtc: pcf2127: conver to use regmap
Date: Fri, 11 Mar 2016 19:11:11 +0100	[thread overview]
Message-ID: <20160311181111.GC4620@piout.net> (raw)
In-Reply-To: <1457713336-24262-1-git-send-email-akinobu.mita@gmail.com>

Hi,

That is nice to see interest in those RTCs. Do you plan to submit more
RTC drivers? How many do you have? :)

One small comment as I didn't have time to read the datasheet.

On 12/03/2016 at 01:22:14 +0900, Akinobu Mita wrote :
> @@ -228,16 +200,113 @@ static const struct of_device_id pcf2127_of_match[] = {
>  MODULE_DEVICE_TABLE(of, pcf2127_of_match);
>  #endif
>  
> -static struct i2c_driver pcf2127_driver = {
> +static int pcf2127_i2c_write(void *context, const void *data, size_t count)
> +{
> +	struct device *dev = context;
> +	struct i2c_client *client = to_i2c_client(dev);
> +	int ret;
> +
> +	ret = i2c_master_send(client, data, count);
> +	if (ret != count)
> +		return ret < 0 ? ret : -EIO;
> +
> +	return 0;
> +}
> +
> +static int pcf2127_i2c_gather_write(void *context,
> +				const void *reg, size_t reg_size,
> +				const void *val, size_t val_size)
> +{
> +	struct device *dev = context;
> +	struct i2c_client *client = to_i2c_client(dev);
> +	int ret;
> +	void *buf;
> +
> +	if (WARN_ON(reg_size != 1))
> +		return -EINVAL;
> +
> +	buf = kmalloc(val_size + 1, GFP_KERNEL);
> +	if (!buf)
> +		return -ENOMEM;
> +
> +	memcpy(buf, reg, 1);
> +	memcpy(buf + 1, val, val_size);
> +
> +	ret = i2c_master_send(client, buf, val_size + 1);
> +	if (ret != val_size + 1)
> +		return ret < 0 ? ret : -EIO;
> +
> +	return 0;
> +}
> +
> +static int pcf2127_i2c_read(void *context, const void *reg, size_t reg_size,
> +				void *val, size_t val_size)
> +{
> +	struct device *dev = context;
> +	struct i2c_client *client = to_i2c_client(dev);
> +	int ret;
> +
> +	if (WARN_ON(reg_size != 1))
> +		return -EINVAL;
> +
> +	ret = i2c_master_send(client, reg, 1);
> +	if (ret != 1)
> +		return ret < 0 ? ret : -EIO;
> +
> +	ret = i2c_master_recv(client, val, val_size);
> +	if (ret != val_size)
> +		return ret < 0 ? ret : -EIO;
> +
> +	return 0;
> +}
> +
> +static const struct regmap_bus pcf2127_i2c_regmap = {
> +	.write = pcf2127_i2c_write,
> +	.gather_write = pcf2127_i2c_gather_write,
> +	.read = pcf2127_i2c_read,
> +};

Do I understand correctly that you have to define that because
regmap_i2c_gather_write doesn't do the right thing for this device?


-- 
Alexandre Belloni, Free Electrons
Embedded Linux, Kernel and Android engineering
http://free-electrons.com

-- 
-- 
You received this message because you are subscribed to "rtc-linux".
Membership options at http://groups.google.com/group/rtc-linux .
Please read http://groups.google.com/group/rtc-linux/web/checklist
before submitting a driver.
--- 
You received this message because you are subscribed to the Google Groups "rtc-linux" group.
To unsubscribe from this group and stop receiving emails from it, send an email to rtc-linux+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

  parent reply	other threads:[~2016-03-11 18:11 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-03-11 16:22 [rtc-linux] [PATCH 1/3] rtc: pcf2127: conver to use regmap Akinobu Mita
2016-03-11 16:22 ` [rtc-linux] [PATCH 2/3] rtc: pcf2127: add support for spi interface Akinobu Mita
2016-03-11 16:22 ` [rtc-linux] [PATCH 3/3] rtc: pcf2127: add pcf2129 device id Akinobu Mita
2016-03-11 18:11 ` Alexandre Belloni [this message]
2016-03-12 15:39   ` [rtc-linux] Re: [PATCH 1/3] rtc: pcf2127: conver to use regmap Akinobu Mita
2016-03-12 15:43     ` Alexandre Belloni

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=20160311181111.GC4620@piout.net \
    --to=alexandre.belloni@free-electrons.com \
    --cc=a.zummo@towertech.it \
    --cc=akinobu.mita@gmail.com \
    --cc=r.cerrato@til-technologies.fr \
    --cc=rtc-linux@googlegroups.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.