devicetree.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Greg KH <gregkh@linuxfoundation.org>
To: Eddie James <eajames@linux.ibm.com>
Cc: linux-kernel@vger.kernel.org, linux-aspeed@lists.ozlabs.org,
	devicetree@vger.kernel.org, andrew@aj.id.au, joel@jms.id.au,
	krzysztof.kozlowski+dt@linaro.org, robh+dt@kernel.org,
	arnd@arndb.de
Subject: Re: [PATCH v3 1/4] eeprom: ee1004: Enable devices on multiple busses
Date: Wed, 29 Mar 2023 12:07:42 +0200	[thread overview]
Message-ID: <ZCQN7uq7Y3xFY1od@kroah.com> (raw)
In-Reply-To: <20230322140348.569397-2-eajames@linux.ibm.com>

On Wed, Mar 22, 2023 at 09:03:45AM -0500, Eddie James wrote:
> The driver previously prevented probing devices on more than one
> bus due to locking constraints with the special page addresses. This
> constraint can be removed by allocating a reference-counted bus
> structure containing the lock, rather than using global variables.
> 
> Signed-off-by: Eddie James <eajames@linux.ibm.com>
> ---
> Changes since v2:
>  - Remove of_device.h include
> 
>  drivers/misc/eeprom/ee1004.c | 174 +++++++++++++++++++++--------------
>  1 file changed, 105 insertions(+), 69 deletions(-)
> 
> diff --git a/drivers/misc/eeprom/ee1004.c b/drivers/misc/eeprom/ee1004.c
> index c8c6deb7ed89..0aed5760e370 100644
> --- a/drivers/misc/eeprom/ee1004.c
> +++ b/drivers/misc/eeprom/ee1004.c
> @@ -9,9 +9,11 @@
>   * Copyright (C) 2008 Wolfram Sang, Pengutronix
>   */
>  
> +#include <linux/err.h>
>  #include <linux/i2c.h>
>  #include <linux/init.h>
>  #include <linux/kernel.h>
> +#include <linux/list.h>
>  #include <linux/mod_devicetable.h>
>  #include <linux/module.h>
>  #include <linux/mutex.h>
> @@ -31,20 +33,24 @@
>   * over performance.
>   */
>  
> -#define EE1004_ADDR_SET_PAGE		0x36
> +#define EE1004_ADDR_SET_PAGE0		0x36
> +#define EE1004_ADDR_SET_PAGE1		0x37
>  #define EE1004_NUM_PAGES		2
>  #define EE1004_PAGE_SIZE		256
>  #define EE1004_PAGE_SHIFT		8
>  #define EE1004_EEPROM_SIZE		(EE1004_PAGE_SIZE * EE1004_NUM_PAGES)
>  
> -/*
> - * Mutex protects ee1004_set_page and ee1004_dev_count, and must be held
> - * from page selection to end of read.
> - */
> -static DEFINE_MUTEX(ee1004_bus_lock);
> -static struct i2c_client *ee1004_set_page[EE1004_NUM_PAGES];
> -static unsigned int ee1004_dev_count;
> -static int ee1004_current_page;
> +struct ee1004_bus {
> +	struct kref kref;
> +	struct list_head list;
> +	struct mutex lock;
> +	struct i2c_adapter *adapter;
> +	struct i2c_client *set_page_clients[EE1004_NUM_PAGES];
> +	int page;
> +};
> +
> +static LIST_HEAD(ee1004_busses);
> +static DEFINE_MUTEX(ee1004_busses_lock);

This really looks like you are just emulating a tiny portion of the
driver core (busses, lists of busses, reference counting, etc.)

Why not just use an aux device instead and get all of that logic "for
free" in a way that will be properly shown to userspace?  Right now it
has no idea what is happening here with individual portions of the
device and the like.

Please look into that instead of this hand-rolled device model.

thanks,

greg k-h

  reply	other threads:[~2023-03-29 10:07 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-03-22 14:03 [PATCH v3 0/4] eeprom: ee1004: Enable devices on multiple busses Eddie James
2023-03-22 14:03 ` [PATCH v3 1/4] " Eddie James
2023-03-29 10:07   ` Greg KH [this message]
2023-03-22 14:03 ` [PATCH v3 2/4] dt-bindings: trivial-devices: Add Atmel AT30TSE004A serial eeprom Eddie James
2023-03-22 21:54   ` Krzysztof Kozlowski
2023-03-22 14:03 ` [PATCH v3 3/4] eeprom: ee1004: Add OF matching support Eddie James
2023-03-22 14:03 ` [PATCH v3 4/4] ARM: dts: aspeed: bonnell: Add DIMM SPD Eddie James
2023-03-27  0:46   ` Joel Stanley

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=ZCQN7uq7Y3xFY1od@kroah.com \
    --to=gregkh@linuxfoundation.org \
    --cc=andrew@aj.id.au \
    --cc=arnd@arndb.de \
    --cc=devicetree@vger.kernel.org \
    --cc=eajames@linux.ibm.com \
    --cc=joel@jms.id.au \
    --cc=krzysztof.kozlowski+dt@linaro.org \
    --cc=linux-aspeed@lists.ozlabs.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=robh+dt@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;
as well as URLs for NNTP newsgroup(s).