mail archive of the barebox mailing list
 help / color / mirror / Atom feed
From: Gerald Loacker <gerald.loacker@wolfvision.net>
To: Sascha Hauer <s.hauer@pengutronix.de>,
	Barebox List <barebox@lists.infradead.org>
Subject: Re: [PATCH v2 1/3] i2c: Add slices for I2C adapters
Date: Mon, 11 Sep 2023 13:48:53 +0200	[thread overview]
Message-ID: <4b02bc9f-e21d-8211-9559-18eb44c88cc9@wolfvision.net> (raw)
In-Reply-To: <20230908131117.1769957-1-s.hauer@pengutronix.de>



Am 08.09.2023 um 15:11 schrieb Sascha Hauer:
> Add a slice for I2C adapters so that devices using I2C in the background
> can check if a I2C bus is busy.
> 
> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>

Tested-by: Gerald Loacker <gerald.loacker@wolfvision.net>

> ---
> 
> Notes:
>     Changes since v1:
>     - Add forgotten slice_init()
> 
>  drivers/i2c/i2c.c | 7 +++++++
>  include/i2c/i2c.h | 7 +++++++
>  2 files changed, 14 insertions(+)
> 
> diff --git a/drivers/i2c/i2c.c b/drivers/i2c/i2c.c
> index 300365bd1f..70d1b810c1 100644
> --- a/drivers/i2c/i2c.c
> +++ b/drivers/i2c/i2c.c
> @@ -23,6 +23,7 @@
>  #include <init.h>
>  #include <of.h>
>  #include <gpio.h>
> +#include <slice.h>
>  
>  #include <i2c/i2c.h>
>  
> @@ -62,6 +63,8 @@ int i2c_transfer(struct i2c_adapter *adap, struct i2c_msg *msgs, int num)
>  	uint64_t start;
>  	int ret, try;
>  
> +	slice_acquire(&adap->slice);
> +
>  	/*
>  	 * REVISIT the fault reporting model here is weak:
>  	 *
> @@ -96,6 +99,8 @@ int i2c_transfer(struct i2c_adapter *adap, struct i2c_msg *msgs, int num)
>  			break;
>  	}
>  
> +	slice_release(&adap->slice);
> +
>  	return ret;
>  }
>  EXPORT_SYMBOL(i2c_transfer);
> @@ -721,6 +726,8 @@ int i2c_add_numbered_adapter(struct i2c_adapter *adapter)
>  
>  	list_add_tail(&adapter->list, &i2c_adapter_list);
>  
> +	slice_init(&adapter->slice, dev_name(&adapter->dev));
> +
>  	/* populate children from any i2c device tables */
>  	scan_boardinfo(adapter);
>  
> diff --git a/include/i2c/i2c.h b/include/i2c/i2c.h
> index b1ab72850c..4fc278f800 100644
> --- a/include/i2c/i2c.h
> +++ b/include/i2c/i2c.h
> @@ -18,6 +18,7 @@
>  
>  #include <driver.h>
>  #include <init.h>
> +#include <slice.h>
>  #include <linux/types.h>
>  
>  struct i2c_adapter;
> @@ -121,6 +122,7 @@ int i2c_generic_scl_recovery(struct i2c_adapter *adap);
>   */
>  struct i2c_adapter {
>  	struct device		dev;	/* ptr to device */
> +	struct slice		slice;
>  	int			nr;	/* bus number */
>  	int (*master_xfer)(struct i2c_adapter *adap, struct i2c_msg *msgs, int num);
>  	struct list_head	list;
> @@ -318,6 +320,11 @@ static inline int i2c_adapter_id(struct i2c_adapter *adap)
>  	return adap->nr;
>  }
>  
> +static inline struct slice *i2c_client_slice(struct i2c_client *client)
> +{
> +	return &client->adapter->slice;
> +}
> +
>  extern int i2c_transfer(struct i2c_adapter *adap, struct i2c_msg *msgs, int num);
>  extern int i2c_master_send(struct i2c_client *client, const char *buf, int count);
>  extern int i2c_master_recv(struct i2c_client *client, char *buf, int count);



      parent reply	other threads:[~2023-09-11 11:50 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-09-08 13:11 Sascha Hauer
2023-09-08 13:11 ` [PATCH v2 2/3] spi: Add slices for SPI controllers Sascha Hauer
2023-09-11 11:49   ` Gerald Loacker
2023-09-08 13:11 ` [PATCH v2 3/3] net: ksz9477: Add mdio bus slice dependency to i2c/spi device Sascha Hauer
2023-09-11 11:49   ` Gerald Loacker
2023-09-11 11:48 ` Gerald Loacker [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=4b02bc9f-e21d-8211-9559-18eb44c88cc9@wolfvision.net \
    --to=gerald.loacker@wolfvision.net \
    --cc=barebox@lists.infradead.org \
    --cc=s.hauer@pengutronix.de \
    /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