From: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
To: Christian Fetzer <fetzer.ch@gmail.com>, linux-i2c@vger.kernel.org
Cc: Jarkko Nikula <jarkko.nikula@linux.intel.com>,
Mika Westerberg <mika.westerberg@linux.intel.com>,
Wolfram Sang <wsa@the-dreams.de>,
galandilias@gmail.com, Thomas Brandon <tbrandonau@gmail.com>,
Eddi De Pieri <eddi@depieri.net>
Subject: Re: [PATCH v2 4/5] i2c-piix4: Add support for multiplexed main adapter in SB800
Date: Mon, 02 Nov 2015 14:09:42 +0200 [thread overview]
Message-ID: <1446466182.6332.92.camel@linux.intel.com> (raw)
In-Reply-To: <1446395529-9987-5-git-send-email-fetzer.ch@gmail.com>
On Sun, 2015-11-01 at 17:32 +0100, Christian Fetzer wrote:
> The SB800 chipset supports a multiplexed main SMBus controller with
> four ports. The multiplexed ports share the same SMBus address and
> register set. The port is selected by bits 2:1 of the smb_en register
> (0x2C).
>
> Only one port can be active at any point in time therefore a mutex is
> needed in order to synchronize access.
>
> Tested on HP ProLiant MicroServer G7 N54L (where this patch adds
> support to access sensor data from the w83795adg).
>
> +static int piix4_add_adapters_sb800(struct pci_dev *dev, unsigned
> short smba)
> +{
> + unsigned short port;
> + int retval;
> + struct i2c_piix4_adapdata *adapdata;
> +
> + for (port = 0; port < PIIX4_MAX_ADAPTERS; port++) {
> + retval = piix4_add_adapter(dev, smba,
> + &piix4_main_adapters[port
> ]);
> + if (retval < 0)
> + goto error;
> +
> + piix4_main_adapters[port]->algo =
> &piix4_smbus_algorithm_sb800;
> +
> + adapdata =
> i2c_get_adapdata(piix4_main_adapters[port]);
> + adapdata->port = port;
> + }
> +
> + return retval;
> +
> +error:
> + dev_err(&dev->dev, "Error setting up SB800 adapters. "
> + "Unregistering all adapters!\n");
This one Mika told already about.
You might use as well
dev_err(&dev->dev,
"…\n")
> + for (port--; port >= 0; port--) {
Isn't look complicated? Like I comment in one of previous patches:
while (--port) {
> + adapdata =
> i2c_get_adapdata(piix4_main_adapters[port]);
> + if (adapdata->smba) {
> + i2c_del_adapter(piix4_main_adapters[port]);
> + kfree(adapdata);
> + kfree(piix4_main_adapters[port]);
> + piix4_main_adapters[port] = NULL;
> + }
> + }
> +
> + return retval;
> +}
> +
> static int piix4_probe(struct pci_dev *dev, const struct
> pci_device_id *id)
> {
> unsigned short smba_idx = 0xcd6;
> @@ -629,19 +714,26 @@ static int piix4_probe(struct pci_dev *dev,
> const struct pci_device_id *id)
>
> /* base address location etc changed in SB800 */
> retval = piix4_setup_sb800(dev, id, 0);
> + if (retval < 0)
> + return retval;
> +
> + /* Try to register multiplexed main SMBus adapter,
> + * give up if we can't */
Block comment
/*
* text1
* text2
*/
> + retval = piix4_add_adapters_sb800(dev, retval);
> } else {
> retval = piix4_setup(dev, id);
> + if (retval < 0)
> + return retval;
> +
> + /* Try to register main SMBus adapter, give up if we
> can't */
> + retval = piix4_add_adapter(dev, retval,
> + &piix4_main_adapters[0]);
> }
>
> /* If no main SMBus found, give up */
> if (retval < 0)
> return retval;
>
> - /* Try to register main SMBus adapter, give up if we can't
> */
> - retval = piix4_add_adapter(dev, retval,
> &piix4_main_adapters[0]);
> - if (retval < 0)
> - return retval;
> -
> /* Check for auxiliary SMBus on some AMD chipsets */
> retval = -ENODEV;
>
--
Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Intel Finland Oy
next prev parent reply other threads:[~2015-11-02 12:09 UTC|newest]
Thread overview: 15+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-11-01 16:32 [PATCH v2 0/5] Support multiplexed main SMBus interface on SB80 Christian Fetzer
2015-11-01 16:32 ` [PATCH v2 1/5] i2c-piix4: Optionally release smba in piix4_adap_remove Christian Fetzer
2015-11-02 10:46 ` Mika Westerberg
2015-11-01 16:32 ` [PATCH v2 2/5] i2c-piix4: Convert piix4_main_adapter to array Christian Fetzer
2015-11-02 10:47 ` Mika Westerberg
2015-11-02 11:55 ` Andy Shevchenko
2015-11-01 16:32 ` [PATCH v2 3/5] i2c-piix4: Request base address index region once for SB800 Christian Fetzer
2015-11-02 10:53 ` Mika Westerberg
2015-11-02 12:02 ` Andy Shevchenko
2015-11-01 16:32 ` [PATCH v2 4/5] i2c-piix4: Add support for multiplexed main adapter in SB800 Christian Fetzer
2015-11-02 10:59 ` Mika Westerberg
2015-11-02 12:09 ` Andy Shevchenko [this message]
2015-11-01 16:32 ` [PATCH v2 5/5] i2c-piix4: Add adapter port name support for SB800 chipset Christian Fetzer
2015-11-02 11:03 ` Mika Westerberg
2015-11-02 12:12 ` Andy Shevchenko
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=1446466182.6332.92.camel@linux.intel.com \
--to=andriy.shevchenko@linux.intel.com \
--cc=eddi@depieri.net \
--cc=fetzer.ch@gmail.com \
--cc=galandilias@gmail.com \
--cc=jarkko.nikula@linux.intel.com \
--cc=linux-i2c@vger.kernel.org \
--cc=mika.westerberg@linux.intel.com \
--cc=tbrandonau@gmail.com \
--cc=wsa@the-dreams.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;
as well as URLs for NNTP newsgroup(s).