Re: [PATCH v3 1/6] mpt3sas: Introduce mpt3sas_base_pci_device_is_available

2018-09-25 Thread Andy Shevchenko
On Tue, Sep 25, 2018 at 1:29 PM Suganath Prabu Subramani
 wrote:
>
> On Tue, Sep 25, 2018 at 3:22 PM Andy Shevchenko
>  wrote:
> >
> > On Tue, Sep 25, 2018 at 12:46 PM Suganath Prabu Subramani
> >  wrote:
> >
> > > > > +   pr_err(MPT3SAS_FMT
> > > > > +   "%s: pci error recovery reset or"
> > > > > +   " pci device unplug occurred\n",
> > > >
> > > > This should be just one line.
> > > Above line crosses over 80 characters, so it is in two lines.
> >
> > For years there is no such requirement for string literals.
> Below is the one i was mentioning,
> WARNING: line over 80 characters
> #30: FILE: drivers/scsi/mpt3sas/mpt3sas_base.c:6861:
> + pr_err(MPT3SAS_FMT "%s: pci error recovery reset or pci device
> unplug occurred\n", ioc->name, __func__);
>
> Warning comes for both characters over 80 chars and string split.
> Do you want us to ignore warning and repost like above in single line ?
> > Please, don't split string literals in ugly way like this.

I didn't tell anything about other parameters to be on the same line.
So, please, try again.

-- 
With Best Regards,
Andy Shevchenko


Re: [PATCH v3 1/6] mpt3sas: Introduce mpt3sas_base_pci_device_is_available

2018-09-25 Thread Andy Shevchenko
On Tue, Sep 25, 2018 at 12:46 PM Suganath Prabu Subramani
 wrote:

> > > +   pr_err(MPT3SAS_FMT
> > > +   "%s: pci error recovery reset or"
> > > +   " pci device unplug occurred\n",
> >
> > This should be just one line.
> Above line crosses over 80 characters, so it is in two lines.

For years there is no such requirement for string literals.
Please, don't split string literals in ugly way like this.

-- 
With Best Regards,
Andy Shevchenko


Re: [PATCH v3 1/6] mpt3sas: Introduce mpt3sas_base_pci_device_is_available

2018-09-25 Thread Andy Shevchenko
On Mon, Sep 24, 2018 at 9:36 AM Suganath Prabu S
 wrote:
>
> * Driver uses "pci_device_is_present" to check whether
> If Hot unplugged:
> the outstanding IOs with 'DID_NO_CONNECT' before removing the drives
> attached to the HBA.
> "DID_NO_CONNECT" status and free the smid, if driver detects that
> HBA is hot unplugged.
>
> * In the hard reset flush out all the outstanding IOs even if diag reset
> fails and also if driver detects that HBA is hot unplugged.

> +   if (!mpt3sas_base_pci_device_is_available(ioc)) {

> +   pr_err(MPT3SAS_FMT
> +   "%s: pci error recovery reset or"
> +   " pci device unplug occurred\n",

This should be just one line.

> +   ioc->name, __func__);
> +   return;
> +   }

-- 
With Best Regards,
Andy Shevchenko


Re: [PATCH v3 0/6] mpt3sas: Hot-Plug Surprise removal support on IOC.

2018-09-25 Thread Andy Shevchenko
On Mon, Sep 24, 2018 at 9:36 AM Suganath Prabu S
 wrote:
>
> Posting below set of patches to support PCIe Hot Plug surprise removal,
> and few defect fixes.
>
> This is NOT the normal PCIe Hot Plug support, whereby the user informs the
> OS that a hot removal is desired, the OS does an orderly shutdown of the
> driver on the device, special hot plug circuitry removes power from the
> PCIe slot, then the user can remove the device and replace it
> (where orderly bring-up of the device is done).
>
> With a true surprise removal (just removing HBA from a slot)
> there is a possibility to get all kinds of PCIe transaction errors,
> Below patches addresses those issues and remove HBA without bringing
> the system down.
>
> For surprise removal detection, driver does a PCI
> read of IOC's vendor field in IOC's PCI configuration space.
> If the read value is 0x this indicates that the device
> might have hot removed and the device will be removed from driver.
>

AFAIR Lukas asked you to Cc new versions to Linux PCI mailing list
and, if I'm not mistaken, to him.

> V1 changes:
> In Patch 0001 - unlock mutex, if active reset is in progress.
>
> V2 changes:
> Replaced mpt3sas_base_pci_device_is_unplugged with
> pci_device_is_present.
>
> V3 Change Set:
> Simplified function "mpt3sas_base_pci_device_is_available" and
> made inline
>
> Suganath Prabu S (6):
>   mpt3sas: Introduce  mpt3sas_base_pci_device_is_available
>   mpt3sas: Separate out  mpt3sas_wait_for_ioc_to_operational
>   mpt3sas: Introdude  _scsih_get_shost_and_ioc.
>   mpt3sas: Fix Sync cache command failure during driver  unload.
>   mpt3sas: Fix driver modifying NVRAM/persistent data.
>   mpt3sas: Bump driver version to 27.100.00.00.
>
>  drivers/scsi/mpt3sas/mpt3sas_base.c  | 135 +++---
>  drivers/scsi/mpt3sas/mpt3sas_base.h  |  11 +-
>  drivers/scsi/mpt3sas/mpt3sas_config.c|  32 +-
>  drivers/scsi/mpt3sas/mpt3sas_ctl.c   |  26 +
>  drivers/scsi/mpt3sas/mpt3sas_scsih.c | 189 
> +++
>  drivers/scsi/mpt3sas/mpt3sas_transport.c |  82 +++---
>  6 files changed, 298 insertions(+), 177 deletions(-)
>
> --
> 1.8.3.1
>


-- 
With Best Regards,
Andy Shevchenko


Re: [Patch v1 0/7] mpt3sas: Hot-Plug Surprise removal support on IOC.

2018-08-31 Thread Andy Shevchenko
+Cc: Lukas (I think he might be interested to look at this)

On Fri, Aug 31, 2018 at 7:37 AM Suganath Prabu S
 wrote:
>
> Posting below set of patches to support PCIe Hot Plug surprise removal,
> and few defect fixes.
>
> This is NOT the normal PCIe Hot Plug support, whereby the user informs the
> OS that a hot removal is desired, the OS does an orderly shutdown of the 
> driver
> on the device, special hot plug circuitry removes power from the PCIe slot,
> then the user can remove the device and replace it
> (where orderly bring-up of the device is done).
>
> With a true surprise removal (just removing HBA from a slot)
> there is a possibility to get all kinds of PCIe transaction errors,
> Below patches addresses those issues and remove HBA without bringing
> the system down.
>
> For surprise removal detection, driver does a PCI
> read of IOC's vendor field in IOC's PCI configuration space.
> If the read value is 0x this indicates that the device
> might have hot removed and the device will be removed from driver.
>
> V1 changes:
> In Patch 0001 - unlock mutex, if active reset is in progress.
>
> Suganath Prabu S (7):
>   mpt3sas: Introduce mpt3sas_base_pci_device_is_unplugged
>   mpt3sas: Add HBA hot plug watchdog thread.
>   mpt3sas: Seperate out  mpt3sas_wait_for_ioc_to_operational
>   mpt3sas: Introdude  _scsih_get_shost_and_ioc.
>   mpt3sas: Fix Sync cache command failure during driver  unload.
>   mpt3sas: Fix driver modifying NVRAM/persistent data.
>   mpt3sas: Bump driver version to 27.100.00.00.
>
>  drivers/scsi/mpt3sas/mpt3sas_base.c  | 248 
> ++-
>  drivers/scsi/mpt3sas/mpt3sas_base.h  |  17 ++-
>  drivers/scsi/mpt3sas/mpt3sas_config.c|  32 +---
>  drivers/scsi/mpt3sas/mpt3sas_ctl.c   |  26 +---
>  drivers/scsi/mpt3sas/mpt3sas_scsih.c | 188 ---
>  drivers/scsi/mpt3sas/mpt3sas_transport.c |  82 +++---
>  6 files changed, 414 insertions(+), 179 deletions(-)
>
> --
> 1.8.3.1
>


-- 
With Best Regards,
Andy Shevchenko


Re: [PATCH v2] mpt3sas: correct reset of smid while clearing scsi tracker

2018-08-03 Thread Andy Shevchenko
On Fri, Aug 3, 2018 at 5:06 PM, Bart Van Assche  wrote:
> On Fri, 2018-08-03 at 06:31 -0400, Sreekanth Reddy wrote:

>> + /* Added memory barrier to make sure that correct chain tracker
>> +  * is retrieved before incrementing the smid pool's chain_offset
>> +  * value in chain lookup table.
>> +  */
>
> Please verify your patch with checkpatch and use the proper kernel comment 
> style.

This kind of style is what net subsystem is using. Last time I heard
about this was that checkpatch doesn't distinguish subsystem and thus
allows this kind of style.

-- 
With Best Regards,
Andy Shevchenko


Re: [PATCH v1 RESEND] mpt3sas: Swap I/O memory read value back to cpu endianness

2018-08-03 Thread Andy Shevchenko
On Thu, 2018-08-02 at 16:16 -0400, Martin K. Petersen wrote:
> Andy,
> 
> Please review the changes Sreekanth made to address your feedback.

>From my point of view they look good.

I assume Sreekanth tested them on real hardware and as I remember davem@
actually the one who possesses sparc machine with this hardware.

> 
> > Swap the I/O memory read value back to cpu endianness before storing
> > it
> > in a data structures which are defined in the MPI headers where
> > u8 components are not defined in the endianness order.
> > 
> > In this area from day one mpt3sas driver is using le32_to_cpu() &
> > cpu_to_le32() APIs. But in the patch cf6bf9710c
> > (mpt3sas: Bug fix for big endian systems) we have removed these APIs
> > before reading I/O memory which we should haven't done it. So
> > in this patch I am correcting it by adding these APIs back
> > before accessing I/O memory.
> > 
> > v1: Changelog:
> > Replaced writeq API with __raw_writeq() & mmiowb() APIs.
> 
> 

-- 
Andy Shevchenko 
Intel Finland Oy


Re: [PATCH] mpt3sas: Swap I/O memory read value back to cpu endianness

2018-07-26 Thread Andy Shevchenko
On Thu, Jul 26, 2018 at 2:25 PM, Sreekanth Reddy
 wrote:
> On Wed, Jul 25, 2018 at 8:32 PM, Andy Shevchenko
>  wrote:
>> On Wed, Jul 25, 2018 at 12:42 PM, Sreekanth Reddy
>>  wrote:
>>> Swap the I/O memory read value back to cpu endianness before storing it
>>> in a data structures which are defined in the MPI headers where
>>> u8 components are not defined in the endianness order.
>>>
>>> In this area from day one mpt3sas driver is using le32_to_cpu() &
>>> cpu_to_le32() APIs. But in the patch cf6bf9710c
>>> (mpt3sas: Bug fix for big endian systems) we have removed these APIs
>>> before reading I/O memory which we should haven't done it. So
>>> in this patch I am correcting it by adding these APIs back
>>> before accessing I/O memory.
>>
>>> -   __u64 data_out = b;
>>> +   __u64 data_out = cpu_to_le64(b);
>>>
>>> spin_lock_irqsave(writeq_lock, flags);
>>> writel((u32)(data_out), addr);
>>
>> Wouldn't be the same as
>>
>> __raw_writel(data_out >> 0, addr);
>> __raw_writel(data_out >> 32, addr + 4);
>> mmiowb();
>>
>> ?
>
> Yes, I can replace the writel() APIs with __raw_writel() with mmiowb()
> memory barrier. Hoping this doesn't create any other side effects.
>
> I will post new patch with this change tomorrow after doing some
> testing in this area.

Thanks!

>
>>
>>>  _base_writeq(__u64 b, volatile void __iomem *addr, spinlock_t *writeq_lock)
>>>  {
>>> -   writeq(b, addr);
>>> +   writeq(cpu_to_le64(b), addr);
>>
>> Similar here
>> __raw_writeq(b, addr);
>> mmiowb();
>>
>>
>>> -   writel((u32)(request[i]), >chip->Doorbell);
>>> +   writel(cpu_to_le32(request[i]), >chip->Doorbell);
>>
>> This kind of endianess play (including above) should make sparse unhappy.
>>
>> Did you run it with
>>
>> C=1 CF=-D__CHECK_ENDIAN__
>>
>> ?
>
> Yes I run it on 4.18 kernel and I don't see any error or warning for
> these lines.

If you try on x86 I'm pretty sure you get some warnings, especially
taken into consideration [1].

[1]:

commit 6469a0ee0a06b2ea1f5afbb1d5a3feed017d4c7a (tip/x86-asm-for-linus)
Author: Andy Shevchenko 
Date:   Tue May 15 14:52:11 2018 +0300

   x86/io: Define readq()/writeq() to use 64-bit type

-- 
With Best Regards,
Andy Shevchenko


Re: [PATCH] mpt3sas: Swap I/O memory read value back to cpu endianness

2018-07-25 Thread Andy Shevchenko
On Wed, Jul 25, 2018 at 12:42 PM, Sreekanth Reddy
 wrote:
> Swap the I/O memory read value back to cpu endianness before storing it
> in a data structures which are defined in the MPI headers where
> u8 components are not defined in the endianness order.
>
> In this area from day one mpt3sas driver is using le32_to_cpu() &
> cpu_to_le32() APIs. But in the patch cf6bf9710c
> (mpt3sas: Bug fix for big endian systems) we have removed these APIs
> before reading I/O memory which we should haven't done it. So
> in this patch I am correcting it by adding these APIs back
> before accessing I/O memory.

> -   __u64 data_out = b;
> +   __u64 data_out = cpu_to_le64(b);
>
> spin_lock_irqsave(writeq_lock, flags);
> writel((u32)(data_out), addr);

Wouldn't be the same as

__raw_writel(data_out >> 0, addr);
__raw_writel(data_out >> 32, addr + 4);
mmiowb();

?

>  _base_writeq(__u64 b, volatile void __iomem *addr, spinlock_t *writeq_lock)
>  {
> -   writeq(b, addr);
> +   writeq(cpu_to_le64(b), addr);

Similar here
__raw_writeq(b, addr);
mmiowb();


> -   writel((u32)(request[i]), >chip->Doorbell);
> +   writel(cpu_to_le32(request[i]), >chip->Doorbell);

This kind of endianess play (including above) should make sparse unhappy.

Did you run it with

C=1 CF=-D__CHECK_ENDIAN__

?

-- 
With Best Regards,
Andy Shevchenko


Re: [PATCH] mpt3sas: Fix for regression caused due to cf6bf9710c patch

2018-06-29 Thread Andy Shevchenko
On Fri, Jun 29, 2018 at 7:06 PM, James Bottomley
 wrote:
> On Fri, 2018-06-29 at 10:58 -0400, Chaitra P B wrote:
>>  "scsi: mpt3sas: Bug fix for big endian systems"
>>
>> Above patch with commit id "cf6bf9710cabba1fe94a4349f4eb8db623c77ebc"
>> was posted to fix sparse warnings. While posting this patch it was
>> assumed that readl() & writel() APIs internally calls le32_to_cpu() &
>> cpu_to_le32() APIs respectively. Looks like it is not true for all
>> architecture
>
> Just a minute, it damn well should be.  The definition of readl/writel
> is barriers and little endian (you can see this in asm-generic/io.h).
>
> Which architecture is getting this wrong?  Because it sounds like
> that's what we need to fix rather than doing something like this in all
> drivers.
>
> Sparc (and parisc) definitely do the little endian thing, so if this
> code is what it takes to get them working again, it looks like you're
> double swapping somewhere.  I really think cf6bf9710c needs to be
> reverted and you should look again at your sparse warnings.  Since the
> driver is using the non-raw readX/writeX it should be cpu endian
> internally which cf6bf9710c upsets.

And we definitely won't see the constructions like
writeq(cpu_to_le64()) in the code, because it's weird.
If I get it correctly it's equivalent to __raw_writeq().

-- 
With Best Regards,
Andy Shevchenko


Re: [PATCH] mpt3sas: Fix for regression caused due to cf6bf9710c patch

2018-06-29 Thread Andy Shevchenko
On Fri, Jun 29, 2018 at 5:58 PM, Chaitra P B
 wrote:
>  "scsi: mpt3sas: Bug fix for big endian systems"
>
> Above patch with commit id "cf6bf9710cabba1fe94a4349f4eb8db623c77ebc" was
> posted to fix sparse warnings. While posting this patch it was assumed that
> readl() & writel() APIs internally calls le32_to_cpu() & cpu_to_le32() APIs
> respectively.

> Looks like it is not true for all architecture

Oh, what a mess. Looking at code comments I could imagine why it's done so...
Sad.

>  and hence
> this patch is reverting back only those hunks which removed le32_to_cpu()
> API call while using readl() API & cpu_to_le32() API call while using
> writel() API.

Can't you move to raw variants at the same time to be more clear with
intentions?
It would work on all architectures in the same way and won't trigger
sparse warnings.

As an example:

> -   writeq(b, addr);
> +   writeq(cpu_to_le64(b), addr);

/* Not all architectures has a writeq() equivalent to the below (sparc64) */
__raw_writeq(...)

-- 
With Best Regards,
Andy Shevchenko


Re: [PATCH] scsi: sd: Keep disk read-only when re-reading partition

2018-03-01 Thread Andy Shevchenko
On Thu, Mar 1, 2018 at 4:08 PM, Jeremy Cline <jer...@jcline.org> wrote:
> If the read-only flag is true on a SCSI disk, re-reading the partition
> table sets the flag back to false.
>
> To observe this bug, you can run:
>
> 1. blockdev --setro /dev/sda
> 2. blockdev --rereadpt /dev/sda
> 3. blockdev --getro /dev/sda
>
> This commit reads the disk's old state and combines it with the device
> disk-reported state rather than unconditionally marking it as RW.

> -   sdkp->write_prot = ((data.device_specific & 0x80) != 0);
> +   sdkp->write_prot = ((data.device_specific & 0x80) != 0) ||
> +   disk_ro;

Perhaps
   sdkp->write_prot = (data.device_specific & 0x80) || disk_ro;

will save a line.

-- 
With Best Regards,
Andy Shevchenko


Re: [PATCH] scsi: lpfc: use memcpy_toio instead of writeq

2018-02-23 Thread Andy Shevchenko
On Fri, Feb 23, 2018 at 7:09 PM, David Laight <david.lai...@aculab.com> wrote:
> From: Andy Shevchenko
>> Sent: 23 February 2018 16:51
>> On Fri, Feb 23, 2018 at 6:41 PM, David Laight <david.lai...@aculab.com> 
>> wrote:


>> The side-effect I referred previously is about tails, i.e. unaligned
>> bytes are transferred in portions
>> like
>>   7 on 64-bit will be  4 + 2 + 1,
>>   5 = 4 + 1
>
> on 64bit memcpy() is allowed to do:
> (long *)(tgt+len)[-1] = (long *)(src+len)[-1];
> rep_movsq(tgt, src, len >> 3);
> provided the length is at least 8.
>
> The misaligned PCIe transfer generates a single TLP covering 12 bytes with the
> relevant byte enables set for the first and last 32bit words.

But is it guaranteed on any type of bus?
memcpy_toio() is a generic helper, so, first of all we need to be sure
what CPU on its side does, this is I think is pretty straight forward
since it's all written in asm for 64-bit case.
So, what about buses?

-- 
With Best Regards,
Andy Shevchenko


Re: [PATCH] scsi: lpfc: use memcpy_toio instead of writeq

2018-02-23 Thread Andy Shevchenko
On Fri, Feb 23, 2018 at 6:51 PM, Andy Shevchenko
<andy.shevche...@gmail.com> wrote:
> On Fri, Feb 23, 2018 at 6:41 PM, David Laight <david.lai...@aculab.com> wrote:
>> From: Arnd Bergmann
>>> Sent: 23 February 2018 15:37
>>>
>>> 32-bit architectures generally cannot use writeq(), so we now get a build
>>> failure for the lpfc driver:
>>>
>>> drivers/scsi/lpfc/lpfc_sli.c: In function 'lpfc_sli4_wq_put':
>>> drivers/scsi/lpfc/lpfc_sli.c:145:4: error: implicit declaration of function 
>>> 'writeq'; did you mean
>>> 'writeb'? [-Werror=implicit-function-declaration]
>>>
>>> Another problem here is that writing out actual data (unlike accessing
>>> mmio registers) means we must write the data with the same endianess
>>> that we have read from memory, but writeq() will perform byte swaps
>>> and add barriers inbetween accesses as we do for registers.
>>>
>>> Using memcpy_toio() should do the right thing here, using register
>>> sized stores with correct endianess conversion and barriers (i.e. none),
>>> but on some architectures might fall back to byte-size access.
>> ...
>>
>> Have you looked at the performance impact of this on x86?
>> Last time I looked memcpy_toio() aliased directly to memcpy().
>> memcpy() is run-time patched between several different algorithms.
>> On recent Intel cpus memcpy() is implemented as 'rep movsb' relying
>> on the hardware to DTRT.
>> For uncached accesses (typical for io) the 'RT' has to be byte transfers.
>> So instead of the 8 byte transfers (on 64 bit) you get single bytes.
>> This won't be what is intended!
>> memcpy_toio() should probably use 'rep movsd' for the bulk of the transfer.
>
> Maybe I'm wrong but it uses movsq on 64-bit and movsl on 32-bit.
>
> The side-effect I referred previously is about tails, i.e. unaligned
> bytes are transferred in portions
> like
>   7 on 64-bit will be  4 + 2 + 1,
>   5 = 4 + 1
> etc
>
> Similar way on 32-bit.

Same for leading bytes as well.

arch/x86/lib/memcpy_64.S

So, I *hope* that in the code in question there is no unaligned access is used.

-- 
With Best Regards,
Andy Shevchenko


Re: [PATCH] scsi: lpfc: use memcpy_toio instead of writeq

2018-02-23 Thread Andy Shevchenko
On Fri, Feb 23, 2018 at 6:41 PM, David Laight <david.lai...@aculab.com> wrote:
> From: Arnd Bergmann
>> Sent: 23 February 2018 15:37
>>
>> 32-bit architectures generally cannot use writeq(), so we now get a build
>> failure for the lpfc driver:
>>
>> drivers/scsi/lpfc/lpfc_sli.c: In function 'lpfc_sli4_wq_put':
>> drivers/scsi/lpfc/lpfc_sli.c:145:4: error: implicit declaration of function 
>> 'writeq'; did you mean
>> 'writeb'? [-Werror=implicit-function-declaration]
>>
>> Another problem here is that writing out actual data (unlike accessing
>> mmio registers) means we must write the data with the same endianess
>> that we have read from memory, but writeq() will perform byte swaps
>> and add barriers inbetween accesses as we do for registers.
>>
>> Using memcpy_toio() should do the right thing here, using register
>> sized stores with correct endianess conversion and barriers (i.e. none),
>> but on some architectures might fall back to byte-size access.
> ...
>
> Have you looked at the performance impact of this on x86?
> Last time I looked memcpy_toio() aliased directly to memcpy().
> memcpy() is run-time patched between several different algorithms.
> On recent Intel cpus memcpy() is implemented as 'rep movsb' relying
> on the hardware to DTRT.
> For uncached accesses (typical for io) the 'RT' has to be byte transfers.
> So instead of the 8 byte transfers (on 64 bit) you get single bytes.
> This won't be what is intended!
> memcpy_toio() should probably use 'rep movsd' for the bulk of the transfer.

Maybe I'm wrong but it uses movsq on 64-bit and movsl on 32-bit.

The side-effect I referred previously is about tails, i.e. unaligned
bytes are transferred in portions
like
  7 on 64-bit will be  4 + 2 + 1,
  5 = 4 + 1
etc

Similar way on 32-bit.

-- 
With Best Regards,
Andy Shevchenko


Re: [PATCH] scsi: lpfc: use memcpy_toio instead of writeq

2018-02-23 Thread Andy Shevchenko
On Fri, Feb 23, 2018 at 5:59 PM, Andy Shevchenko
<andy.shevche...@gmail.com> wrote:
> On Fri, Feb 23, 2018 at 5:36 PM, Arnd Bergmann <a...@arndb.de> wrote:

> IIRC memcpy_toio() doesn't increment the destination address.
>
> lo_hi or hi_lo helpers sound better.

Ah, sorry, I messed up with writesl() / etc.

memcpy_toio() has another side-effect, but here it seems unimportant.

-- 
With Best Regards,
Andy Shevchenko


Re: [PATCH] scsi: lpfc: use memcpy_toio instead of writeq

2018-02-23 Thread Andy Shevchenko
On Fri, Feb 23, 2018 at 5:36 PM, Arnd Bergmann <a...@arndb.de> wrote:
> 32-bit architectures generally cannot use writeq(), so we now get a build
> failure for the lpfc driver:
>
> drivers/scsi/lpfc/lpfc_sli.c: In function 'lpfc_sli4_wq_put':
> drivers/scsi/lpfc/lpfc_sli.c:145:4: error: implicit declaration of function 
> 'writeq'; did you mean 'writeb'? [-Werror=implicit-function-declaration]
>
> Another problem here is that writing out actual data (unlike accessing
> mmio registers) means we must write the data with the same endianess
> that we have read from memory, but writeq() will perform byte swaps
> and add barriers inbetween accesses as we do for registers.
>
> Using memcpy_toio() should do the right thing here, using register
> sized stores with correct endianess conversion and barriers (i.e. none),
> but on some architectures might fall back to byte-size access.
>
> Side note: shouldn't the driver use ioremap_wc() instead of ioremap()
> to get a write-combining mapping on all architectures that support this?

IIRC memcpy_toio() doesn't increment the destination address.

lo_hi or hi_lo helpers sound better.

> Fixes: 1351e69fc6db ("scsi: lpfc: Add push-to-adapter support to sli4")
> Signed-off-by: Arnd Bergmann <a...@arndb.de>

> @@ -115,7 +115,6 @@ lpfc_sli4_wq_put(struct lpfc_queue *q, union lpfc_wqe 
> *wqe)
> struct lpfc_register doorbell;
> uint32_t host_index;
> uint32_t idx;
> -   uint32_t i = 0;
> uint8_t *tmp;
>
> /* sanity check on queue memory */
> @@ -138,12 +137,10 @@ lpfc_sli4_wq_put(struct lpfc_queue *q, union lpfc_wqe 
> *wqe)
> if (q->phba->sli3_options & LPFC_SLI4_PHWQ_ENABLED)
> bf_set(wqe_wqid, >generic.wqe_com, q->queue_id);
> lpfc_sli_pcimem_bcopy(wqe, temp_wqe, q->entry_size);
> -   if (q->dpp_enable && q->phba->cfg_enable_dpp) {
> +   if (q->dpp_enable && q->phba->cfg_enable_dpp)
> /* write to DPP aperture taking advatage of Combined Writes */
> -   tmp = (uint8_t *)wqe;
> -   for (i = 0; i < q->entry_size; i += sizeof(uint64_t))
> -   writeq(*((uint64_t *)(tmp + i)), q->dpp_regaddr + i);
> -   }
> +   memcpy_toio(tmp, q->dpp_regaddr, q->entry_size);
> +
> /* ensure WQE bcopy and DPP flushed before doorbell write */
> wmb();
>
> --
> 2.9.0
>



-- 
With Best Regards,
Andy Shevchenko


Re: [PATCH v1] scsi: mpt3sas: Use lo_hi_writeq() helper

2018-02-14 Thread Andy Shevchenko
On Wed, 2018-02-14 at 11:40 -0800, James Bottomley wrote:
> On Wed, 2018-02-14 at 20:10 +0200, Andy Shevchenko wrote:
> > Since we have a writeq() for 32-bit architectures as provided by IO
> > non-atomic helpers, there is no need to open code it.
> > 
> > Moreover sparse complains about this:
> > 
> > drivers/scsi/mpt3sas/mpt3sas_base.c:2975:16: expected unsigned long
> > long val
> > drivers/scsi/mpt3sas/mpt3sas_base.c:2975:16: got restricted __le64
> > 
> > 
> > Fixing this by replacing custom writeq() with one provided by
> > io-64-nonatomic-lo-hi.h header.
> > 

> > -#if defined(writeq) && defined(CONFIG_64BIT)
> > -static inline void
> > -_base_writeq(__u64 b, volatile void __iomem *addr, spinlock_t
> > *writeq_lock)
> > -{
> > -   writeq(cpu_to_le64(b), addr);
> > -}
> > -#else
> >  static inline void
> >  _base_writeq(__u64 b, volatile void __iomem *addr, spinlock_t
> > *writeq_lock)
> >  {
> > @@ -2985,11 +2979,9 @@ _base_writeq(__u64 b, volatile void __iomem
> > *addr, spinlock_t *writeq_lock)
> > __u64 data_out = cpu_to_le64(b);
> >  
> > spin_lock_irqsave(writeq_lock, flags);
> > -   writel((u32)(data_out), addr);
> > -   writel((u32)(data_out >> 32), (addr + 4));
> > +   writeq(data_out, addr);
> > spin_unlock_irqrestore(writeq_lock, flags);
> >  }
> > -#endif
> 
> This would rather defeat the purpose of the original code, I think.

James, TBH, I don't see any value of that lock. What it's protecting
from? simultaneous thread doing writeq()? But this is pointless if at
the same time you will have writel() to the device.

For my opinion perhaps complete removal of the custom writeq() and
replacing it by just writeq() with enabled non-atomic helpers will do
the job.

The code is very old, and I have no idea why it's done this (strange)
way.

>  The coding seems to indicate that if the platform can do a writeq
> atomically (i.e. it's 64 bit and has the primitive) then it should and
> not take the hit of using a lock.  Otherwise the 64 bit value is
> updated by two 32 bit writes protected by a lock to ensure we don't
> get
> interleaving of the write.
> 
> So I think you can replace the double writel with a lo_hi_writeq but
> you have to lose the lock if the platform supports the atomic 64 bit
> write for performance reasons.


-- 
Andy Shevchenko <andriy.shevche...@linux.intel.com>
Intel Finland Oy


[PATCH v1] scsi: mpt3sas: Use lo_hi_writeq() helper

2018-02-14 Thread Andy Shevchenko
Since we have a writeq() for 32-bit architectures as provided by IO
non-atomic helpers, there is no need to open code it.

Moreover sparse complains about this:

drivers/scsi/mpt3sas/mpt3sas_base.c:2975:16: expected unsigned long long val
drivers/scsi/mpt3sas/mpt3sas_base.c:2975:16: got restricted __le64 

Fixing this by replacing custom writeq() with one provided by
io-64-nonatomic-lo-hi.h header.

Reported-by: kbuild test robot <fengguang...@intel.com>
Signed-off-by: Andy Shevchenko <andriy.shevche...@linux.intel.com>
---
 drivers/scsi/mpt3sas/mpt3sas_base.c | 14 +++---
 1 file changed, 3 insertions(+), 11 deletions(-)

diff --git a/drivers/scsi/mpt3sas/mpt3sas_base.c 
b/drivers/scsi/mpt3sas/mpt3sas_base.c
index 59a87ca328d3..a92ab4a801d7 100644
--- a/drivers/scsi/mpt3sas/mpt3sas_base.c
+++ b/drivers/scsi/mpt3sas/mpt3sas_base.c
@@ -56,6 +56,7 @@
 #include 
 #include 
 #include 
+#include 
 #include 
 #include 
 #include 
@@ -2968,16 +2969,9 @@ mpt3sas_base_free_smid(struct MPT3SAS_ADAPTER *ioc, u16 
smid)
  * @writeq_lock: spin lock
  *
  * Glue for handling an atomic 64 bit word to MMIO. This special handling takes
- * care of 32 bit environment where its not quarenteed to send the entire word
+ * care of 32 bit environment where its not guaranteed to send the entire word
  * in one transfer.
  */
-#if defined(writeq) && defined(CONFIG_64BIT)
-static inline void
-_base_writeq(__u64 b, volatile void __iomem *addr, spinlock_t *writeq_lock)
-{
-   writeq(cpu_to_le64(b), addr);
-}
-#else
 static inline void
 _base_writeq(__u64 b, volatile void __iomem *addr, spinlock_t *writeq_lock)
 {
@@ -2985,11 +2979,9 @@ _base_writeq(__u64 b, volatile void __iomem *addr, 
spinlock_t *writeq_lock)
__u64 data_out = cpu_to_le64(b);
 
spin_lock_irqsave(writeq_lock, flags);
-   writel((u32)(data_out), addr);
-   writel((u32)(data_out >> 32), (addr + 4));
+   writeq(data_out, addr);
spin_unlock_irqrestore(writeq_lock, flags);
 }
-#endif
 
 /**
  * _base_put_smid_scsi_io - send SCSI_IO request to firmware
-- 
2.15.1



Re: [PATCH] mptfusion: use strlcpy() instead of strncpy()

2018-01-15 Thread Andy Shevchenko
On Fri, Jan 12, 2018 at 5:09 PM, Bart Van Assche <bart.vanass...@wdc.com> wrote:
> On Fri, 2018-01-12 at 15:45 +0200, Andy Shevchenko wrote:
>> On Fri, Jan 12, 2018 at 1:46 PM,  Wang <wangxiongfe...@huawei.com> wrote:

>> This one is false positive.


>> > +   strlcpy (karg.name, ioc->name, MPT_MAX_NAME);
>> > +   strlcpy (karg.product, ioc->prod_name, MPT_PRODUCT_LENGTH);
>>
>> These two as well.
>
> But using strlcpy() makes the code easier to read.

This is another story, not mentioned in the original commit message.

> Xiongfeng, if you want to continue with this patch, please change the third
> argument of all strlcpy() calls into a sizeof() expression. That make the
> code easier to verify.
>
>> > -   strncpy(karg.serial_number, " ", 24);
>> > +   strlcpy(karg.serial_number, " ", 24);
>>
>> This one is interesting indeed.
>> Though the fix would be rather something like
>>
>> memset(_number, " ", 24); // leave 24 for best performance of 
>> memset
>> karg.serial_number[24-1] = '\0';
>
> Does performance really matter in this context?

Nope, but still good to understand this aspect. On some architectures
unaligned access is expensive.

> How about the following instead:
>
> snprintf(karg.serial_number, sizeof(karg.serial_number), "%*s", 
> (int)(karg.serial_number) - 1, "");

...and you is talking about "easy to read"?!

So, my view on the patch is:
1) fix a real issue w/o touching everything around;
2) (optionally) move to strlcpy() with a correct selling point.

-- 
With Best Regards,
Andy Shevchenko


[PATCH v1] mptfusion: Use snprintf() instead of open coded divisions

2018-01-15 Thread Andy Shevchenko
Numbers up to 100 snprintf() prints without using a division.
Besides that the code looks more readable.

Signed-off-by: Andy Shevchenko <andriy.shevche...@linux.intel.com>
---
 drivers/message/fusion/mptctl.c | 25 +++--
 1 file changed, 7 insertions(+), 18 deletions(-)

diff --git a/drivers/message/fusion/mptctl.c b/drivers/message/fusion/mptctl.c
index 7b3b41368931..8d12017b9893 100644
--- a/drivers/message/fusion/mptctl.c
+++ b/drivers/message/fusion/mptctl.c
@@ -2481,24 +2481,13 @@ mptctl_hp_hostinfo(unsigned long arg, unsigned int 
data_size)
else
karg.host_no =  -1;
 
-   /* Reformat the fw_version into a string
-*/
-   karg.fw_version[0] = ioc->facts.FWVersion.Struct.Major >= 10 ?
-   ((ioc->facts.FWVersion.Struct.Major / 10) + '0') : '0';
-   karg.fw_version[1] = (ioc->facts.FWVersion.Struct.Major % 10 ) + '0';
-   karg.fw_version[2] = '.';
-   karg.fw_version[3] = ioc->facts.FWVersion.Struct.Minor >= 10 ?
-   ((ioc->facts.FWVersion.Struct.Minor / 10) + '0') : '0';
-   karg.fw_version[4] = (ioc->facts.FWVersion.Struct.Minor % 10 ) + '0';
-   karg.fw_version[5] = '.';
-   karg.fw_version[6] = ioc->facts.FWVersion.Struct.Unit >= 10 ?
-   ((ioc->facts.FWVersion.Struct.Unit / 10) + '0') : '0';
-   karg.fw_version[7] = (ioc->facts.FWVersion.Struct.Unit % 10 ) + '0';
-   karg.fw_version[8] = '.';
-   karg.fw_version[9] = ioc->facts.FWVersion.Struct.Dev >= 10 ?
-   ((ioc->facts.FWVersion.Struct.Dev / 10) + '0') : '0';
-   karg.fw_version[10] = (ioc->facts.FWVersion.Struct.Dev % 10 ) + '0';
-   karg.fw_version[11] = '\0';
+   /* Reformat the fw_version into a string */
+   snprintf(karg.fw_version, sizeof(karg.fw_version),
+"%.2hhu.%.2hhu.%.2hhu.%.2hhu",
+ioc->facts.FWVersion.Struct.Major,
+ioc->facts.FWVersion.Struct.Minor,
+ioc->facts.FWVersion.Struct.Unit,
+ioc->facts.FWVersion.Struct.Dev);
 
/* Issue a config request to get the device serial number
 */
-- 
2.15.1



Re: [PATCH] mptfusion: use strlcpy() instead of strncpy()

2018-01-12 Thread Andy Shevchenko
On Fri, Jan 12, 2018 at 1:46 PM, Xiongfeng Wang
<wangxiongfe...@huawei.com> wrote:
> From: Xiongfeng Wang <xiongfeng.w...@linaro.org>
>
> drivers/message/fusion/mptctl.c: In function '__mptctl_ioctl.isra.3':
> ./include/linux/string.h:245:9: warning: '__builtin_strncpy' specified
> bound 12 equals destination size [-Wstringop-truncation]
>
> The compiler requires that the destination size should be greater than
> the length we copy to make sure the dest string is nul-terminated. We
> can just use strlcpy() to avoid this warning.

Are you sure it's a best approach in this case?

> -   strncpy (karg->driverVersion, MPT_LINUX_PACKAGE_NAME, 
> MPT_IOCTL_VERSION_LENGTH);
> -   karg->driverVersion[MPT_IOCTL_VERSION_LENGTH-1]='\0';
> +   strlcpy (karg->driverVersion, MPT_LINUX_PACKAGE_NAME, 
> MPT_IOCTL_VERSION_LENGTH);

This one is false positive.

> -   strncpy (karg.name, ioc->name, MPT_MAX_NAME);
> -   karg.name[MPT_MAX_NAME-1]='\0';
> -   strncpy (karg.product, ioc->prod_name, MPT_PRODUCT_LENGTH);
> -   karg.product[MPT_PRODUCT_LENGTH-1]='\0';
> +   strlcpy (karg.name, ioc->name, MPT_MAX_NAME);
> +   strlcpy (karg.product, ioc->prod_name, MPT_PRODUCT_LENGTH);

These two as well.

> -   strncpy(karg.serial_number, " ", 24);
> +   strlcpy(karg.serial_number, " ", 24);

This one is interesting indeed.
Though the fix would be rather something like

memset(_number, " ", 24); // leave 24 for best performance of memset
karg.serial_number[24-1] = '\0';

> if (mpt_config(ioc, ) == 0) {
> ManufacturingPage0_t *pdata = 
> (ManufacturingPage0_t *) pbuf;

> if (strlen(pdata->BoardTracerNumber) 
> > 1) {
> -   strncpy(karg.serial_number,   
>   
> pdata->BoardTracerNumber, 24);
> -   karg.serial_number[24-1]='\0';
> +   strlcpy(karg.serial_number,
> +       
> pdata->BoardTracerNumber, 24);
> }

...and here you don't need to touch anything.

-- 
With Best Regards,
Andy Shevchenko


Re: [-next PATCH 2/4] treewide: Use DEVICE_ATTR_RW

2017-12-19 Thread Andy Shevchenko
On Tue, Dec 19, 2017 at 8:15 PM, Joe Perches <j...@perches.com> wrote:
> Convert DEVICE_ATTR uses to DEVICE_ATTR_RW where possible.
>
> Done with perl script:
>
> $ git grep -w --name-only DEVICE_ATTR | \
>   xargs perl -i -e 'local $/; while (<>) { 
> s/\bDEVICE_ATTR\s*\(\s*(\w+)\s*,\s*\(?(\s*S_IRUGO\s*\|\s*S_IWUSR|\s*S_IWUSR\s*\|\s*S_IRUGO\s*|\s*0644\s*)\)?\s*,\s*\1_show\s*,\s*\1_store\s*\)/DEVICE_ATTR_RW(\1)/g;
>  print;}'

>  drivers/platform/x86/compal-laptop.c | 18 +--

> --- a/drivers/platform/x86/compal-laptop.c
> +++ b/drivers/platform/x86/compal-laptop.c
> @@ -679,18 +679,12 @@ static int bat_writeable_property(struct power_supply 
> *psy,
>  /* == */
>  /* Driver Globals */
>  /* == */
> -static DEVICE_ATTR(wake_up_pme,
> -   0644, wake_up_pme_show, wake_up_pme_store);
> -static DEVICE_ATTR(wake_up_modem,
> -   0644, wake_up_modem_show,   wake_up_modem_store);
> -static DEVICE_ATTR(wake_up_lan,
> -   0644, wake_up_lan_show, wake_up_lan_store);
> -static DEVICE_ATTR(wake_up_wlan,
> -   0644, wake_up_wlan_show,wake_up_wlan_store);
> -static DEVICE_ATTR(wake_up_key,
> -   0644, wake_up_key_show, wake_up_key_store);
> -static DEVICE_ATTR(wake_up_mouse,
> -   0644, wake_up_mouse_show,   wake_up_mouse_store);
> +static DEVICE_ATTR_RW(wake_up_pme);
> +static DEVICE_ATTR_RW(wake_up_modem);
> +static DEVICE_ATTR_RW(wake_up_lan);
> +static DEVICE_ATTR_RW(wake_up_wlan);
> +static DEVICE_ATTR_RW(wake_up_key);
> +static DEVICE_ATTR_RW(wake_up_mouse);

Acked-by: Andy Shevchenko <andy.shevche...@gmail.com>

for PDx86 bits.

Have to say that while it doesn't change the attributes here, it might
require still to be revisited by security people, if they wish.

-- 
With Best Regards,
Andy Shevchenko


[PATCH v1] libsas: remove private hex2bin() implementation

2017-12-19 Thread Andy Shevchenko
The function sas_parse_addr() could be easily substituted by hex2bin() which is
in kernel library code.

Cc: Christoph Hellwig <h...@lst.de>
Signed-off-by: Andy Shevchenko <andriy.shevche...@linux.intel.com>
---
 drivers/scsi/libsas/sas_scsi_host.c | 20 
 1 file changed, 4 insertions(+), 16 deletions(-)

diff --git a/drivers/scsi/libsas/sas_scsi_host.c 
b/drivers/scsi/libsas/sas_scsi_host.c
index 58476b728c57..626727207889 100644
--- a/drivers/scsi/libsas/sas_scsi_host.c
+++ b/drivers/scsi/libsas/sas_scsi_host.c
@@ -27,6 +27,7 @@
 #include 
 #include 
 #include 
+#include 
 
 #include "sas_internal.h"
 
@@ -946,21 +947,6 @@ void sas_target_destroy(struct scsi_target *starget)
sas_put_device(found_dev);
 }
 
-static void sas_parse_addr(u8 *sas_addr, const char *p)
-{
-   int i;
-   for (i = 0; i < SAS_ADDR_SIZE; i++) {
-   u8 h, l;
-   if (!*p)
-   break;
-   h = isdigit(*p) ? *p-'0' : toupper(*p)-'A'+10;
-   p++;
-   l = isdigit(*p) ? *p-'0' : toupper(*p)-'A'+10;
-   p++;
-   sas_addr[i] = (h<<4) | l;
-   }
-}
-
 #define SAS_STRING_ADDR_SIZE   16
 
 int sas_request_addr(struct Scsi_Host *shost, u8 *addr)
@@ -977,7 +963,9 @@ int sas_request_addr(struct Scsi_Host *shost, u8 *addr)
goto out;
}
 
-   sas_parse_addr(addr, fw->data);
+   res = hex2bin(addr, fw->data, strnlen(fw->data, SAS_ADDR_SIZE * 2) / 2);
+   if (res)
+   goto out;
 
 out:
release_firmware(fw);
-- 
2.15.1



[PATCH v1] scsi: hpsa: Use vsnprintf extension %phN

2017-12-19 Thread Andy Shevchenko
Using this extension reduces the object size.

Signed-off-by: Andy Shevchenko <andriy.shevche...@linux.intel.com>
---
 drivers/scsi/hpsa.c | 14 +++---
 1 file changed, 3 insertions(+), 11 deletions(-)

diff --git a/drivers/scsi/hpsa.c b/drivers/scsi/hpsa.c
index b0aa5dc1d54c..4c018b653f18 100644
--- a/drivers/scsi/hpsa.c
+++ b/drivers/scsi/hpsa.c
@@ -4619,21 +4619,13 @@ static int hpsa_scatter_gather(struct ctlr_info *h,
return 0;
 }
 
-#define BUFLEN 128
 static inline void warn_zero_length_transfer(struct ctlr_info *h,
u8 *cdb, int cdb_len,
const char *func)
 {
-   char buf[BUFLEN];
-   int outlen;
-   int i;
-
-   outlen = scnprintf(buf, BUFLEN,
-   "%s: Blocking zero-length request: CDB:", func);
-   for (i = 0; i < cdb_len; i++)
-   outlen += scnprintf(buf+outlen, BUFLEN - outlen,
-   "%02hhx", cdb[i]);
-   dev_warn(>pdev->dev, "%s\n", buf);
+   dev_warn(>pdev->dev,
+"%s: Blocking zero-length request: CDB:%*phN\n",
+func, cdb_len, cdb);
 }
 
 #define IO_ACCEL_INELIGIBLE 1
-- 
2.15.1



Re: [trivial PATCH] treewide: Align function definition open/close braces

2017-12-18 Thread Andy Shevchenko
On Mon, Dec 18, 2017 at 2:28 AM, Joe Perches <j...@perches.com> wrote:
> Some functions definitions have either the initial open brace and/or
> the closing brace outside of column 1.
>
> Move those braces to column 1.
>
> This allows various function analyzers like gnu complexity to work
> properly for these modified functions.
>
> Miscellanea:
>
> o Remove extra trailing ; and blank line from xfs_agf_verify
>
> Signed-off-by: Joe Perches <j...@perches.com>

>  drivers/platform/x86/eeepc-laptop.c  |  2 +-

> diff --git a/drivers/platform/x86/eeepc-laptop.c 
> b/drivers/platform/x86/eeepc-laptop.c
> index 5a681962899c..4c38904a8a32 100644
> --- a/drivers/platform/x86/eeepc-laptop.c
> +++ b/drivers/platform/x86/eeepc-laptop.c
> @@ -492,7 +492,7 @@ static void eeepc_platform_exit(struct eeepc_laptop 
> *eeepc)
>   * potentially bad time, such as a timer interrupt.
>   */
>  static void tpd_led_update(struct work_struct *work)
> - {
> +{
> struct eeepc_laptop *eeepc;
>
> eeepc = container_of(work, struct eeepc_laptop, tpd_led_work);
> diff --git a/drivers/rtc/rtc-ab-b5ze-s3.c b/drivers/rtc/rtc-ab-b5ze-s3.c
> index a319bf1e49de..ef5c16dfabfa 100644

Acked-by: Andy Shevchenko <andy.shevche...@gmail.com>

for PDx86 changes.


-- 
With Best Regards,
Andy Shevchenko


Re: [PATCH 17/22] platform/x86: alienware-wmi: fix format string overflow warning

2017-07-14 Thread Andy Shevchenko
On Fri, Jul 14, 2017 at 10:37 PM, Arnd Bergmann <a...@arndb.de> wrote:
> On Fri, Jul 14, 2017 at 9:18 PM, Andy Shevchenko
> <andy.shevche...@gmail.com> wrote:
>> On Fri, Jul 14, 2017 at 3:07 PM, Arnd Bergmann <a...@arndb.de> wrote:
>>> gcc points out a possible format string overflow for a large value of 
>>> 'zone':

>> Here we need to convert
>>
>> int i;
>>
>> to
>>
>> u8 i;
>
> That was my first impulse, but then I decided not to change the
> idiomatic 'int i' for the index variable to 'u8' as that would be
> less idiomatic.
>
>> I will take it after addressing above.
>>
>> P.S. You may do this change across the file.
>
> How about changing it to 'u8 zone'?

I'm ultimately fine with that (just gentle reminder you might fix all
3 occurrences of it in that driver).

-- 
With Best Regards,
Andy Shevchenko


Re: [PATCH 17/22] platform/x86: alienware-wmi: fix format string overflow warning

2017-07-14 Thread Andy Shevchenko
On Fri, Jul 14, 2017 at 3:07 PM, Arnd Bergmann <a...@arndb.de> wrote:
> gcc points out a possible format string overflow for a large value of 'zone':
>
> drivers/platform/x86/alienware-wmi.c: In function 'alienware_wmi_init':
> drivers/platform/x86/alienware-wmi.c:461:24: error: '%02X' directive writing 
> between 2 and 8 bytes into a region of size 6 [-Werror=format-overflow=]
>sprintf(buffer, "zone%02X", i);
> ^~~~
> drivers/platform/x86/alienware-wmi.c:461:19: note: directive argument in the 
> range [0, 2147483646]
>sprintf(buffer, "zone%02X", i);
>^~
> drivers/platform/x86/alienware-wmi.c:461:3: note: 'sprintf' output between 7 
> and 13 bytes into a destination of size 10
>
> While the zone should never be that large, it's easy to make the
> buffer a few bytes longer so gcc can prove this to be safe.

Please, be a bit smarter on such fixes.

Here we need to convert

int i;

to

u8 i;

I will take it after addressing above.

P.S. You may do this change across the file.

> Signed-off-by: Arnd Bergmann <a...@arndb.de>
> ---
>  drivers/platform/x86/alienware-wmi.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/drivers/platform/x86/alienware-wmi.c 
> b/drivers/platform/x86/alienware-wmi.c
> index 0831b428c217..acc01242da82 100644
> --- a/drivers/platform/x86/alienware-wmi.c
> +++ b/drivers/platform/x86/alienware-wmi.c
> @@ -421,7 +421,7 @@ static DEVICE_ATTR(lighting_control_state, 0644, 
> show_control_state,
>  static int alienware_zone_init(struct platform_device *dev)
>  {
> int i;
> -   char buffer[10];
> +   char buffer[13];
> char *name;
>
> if (interface == WMAX) {
> --
> 2.9.0
>



-- 
With Best Regards,
Andy Shevchenko


Re: [PATCH 18/22] gpio: acpi: fix string overflow for large pin numbers

2017-07-14 Thread Andy Shevchenko
On Fri, 2017-07-14 at 14:07 +0200, Arnd Bergmann wrote:
> gcc-7 notices that the pin_table is an array of 16-bit numbers,
> but we assume it can be printed as a two-character hexadecimal
> string:
> 
> drivers/gpio/gpiolib-acpi.c: In function
> 'acpi_gpiochip_request_interrupt':
> drivers/gpio/gpiolib-acpi.c:206:24: warning: '%02X' directive writing
> between 2 and 4 bytes into a region of size 3 [-Wformat-overflow=]
>    sprintf(ev_name, "_%c%02X",
> ^~~~
> drivers/gpio/gpiolib-acpi.c:206:20: note: directive argument in the
> range [0, 65535]
>    sprintf(ev_name, "_%c%02X",
> ^
> drivers/gpio/gpiolib-acpi.c:206:3: note: 'sprintf' output between 5
> and 7 bytes into a destination of size 5
>    sprintf(ev_name, "_%c%02X",
>    ^~~
> agpio->triggering == ACPI_EDGE_SENSITIVE ? 'E' : 'L',
> ~
> pin);
> 


This is obviously a false positive warning.

Here we have
int pin = u16 pin_table[0] <= 255 (implying >= 0).

I see few options how to make it more clear
1) your proposal;
2) use "%02hhX" instead;
3) use if (ret >= 0 && ret <= 255) condition.

I would choose one of the 2-3.

In case gcc will complain about 3), file a bug to gcc crazy warning.

> 
> This can't be right, so this changes it to truncate the number to
> an 8-bit pin number.
> 
> Fixes: 0d1c28a449c6 ("gpiolib-acpi: Add ACPI5 event model support to
> gpio.")
> Signed-off-by: Arnd Bergmann <a...@arndb.de>
> ---
>  drivers/gpio/gpiolib-acpi.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/drivers/gpio/gpiolib-acpi.c b/drivers/gpio/gpiolib-acpi.c
> index c9b42dd12dfa..c3faea724af8 100644
> --- a/drivers/gpio/gpiolib-acpi.c
> +++ b/drivers/gpio/gpiolib-acpi.c
> @@ -205,7 +205,7 @@ static acpi_status
> acpi_gpiochip_request_interrupt(struct acpi_resource *ares,
>   char ev_name[5];
>   sprintf(ev_name, "_%c%02X",
>   agpio->triggering == ACPI_EDGE_SENSITIVE ?
> 'E' : 'L',
> -     pin);
> + (u8)pin);
>   if (ACPI_SUCCESS(acpi_get_handle(handle, ev_name,
> _handle)))
>   handler = acpi_gpio_irq_handler;
>   }

-- 
Andy Shevchenko <andriy.shevche...@linux.intel.com>
Intel Finland Oy


[PATCH v3 5/6] scsi: replace custom approach to hexdump small buffers

2016-10-22 Thread Andy Shevchenko
In kernel we have defined specifier (%*ph[C]) to dump small buffers in a hex
format. Replace custom approach by a generic one.

Cc: Jon Mason <jonma...@broadcom.com>
Signed-off-by: Andy Shevchenko <andriy.shevche...@linux.intel.com>
---
 drivers/scsi/scsi_transport_srp.c | 11 +--
 drivers/scsi/sd.c |  4 +---
 2 files changed, 2 insertions(+), 13 deletions(-)

diff --git a/drivers/scsi/scsi_transport_srp.c 
b/drivers/scsi/scsi_transport_srp.c
index e3cd3ec..02cfc6b 100644
--- a/drivers/scsi/scsi_transport_srp.c
+++ b/drivers/scsi/scsi_transport_srp.c
@@ -115,21 +115,12 @@ static DECLARE_TRANSPORT_CLASS(srp_host_class, 
"srp_host", srp_host_setup,
 static DECLARE_TRANSPORT_CLASS(srp_rport_class, "srp_remote_ports",
   NULL, NULL, NULL);
 
-#define SRP_PID(p) \
-   (p)->port_id[0], (p)->port_id[1], (p)->port_id[2], (p)->port_id[3], \
-   (p)->port_id[4], (p)->port_id[5], (p)->port_id[6], (p)->port_id[7], \
-   (p)->port_id[8], (p)->port_id[9], (p)->port_id[10], (p)->port_id[11], \
-   (p)->port_id[12], (p)->port_id[13], (p)->port_id[14], (p)->port_id[15]
-
-#define SRP_PID_FMT "%02x:%02x:%02x:%02x:%02x:%02x:%02x:%02x:" \
-   "%02x:%02x:%02x:%02x:%02x:%02x:%02x:%02x"
-
 static ssize_t
 show_srp_rport_id(struct device *dev, struct device_attribute *attr,
  char *buf)
 {
struct srp_rport *rport = transport_class_to_srp_rport(dev);
-   return sprintf(buf, SRP_PID_FMT "\n", SRP_PID(rport));
+   return sprintf(buf, "%16phC\n", rport->port_id);
 }
 
 static DEVICE_ATTR(port_id, S_IRUGO, show_srp_rport_id, NULL);
diff --git a/drivers/scsi/sd.c b/drivers/scsi/sd.c
index b9618ff..5634b54 100644
--- a/drivers/scsi/sd.c
+++ b/drivers/scsi/sd.c
@@ -2472,9 +2472,7 @@ sd_read_write_protect_flag(struct scsi_disk *sdkp, 
unsigned char *buffer)
if (sdkp->first_scan || old_wp != sdkp->write_prot) {
sd_printk(KERN_NOTICE, sdkp, "Write Protect is %s\n",
  sdkp->write_prot ? "on" : "off");
-   sd_printk(KERN_DEBUG, sdkp,
- "Mode Sense: %02x %02x %02x %02x\n",
- buffer[0], buffer[1], buffer[2], buffer[3]);
+   sd_printk(KERN_DEBUG, sdkp, "Mode Sense: %4ph\n", 
buffer);
}
}
 }
-- 
2.9.3

--
To unsubscribe from this list: send the line "unsubscribe linux-scsi" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH v3 4/6] [SCSI] ips: don't use custom hex_asc_upper[] table

2016-10-22 Thread Andy Shevchenko
From: Andy Shevchenko <andy.shevche...@gmail.com>

We have table of the HEX characters in the kernel. Replace custom by a generic
one.

Cc: Adaptec OEM Raid Solutions <aacr...@adaptec.com>
Signed-off-by: Andy Shevchenko <andy.shevche...@gmail.com>
---
 drivers/scsi/ips.c | 13 +
 1 file changed, 5 insertions(+), 8 deletions(-)

diff --git a/drivers/scsi/ips.c b/drivers/scsi/ips.c
index 02cb76f..3419e1b 100644
--- a/drivers/scsi/ips.c
+++ b/drivers/scsi/ips.c
@@ -2241,9 +2241,6 @@ ips_get_bios_version(ips_ha_t * ha, int intr)
uint8_t minor;
uint8_t subminor;
uint8_t *buffer;
-   char hexDigits[] =
-   { '0', '1', '2', '3', '4', '5', '6', '7', '8', '9', 'A', 'B', 'C',
- 'D', 'E', 'F' };
 
METHOD_TRACE("ips_get_bios_version", 1);
 
@@ -2374,13 +2371,13 @@ ips_get_bios_version(ips_ha_t * ha, int intr)
}
}
 
-   ha->bios_version[0] = hexDigits[(major & 0xF0) >> 4];
+   ha->bios_version[0] = hex_asc_upper_hi(major);
ha->bios_version[1] = '.';
-   ha->bios_version[2] = hexDigits[major & 0x0F];
-   ha->bios_version[3] = hexDigits[subminor];
+   ha->bios_version[2] = hex_asc_upper_lo(major);
+   ha->bios_version[3] = hex_asc_upper_lo(subminor);
ha->bios_version[4] = '.';
-   ha->bios_version[5] = hexDigits[(minor & 0xF0) >> 4];
-   ha->bios_version[6] = hexDigits[minor & 0x0F];
+   ha->bios_version[5] = hex_asc_upper_hi(minor);
+   ha->bios_version[6] = hex_asc_upper_lo(minor);
ha->bios_version[7] = 0;
 }
 
-- 
2.9.3

--
To unsubscribe from this list: send the line "unsubscribe linux-scsi" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH v3 6/6] cciss: replace custom function to hexdump

2016-10-22 Thread Andy Shevchenko
For small buffers we may use %*ph[N] specifier, for the bigger blocks
print_hex_dump() call.

Cc: Don Brace <don.br...@microsemi.com>
Cc: esc.storage...@microsemi.com
Signed-off-by: Andy Shevchenko <andriy.shevche...@linux.intel.com>
---
 drivers/block/cciss_scsi.c | 72 +++---
 1 file changed, 10 insertions(+), 62 deletions(-)

diff --git a/drivers/block/cciss_scsi.c b/drivers/block/cciss_scsi.c
index 1537302..a18de9d 100644
--- a/drivers/block/cciss_scsi.c
+++ b/drivers/block/cciss_scsi.c
@@ -260,43 +260,6 @@ scsi_cmd_stack_free(ctlr_info_t *h)
 }
 
 #if 0
-static int xmargin=8;
-static int amargin=60;
-
-static void
-print_bytes (unsigned char *c, int len, int hex, int ascii)
-{
-
-   int i;
-   unsigned char *x;
-
-   if (hex)
-   {
-   x = c;
-   for (i=0;i<len;i++)
-   {
-   if ((i % xmargin) == 0 && i>0) printk("\n");
-   if ((i % xmargin) == 0) printk("0x%04x:", i);
-   printk(" %02x", *x);
-   x++;
-   }
-   printk("\n");
-   }
-   if (ascii)
-   {
-   x = c;
-   for (i=0;i<len;i++)
-   {
-   if ((i % amargin) == 0 && i>0) printk("\n");
-   if ((i % amargin) == 0) printk("0x%04x:", i);
-   if (*x > 26 && *x < 128) printk("%c", *x);
-   else printk(".");
-   x++;
-   }
-   printk("\n");
-   }
-}
-
 static void
 print_cmd(CommandList_struct *cp)
 {
@@ -305,30 +268,13 @@ print_cmd(CommandList_struct *cp)
printk("sgtot:%d\n", cp->Header.SGTotal);
printk("Tag:0x%08x/0x%08x\n", cp->Header.Tag.upper, 
cp->Header.Tag.lower);
-   printk("LUN:0x%02x%02x%02x%02x%02x%02x%02x%02x\n",
-   cp->Header.LUN.LunAddrBytes[0],
-   cp->Header.LUN.LunAddrBytes[1],
-   cp->Header.LUN.LunAddrBytes[2],
-   cp->Header.LUN.LunAddrBytes[3],
-   cp->Header.LUN.LunAddrBytes[4],
-   cp->Header.LUN.LunAddrBytes[5],
-   cp->Header.LUN.LunAddrBytes[6],
-   cp->Header.LUN.LunAddrBytes[7]);
+   printk("LUN:0x%8phN\n", cp->Header.LUN.LunAddrBytes);
printk("CDBLen:%d\n", cp->Request.CDBLen);
printk("Type:%d\n",cp->Request.Type.Type);
printk("Attr:%d\n",cp->Request.Type.Attribute);
printk(" Dir:%d\n",cp->Request.Type.Direction);
printk("Timeout:%d\n",cp->Request.Timeout);
-   printk( "CDB: %02x %02x %02x %02x %02x %02x %02x %02x"
-   " %02x %02x %02x %02x %02x %02x %02x %02x\n",
-   cp->Request.CDB[0], cp->Request.CDB[1],
-   cp->Request.CDB[2], cp->Request.CDB[3],
-   cp->Request.CDB[4], cp->Request.CDB[5],
-   cp->Request.CDB[6], cp->Request.CDB[7],
-   cp->Request.CDB[8], cp->Request.CDB[9],
-   cp->Request.CDB[10], cp->Request.CDB[11],
-   cp->Request.CDB[12], cp->Request.CDB[13],
-   cp->Request.CDB[14], cp->Request.CDB[15]),
+   printk("CDB: %16ph\n", cp->Request.CDB);
printk("edesc.Addr: 0x%08x/0%08x, Len  = %d\n", 
cp->ErrDesc.Addr.upper, cp->ErrDesc.Addr.lower, 
cp->ErrDesc.Len);
@@ -340,9 +286,7 @@ print_cmd(CommandList_struct *cp)
printk("offense size:%d\n", 
cp->err_info->MoreErrInfo.Invalid_Cmd.offense_size);
printk("offense byte:%d\n", 
cp->err_info->MoreErrInfo.Invalid_Cmd.offense_num);
printk("offense value:%d\n", 
cp->err_info->MoreErrInfo.Invalid_Cmd.offense_value);
-   
 }
-
 #endif
 
 static int 
@@ -782,8 +726,10 @@ static void complete_scsi_command(CommandList_struct *c, 
int timeout,
"reported\n", c);
break;
case CMD_INVALID: {
-   /* print_bytes(c, sizeof(*c), 1, 0);
-   print_cmd(c); */
+   /*
+   print_hex_dump(KERN_INFO, "", 
DUMP_PREFIX_OFFSET, 16, 1, c, sizeof(*c), false);
+   print_cmd(c);
+*/
  /* We get CMD_INVALID if you address a non-existent tape drive instead
of a selection timeout (no response).  You will see this if you yank 
out a

[PATCH v3 3/6] scsi: qla4xxx: print MAC and SID via %p[mM][R]

2016-10-22 Thread Andy Shevchenko
From: Oleksandr Khoshaba <oleksandr.khosh...@gmail.com>

In the kernel we have nice specifier to print MAC by given pointer to the
address in a binary form.

Signed-off-by: Oleksandr Khoshaba <oleksandr.khosh...@gmail.com>
Acked-by: Vikas Chaudhary <vikas.chaudh...@qlogic.com>
Cc: qlogic-storage-upstr...@qlogic.com
Signed-off-by: Andy Shevchenko <andriy.shevche...@linux.intel.com>
---
 drivers/scsi/qla4xxx/ql4_mbx.c |  5 +
 drivers/scsi/qla4xxx/ql4_nx.c  |  8 ++--
 drivers/scsi/qla4xxx/ql4_os.c  | 15 ---
 3 files changed, 7 insertions(+), 21 deletions(-)

diff --git a/drivers/scsi/qla4xxx/ql4_mbx.c b/drivers/scsi/qla4xxx/ql4_mbx.c
index c291fdf..1da04f3 100644
--- a/drivers/scsi/qla4xxx/ql4_mbx.c
+++ b/drivers/scsi/qla4xxx/ql4_mbx.c
@@ -2032,10 +2032,7 @@ int qla4xxx_set_param_ddbentry(struct scsi_qla_host *ha,
ptid = (uint16_t *)_ddb_entry->isid[1];
*ptid = cpu_to_le16((uint16_t)ddb_entry->sess->target_id);
 
-   DEBUG2(ql4_printk(KERN_INFO, ha, "ISID [%02x%02x%02x%02x%02x%02x]\n",
- fw_ddb_entry->isid[5], fw_ddb_entry->isid[4],
- fw_ddb_entry->isid[3], fw_ddb_entry->isid[2],
- fw_ddb_entry->isid[1], fw_ddb_entry->isid[0]));
+   DEBUG2(ql4_printk(KERN_INFO, ha, "ISID [%pmR]\n", fw_ddb_entry->isid));
 
iscsi_opts = le16_to_cpu(fw_ddb_entry->iscsi_options);
memset(fw_ddb_entry->iscsi_alias, 0, sizeof(fw_ddb_entry->iscsi_alias));
diff --git a/drivers/scsi/qla4xxx/ql4_nx.c b/drivers/scsi/qla4xxx/ql4_nx.c
index 06ddd13..bccd8b6 100644
--- a/drivers/scsi/qla4xxx/ql4_nx.c
+++ b/drivers/scsi/qla4xxx/ql4_nx.c
@@ -4094,12 +4094,8 @@ int qla4_8xxx_get_sys_info(struct scsi_qla_host *ha)
ha->phy_port_num = sys_info->port_num;
ha->iscsi_pci_func_cnt = sys_info->iscsi_pci_func_cnt;
 
-   DEBUG2(printk("scsi%ld: %s: "
-   "mac %02x:%02x:%02x:%02x:%02x:%02x "
-   "serial %s\n", ha->host_no, __func__,
-   ha->my_mac[0], ha->my_mac[1], ha->my_mac[2],
-   ha->my_mac[3], ha->my_mac[4], ha->my_mac[5],
-   ha->serial_number));
+   DEBUG2(printk("scsi%ld: %s: mac %pM serial %s\n",
+   ha->host_no, __func__, ha->my_mac, ha->serial_number));
 
status = QLA_SUCCESS;
 
diff --git a/drivers/scsi/qla4xxx/ql4_os.c b/drivers/scsi/qla4xxx/ql4_os.c
index 01c3610..9fbb33f 100644
--- a/drivers/scsi/qla4xxx/ql4_os.c
+++ b/drivers/scsi/qla4xxx/ql4_os.c
@@ -6304,13 +6304,9 @@ static int qla4xxx_compare_tuple_ddb(struct 
scsi_qla_host *ha,
 * ISID would not match firmware generated ISID.
 */
if (is_isid_compare) {
-   DEBUG2(ql4_printk(KERN_INFO, ha, "%s: old ISID [%02x%02x%02x"
-   "%02x%02x%02x] New ISID [%02x%02x%02x%02x%02x%02x]\n",
-   __func__, old_tddb->isid[5], old_tddb->isid[4],
-   old_tddb->isid[3], old_tddb->isid[2], old_tddb->isid[1],
-   old_tddb->isid[0], new_tddb->isid[5], new_tddb->isid[4],
-   new_tddb->isid[3], new_tddb->isid[2], new_tddb->isid[1],
-   new_tddb->isid[0]));
+   DEBUG2(ql4_printk(KERN_INFO, ha,
+   "%s: old ISID [%pmR] New ISID [%pmR]\n",
+   __func__, old_tddb->isid, new_tddb->isid));
 
if (memcmp(_tddb->isid[0], _tddb->isid[0],
   sizeof(old_tddb->isid)))
@@ -7925,10 +7921,7 @@ qla4xxx_sysfs_ddb_get_param(struct 
iscsi_bus_flash_session *fnode_sess,
rc = sprintf(buf, "%u\n", fnode_conn->keepalive_timeout);
break;
case ISCSI_FLASHNODE_ISID:
-   rc = sprintf(buf, "%02x%02x%02x%02x%02x%02x\n",
-fnode_sess->isid[0], fnode_sess->isid[1],
-fnode_sess->isid[2], fnode_sess->isid[3],
-fnode_sess->isid[4], fnode_sess->isid[5]);
+   rc = sprintf(buf, "%pm\n", fnode_sess->isid);
break;
case ISCSI_FLASHNODE_TSID:
rc = sprintf(buf, "%u\n", fnode_sess->tsid);
-- 
2.9.3

--
To unsubscribe from this list: send the line "unsubscribe linux-scsi" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH v3 0/6] scsi: collection of clean ups

2016-10-22 Thread Andy Shevchenko
Just collection of clean ups against SCSI drivers. Some of them were Acked
quite long ago, but didn't make upstream yet.

Andy Shevchenko (5):
  scsi: fnic: use kernel's '%pM' format option to print MAC
  fusion: print lan address via %pMR
  [SCSI] ips: don't use custom hex_asc_upper[] table
  scsi: replace custom approach to hexdump small buffers
  cciss: replace custom function to hexdump

Oleksandr Khoshaba (1):
  scsi: qla4xxx: print MAC and SID via %p[mM][R]

 drivers/block/cciss_scsi.c| 72 ++-
 drivers/message/fusion/mptbase.c  | 14 +++-
 drivers/scsi/fnic/vnic_dev.c  | 10 ++
 drivers/scsi/ips.c| 13 +++
 drivers/scsi/qla4xxx/ql4_mbx.c|  5 +--
 drivers/scsi/qla4xxx/ql4_nx.c |  8 ++---
 drivers/scsi/qla4xxx/ql4_os.c | 15 +++-
 drivers/scsi/scsi_transport_srp.c | 11 +-
 drivers/scsi/sd.c |  4 +--
 9 files changed, 30 insertions(+), 122 deletions(-)

-- 
2.9.3

--
To unsubscribe from this list: send the line "unsubscribe linux-scsi" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH v3 1/6] scsi: fnic: use kernel's '%pM' format option to print MAC

2016-10-22 Thread Andy Shevchenko
Instead of supplying each byte through stack let's use %pM specifier.

Cc: Hiral Patel <hiral...@cisco.com>
Cc: Suma Ramars <sram...@cisco.com>
Acked-by: Tom Tucker <t...@opengridcomputing.com>
Signed-off-by: Andy Shevchenko <andriy.shevche...@linux.intel.com>
---
 drivers/scsi/fnic/vnic_dev.c | 10 ++
 1 file changed, 2 insertions(+), 8 deletions(-)

diff --git a/drivers/scsi/fnic/vnic_dev.c b/drivers/scsi/fnic/vnic_dev.c
index 9795d6f..ba69d61 100644
--- a/drivers/scsi/fnic/vnic_dev.c
+++ b/drivers/scsi/fnic/vnic_dev.c
@@ -499,10 +499,7 @@ void vnic_dev_add_addr(struct vnic_dev *vdev, u8 *addr)
 
err = vnic_dev_cmd(vdev, CMD_ADDR_ADD, , , wait);
if (err)
-   printk(KERN_ERR
-   "Can't add addr [%02x:%02x:%02x:%02x:%02x:%02x], %d\n",
-   addr[0], addr[1], addr[2], addr[3], addr[4], addr[5],
-   err);
+   pr_err("Can't add addr [%pM], %d\n", addr, err);
 }
 
 void vnic_dev_del_addr(struct vnic_dev *vdev, u8 *addr)
@@ -517,10 +514,7 @@ void vnic_dev_del_addr(struct vnic_dev *vdev, u8 *addr)
 
err = vnic_dev_cmd(vdev, CMD_ADDR_DEL, , , wait);
if (err)
-   printk(KERN_ERR
-   "Can't del addr [%02x:%02x:%02x:%02x:%02x:%02x], %d\n",
-   addr[0], addr[1], addr[2], addr[3], addr[4], addr[5],
-   err);
+   pr_err("Can't del addr [%pM], %d\n", addr, err);
 }
 
 int vnic_dev_notify_set(struct vnic_dev *vdev, u16 intr)
-- 
2.9.3

--
To unsubscribe from this list: send the line "unsubscribe linux-scsi" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH v3 2/6] fusion: print lan address via %pMR

2016-10-22 Thread Andy Shevchenko
LAN MAC addresses can be printed directly using %pMR specifier.

Cc: Sathya Prakash <sathya.prak...@broadcom.com>
Cc: Chaitra P B <chaitra.basa...@broadcom.com>
Cc: Suganath Prabu Subramani <suganath-prabu.subram...@broadcom.com>
Signed-off-by: Andy Shevchenko <andriy.shevche...@linux.intel.com>
---
 drivers/message/fusion/mptbase.c | 14 --
 1 file changed, 4 insertions(+), 10 deletions(-)

diff --git a/drivers/message/fusion/mptbase.c b/drivers/message/fusion/mptbase.c
index 89c7ed1..f82745c 100644
--- a/drivers/message/fusion/mptbase.c
+++ b/drivers/message/fusion/mptbase.c
@@ -2585,10 +2585,7 @@ mpt_do_ioc_recovery(MPT_ADAPTER *ioc, u32 reason, int 
sleepFlag)
(void) GetLanConfigPages(ioc);
a = 
(u8*)>lan_cnfg_page1.HardwareAddressLow;
dprintk(ioc, printk(MYIOC_s_DEBUG_FMT
-   "LanAddr = %02X:%02X:%02X"
-   ":%02X:%02X:%02X\n",
-   ioc->name, a[5], a[4],
-   a[3], a[2], a[1], a[0]));
+   "LanAddr = %pMR\n", ioc->name, a));
}
break;
 
@@ -6783,8 +6780,7 @@ static int mpt_iocinfo_proc_show(struct seq_file *m, void 
*v)
if (ioc->bus_type == FC) {
if (ioc->pfacts[p].ProtocolFlags & 
MPI_PORTFACTS_PROTOCOL_LAN) {
u8 *a = 
(u8*)>lan_cnfg_page1.HardwareAddressLow;
-   seq_printf(m, "LanAddr = 
%02X:%02X:%02X:%02X:%02X:%02X\n",
-   a[5], a[4], a[3], a[2], a[1], 
a[0]);
+   seq_printf(m, "LanAddr = %pMR\n", a);
}
seq_printf(m, "WWN = %08X%08X:%08X%08X\n",
ioc->fc_port_page0[p].WWNN.High,
@@ -6861,8 +6857,7 @@ mpt_print_ioc_summary(MPT_ADAPTER *ioc, char *buffer, int 
*size, int len, int sh
 
if (showlan && (ioc->pfacts[0].ProtocolFlags & 
MPI_PORTFACTS_PROTOCOL_LAN)) {
u8 *a = (u8*)>lan_cnfg_page1.HardwareAddressLow;
-   y += sprintf(buffer+len+y, ", 
LanAddr=%02X:%02X:%02X:%02X:%02X:%02X",
-   a[5], a[4], a[3], a[2], a[1], a[0]);
+   y += sprintf(buffer+len+y, ", LanAddr=%pMR", a);
}
 
y += sprintf(buffer+len+y, ", IRQ=%d", ioc->pci_irq);
@@ -6896,8 +6891,7 @@ static void seq_mpt_print_ioc_summary(MPT_ADAPTER *ioc, 
struct seq_file *m, int
 
if (showlan && (ioc->pfacts[0].ProtocolFlags & 
MPI_PORTFACTS_PROTOCOL_LAN)) {
u8 *a = (u8*)>lan_cnfg_page1.HardwareAddressLow;
-   seq_printf(m, ", LanAddr=%02X:%02X:%02X:%02X:%02X:%02X",
-   a[5], a[4], a[3], a[2], a[1], a[0]);
+   seq_printf(m, ", LanAddr=%pMR", a);
}
 
seq_printf(m, ", IRQ=%d", ioc->pci_irq);
-- 
2.9.3

--
To unsubscribe from this list: send the line "unsubscribe linux-scsi" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH v1 0/4] scsi: some (very) old clean ups

2016-06-20 Thread Andy Shevchenko
On Fri, 2016-05-06 at 19:23 +0300, Andy Shevchenko wrote:
> This is a set of independent clean ups that didn't land upstream for
> ages (some
> are dated 2010!).  As agreed with Martin at some point I resend
> them.
> 
> I have more, but the rest is not yet ready for submission.

Gentle ping to get know what is the destiny of my patches.

> 
> Andy Shevchenko (3):
>   libsas: remove private hex2bin() implementation
>   scsi: fnic: use kernel's '%pM' format option to print MAC
>   fusion: print lan address via %pMR
> 
> Oleksandr Khoshaba (1):
>   scsi: qla4xxx: print MAC and SID via %p[mM][R]
> 
>  drivers/message/fusion/mptbase.c| 14 --
>  drivers/scsi/fnic/vnic_dev.c| 10 ++
>  drivers/scsi/libsas/sas_scsi_host.c | 22 ++
>  drivers/scsi/qla4xxx/ql4_mbx.c  |  5 +
>  drivers/scsi/qla4xxx/ql4_nx.c   |  8 ++--
>  drivers/scsi/qla4xxx/ql4_os.c   | 15 ---
>  6 files changed, 19 insertions(+), 55 deletions(-)
> 

-- 

Andy Shevchenko <andriy.shevche...@linux.intel.com>
Intel Finland Oy
--
To unsubscribe from this list: send the line "unsubscribe linux-scsi" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH v3 5/6] scsi_debug: uuid for lu name

2016-05-31 Thread Andy Shevchenko
On Fri, May 6, 2016 at 7:40 AM, Douglas Gilbert <dgilb...@interlog.com> wrote:
> Permit changing of a LU name from a (fake) IEEE registered NAA (5)
> to a locally assigned UUID. Using a UUID (RFC 4122) for a SCSI
> designation descriptor (e.g. a LU name) was added in spc5r08.pdf
> (a draft INCITS standard) on 25 January 2016. Add parameter
> uuid_ctl to use a separate UUID for each LU (storage device) name.
> Additional option for all LU names to have the same UUID (since
> their storage is shared). Previous action of using NAA identifier
> for LU name remains the default.

> @@ -3503,6 +3520,9 @@ static void sdebug_q_cmd_wq_complete(struct work_struct 
> *work)
> sdebug_q_cmd_complete(sd_dp);
>  }
>
> +static bool got_shared_uuid;
> +static uuid_be shared_uuid;

So, the assignment to them is non-atomic, is it a problem here?

> @@ -3510,6 +3530,17 @@ static struct sdebug_dev_info *sdebug_device_create(
>
> devip = kzalloc(sizeof(*devip), flags);
> if (devip) {
> +   if (sdebug_uuid_ctl == 1)
> +   uuid_be_gen(>lu_name);
> +   else if (sdebug_uuid_ctl == 2) {
> +   if (got_shared_uuid)
> +   devip->lu_name = shared_uuid;
> +   else {
> +   uuid_be_gen(_uuid);
> +   got_shared_uuid = true;
> +   devip->lu_name = shared_uuid;
> +   }
> +   }

Perhaps
   if (got_shared_uuid == false)
   uuid_be_gen(_uuid);
   got_shared_uuid = true;
   }
   devip->lu_name = shared_uuid;

> devip->sdbg_host = sdbg_host;
> list_add_tail(>dev_list, _host->dev_info_list);
> }

> @@ -4150,6 +4182,8 @@ MODULE_PARM_DESC(unmap_alignment, "lowest aligned thin 
> provisioning lba (def=0)"
>  MODULE_PARM_DESC(unmap_granularity, "thin provisioning granularity in blocks 
> (def=1)");
>  MODULE_PARM_DESC(unmap_max_blocks, "max # of blocks can be unmapped in one 
> cmd (def=0x)");
>  MODULE_PARM_DESC(unmap_max_desc, "max # of ranges that can be unmapped in 
> one cmd (def=256)");
> +MODULE_PARM_DESC(uuid_ctl,
> +"1->use uuid for lu name, 0->don't, 2->all use same 
> (def=0)");

Why not on one line?

>  MODULE_PARM_DESC(virtual_gb, "virtual gigabyte (GiB) size (def=0 -> use 
> dev_size_mb)");
>  MODULE_PARM_DESC(vpd_use_hostno, "0 -> dev ids ignore hostno (def=1 -> 
> unique dev ids)");
>  MODULE_PARM_DESC(write_same_length, "Maximum blocks per WRITE SAME cmd 
> (def=0x)");
> @@ -4787,6 +4821,12 @@ static ssize_t strict_store(struct device_driver *ddp, 
> const char *buf,
>  }
>  static DRIVER_ATTR_RW(strict);
>
> +static ssize_t uuid_ctl_show(struct device_driver *ddp, char *buf)
> +{
> +   return scnprintf(buf, PAGE_SIZE, "%d\n", !!sdebug_uuid_ctl);

It will never show the difference between 1 and 2. Was it on purpose?

> +}
> +static DRIVER_ATTR_RO(uuid_ctl);

-- 
With Best Regards,
Andy Shevchenko
--
To unsubscribe from this list: send the line "unsubscribe linux-scsi" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH v1 1/1] cciss: replace custom function to hexdump

2016-05-06 Thread Andy Shevchenko
For small buffers we may use %*ph[N] specifier, for the bigger blocks
print_hex_dump() call.

Cc: Christoph Hellwig <h...@lst.de>
Signed-off-by: Andy Shevchenko <andriy.shevche...@linux.intel.com>
---
 drivers/block/cciss_scsi.c | 72 +++---
 1 file changed, 10 insertions(+), 62 deletions(-)

diff --git a/drivers/block/cciss_scsi.c b/drivers/block/cciss_scsi.c
index 1537302..8988131 100644
--- a/drivers/block/cciss_scsi.c
+++ b/drivers/block/cciss_scsi.c
@@ -260,43 +260,6 @@ scsi_cmd_stack_free(ctlr_info_t *h)
 }
 
 #if 0
-static int xmargin=8;
-static int amargin=60;
-
-static void
-print_bytes (unsigned char *c, int len, int hex, int ascii)
-{
-
-   int i;
-   unsigned char *x;
-
-   if (hex)
-   {
-   x = c;
-   for (i=0;i<len;i++)
-   {
-   if ((i % xmargin) == 0 && i>0) printk("\n");
-   if ((i % xmargin) == 0) printk("0x%04x:", i);
-   printk(" %02x", *x);
-   x++;
-   }
-   printk("\n");
-   }
-   if (ascii)
-   {
-   x = c;
-   for (i=0;i<len;i++)
-   {
-   if ((i % amargin) == 0 && i>0) printk("\n");
-   if ((i % amargin) == 0) printk("0x%04x:", i);
-   if (*x > 26 && *x < 128) printk("%c", *x);
-   else printk(".");
-   x++;
-   }
-   printk("\n");
-   }
-}
-
 static void
 print_cmd(CommandList_struct *cp)
 {
@@ -305,30 +268,13 @@ print_cmd(CommandList_struct *cp)
printk("sgtot:%d\n", cp->Header.SGTotal);
printk("Tag:0x%08x/0x%08x\n", cp->Header.Tag.upper, 
cp->Header.Tag.lower);
-   printk("LUN:0x%02x%02x%02x%02x%02x%02x%02x%02x\n",
-   cp->Header.LUN.LunAddrBytes[0],
-   cp->Header.LUN.LunAddrBytes[1],
-   cp->Header.LUN.LunAddrBytes[2],
-   cp->Header.LUN.LunAddrBytes[3],
-   cp->Header.LUN.LunAddrBytes[4],
-   cp->Header.LUN.LunAddrBytes[5],
-   cp->Header.LUN.LunAddrBytes[6],
-   cp->Header.LUN.LunAddrBytes[7]);
+   printk("LUN:0x%8phN\n", cp->Header.LUN.LunAddrBytes);
printk("CDBLen:%d\n", cp->Request.CDBLen);
printk("Type:%d\n",cp->Request.Type.Type);
printk("Attr:%d\n",cp->Request.Type.Attribute);
printk(" Dir:%d\n",cp->Request.Type.Direction);
printk("Timeout:%d\n",cp->Request.Timeout);
-   printk( "CDB: %02x %02x %02x %02x %02x %02x %02x %02x"
-   " %02x %02x %02x %02x %02x %02x %02x %02x\n",
-   cp->Request.CDB[0], cp->Request.CDB[1],
-   cp->Request.CDB[2], cp->Request.CDB[3],
-   cp->Request.CDB[4], cp->Request.CDB[5],
-   cp->Request.CDB[6], cp->Request.CDB[7],
-   cp->Request.CDB[8], cp->Request.CDB[9],
-   cp->Request.CDB[10], cp->Request.CDB[11],
-   cp->Request.CDB[12], cp->Request.CDB[13],
-   cp->Request.CDB[14], cp->Request.CDB[15]),
+   printk( "CDB: %16ph\n", cp->Request.CDB);
printk("edesc.Addr: 0x%08x/0%08x, Len  = %d\n", 
cp->ErrDesc.Addr.upper, cp->ErrDesc.Addr.lower, 
cp->ErrDesc.Len);
@@ -340,9 +286,7 @@ print_cmd(CommandList_struct *cp)
printk("offense size:%d\n", 
cp->err_info->MoreErrInfo.Invalid_Cmd.offense_size);
printk("offense byte:%d\n", 
cp->err_info->MoreErrInfo.Invalid_Cmd.offense_num);
printk("offense value:%d\n", 
cp->err_info->MoreErrInfo.Invalid_Cmd.offense_value);
-   
 }
-
 #endif
 
 static int 
@@ -782,8 +726,10 @@ static void complete_scsi_command(CommandList_struct *c, 
int timeout,
"reported\n", c);
break;
case CMD_INVALID: {
-   /* print_bytes(c, sizeof(*c), 1, 0);
-   print_cmd(c); */
+   /*
+   print_hex_dump(KERN_INFO, "", 
DUMP_PREFIX_OFFSET, 16, 1, c, sizeof(*c), false);
+   print_cmd(c);
+*/
  /* We get CMD_INVALID if you address a non-existent tape drive instead
of a selection timeout (no response).  You will see this if you yank 
out a t

[PATCH v1 1/1] scsi: replace custom approach to hexdump small buffers

2016-05-06 Thread Andy Shevchenko
In kernel we have defined specifier (%*ph[C]) to dump small buffers in a hex
format. Replace custom approach by a generic one.

Signed-off-by: Andy Shevchenko <andriy.shevche...@linux.intel.com>
---
 drivers/scsi/scsi_transport_srp.c | 11 +--
 drivers/scsi/sd.c |  4 +---
 2 files changed, 2 insertions(+), 13 deletions(-)

diff --git a/drivers/scsi/scsi_transport_srp.c 
b/drivers/scsi/scsi_transport_srp.c
index e3cd3ec..02cfc6b 100644
--- a/drivers/scsi/scsi_transport_srp.c
+++ b/drivers/scsi/scsi_transport_srp.c
@@ -115,21 +115,12 @@ static DECLARE_TRANSPORT_CLASS(srp_host_class, 
"srp_host", srp_host_setup,
 static DECLARE_TRANSPORT_CLASS(srp_rport_class, "srp_remote_ports",
   NULL, NULL, NULL);
 
-#define SRP_PID(p) \
-   (p)->port_id[0], (p)->port_id[1], (p)->port_id[2], (p)->port_id[3], \
-   (p)->port_id[4], (p)->port_id[5], (p)->port_id[6], (p)->port_id[7], \
-   (p)->port_id[8], (p)->port_id[9], (p)->port_id[10], (p)->port_id[11], \
-   (p)->port_id[12], (p)->port_id[13], (p)->port_id[14], (p)->port_id[15]
-
-#define SRP_PID_FMT "%02x:%02x:%02x:%02x:%02x:%02x:%02x:%02x:" \
-   "%02x:%02x:%02x:%02x:%02x:%02x:%02x:%02x"
-
 static ssize_t
 show_srp_rport_id(struct device *dev, struct device_attribute *attr,
  char *buf)
 {
struct srp_rport *rport = transport_class_to_srp_rport(dev);
-   return sprintf(buf, SRP_PID_FMT "\n", SRP_PID(rport));
+   return sprintf(buf, "%16phC\n", rport->port_id);
 }
 
 static DEVICE_ATTR(port_id, S_IRUGO, show_srp_rport_id, NULL);
diff --git a/drivers/scsi/sd.c b/drivers/scsi/sd.c
index 428c03e..c1b6b45 100644
--- a/drivers/scsi/sd.c
+++ b/drivers/scsi/sd.c
@@ -2408,9 +2408,7 @@ sd_read_write_protect_flag(struct scsi_disk *sdkp, 
unsigned char *buffer)
if (sdkp->first_scan || old_wp != sdkp->write_prot) {
sd_printk(KERN_NOTICE, sdkp, "Write Protect is %s\n",
  sdkp->write_prot ? "on" : "off");
-   sd_printk(KERN_DEBUG, sdkp,
- "Mode Sense: %02x %02x %02x %02x\n",
- buffer[0], buffer[1], buffer[2], buffer[3]);
+   sd_printk(KERN_DEBUG, sdkp, "Mode Sense: %4ph\n", 
buffer);
}
}
 }
-- 
2.8.1

--
To unsubscribe from this list: send the line "unsubscribe linux-scsi" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH v1 0/4] scsi: some (very) old clean ups

2016-05-06 Thread Andy Shevchenko
This is a set of independent clean ups that didn't land upstream for ages (some
are dated 2010!).  As agreed with Martin at some point I resend
them.

I have more, but the rest is not yet ready for submission.

Andy Shevchenko (3):
  libsas: remove private hex2bin() implementation
  scsi: fnic: use kernel's '%pM' format option to print MAC
  fusion: print lan address via %pMR

Oleksandr Khoshaba (1):
  scsi: qla4xxx: print MAC and SID via %p[mM][R]

 drivers/message/fusion/mptbase.c| 14 --
 drivers/scsi/fnic/vnic_dev.c| 10 ++
 drivers/scsi/libsas/sas_scsi_host.c | 22 ++
 drivers/scsi/qla4xxx/ql4_mbx.c  |  5 +
 drivers/scsi/qla4xxx/ql4_nx.c   |  8 ++--
 drivers/scsi/qla4xxx/ql4_os.c   | 15 ---
 6 files changed, 19 insertions(+), 55 deletions(-)

-- 
2.8.1

--
To unsubscribe from this list: send the line "unsubscribe linux-scsi" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH v1 4/4] scsi: qla4xxx: print MAC and SID via %p[mM][R]

2016-05-06 Thread Andy Shevchenko
From: Oleksandr Khoshaba <oleksandr.khosh...@gmail.com>

In the kernel we have nice specifier to print MAC by given pointer to the
address in a binary form.

Signed-off-by: Oleksandr Khoshaba <oleksandr.khosh...@gmail.com>
Acked-by: Vikas Chaudhary <vikas.chaudh...@qlogic.com>
Cc: qlogic-storage-upstr...@qlogic.com
Signed-off-by: Andy Shevchenko <andriy.shevche...@linux.intel.com>
---
 drivers/scsi/qla4xxx/ql4_mbx.c |  5 +
 drivers/scsi/qla4xxx/ql4_nx.c  |  8 ++--
 drivers/scsi/qla4xxx/ql4_os.c  | 15 ---
 3 files changed, 7 insertions(+), 21 deletions(-)

diff --git a/drivers/scsi/qla4xxx/ql4_mbx.c b/drivers/scsi/qla4xxx/ql4_mbx.c
index c291fdf..1da04f3 100644
--- a/drivers/scsi/qla4xxx/ql4_mbx.c
+++ b/drivers/scsi/qla4xxx/ql4_mbx.c
@@ -2032,10 +2032,7 @@ int qla4xxx_set_param_ddbentry(struct scsi_qla_host *ha,
ptid = (uint16_t *)_ddb_entry->isid[1];
*ptid = cpu_to_le16((uint16_t)ddb_entry->sess->target_id);
 
-   DEBUG2(ql4_printk(KERN_INFO, ha, "ISID [%02x%02x%02x%02x%02x%02x]\n",
- fw_ddb_entry->isid[5], fw_ddb_entry->isid[4],
- fw_ddb_entry->isid[3], fw_ddb_entry->isid[2],
- fw_ddb_entry->isid[1], fw_ddb_entry->isid[0]));
+   DEBUG2(ql4_printk(KERN_INFO, ha, "ISID [%pmR]\n", fw_ddb_entry->isid));
 
iscsi_opts = le16_to_cpu(fw_ddb_entry->iscsi_options);
memset(fw_ddb_entry->iscsi_alias, 0, sizeof(fw_ddb_entry->iscsi_alias));
diff --git a/drivers/scsi/qla4xxx/ql4_nx.c b/drivers/scsi/qla4xxx/ql4_nx.c
index ae87d6c..157938e 100644
--- a/drivers/scsi/qla4xxx/ql4_nx.c
+++ b/drivers/scsi/qla4xxx/ql4_nx.c
@@ -4094,12 +4094,8 @@ int qla4_8xxx_get_sys_info(struct scsi_qla_host *ha)
ha->phy_port_num = sys_info->port_num;
ha->iscsi_pci_func_cnt = sys_info->iscsi_pci_func_cnt;
 
-   DEBUG2(printk("scsi%ld: %s: "
-   "mac %02x:%02x:%02x:%02x:%02x:%02x "
-   "serial %s\n", ha->host_no, __func__,
-   ha->my_mac[0], ha->my_mac[1], ha->my_mac[2],
-   ha->my_mac[3], ha->my_mac[4], ha->my_mac[5],
-   ha->serial_number));
+   DEBUG2(printk("scsi%ld: %s: mac %pM serial %s\n",
+   ha->host_no, __func__, ha->my_mac, ha->serial_number));
 
status = QLA_SUCCESS;
 
diff --git a/drivers/scsi/qla4xxx/ql4_os.c b/drivers/scsi/qla4xxx/ql4_os.c
index 01c3610..9fbb33f 100644
--- a/drivers/scsi/qla4xxx/ql4_os.c
+++ b/drivers/scsi/qla4xxx/ql4_os.c
@@ -6304,13 +6304,9 @@ static int qla4xxx_compare_tuple_ddb(struct 
scsi_qla_host *ha,
 * ISID would not match firmware generated ISID.
 */
if (is_isid_compare) {
-   DEBUG2(ql4_printk(KERN_INFO, ha, "%s: old ISID [%02x%02x%02x"
-   "%02x%02x%02x] New ISID [%02x%02x%02x%02x%02x%02x]\n",
-   __func__, old_tddb->isid[5], old_tddb->isid[4],
-   old_tddb->isid[3], old_tddb->isid[2], old_tddb->isid[1],
-   old_tddb->isid[0], new_tddb->isid[5], new_tddb->isid[4],
-   new_tddb->isid[3], new_tddb->isid[2], new_tddb->isid[1],
-   new_tddb->isid[0]));
+   DEBUG2(ql4_printk(KERN_INFO, ha,
+   "%s: old ISID [%pmR] New ISID [%pmR]\n",
+   __func__, old_tddb->isid, new_tddb->isid));
 
if (memcmp(_tddb->isid[0], _tddb->isid[0],
   sizeof(old_tddb->isid)))
@@ -7925,10 +7921,7 @@ qla4xxx_sysfs_ddb_get_param(struct 
iscsi_bus_flash_session *fnode_sess,
rc = sprintf(buf, "%u\n", fnode_conn->keepalive_timeout);
break;
case ISCSI_FLASHNODE_ISID:
-   rc = sprintf(buf, "%02x%02x%02x%02x%02x%02x\n",
-fnode_sess->isid[0], fnode_sess->isid[1],
-fnode_sess->isid[2], fnode_sess->isid[3],
-fnode_sess->isid[4], fnode_sess->isid[5]);
+   rc = sprintf(buf, "%pm\n", fnode_sess->isid);
break;
case ISCSI_FLASHNODE_TSID:
rc = sprintf(buf, "%u\n", fnode_sess->tsid);
-- 
2.8.1

--
To unsubscribe from this list: send the line "unsubscribe linux-scsi" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH v1 3/4] fusion: print lan address via %pMR

2016-05-06 Thread Andy Shevchenko
LAN MAC addresses can be printed directly using %pMR specifier.

Cc: Sathya Prakash <sathya.prak...@broadcom.com>
Cc: mpt-fusionlinux@broadcom.com
Signed-off-by: Andy Shevchenko <andriy.shevche...@linux.intel.com>
---
 drivers/message/fusion/mptbase.c | 14 --
 1 file changed, 4 insertions(+), 10 deletions(-)

diff --git a/drivers/message/fusion/mptbase.c b/drivers/message/fusion/mptbase.c
index 5537f8d..3af67e6 100644
--- a/drivers/message/fusion/mptbase.c
+++ b/drivers/message/fusion/mptbase.c
@@ -2584,10 +2584,7 @@ mpt_do_ioc_recovery(MPT_ADAPTER *ioc, u32 reason, int 
sleepFlag)
(void) GetLanConfigPages(ioc);
a = 
(u8*)>lan_cnfg_page1.HardwareAddressLow;
dprintk(ioc, printk(MYIOC_s_DEBUG_FMT
-   "LanAddr = %02X:%02X:%02X"
-   ":%02X:%02X:%02X\n",
-   ioc->name, a[5], a[4],
-   a[3], a[2], a[1], a[0]));
+   "LanAddr = %pMR\n", ioc->name, a));
}
break;
 
@@ -6782,8 +6779,7 @@ static int mpt_iocinfo_proc_show(struct seq_file *m, void 
*v)
if (ioc->bus_type == FC) {
if (ioc->pfacts[p].ProtocolFlags & 
MPI_PORTFACTS_PROTOCOL_LAN) {
u8 *a = 
(u8*)>lan_cnfg_page1.HardwareAddressLow;
-   seq_printf(m, "LanAddr = 
%02X:%02X:%02X:%02X:%02X:%02X\n",
-   a[5], a[4], a[3], a[2], a[1], 
a[0]);
+   seq_printf(m, "LanAddr = %pMR\n", a);
}
seq_printf(m, "WWN = %08X%08X:%08X%08X\n",
ioc->fc_port_page0[p].WWNN.High,
@@ -6860,8 +6856,7 @@ mpt_print_ioc_summary(MPT_ADAPTER *ioc, char *buffer, int 
*size, int len, int sh
 
if (showlan && (ioc->pfacts[0].ProtocolFlags & 
MPI_PORTFACTS_PROTOCOL_LAN)) {
u8 *a = (u8*)>lan_cnfg_page1.HardwareAddressLow;
-   y += sprintf(buffer+len+y, ", 
LanAddr=%02X:%02X:%02X:%02X:%02X:%02X",
-   a[5], a[4], a[3], a[2], a[1], a[0]);
+   y += sprintf(buffer+len+y, ", LanAddr=%pMR", a);
}
 
y += sprintf(buffer+len+y, ", IRQ=%d", ioc->pci_irq);
@@ -6895,8 +6890,7 @@ static void seq_mpt_print_ioc_summary(MPT_ADAPTER *ioc, 
struct seq_file *m, int
 
if (showlan && (ioc->pfacts[0].ProtocolFlags & 
MPI_PORTFACTS_PROTOCOL_LAN)) {
u8 *a = (u8*)>lan_cnfg_page1.HardwareAddressLow;
-   seq_printf(m, ", LanAddr=%02X:%02X:%02X:%02X:%02X:%02X",
-   a[5], a[4], a[3], a[2], a[1], a[0]);
+   seq_printf(m, ", LanAddr=%pMR", a);
}
 
seq_printf(m, ", IRQ=%d", ioc->pci_irq);
-- 
2.8.1

--
To unsubscribe from this list: send the line "unsubscribe linux-scsi" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH v1 2/4] scsi: fnic: use kernel's '%pM' format option to print MAC

2016-05-06 Thread Andy Shevchenko
Instead of supplying each byte through stack let's use %pM specifier.

Cc: Hiral Patel <hiral...@cisco.com>
Cc: Suma Ramars <sram...@cisco.com>
Cc: Brian Uchino <buch...@cisco.com>
Signed-off-by: Andy Shevchenko <andriy.shevche...@linux.intel.com>
---
 drivers/scsi/fnic/vnic_dev.c | 10 ++
 1 file changed, 2 insertions(+), 8 deletions(-)

diff --git a/drivers/scsi/fnic/vnic_dev.c b/drivers/scsi/fnic/vnic_dev.c
index 9795d6f..ba69d61 100644
--- a/drivers/scsi/fnic/vnic_dev.c
+++ b/drivers/scsi/fnic/vnic_dev.c
@@ -499,10 +499,7 @@ void vnic_dev_add_addr(struct vnic_dev *vdev, u8 *addr)
 
err = vnic_dev_cmd(vdev, CMD_ADDR_ADD, , , wait);
if (err)
-   printk(KERN_ERR
-   "Can't add addr [%02x:%02x:%02x:%02x:%02x:%02x], %d\n",
-   addr[0], addr[1], addr[2], addr[3], addr[4], addr[5],
-   err);
+   pr_err("Can't add addr [%pM], %d\n", addr, err);
 }
 
 void vnic_dev_del_addr(struct vnic_dev *vdev, u8 *addr)
@@ -517,10 +514,7 @@ void vnic_dev_del_addr(struct vnic_dev *vdev, u8 *addr)
 
err = vnic_dev_cmd(vdev, CMD_ADDR_DEL, , , wait);
if (err)
-   printk(KERN_ERR
-   "Can't del addr [%02x:%02x:%02x:%02x:%02x:%02x], %d\n",
-   addr[0], addr[1], addr[2], addr[3], addr[4], addr[5],
-   err);
+   pr_err("Can't del addr [%pM], %d\n", addr, err);
 }
 
 int vnic_dev_notify_set(struct vnic_dev *vdev, u16 intr)
-- 
2.8.1

--
To unsubscribe from this list: send the line "unsubscribe linux-scsi" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH v1 1/4] libsas: remove private hex2bin() implementation

2016-05-06 Thread Andy Shevchenko
The function sas_parse_addr() could be easily substituted by hex2bin() which is
in kernel library code.

Cc: Christoph Hellwig <h...@lst.de>
Signed-off-by: Andy Shevchenko <andriy.shevche...@linux.intel.com>
---
 drivers/scsi/libsas/sas_scsi_host.c | 22 ++
 1 file changed, 6 insertions(+), 16 deletions(-)

diff --git a/drivers/scsi/libsas/sas_scsi_host.c 
b/drivers/scsi/libsas/sas_scsi_host.c
index 519dac4..30a5970 100644
--- a/drivers/scsi/libsas/sas_scsi_host.c
+++ b/drivers/scsi/libsas/sas_scsi_host.c
@@ -27,6 +27,7 @@
 #include 
 #include 
 #include 
+#include 
 
 #include "sas_internal.h"
 
@@ -961,21 +962,6 @@ void sas_target_destroy(struct scsi_target *starget)
sas_put_device(found_dev);
 }
 
-static void sas_parse_addr(u8 *sas_addr, const char *p)
-{
-   int i;
-   for (i = 0; i < SAS_ADDR_SIZE; i++) {
-   u8 h, l;
-   if (!*p)
-   break;
-   h = isdigit(*p) ? *p-'0' : toupper(*p)-'A'+10;
-   p++;
-   l = isdigit(*p) ? *p-'0' : toupper(*p)-'A'+10;
-   p++;
-   sas_addr[i] = (h<<4) | l;
-   }
-}
-
 #define SAS_STRING_ADDR_SIZE   16
 
 int sas_request_addr(struct Scsi_Host *shost, u8 *addr)
@@ -992,7 +978,11 @@ int sas_request_addr(struct Scsi_Host *shost, u8 *addr)
goto out;
}
 
-   sas_parse_addr(addr, fw->data);
+   res = hex2bin(addr, fw->data, strnlen(fw->data, SAS_ADDR_SIZE * 2) / 2);
+   if (res) {
+   res = -EINVAL;
+   goto out;
+   }
 
 out:
release_firmware(fw);
-- 
2.8.1

--
To unsubscribe from this list: send the line "unsubscribe linux-scsi" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH v2] mvsas: Generalize Marvell 9485 in pci_device_id

2016-04-07 Thread Andy Shevchenko
On Thu, Apr 7, 2016 at 8:06 PM, Leonid Moiseichuk
<leonid.moiseic...@gmail.com> wrote:
> For generic subvendor has sense to use generic subdevice.
> If subdevice ID not equal to 0x9480/0x9485 mvsas will be not activated.
>
> Tested on ASUS P9A-I/C2550/SAS/4L which uses vendor-specific 1043:8635.

Minors below.

FWIW:
Reviewed-by: Andy Shevchenko <andy.shevche...@gmail.com>

>
> Signed-off-by: Leonid Moiseichuk <leonid.moiseic...@gmail.com>
> ---

Missed changelog vfrom v1 to v2.

>  drivers/scsi/mvsas/mv_init.c | 19 +--
>  1 file changed, 1 insertion(+), 18 deletions(-)
>
> diff --git a/drivers/scsi/mvsas/mv_init.c b/drivers/scsi/mvsas/mv_init.c
> index c7c250519c4b..a6a4f09df0be 100644
> --- a/drivers/scsi/mvsas/mv_init.c
> +++ b/drivers/scsi/mvsas/mv_init.c
> @@ -704,24 +704,7 @@ static struct pci_device_id mvs_pci_table[] = {
> .class_mask = 0,
> .driver_data= chip_9445,
> },
> -   {
> -   .vendor = PCI_VENDOR_ID_MARVELL_EXT,
> -   .device = 0x9485,
> -   .subvendor  = PCI_ANY_ID,
> -   .subdevice  = 0x9480,
> -   .class  = 0,
> -   .class_mask = 0,
> -   .driver_data= chip_9485,
> -   },
> -   {
> -   .vendor = PCI_VENDOR_ID_MARVELL_EXT,
> -   .device = 0x9485,
> -   .subvendor  = PCI_ANY_ID,
> -   .subdevice  = 0x9485,
> -   .class  = 0,
> -   .class_mask = 0,
> -   .driver_data= chip_9485,
> -   },
> +   { PCI_VDEVICE(MARVELL_EXT, 0x9485), chip_9485 },

+ commentary line?

... /* MARVELL bla-bla-bla */

> { PCI_VDEVICE(OCZ, 0x1021), chip_9485}, /* OCZ RevoDrive3 */
> { PCI_VDEVICE(OCZ, 0x1022), chip_9485}, /* OCZ RevoDrive3/zDriveR4 
> (exact model unknown) */
> { PCI_VDEVICE(OCZ, 0x1040), chip_9485}, /* OCZ RevoDrive3/zDriveR4 
> (exact model unknown) */
> --
> 2.8.0.rc3
>
> --
> To unsubscribe from this list: send the line "unsubscribe linux-scsi" in
> the body of a message to majord...@vger.kernel.org
> More majordomo info at  http://vger.kernel.org/majordomo-info.html



-- 
With Best Regards,
Andy Shevchenko
--
To unsubscribe from this list: send the line "unsubscribe linux-scsi" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH 5/7] ahci: Convert driver to use modern PM hooks

2016-02-18 Thread Andy Shevchenko
On Thu, Feb 18, 2016 at 10:54 AM, Mika Westerberg
<mika.westerb...@linux.intel.com> wrote:
> In order to add support for runtime PM to the ahci driver we first need to
> convert the driver to use modern non-legacy system suspend hooks. There
> should be no functional changes.
>

One comment below, otherwise:
Reviewed-by: Andy Shevchenko <andy.shevche...@gmail.com>

> Signed-off-by: Mika Westerberg <mika.westerb...@linux.intel.com>
> ---
>  drivers/ata/ahci.c | 49 ++---
>  1 file changed, 22 insertions(+), 27 deletions(-)
>
> diff --git a/drivers/ata/ahci.c b/drivers/ata/ahci.c
> index 546a3692774f..44f9d1c09bbe 100644
> --- a/drivers/ata/ahci.c
> +++ b/drivers/ata/ahci.c
> @@ -93,9 +93,9 @@ static void ahci_mcp89_apple_enable(struct pci_dev *pdev);
>  static bool is_mcp89_apple(struct pci_dev *pdev);
>  static int ahci_p5wdh_hardreset(struct ata_link *link, unsigned int *class,
> unsigned long deadline);
> -#ifdef CONFIG_PM
> -static int ahci_pci_device_suspend(struct pci_dev *pdev, pm_message_t mesg);
> -static int ahci_pci_device_resume(struct pci_dev *pdev);
> +#ifdef CONFIG_PM_SLEEP
> +static int ahci_pci_device_suspend(struct device *dev);
> +static int ahci_pci_device_resume(struct device *dev);
>  #endif
>
>  static struct scsi_host_template ahci_sht = {
> @@ -557,16 +557,16 @@ static const struct pci_device_id ahci_pci_tbl[] = {
> { } /* terminate list */
>  };
>
> +static const struct dev_pm_ops ahci_pci_pm_ops = {
> +   SET_SYSTEM_SLEEP_PM_OPS(ahci_pci_device_suspend, 
> ahci_pci_device_resume)
> +};
>
>  static struct pci_driver ahci_pci_driver = {
> .name   = DRV_NAME,
> .id_table   = ahci_pci_tbl,
> .probe  = ahci_init_one,
> .remove = ata_pci_remove_one,
> -#ifdef CONFIG_PM
> -   .suspend= ahci_pci_device_suspend,
> -   .resume = ahci_pci_device_resume,
> -#endif
> +   .driver.pm  = _pci_pm_ops,

Please, do this in several assignments, since to support older compilers.

>  };
>
>  #if defined(CONFIG_PATA_MARVELL) || defined(CONFIG_PATA_MARVELL_MODULE)
> @@ -794,44 +794,39 @@ static int ahci_avn_hardreset(struct ata_link *link, 
> unsigned int *class,
>  }
>
>
> -#ifdef CONFIG_PM
> -static int ahci_pci_device_suspend(struct pci_dev *pdev, pm_message_t mesg)
> +#ifdef CONFIG_PM_SLEEP
> +static int ahci_pci_device_suspend(struct device *dev)
>  {
> +   struct pci_dev *pdev = to_pci_dev(dev);
> struct ata_host *host = pci_get_drvdata(pdev);
> struct ahci_host_priv *hpriv = host->private_data;
> void __iomem *mmio = hpriv->mmio;
> u32 ctl;
>
> -   if (mesg.event & PM_EVENT_SUSPEND &&
> -   hpriv->flags & AHCI_HFLAG_NO_SUSPEND) {
> +   if (hpriv->flags & AHCI_HFLAG_NO_SUSPEND) {
> dev_err(>dev,
> "BIOS update required for suspend/resume\n");
> return -EIO;
> }
>
> -   if (mesg.event & PM_EVENT_SLEEP) {
> -   /* AHCI spec rev1.1 section 8.3.3:
> -* Software must disable interrupts prior to requesting a
> -* transition of the HBA to D3 state.
> -*/
> -   ctl = readl(mmio + HOST_CTL);
> -   ctl &= ~HOST_IRQ_EN;
> -   writel(ctl, mmio + HOST_CTL);
> -   readl(mmio + HOST_CTL); /* flush */
> -   }
> +   /* AHCI spec rev1.1 section 8.3.3:
> +* Software must disable interrupts prior to requesting a
> +* transition of the HBA to D3 state.
> +*/
> +   ctl = readl(mmio + HOST_CTL);
> +   ctl &= ~HOST_IRQ_EN;
> +   writel(ctl, mmio + HOST_CTL);
> +   readl(mmio + HOST_CTL); /* flush */
>
> -   return ata_pci_device_suspend(pdev, mesg);
> +   return ata_host_suspend(host, PMSG_SUSPEND);
>  }
>
> -static int ahci_pci_device_resume(struct pci_dev *pdev)
> +static int ahci_pci_device_resume(struct device *dev)
>  {
> +   struct pci_dev *pdev = to_pci_dev(dev);
> struct ata_host *host = pci_get_drvdata(pdev);
> int rc;
>
> -   rc = ata_pci_device_do_resume(pdev);
> -   if (rc)
> -   return rc;
> -
> /* Apple BIOS helpfully mangles the registers on resume */
> if (is_mcp89_apple(pdev))
> ahci_mcp89_apple_enable(pdev);
> --
> 2.7.0
>
> --
> To unsubscribe from this list: send the line "unsubscribe linux-scsi" in
> the body of a message to majord...@vger.kernel.org
> More majordomo info at  http://vger.kernel.org/majordomo-info.html



-- 
With Best Regards,
Andy Shevchenko
--
To unsubscribe from this list: send the line "unsubscribe linux-scsi" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH] [SCSI] osd: fix signed char versus %02x issue

2015-12-10 Thread Andy Shevchenko
On Thu, Dec 10, 2015 at 8:15 PM, Martin K. Petersen
<martin.peter...@oracle.com> wrote:
>>>>>> "Rasmus" == Rasmus Villemoes <li...@rasmusvillemoes.dk> writes:
>
> Rasmus> If char is signed and one of these bytes happen to have a value
> Rasmus> outside the ascii range, the corresponding output will consist
> Rasmus> of "ff" followed by the two hex chars that were actually
> Rasmus> intended. One way to fix it would be to change the casts to
> Rasmus> (u8*) aka (unsigned char*), but it is much simpler (and
> Rasmus> generates smaller code) to use the %ph extension which was
> Rasmus> created for such short hexdumps.
>
> Applied to 4.5/scsi-queue.

How fast!

Martin, I have several patches on SCSI subsytem like this one. Some of
them didn't manage kernel (even having Ack!) for years already.
Is it okay if I collect them together and send a bunch once again Cc'ing you?

-- 
With Best Regards,
Andy Shevchenko
--
To unsubscribe from this list: send the line "unsubscribe linux-scsi" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH RESEND] scsi_debug: fix prevent_allow+verify regressions

2015-11-27 Thread Andy Shevchenko
On Thu, Nov 26, 2015 at 4:14 AM, Martin K. Petersen
<martin.peter...@oracle.com> wrote:
>>>>>> "Andy" == Andy Shevchenko <andy.shevche...@gmail.com> writes:
>
> Andy,
>
> Andy> but can you pay a little attention to
> Andy> http://www.spinics.net/lists/linux-scsi/msg81778.html ? It seems
> Andy> it wasn't applied.
>
> Please resubmit to linux-scsi. We'll take a look.

Done:

http://www.spinics.net/lists/linux-scsi/msg91207.html

-- 
With Best Regards,
Andy Shevchenko
--
To unsubscribe from this list: send the line "unsubscribe linux-scsi" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH v1 1/1] scsi_debug: check for bigger value first

2015-11-26 Thread Andy Shevchenko
From: Andy Shevchenko <andy.shevche...@gmail.com>

Even for signed types we have to check for bigger positive value first.
Otherwise it will be never happened.

Acked-by: Douglas Gilbert <dgilb...@interlog.com>
Signed-off-by: Andy Shevchenko <andy.shevche...@gmail.com>
---
 drivers/scsi/scsi_debug.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/drivers/scsi/scsi_debug.c b/drivers/scsi/scsi_debug.c
index dfcc45b..f773b34 100644
--- a/drivers/scsi/scsi_debug.c
+++ b/drivers/scsi/scsi_debug.c
@@ -4846,10 +4846,10 @@ static int __init scsi_debug_init(void)
/* play around with geometry, don't waste too much on track 0 */
sdebug_heads = 8;
sdebug_sectors_per = 32;
-   if (scsi_debug_dev_size_mb >= 16)
-   sdebug_heads = 32;
-   else if (scsi_debug_dev_size_mb >= 256)
+   if (scsi_debug_dev_size_mb >= 256)
sdebug_heads = 64;
+   else if (scsi_debug_dev_size_mb >= 16)
+   sdebug_heads = 32;
sdebug_cylinders_per = (unsigned long)sdebug_capacity /
   (sdebug_sectors_per * sdebug_heads);
if (sdebug_cylinders_per >= 1024) {
-- 
2.6.2

--
To unsubscribe from this list: send the line "unsubscribe linux-scsi" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH RESEND] scsi_debug: fix prevent_allow+verify regressions

2015-11-25 Thread Andy Shevchenko
Martin, sorry for offtopic, but can you pay a little attention to
http://www.spinics.net/lists/linux-scsi/msg81778.html ? It seems it
wasn't applied.


-- 
With Best Regards,
Andy Shevchenko
--
To unsubscribe from this list: send the line "unsubscribe linux-scsi" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH V2 2/3] scsi: fix compiler warning for sg

2015-11-10 Thread Andy Shevchenko
On Tue, Nov 10, 2015 at 6:53 AM, Timur Tabi <ti...@codeaurora.org> wrote:
> Sinan Kaya wrote:
>>
>>
>> The code says it is using these macros for small integers only which
>> can't overflow. I was trying to get rid of compiler warning and it seems
>> to have disappeared.
>
>
> I would double-check the assembly code, if I were you.  I don't like it when
> warnings just go away like that.

+1 to that.

>
> Besides, we *should* be using do_div() for 64-bit division.

But here looks like all numbers are guaranteed to be less than or
equal to INT_MAX.
Thus, the matter is only to replace MULDIV() by mult_frac() which is
already in kernel.

-- 
With Best Regards,
Andy Shevchenko
--
To unsubscribe from this list: send the line "unsubscribe linux-scsi" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH V2 2/3] scsi: fix compiler warning for sg

2015-11-09 Thread Andy Shevchenko
On Mon, Nov 9, 2015 at 3:57 AM, Sinan Kaya <ok...@codeaurora.org> wrote:
> The MULDIV macro has been designed for small numbers.
> Compiler emits an overflow warning on 64 bit systems.
> This patch uses 64 bit numbers in order to suppress
> warning.
>
> Signed-off-by: Sinan Kaya <ok...@codeaurora.org>


> ---
>  drivers/scsi/sg.c | 20 +---
>  1 file changed, 13 insertions(+), 7 deletions(-)
>
> diff --git a/drivers/scsi/sg.c b/drivers/scsi/sg.c
> index 9d7b7db..112d8974 100644
> --- a/drivers/scsi/sg.c
> +++ b/drivers/scsi/sg.c
> @@ -51,6 +51,7 @@ static int sg_version_num = 30536;/* 2 digits for each 
> component */
>  #include 
>  #include 
>  #include 
> +#include 
>
>  #include "scsi.h"
>  #include 
> @@ -85,12 +86,17 @@ static void sg_proc_cleanup(void);
>   * Replacing muldiv(x) by muldiv(x)=((x % d) * m) / d + int(x / d) * m
>   * calculates the same, but prevents the overflow when both m and d
>   * are "small" numbers (like HZ and USER_HZ).
> - * Of course an overflow is inavoidable if the result of muldiv doesn't fit
> - * in 32 bits.
>   */
> -#define MULDIV(X,MUL,DIV) X % DIV) * MUL) / DIV) + ((X / DIV) * MUL))
> +static inline u64 mult_frac64(u64 x, u32 numer, u32 denom)
> +{
> +   u64 r1 = do_div(x, denom);
> +   u64 r2 = r1 * numer;
> +
> +   do_div(r2, denom);

> +   return (x * numer) + r2;

Parens are useless, noticed later, sorry.

Isn't mult_frac() enough here?

Btw, can you mention explicitly what is the warning you get
(copy'n'paste of the line would be okay)?

> +}
>
> -#define SG_DEFAULT_TIMEOUT MULDIV(SG_DEFAULT_TIMEOUT_USER, HZ, USER_HZ)
> +#define SG_DEFAULT_TIMEOUT mult_frac64(SG_DEFAULT_TIMEOUT_USER, HZ, USER_HZ)
>
>  int sg_big_buff = SG_DEF_RESERVED_SIZE;
>  /* N.B. This variable is readable and writeable via
> @@ -877,10 +883,10 @@ sg_ioctl(struct file *filp, unsigned int cmd_in, 
> unsigned long arg)
> return result;
> if (val < 0)
> return -EIO;
> -   if (val >= MULDIV (INT_MAX, USER_HZ, HZ))
> -   val = MULDIV (INT_MAX, USER_HZ, HZ);
> +   if (val >= mult_frac64(INT_MAX, USER_HZ, HZ))
> +   val = mult_frac64(INT_MAX, USER_HZ, HZ);


> sfp->timeout_user = val;
> -   sfp->timeout = MULDIV (val, HZ, USER_HZ);
> +   sfp->timeout = mult_frac64(val, HZ, USER_HZ);
>
> return 0;
> case SG_GET_TIMEOUT:/* N.B. User receives timeout as return value 
> */
> --
> Qualcomm Technologies, Inc. on behalf of Qualcomm Innovation Center, Inc.
> Qualcomm Innovation Center, Inc. is a member of Code Aurora Forum, a Linux 
> Foundation Collaborative Project
>
> --
> To unsubscribe from this list: send the line "unsubscribe linux-scsi" in
> the body of a message to majord...@vger.kernel.org
> More majordomo info at  http://vger.kernel.org/majordomo-info.html



-- 
With Best Regards,
Andy Shevchenko
--
To unsubscribe from this list: send the line "unsubscribe linux-scsi" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH 3/4] scsi: fix compiler warning for sg

2015-11-05 Thread Andy Shevchenko
On Thu, Nov 5, 2015 at 6:46 AM, Sinan Kaya <ok...@codeaurora.org> wrote:
> The MULDIV macro has been designed for small
> numbers. It emits an overflow warning on 64 bit
> systems. This patch places type casts in the
> parameters to fix the compiler warning.
>
> Signed-off-by: Sinan Kaya <ok...@codeaurora.org>
> ---
>  drivers/scsi/sg.c | 5 -
>  1 file changed, 4 insertions(+), 1 deletion(-)
>
> diff --git a/drivers/scsi/sg.c b/drivers/scsi/sg.c
> index 9d7b7db..eb2739d 100644
> --- a/drivers/scsi/sg.c
> +++ b/drivers/scsi/sg.c
> @@ -88,7 +88,10 @@ static void sg_proc_cleanup(void);
>   * Of course an overflow is inavoidable if the result of muldiv doesn't fit
>   * in 32 bits.
>   */
> -#define MULDIV(X,MUL,DIV) X % DIV) * MUL) / DIV) + ((X / DIV) * MUL))
> +static inline u64 MULDIV(u64 X, u32 MUL, u32 DIV)
> +{
> +   return X % DIV) * MUL) / DIV) + ((X / DIV) * MUL));
> +}

Like kbuild bot already told you it would be nice to think of 32-bit
architectures.

Moreover we have mult_frac() macro already for 32-bit numbers.

For 64 bit numbers you need to do do_div().

Like:

static inline u64 mult_frac64(u64 x, u32 m, u32 n)
{
u64 ret;

ret = do_div(x, n);
return ret * m;
}


>
>  #define SG_DEFAULT_TIMEOUT MULDIV(SG_DEFAULT_TIMEOUT_USER, HZ, USER_HZ)
>
> --
> Qualcomm Technologies, Inc. on behalf of Qualcomm Innovation Center, Inc.
> Qualcomm Innovation Center, Inc. is a member of Code Aurora Forum, a Linux 
> Foundation Collaborative Project
>
> --
> To unsubscribe from this list: send the line "unsubscribe linux-scsi" in
> the body of a message to majord...@vger.kernel.org
> More majordomo info at  http://vger.kernel.org/majordomo-info.html



-- 
With Best Regards,
Andy Shevchenko
--
To unsubscribe from this list: send the line "unsubscribe linux-scsi" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH 3/4] scsi: fix compiler warning for sg

2015-11-05 Thread Andy Shevchenko
On Thu, Nov 5, 2015 at 5:10 PM, Sinan Kaya <ok...@codeaurora.org> wrote:
>
>
> On 11/5/2015 3:48 AM, Andy Shevchenko wrote:
>>
>> On Thu, Nov 5, 2015 at 6:46 AM, Sinan Kaya <ok...@codeaurora.org> wrote:
>>>
>>> The MULDIV macro has been designed for small
>>> numbers. It emits an overflow warning on 64 bit
>>> systems. This patch places type casts in the
>>> parameters to fix the compiler warning.
>>>
>>> Signed-off-by: Sinan Kaya <ok...@codeaurora.org>
>>> ---
>>>   drivers/scsi/sg.c | 5 -
>>>   1 file changed, 4 insertions(+), 1 deletion(-)
>>>
>>> diff --git a/drivers/scsi/sg.c b/drivers/scsi/sg.c
>>> index 9d7b7db..eb2739d 100644
>>> --- a/drivers/scsi/sg.c
>>> +++ b/drivers/scsi/sg.c
>>> @@ -88,7 +88,10 @@ static void sg_proc_cleanup(void);
>>>* Of course an overflow is inavoidable if the result of muldiv doesn't
>>> fit
>>>* in 32 bits.
>>>*/
>>> -#define MULDIV(X,MUL,DIV) X % DIV) * MUL) / DIV) + ((X / DIV) *
>>> MUL))
>>> +static inline u64 MULDIV(u64 X, u32 MUL, u32 DIV)
>>> +{
>>> +   return X % DIV) * MUL) / DIV) + ((X / DIV) * MUL));
>>> +}
>>
>>
>> Like kbuild bot already told you it would be nice to think of 32-bit
>> architectures.
>>
>> Moreover we have mult_frac() macro already for 32-bit numbers.
>>
>> For 64 bit numbers you need to do do_div().
>>
>> Like:
>>
>> static inline u64 mult_frac64(u64 x, u32 m, u32 n)
>> {
>> u64 ret;
>>
>> ret = do_div(x, n);
>> return ret * m;
>> }
>>
>
> OK, I didn't know that we had such a macro. To make this look like the other
> macro, I can do this.
>
> static inline u64 mult_frac64(u64 x, u32 numer, u32 denom)
> {
> u64 quot;
> u64 rem  = x % denom;
> u64 rem2;
>
> quot = x;
> do_div(quot, denom);
>
> rem2 = rem * numer;
> do_div(rem2, denom);
>
> return (quot * numer) + rem2;
> }

Might be I did a wrong smaple, but do_div() returns two values actually.
You perhaps overlooked it and thus wrote something redundant above.

>
> #define MULDIV(X,MUL,DIV)   mult_frac64(X, MUL, DIV)
>
>>
>>>
>>>   #define SG_DEFAULT_TIMEOUT MULDIV(SG_DEFAULT_TIMEOUT_USER, HZ, USER_HZ)
>>>
>>> --
>>> Qualcomm Technologies, Inc. on behalf of Qualcomm Innovation Center, Inc.
>>> Qualcomm Innovation Center, Inc. is a member of Code Aurora Forum, a
>>> Linux Foundation Collaborative Project
>>>
>>> --
>>> To unsubscribe from this list: send the line "unsubscribe linux-scsi" in
>>> the body of a message to majord...@vger.kernel.org
>>> More majordomo info at  http://vger.kernel.org/majordomo-info.html
>>
>>
>>
>>
>
> --
> Sinan Kaya
> Qualcomm Technologies, Inc. on behalf of Qualcomm Innovation Center, Inc.
> Qualcomm Innovation Center, Inc. is a member of Code Aurora Forum, a Linux
> Foundation Collaborative Project



-- 
With Best Regards,
Andy Shevchenko
--
To unsubscribe from this list: send the line "unsubscribe linux-scsi" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH 3/4] scsi: fix compiler warning for sg

2015-11-05 Thread Andy Shevchenko
On Thu, Nov 5, 2015 at 8:32 PM, Sinan Kaya <ok...@codeaurora.org> wrote:
> On 11/5/2015 1:07 PM, Andy Shevchenko wrote:

> Let's try again.
>
> static inline u64 mult_frac64(u64 x, u32 numer, u32 denom) {
> u64 rem  = x % denom;
> u64 quot = do_div(x, denom);
> u64 mul = rem * numer;
>
> return (quot * numer) + do_div(mul, denom);
> }

First of all why not to put this to generic header? We have math64.h
and kernel.h.
Might be a good idea (needs to check current users) to move mult_frac
to math64.h.

Then, x % y is already a problem. After all, you seems messed quot and
remainder.

What about something like

#if BITS_PER_LONG == 64

#define mult_frac64(x,n,d)  mult_frac(x,n,d)

#else

static inline u64 mult_frac64(u64 x, u32 numer, u32 denom) {
u64 r1 = do_div(x, denom);
u64 r2 = r1 * numer;

do_div(r2, denom);
return (x * numer) + r2;
}

#endif

?

-- 
With Best Regards,
Andy Shevchenko
--
To unsubscribe from this list: send the line "unsubscribe linux-scsi" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH 3/4] scsi: fix compiler warning for sg

2015-11-05 Thread Andy Shevchenko
On Thu, Nov 5, 2015 at 9:31 PM, Andy Shevchenko
<andy.shevche...@gmail.com> wrote:
> On Thu, Nov 5, 2015 at 8:32 PM, Sinan Kaya <ok...@codeaurora.org> wrote:
>> On 11/5/2015 1:07 PM, Andy Shevchenko wrote:
>
>> Let's try again.
>>
>> static inline u64 mult_frac64(u64 x, u32 numer, u32 denom) {
>> u64 rem  = x % denom;
>> u64 quot = do_div(x, denom);
>> u64 mul = rem * numer;
>>
>> return (quot * numer) + do_div(mul, denom);
>> }
>
> First of all why not to put this to generic header? We have math64.h
> and kernel.h.
> Might be a good idea (needs to check current users) to move mult_frac
> to math64.h.
>
> Then, x % y is already a problem. After all, you seems messed quot and
> remainder.
>
> What about something like
>
> #if BITS_PER_LONG == 64
>
> #define mult_frac64(x,n,d)  mult_frac(x,n,d)
>
> #else
>
> static inline u64 mult_frac64(u64 x, u32 numer, u32 denom) {
> u64 r1 = do_div(x, denom);
> u64 r2 = r1 * numer;
>
> do_div(r2, denom);
> return (x * numer) + r2;
> }
>
> #endif
>
> ?

One more look to the users of MULDIV.

They all seems 32 bit for x.
It means you don't need two do_div()s at all.

Just do something like:

u64 d = x * numer;
do_div(d, denom);
return d;

-- 
With Best Regards,
Andy Shevchenko
--
To unsubscribe from this list: send the line "unsubscribe linux-scsi" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH] scsi: fnic: use kernel's '%pM' format option to print MAC

2015-09-30 Thread Andy Shevchenko
On Thu, 2015-03-19 at 21:50 -0500, Tom Tucker wrote:
> Hi Andy,
> 
> On 3/19/15 12:54 PM, Andy Shevchenko wrote:
> > On Tue, 2014-04-29 at 17:45 +0300, Andy Shevchenko wrote:
> > > Instead of supplying each byte through stack let's use %pM 
> > > specifier.
> > Anyone to comment or apply this patch?
> > 
> > > Signed-off-by: Andy Shevchenko <andriy.shevche...@linux.intel.com
> > > >
> > > Cc: Tom Tucker <t...@opengridcomputing.com>
> > > Cc: Steve Wise <sw...@opengridcomputing.com>
> > > Cc: linux-r...@vger.kernel.org
> > > ---
> > >   drivers/scsi/fnic/vnic_dev.c | 10 ++
> > >   1 file changed, 2 insertions(+), 8 deletions(-)
> > > 
> > > diff --git a/drivers/scsi/fnic/vnic_dev.c 
> > > b/drivers/scsi/fnic/vnic_dev.c
> > > index 9795d6f..ba69d61 100644
> > > --- a/drivers/scsi/fnic/vnic_dev.c
> > > +++ b/drivers/scsi/fnic/vnic_dev.c
> > > @@ -499,10 +499,7 @@ void vnic_dev_add_addr(struct vnic_dev 
> > > *vdev, u8 *addr)
> > >   
> > >   err = vnic_dev_cmd(vdev, CMD_ADDR_ADD, , , wait);
> > >   if (err)
> > > - printk(KERN_ERR
> > > - "Can't add addr 
> > > [%02x:%02x:%02x:%02x:%02x:%02x], %d\n",
> > > - addr[0], addr[1], addr[2], addr[3], 
> > > addr[4], addr[5],
> > > - err);
> > > + pr_err("Can't add addr [%pM], %d\n", addr, err);
> 
> This looks completely reasonable to me.

Anyone to apply then?

> 
> Tom
> > >   }
> > >   
> > >   void vnic_dev_del_addr(struct vnic_dev *vdev, u8 *addr)
> > > @@ -517,10 +514,7 @@ void vnic_dev_del_addr(struct vnic_dev 
> > > *vdev, u8 *addr)
> > >   
> > >   err = vnic_dev_cmd(vdev, CMD_ADDR_DEL, , , wait);
> > >   if (err)
> > > - printk(KERN_ERR
> > > - "Can't del addr 
> > > [%02x:%02x:%02x:%02x:%02x:%02x], %d\n",
> > > - addr[0], addr[1], addr[2], addr[3], 
> > > addr[4], addr[5],
> > > - err);
> > > + pr_err("Can't del addr [%pM], %d\n", addr, err);
> > >   }
> > >   
> > >   int vnic_dev_notify_set(struct vnic_dev *vdev, u16 intr)
> > 
> 

-- 
Andy Shevchenko <andriy.shevche...@linux.intel.com>
Intel Finland Oy
--
To unsubscribe from this list: send the line "unsubscribe linux-scsi" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH 1/1] scsi: qla4xxx: print MAC and SID via %p[mM][R]

2015-09-30 Thread Andy Shevchenko
From: Oleksandr Khoshaba <oleksandr.khosh...@gmail.com>

In the kernel we have nice specifier to print MAC by given pointer to the
address in binary form.

Signed-off-by: Oleksandr Khoshaba <oleksandr.khosh...@gmail.com>
Acked-by: Vikas Chaudhary <vikas.chaudh...@qlogic.com>
Signed-off-by: Andy Shevchenko <andriy.shevche...@linux.intel.com>
---
 drivers/scsi/qla4xxx/ql4_mbx.c |  5 +
 drivers/scsi/qla4xxx/ql4_nx.c  |  8 ++--
 drivers/scsi/qla4xxx/ql4_os.c  | 15 ---
 3 files changed, 7 insertions(+), 21 deletions(-)

diff --git a/drivers/scsi/qla4xxx/ql4_mbx.c b/drivers/scsi/qla4xxx/ql4_mbx.c
index c291fdf..1da04f3 100644
--- a/drivers/scsi/qla4xxx/ql4_mbx.c
+++ b/drivers/scsi/qla4xxx/ql4_mbx.c
@@ -2032,10 +2032,7 @@ int qla4xxx_set_param_ddbentry(struct scsi_qla_host *ha,
ptid = (uint16_t *)_ddb_entry->isid[1];
*ptid = cpu_to_le16((uint16_t)ddb_entry->sess->target_id);
 
-   DEBUG2(ql4_printk(KERN_INFO, ha, "ISID [%02x%02x%02x%02x%02x%02x]\n",
- fw_ddb_entry->isid[5], fw_ddb_entry->isid[4],
- fw_ddb_entry->isid[3], fw_ddb_entry->isid[2],
- fw_ddb_entry->isid[1], fw_ddb_entry->isid[0]));
+   DEBUG2(ql4_printk(KERN_INFO, ha, "ISID [%pmR]\n", fw_ddb_entry->isid));
 
iscsi_opts = le16_to_cpu(fw_ddb_entry->iscsi_options);
memset(fw_ddb_entry->iscsi_alias, 0, sizeof(fw_ddb_entry->iscsi_alias));
diff --git a/drivers/scsi/qla4xxx/ql4_nx.c b/drivers/scsi/qla4xxx/ql4_nx.c
index 7c33658..05a4b77 100644
--- a/drivers/scsi/qla4xxx/ql4_nx.c
+++ b/drivers/scsi/qla4xxx/ql4_nx.c
@@ -4094,12 +4094,8 @@ int qla4_8xxx_get_sys_info(struct scsi_qla_host *ha)
ha->phy_port_num = sys_info->port_num;
ha->iscsi_pci_func_cnt = sys_info->iscsi_pci_func_cnt;
 
-   DEBUG2(printk("scsi%ld: %s: "
-   "mac %02x:%02x:%02x:%02x:%02x:%02x "
-   "serial %s\n", ha->host_no, __func__,
-   ha->my_mac[0], ha->my_mac[1], ha->my_mac[2],
-   ha->my_mac[3], ha->my_mac[4], ha->my_mac[5],
-   ha->serial_number));
+   DEBUG2(printk("scsi%ld: %s: mac %pM serial %s\n",
+   ha->host_no, __func__, ha->my_mac, ha->serial_number));
 
status = QLA_SUCCESS;
 
diff --git a/drivers/scsi/qla4xxx/ql4_os.c b/drivers/scsi/qla4xxx/ql4_os.c
index 6d25879..0cc230d 100644
--- a/drivers/scsi/qla4xxx/ql4_os.c
+++ b/drivers/scsi/qla4xxx/ql4_os.c
@@ -6305,13 +6305,9 @@ static int qla4xxx_compare_tuple_ddb(struct 
scsi_qla_host *ha,
 * ISID would not match firmware generated ISID.
 */
if (is_isid_compare) {
-   DEBUG2(ql4_printk(KERN_INFO, ha, "%s: old ISID [%02x%02x%02x"
-   "%02x%02x%02x] New ISID [%02x%02x%02x%02x%02x%02x]\n",
-   __func__, old_tddb->isid[5], old_tddb->isid[4],
-   old_tddb->isid[3], old_tddb->isid[2], old_tddb->isid[1],
-   old_tddb->isid[0], new_tddb->isid[5], new_tddb->isid[4],
-   new_tddb->isid[3], new_tddb->isid[2], new_tddb->isid[1],
-   new_tddb->isid[0]));
+   DEBUG2(ql4_printk(KERN_INFO, ha,
+   "%s: old ISID [%pmR] New ISID [%pmR]\n",
+   __func__, old_tddb->isid, new_tddb->isid));
 
if (memcmp(_tddb->isid[0], _tddb->isid[0],
   sizeof(old_tddb->isid)))
@@ -7926,10 +7922,7 @@ qla4xxx_sysfs_ddb_get_param(struct 
iscsi_bus_flash_session *fnode_sess,
rc = sprintf(buf, "%u\n", fnode_conn->keepalive_timeout);
break;
case ISCSI_FLASHNODE_ISID:
-   rc = sprintf(buf, "%02x%02x%02x%02x%02x%02x\n",
-fnode_sess->isid[0], fnode_sess->isid[1],
-fnode_sess->isid[2], fnode_sess->isid[3],
-fnode_sess->isid[4], fnode_sess->isid[5]);
+   rc = sprintf(buf, "%pm\n", fnode_sess->isid);
break;
case ISCSI_FLASHNODE_TSID:
rc = sprintf(buf, "%u\n", fnode_sess->tsid);
-- 
2.5.1

--
To unsubscribe from this list: send the line "unsubscribe linux-scsi" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH] scsi: fnic: use kernel's '%pM' format option to print MAC

2015-03-19 Thread Andy Shevchenko
On Tue, 2014-04-29 at 17:45 +0300, Andy Shevchenko wrote:
 Instead of supplying each byte through stack let's use %pM specifier.

Anyone to comment or apply this patch?

 
 Signed-off-by: Andy Shevchenko andriy.shevche...@linux.intel.com
 Cc: Tom Tucker t...@opengridcomputing.com
 Cc: Steve Wise sw...@opengridcomputing.com
 Cc: linux-r...@vger.kernel.org
 ---
  drivers/scsi/fnic/vnic_dev.c | 10 ++
  1 file changed, 2 insertions(+), 8 deletions(-)
 
 diff --git a/drivers/scsi/fnic/vnic_dev.c b/drivers/scsi/fnic/vnic_dev.c
 index 9795d6f..ba69d61 100644
 --- a/drivers/scsi/fnic/vnic_dev.c
 +++ b/drivers/scsi/fnic/vnic_dev.c
 @@ -499,10 +499,7 @@ void vnic_dev_add_addr(struct vnic_dev *vdev, u8 *addr)
  
   err = vnic_dev_cmd(vdev, CMD_ADDR_ADD, a0, a1, wait);
   if (err)
 - printk(KERN_ERR
 - Can't add addr [%02x:%02x:%02x:%02x:%02x:%02x], %d\n,
 - addr[0], addr[1], addr[2], addr[3], addr[4], addr[5],
 - err);
 + pr_err(Can't add addr [%pM], %d\n, addr, err);
  }
  
  void vnic_dev_del_addr(struct vnic_dev *vdev, u8 *addr)
 @@ -517,10 +514,7 @@ void vnic_dev_del_addr(struct vnic_dev *vdev, u8 *addr)
  
   err = vnic_dev_cmd(vdev, CMD_ADDR_DEL, a0, a1, wait);
   if (err)
 - printk(KERN_ERR
 - Can't del addr [%02x:%02x:%02x:%02x:%02x:%02x], %d\n,
 - addr[0], addr[1], addr[2], addr[3], addr[4], addr[5],
 - err);
 + pr_err(Can't del addr [%pM], %d\n, addr, err);
  }
  
  int vnic_dev_notify_set(struct vnic_dev *vdev, u16 intr)


-- 
Andy Shevchenko andriy.shevche...@intel.com
Intel Finland Oy

--
To unsubscribe from this list: send the line unsubscribe linux-scsi in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCHv2 3/3] scsi: qla4xxx: print MAC and SID via %p[mM][R]

2015-03-18 Thread Andy Shevchenko
On Thu, Jul 25, 2013 at 12:10 PM, Andy Shevchenko
andriy.shevche...@linux.intel.com wrote:
 From: Oleksandr Khoshaba oleksandr.khosh...@gmail.com

 In the kernel we have nice specifier to print MAC by given pointer to the
 address in binary form.

 Signed-off-by: Oleksandr Khoshaba oleksandr.khosh...@gmail.com
 Acked-by: Vikas Chaudhary vikas.chaudh...@qlogic.com

Could anyone take this patch?

 ---
  drivers/scsi/qla4xxx/ql4_mbx.c |  5 +
  drivers/scsi/qla4xxx/ql4_nx.c  |  8 ++--
  drivers/scsi/qla4xxx/ql4_os.c  | 15 ---
  3 files changed, 7 insertions(+), 21 deletions(-)

 diff --git a/drivers/scsi/qla4xxx/ql4_mbx.c b/drivers/scsi/qla4xxx/ql4_mbx.c
 index a501bea..f01b8ae 100644
 --- a/drivers/scsi/qla4xxx/ql4_mbx.c
 +++ b/drivers/scsi/qla4xxx/ql4_mbx.c
 @@ -1837,10 +1837,7 @@ int qla4xxx_set_param_ddbentry(struct scsi_qla_host 
 *ha,
 ptid = (uint16_t *)fw_ddb_entry-isid[1];
 *ptid = cpu_to_le16((uint16_t)ddb_entry-sess-target_id);

 -   DEBUG2(ql4_printk(KERN_INFO, ha, ISID [%02x%02x%02x%02x%02x%02x]\n,
 - fw_ddb_entry-isid[5], fw_ddb_entry-isid[4],
 - fw_ddb_entry-isid[3], fw_ddb_entry-isid[2],
 - fw_ddb_entry-isid[1], fw_ddb_entry-isid[0]));
 +   DEBUG2(ql4_printk(KERN_INFO, ha, ISID [%pmR]\n, 
 fw_ddb_entry-isid));

 iscsi_opts = le16_to_cpu(fw_ddb_entry-iscsi_options);
 memset(fw_ddb_entry-iscsi_alias, 0, 
 sizeof(fw_ddb_entry-iscsi_alias));
 diff --git a/drivers/scsi/qla4xxx/ql4_nx.c b/drivers/scsi/qla4xxx/ql4_nx.c
 index eaf00c1..2bc1046 100644
 --- a/drivers/scsi/qla4xxx/ql4_nx.c
 +++ b/drivers/scsi/qla4xxx/ql4_nx.c
 @@ -3455,12 +3455,8 @@ int qla4_8xxx_get_sys_info(struct scsi_qla_host *ha)
 ha-phy_port_num = sys_info-port_num;
 ha-iscsi_pci_func_cnt = sys_info-iscsi_pci_func_cnt;

 -   DEBUG2(printk(scsi%ld: %s: 
 -   mac %02x:%02x:%02x:%02x:%02x:%02x 
 -   serial %s\n, ha-host_no, __func__,
 -   ha-my_mac[0], ha-my_mac[1], ha-my_mac[2],
 -   ha-my_mac[3], ha-my_mac[4], ha-my_mac[5],
 -   ha-serial_number));
 +   DEBUG2(printk(scsi%ld: %s: mac %pM serial %s\n, ha-host_no,
 +   __func__, ha-my_mac, ha-serial_number));

 status = QLA_SUCCESS;

 diff --git a/drivers/scsi/qla4xxx/ql4_os.c b/drivers/scsi/qla4xxx/ql4_os.c
 index b246b3c..2797b8f 100644
 --- a/drivers/scsi/qla4xxx/ql4_os.c
 +++ b/drivers/scsi/qla4xxx/ql4_os.c
 @@ -4786,13 +4786,9 @@ static int qla4xxx_compare_tuple_ddb(struct 
 scsi_qla_host *ha,
  * ISID would not match firmware generated ISID.
  */
 if (is_isid_compare) {
 -   DEBUG2(ql4_printk(KERN_INFO, ha, %s: old ISID [%02x%02x%02x
 -   %02x%02x%02x] New ISID [%02x%02x%02x%02x%02x%02x]\n,
 -   __func__, old_tddb-isid[5], old_tddb-isid[4],
 -   old_tddb-isid[3], old_tddb-isid[2], 
 old_tddb-isid[1],
 -   old_tddb-isid[0], new_tddb-isid[5], 
 new_tddb-isid[4],
 -   new_tddb-isid[3], new_tddb-isid[2], 
 new_tddb-isid[1],
 -   new_tddb-isid[0]));
 +   DEBUG2(ql4_printk(KERN_INFO, ha,
 +   %s: old ISID [%pmR] New ISID [%pmR]\n,
 +   __func__, old_tddb-isid, new_tddb-isid));

 if (memcmp(old_tddb-isid[0], new_tddb-isid[0],
sizeof(old_tddb-isid)))
 @@ -6211,10 +6207,7 @@ qla4xxx_sysfs_ddb_get_param(struct 
 iscsi_bus_flash_session *fnode_sess,
 rc = sprintf(buf, %u\n, fnode_conn-keepalive_timeout);
 break;
 case ISCSI_FLASHNODE_ISID:
 -   rc = sprintf(buf, %02x%02x%02x%02x%02x%02x\n,
 -fnode_sess-isid[0], fnode_sess-isid[1],
 -fnode_sess-isid[2], fnode_sess-isid[3],
 -fnode_sess-isid[4], fnode_sess-isid[5]);
 +   rc = sprintf(buf, %pm\n, fnode_sess-isid);
 break;
 case ISCSI_FLASHNODE_TSID:
 rc = sprintf(buf, %u\n, fnode_sess-tsid);
 --
 1.8.3.2

 --
 To unsubscribe from this list: send the line unsubscribe linux-scsi in
 the body of a message to majord...@vger.kernel.org
 More majordomo info at  http://vger.kernel.org/majordomo-info.html



-- 
With Best Regards,
Andy Shevchenko
--
To unsubscribe from this list: send the line unsubscribe linux-scsi in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH] iscsi-target: use '%*ph' specifier to dump hex buffer

2015-01-15 Thread Andy Shevchenko
Instead of pushing each byte via stack the %*ph specifier allows to supply just
a pointer and length of the buffer. The patch converts code to use the
specifier.

Signed-off-by: Andy Shevchenko andriy.shevche...@linux.intel.com
---
 drivers/target/iscsi/iscsi_target_configfs.c | 13 -
 1 file changed, 4 insertions(+), 9 deletions(-)

diff --git a/drivers/target/iscsi/iscsi_target_configfs.c 
b/drivers/target/iscsi/iscsi_target_configfs.c
index 9059c1e..526becd 100644
--- a/drivers/target/iscsi/iscsi_target_configfs.c
+++ b/drivers/target/iscsi/iscsi_target_configfs.c
@@ -674,12 +674,9 @@ static ssize_t lio_target_nacl_show_info(
rb += sprintf(page+rb, InitiatorAlias: %s\n,
sess-sess_ops-InitiatorAlias);
 
-   rb += sprintf(page+rb, LIO Session ID: %u   
-   ISID: 0x%02x %02x %02x %02x %02x %02x  
-   TSIH: %hu  , sess-sid,
-   sess-isid[0], sess-isid[1], sess-isid[2],
-   sess-isid[3], sess-isid[4], sess-isid[5],
-   sess-tsih);
+   rb += sprintf(page+rb,
+ LIO Session ID: %u   ISID: 0x%6ph  TSIH: %hu  ,
+ sess-sid, sess-isid, sess-tsih);
rb += sprintf(page+rb, SessionType: %s\n,
(sess-sess_ops-SessionType) ?
Discovery : Normal);
@@ -1758,9 +1755,7 @@ static u32 lio_sess_get_initiator_sid(
/*
 * iSCSI Initiator Session Identifier from RFC-3720.
 */
-   return snprintf(buf, size, %02x%02x%02x%02x%02x%02x,
-   sess-isid[0], sess-isid[1], sess-isid[2],
-   sess-isid[3], sess-isid[4], sess-isid[5]);
+   return snprintf(buf, size, %6phN, sess-isid);
 }
 
 static int lio_queue_data_in(struct se_cmd *se_cmd)
-- 
2.1.4

--
To unsubscribe from this list: send the line unsubscribe linux-scsi in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH] scsi: qla2xxx: print port name via %*phC

2015-01-15 Thread Andy Shevchenko
Instead of pushing each byte via stack let's use custom specifier which allows
to print small buffers as a hex string.

Signed-off-by: Andy Shevchenko andriy.shevche...@linux.intel.com
---
 drivers/scsi/qla2xxx/tcm_qla2xxx.c | 4 +---
 1 file changed, 1 insertion(+), 3 deletions(-)

diff --git a/drivers/scsi/qla2xxx/tcm_qla2xxx.c 
b/drivers/scsi/qla2xxx/tcm_qla2xxx.c
index 73f9fee..99f43b7 100644
--- a/drivers/scsi/qla2xxx/tcm_qla2xxx.c
+++ b/drivers/scsi/qla2xxx/tcm_qla2xxx.c
@@ -1570,9 +1570,7 @@ static int tcm_qla2xxx_check_initiator_node_acl(
 * match the format by tcm_qla2xxx explict ConfigFS NodeACLs.
 */
memset(port_name, 0, 36);
-   snprintf(port_name, 36, %02x:%02x:%02x:%02x:%02x:%02x:%02x:%02x,
-   fc_wwpn[0], fc_wwpn[1], fc_wwpn[2], fc_wwpn[3], fc_wwpn[4],
-   fc_wwpn[5], fc_wwpn[6], fc_wwpn[7]);
+   snprintf(port_name, sizeof(port_name), %8phC, fc_wwpn);
/*
 * Locate our struct se_node_acl either from an explict NodeACL created
 * via ConfigFS, or via running in TPG demo mode.
-- 
2.1.4

--
To unsubscribe from this list: send the line unsubscribe linux-scsi in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH] scsi_debug: check for bigger value first

2015-01-06 Thread Andy Shevchenko
Even for signed types we have to check for bigger positive value first.
Otherwise it will be never happened.

Signed-off-by: Andy Shevchenko andy.shevche...@gmail.com
---
 drivers/scsi/scsi_debug.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/drivers/scsi/scsi_debug.c b/drivers/scsi/scsi_debug.c
index 8bcf6ad..a34df1d 100644
--- a/drivers/scsi/scsi_debug.c
+++ b/drivers/scsi/scsi_debug.c
@@ -4850,10 +4850,10 @@ static int __init scsi_debug_init(void)
/* play around with geometry, don't waste too much on track 0 */
sdebug_heads = 8;
sdebug_sectors_per = 32;
-   if (scsi_debug_dev_size_mb = 16)
-   sdebug_heads = 32;
-   else if (scsi_debug_dev_size_mb = 256)
+   if (scsi_debug_dev_size_mb = 256)
sdebug_heads = 64;
+   else if (scsi_debug_dev_size_mb = 16)
+   sdebug_heads = 32;
sdebug_cylinders_per = (unsigned long)sdebug_capacity /
   (sdebug_sectors_per * sdebug_heads);
if (sdebug_cylinders_per = 1024) {
-- 
1.8.3.101.g727a46b

--
To unsubscribe from this list: send the line unsubscribe linux-scsi in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH] scsi: qla2xxx: print port name via %*phC

2014-04-29 Thread Andy Shevchenko
Instead of pushing each byte via stack let's use custom specifier which allows
to print small buffers as a hex string.

Signed-off-by: Andy Shevchenko andriy.shevche...@linux.intel.com
---
 drivers/scsi/qla2xxx/tcm_qla2xxx.c | 4 +---
 1 file changed, 1 insertion(+), 3 deletions(-)

diff --git a/drivers/scsi/qla2xxx/tcm_qla2xxx.c 
b/drivers/scsi/qla2xxx/tcm_qla2xxx.c
index 68fb66fd..c9b2421 100644
--- a/drivers/scsi/qla2xxx/tcm_qla2xxx.c
+++ b/drivers/scsi/qla2xxx/tcm_qla2xxx.c
@@ -1492,9 +1492,7 @@ static int tcm_qla2xxx_check_initiator_node_acl(
 * match the format by tcm_qla2xxx explict ConfigFS NodeACLs.
 */
memset(port_name, 0, 36);
-   snprintf(port_name, 36, %02x:%02x:%02x:%02x:%02x:%02x:%02x:%02x,
-   fc_wwpn[0], fc_wwpn[1], fc_wwpn[2], fc_wwpn[3], fc_wwpn[4],
-   fc_wwpn[5], fc_wwpn[6], fc_wwpn[7]);
+   snprintf(port_name, sizeof(port_name), %8phC, fc_wwpn);
/*
 * Locate our struct se_node_acl either from an explict NodeACL created
 * via ConfigFS, or via running in TPG demo mode.
-- 
1.9.2

--
To unsubscribe from this list: send the line unsubscribe linux-scsi in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH] scsi: remove private hex2bin() implementation

2014-04-29 Thread Andy Shevchenko
The function sas_parse_addr() could be easily substituted by hex2bin() which is
in kernel library code.

Signed-off-by: Andy Shevchenko andriy.shevche...@linux.intel.com
Cc: James E.J. Bottomley james.bottom...@suse.de
Cc: linux-scsi@vger.kernel.org
---
 drivers/scsi/libsas/sas_scsi_host.c | 23 +++
 1 file changed, 7 insertions(+), 16 deletions(-)

diff --git a/drivers/scsi/libsas/sas_scsi_host.c 
b/drivers/scsi/libsas/sas_scsi_host.c
index 25d0f12..03344ad 100644
--- a/drivers/scsi/libsas/sas_scsi_host.c
+++ b/drivers/scsi/libsas/sas_scsi_host.c
@@ -27,6 +27,7 @@
 #include linux/firmware.h
 #include linux/export.h
 #include linux/ctype.h
+#include linux/kernel.h
 
 #include sas_internal.h
 
@@ -1167,21 +1168,6 @@ void sas_target_destroy(struct scsi_target *starget)
sas_put_device(found_dev);
 }
 
-static void sas_parse_addr(u8 *sas_addr, const char *p)
-{
-   int i;
-   for (i = 0; i  SAS_ADDR_SIZE; i++) {
-   u8 h, l;
-   if (!*p)
-   break;
-   h = isdigit(*p) ? *p-'0' : toupper(*p)-'A'+10;
-   p++;
-   l = isdigit(*p) ? *p-'0' : toupper(*p)-'A'+10;
-   p++;
-   sas_addr[i] = (h4) | l;
-   }
-}
-
 #define SAS_STRING_ADDR_SIZE   16
 
 int sas_request_addr(struct Scsi_Host *shost, u8 *addr)
@@ -1198,7 +1184,12 @@ int sas_request_addr(struct Scsi_Host *shost, u8 *addr)
goto out;
}
 
-   sas_parse_addr(addr, fw-data);
+   res = hex2bin(addr, fw-data,
+ min_t(size_t, SAS_ADDR_SIZE, strlen(fw-data)) / 2);
+   if (res) {
+   res = -EINVAL;
+   goto out;
+   }
 
 out:
release_firmware(fw);
-- 
1.9.2

--
To unsubscribe from this list: send the line unsubscribe linux-scsi in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH] scsi: fnic: use kernel's '%pM' format option to print MAC

2014-04-29 Thread Andy Shevchenko
Instead of supplying each byte through stack let's use %pM specifier.

Signed-off-by: Andy Shevchenko andriy.shevche...@linux.intel.com
Cc: Tom Tucker t...@opengridcomputing.com
Cc: Steve Wise sw...@opengridcomputing.com
Cc: linux-r...@vger.kernel.org
---
 drivers/scsi/fnic/vnic_dev.c | 10 ++
 1 file changed, 2 insertions(+), 8 deletions(-)

diff --git a/drivers/scsi/fnic/vnic_dev.c b/drivers/scsi/fnic/vnic_dev.c
index 9795d6f..ba69d61 100644
--- a/drivers/scsi/fnic/vnic_dev.c
+++ b/drivers/scsi/fnic/vnic_dev.c
@@ -499,10 +499,7 @@ void vnic_dev_add_addr(struct vnic_dev *vdev, u8 *addr)
 
err = vnic_dev_cmd(vdev, CMD_ADDR_ADD, a0, a1, wait);
if (err)
-   printk(KERN_ERR
-   Can't add addr [%02x:%02x:%02x:%02x:%02x:%02x], %d\n,
-   addr[0], addr[1], addr[2], addr[3], addr[4], addr[5],
-   err);
+   pr_err(Can't add addr [%pM], %d\n, addr, err);
 }
 
 void vnic_dev_del_addr(struct vnic_dev *vdev, u8 *addr)
@@ -517,10 +514,7 @@ void vnic_dev_del_addr(struct vnic_dev *vdev, u8 *addr)
 
err = vnic_dev_cmd(vdev, CMD_ADDR_DEL, a0, a1, wait);
if (err)
-   printk(KERN_ERR
-   Can't del addr [%02x:%02x:%02x:%02x:%02x:%02x], %d\n,
-   addr[0], addr[1], addr[2], addr[3], addr[4], addr[5],
-   err);
+   pr_err(Can't del addr [%pM], %d\n, addr, err);
 }
 
 int vnic_dev_notify_set(struct vnic_dev *vdev, u16 intr)
-- 
1.9.2

--
To unsubscribe from this list: send the line unsubscribe linux-scsi in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCHv2 0/3] qla2xxx, qla4xxx: re-use %p[hmM] specifiers to print variables

2013-07-25 Thread Andy Shevchenko
We have nice specifiers in the kernel that helps us to simplify printing of the
small buffers (as hexstring) and MAC addresses.

Since v1:
 - rewritten commit messages to reflect changes better
 - append patch 2/3
 - apply ACK to patch 3/3

Andy Shevchenko (1):
  scsi: qla2xxx: print MAC via %pMR

Oleksandr Khoshaba (2):
  scsi: qla2xxx: print some variables via %*phC or %*phN format
  scsi: qla4xxx: print MAC and SID via %p[mM][R]

 drivers/scsi/qla2xxx/qla_attr.c|  5 +-
 drivers/scsi/qla2xxx/qla_bsg.c |  8 +---
 drivers/scsi/qla2xxx/qla_gs.c  | 96 ++
 drivers/scsi/qla2xxx/qla_init.c| 24 ++
 drivers/scsi/qla2xxx/qla_isr.c |  9 +---
 drivers/scsi/qla2xxx/qla_mr.c  | 10 +---
 drivers/scsi/qla2xxx/qla_os.c  | 10 +---
 drivers/scsi/qla2xxx/qla_target.c  | 71 +++-
 drivers/scsi/qla2xxx/tcm_qla2xxx.c | 18 +++
 drivers/scsi/qla4xxx/ql4_mbx.c |  5 +-
 drivers/scsi/qla4xxx/ql4_nx.c  |  8 +---
 drivers/scsi/qla4xxx/ql4_os.c  | 15 ++
 12 files changed, 60 insertions(+), 219 deletions(-)

-- 
1.8.3.2

--
To unsubscribe from this list: send the line unsubscribe linux-scsi in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCHv2 1/3] scsi: qla2xxx: print some variables via %*phC or %*phN format

2013-07-25 Thread Andy Shevchenko
From: Oleksandr Khoshaba oleksandr.khosh...@gmail.com

The patch changes a specifier used to output some variables. Instead of using
stack for each byte the '%*ph[CN]' allows to take a one pointer and prints
entire buffer as a hexadecimal string with the separator ':' or ''.

Signed-off-by: Oleksandr Khoshaba oleksandr.khosh...@gmail.com
---
 drivers/scsi/qla2xxx/qla_bsg.c |  8 +---
 drivers/scsi/qla2xxx/qla_gs.c  | 96 ++
 drivers/scsi/qla2xxx/qla_init.c| 24 ++
 drivers/scsi/qla2xxx/qla_isr.c |  9 +---
 drivers/scsi/qla2xxx/qla_mr.c  | 10 +---
 drivers/scsi/qla2xxx/qla_os.c  | 10 +---
 drivers/scsi/qla2xxx/qla_target.c  | 71 +++-
 drivers/scsi/qla2xxx/tcm_qla2xxx.c | 18 +++
 8 files changed, 52 insertions(+), 194 deletions(-)

diff --git a/drivers/scsi/qla2xxx/qla_bsg.c b/drivers/scsi/qla2xxx/qla_bsg.c
index 417eaad..8e2ac93 100644
--- a/drivers/scsi/qla2xxx/qla_bsg.c
+++ b/drivers/scsi/qla2xxx/qla_bsg.c
@@ -1318,12 +1318,8 @@ qla24xx_iidma(struct fc_bsg_job *bsg_job)
 
if (rval) {
ql_log(ql_log_warn, vha, 0x704c,
-   iIDMA cmd failed for %02x%02x%02x%02x%02x%02x%02x%02x -- 
-   %04x %x %04x %04x.\n, fcport-port_name[0],
-   fcport-port_name[1], fcport-port_name[2],
-   fcport-port_name[3], fcport-port_name[4],
-   fcport-port_name[5], fcport-port_name[6],
-   fcport-port_name[7], rval, fcport-fp_speed, mb[0], mb[1]);
+   iIDMA cmd failed for %8phN -- %04x %x %04x %04x.\n,
+   fcport-port_name, rval, fcport-fp_speed, mb[0], mb[1]);
rval = (DID_ERROR  16);
} else {
if (!port_param-mode) {
diff --git a/drivers/scsi/qla2xxx/qla_gs.c b/drivers/scsi/qla2xxx/qla_gs.c
index 0926451..0890c3a 100644
--- a/drivers/scsi/qla2xxx/qla_gs.c
+++ b/drivers/scsi/qla2xxx/qla_gs.c
@@ -226,17 +226,8 @@ qla2x00_ga_nxt(scsi_qla_host_t *vha, fc_port_t *fcport)
fcport-d_id.b.domain = 0xf0;
 
ql_dbg(ql_dbg_disc, vha, 0x2063,
-   GA_NXT entry - nn %02x%02x%02x%02x%02x%02x%02x%02x 
-   pn %02x%02x%02x%02x%02x%02x%02x%02x 
-   port_id=%02x%02x%02x.\n,
-   fcport-node_name[0], fcport-node_name[1],
-   fcport-node_name[2], fcport-node_name[3],
-   fcport-node_name[4], fcport-node_name[5],
-   fcport-node_name[6], fcport-node_name[7],
-   fcport-port_name[0], fcport-port_name[1],
-   fcport-port_name[2], fcport-port_name[3],
-   fcport-port_name[4], fcport-port_name[5],
-   fcport-port_name[6], fcport-port_name[7],
+   GA_NXT entry - nn %8phN pn %8phN port_id=%02x%02x%02x.\n,
+   fcport-node_name, fcport-port_name,
fcport-d_id.b.domain, fcport-d_id.b.area,
fcport-d_id.b.al_pa);
}
@@ -447,17 +438,8 @@ qla2x00_gnn_id(scsi_qla_host_t *vha, sw_info_t *list)
ct_rsp-rsp.gnn_id.node_name, WWN_SIZE);
 
ql_dbg(ql_dbg_disc, vha, 0x2058,
-   GID_PT entry - nn %02x%02x%02x%02x%02x%02x%02X%02x 

-   pn %02x%02x%02x%02x%02x%02x%02X%02x 
-   portid=%02x%02x%02x.\n,
-   list[i].node_name[0], list[i].node_name[1],
-   list[i].node_name[2], list[i].node_name[3],
-   list[i].node_name[4], list[i].node_name[5],
-   list[i].node_name[6], list[i].node_name[7],
-   list[i].port_name[0], list[i].port_name[1],
-   list[i].port_name[2], list[i].port_name[3],
-   list[i].port_name[4], list[i].port_name[5],
-   list[i].port_name[6], list[i].port_name[7],
+   GID_PT entry - nn %8phN pn %8phN 
portid=%02x%02x%02x.\n,
+   list[i].node_name, list[i].port_name,
list[i].d_id.b.domain, list[i].d_id.b.area,
list[i].d_id.b.al_pa);
}
@@ -796,17 +778,8 @@ qla2x00_sns_ga_nxt(scsi_qla_host_t *vha, fc_port_t *fcport)
fcport-d_id.b.domain = 0xf0;
 
ql_dbg(ql_dbg_disc, vha, 0x2061,
-   GA_NXT entry - nn %02x%02x%02x%02x%02x%02x%02x%02x 
-   pn %02x%02x%02x%02x%02x%02x%02x%02x 
-   port_id=%02x%02x%02x.\n,
-   fcport-node_name[0], fcport-node_name[1],
-   fcport-node_name[2], fcport-node_name[3],
-   fcport-node_name[4], fcport-node_name[5],
-   fcport-node_name[6], fcport-node_name[7],
-   fcport-port_name[0], 

[PATCHv2 2/3] scsi: qla2xxx: print MAC via %pMR

2013-07-25 Thread Andy Shevchenko
Signed-off-by: Andy Shevchenko andriy.shevche...@linux.intel.com
---
 drivers/scsi/qla2xxx/qla_attr.c | 5 +
 1 file changed, 1 insertion(+), 4 deletions(-)

diff --git a/drivers/scsi/qla2xxx/qla_attr.c b/drivers/scsi/qla2xxx/qla_attr.c
index d7a99ae..f925f07 100644
--- a/drivers/scsi/qla2xxx/qla_attr.c
+++ b/drivers/scsi/qla2xxx/qla_attr.c
@@ -1265,10 +1265,7 @@ qla2x00_vn_port_mac_address_show(struct device *dev,
if (!IS_CNA_CAPABLE(vha-hw))
return snprintf(buf, PAGE_SIZE, \n);
 
-   return snprintf(buf, PAGE_SIZE, %02x:%02x:%02x:%02x:%02x:%02x\n,
-   vha-fcoe_vn_port_mac[5], vha-fcoe_vn_port_mac[4],
-   vha-fcoe_vn_port_mac[3], vha-fcoe_vn_port_mac[2],
-   vha-fcoe_vn_port_mac[1], vha-fcoe_vn_port_mac[0]);
+   return snprintf(buf, PAGE_SIZE, %pMR\n, vha-fcoe_vn_port_mac);
 }
 
 static ssize_t
-- 
1.8.3.2

--
To unsubscribe from this list: send the line unsubscribe linux-scsi in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCHv2 3/3] scsi: qla4xxx: print MAC and SID via %p[mM][R]

2013-07-25 Thread Andy Shevchenko
From: Oleksandr Khoshaba oleksandr.khosh...@gmail.com

In the kernel we have nice specifier to print MAC by given pointer to the
address in binary form.

Signed-off-by: Oleksandr Khoshaba oleksandr.khosh...@gmail.com
Acked-by: Vikas Chaudhary vikas.chaudh...@qlogic.com
---
 drivers/scsi/qla4xxx/ql4_mbx.c |  5 +
 drivers/scsi/qla4xxx/ql4_nx.c  |  8 ++--
 drivers/scsi/qla4xxx/ql4_os.c  | 15 ---
 3 files changed, 7 insertions(+), 21 deletions(-)

diff --git a/drivers/scsi/qla4xxx/ql4_mbx.c b/drivers/scsi/qla4xxx/ql4_mbx.c
index a501bea..f01b8ae 100644
--- a/drivers/scsi/qla4xxx/ql4_mbx.c
+++ b/drivers/scsi/qla4xxx/ql4_mbx.c
@@ -1837,10 +1837,7 @@ int qla4xxx_set_param_ddbentry(struct scsi_qla_host *ha,
ptid = (uint16_t *)fw_ddb_entry-isid[1];
*ptid = cpu_to_le16((uint16_t)ddb_entry-sess-target_id);
 
-   DEBUG2(ql4_printk(KERN_INFO, ha, ISID [%02x%02x%02x%02x%02x%02x]\n,
- fw_ddb_entry-isid[5], fw_ddb_entry-isid[4],
- fw_ddb_entry-isid[3], fw_ddb_entry-isid[2],
- fw_ddb_entry-isid[1], fw_ddb_entry-isid[0]));
+   DEBUG2(ql4_printk(KERN_INFO, ha, ISID [%pmR]\n, fw_ddb_entry-isid));
 
iscsi_opts = le16_to_cpu(fw_ddb_entry-iscsi_options);
memset(fw_ddb_entry-iscsi_alias, 0, sizeof(fw_ddb_entry-iscsi_alias));
diff --git a/drivers/scsi/qla4xxx/ql4_nx.c b/drivers/scsi/qla4xxx/ql4_nx.c
index eaf00c1..2bc1046 100644
--- a/drivers/scsi/qla4xxx/ql4_nx.c
+++ b/drivers/scsi/qla4xxx/ql4_nx.c
@@ -3455,12 +3455,8 @@ int qla4_8xxx_get_sys_info(struct scsi_qla_host *ha)
ha-phy_port_num = sys_info-port_num;
ha-iscsi_pci_func_cnt = sys_info-iscsi_pci_func_cnt;
 
-   DEBUG2(printk(scsi%ld: %s: 
-   mac %02x:%02x:%02x:%02x:%02x:%02x 
-   serial %s\n, ha-host_no, __func__,
-   ha-my_mac[0], ha-my_mac[1], ha-my_mac[2],
-   ha-my_mac[3], ha-my_mac[4], ha-my_mac[5],
-   ha-serial_number));
+   DEBUG2(printk(scsi%ld: %s: mac %pM serial %s\n, ha-host_no,
+   __func__, ha-my_mac, ha-serial_number));
 
status = QLA_SUCCESS;
 
diff --git a/drivers/scsi/qla4xxx/ql4_os.c b/drivers/scsi/qla4xxx/ql4_os.c
index b246b3c..2797b8f 100644
--- a/drivers/scsi/qla4xxx/ql4_os.c
+++ b/drivers/scsi/qla4xxx/ql4_os.c
@@ -4786,13 +4786,9 @@ static int qla4xxx_compare_tuple_ddb(struct 
scsi_qla_host *ha,
 * ISID would not match firmware generated ISID.
 */
if (is_isid_compare) {
-   DEBUG2(ql4_printk(KERN_INFO, ha, %s: old ISID [%02x%02x%02x
-   %02x%02x%02x] New ISID [%02x%02x%02x%02x%02x%02x]\n,
-   __func__, old_tddb-isid[5], old_tddb-isid[4],
-   old_tddb-isid[3], old_tddb-isid[2], old_tddb-isid[1],
-   old_tddb-isid[0], new_tddb-isid[5], new_tddb-isid[4],
-   new_tddb-isid[3], new_tddb-isid[2], new_tddb-isid[1],
-   new_tddb-isid[0]));
+   DEBUG2(ql4_printk(KERN_INFO, ha,
+   %s: old ISID [%pmR] New ISID [%pmR]\n,
+   __func__, old_tddb-isid, new_tddb-isid));
 
if (memcmp(old_tddb-isid[0], new_tddb-isid[0],
   sizeof(old_tddb-isid)))
@@ -6211,10 +6207,7 @@ qla4xxx_sysfs_ddb_get_param(struct 
iscsi_bus_flash_session *fnode_sess,
rc = sprintf(buf, %u\n, fnode_conn-keepalive_timeout);
break;
case ISCSI_FLASHNODE_ISID:
-   rc = sprintf(buf, %02x%02x%02x%02x%02x%02x\n,
-fnode_sess-isid[0], fnode_sess-isid[1],
-fnode_sess-isid[2], fnode_sess-isid[3],
-fnode_sess-isid[4], fnode_sess-isid[5]);
+   rc = sprintf(buf, %pm\n, fnode_sess-isid);
break;
case ISCSI_FLASHNODE_TSID:
rc = sprintf(buf, %u\n, fnode_sess-tsid);
-- 
1.8.3.2

--
To unsubscribe from this list: send the line unsubscribe linux-scsi in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH 2/2] scsi: qla2xxx: change some variables to hexadecimal string via %*phN format

2013-07-10 Thread Andy Shevchenko
[ - bunch of QLogic people from Cc list, I don't know why you put them
there, but I think my comments are not to bother people personally,
so, I left few and SCSI ML]

First of all, didn't you notice the
http://www.spinics.net/lists/linux-scsi/msg66798.html ?
I think there is subject is wrong a bit and this patch either should
be combined with that one, or goes after.
I'm sorry for this little mess, Oleksandr is newbie in the community,
I'm kinda a mentor to him.

Also, comment below.

On Wed, Jul 10, 2013 at 2:13 PM, Saurav Kashyap
saurav.kash...@qlogic.com wrote:
 HI Oleksandr,
 Thanks for the patch. In the below patch couple of lines exceed 80 characters.

I think is quite okay to combine string literals to long lines since
checkpatch.pl recommends to do so.
What is your opinion?

--
With Best Regards,
Andy Shevchenko
--
To unsubscribe from this list: send the line unsubscribe linux-scsi in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH V2] scsi: replace strict_strtoul() with kstrtoul()

2013-06-03 Thread Andy Shevchenko
On Mon, Jun 3, 2013 at 12:06 PM, Jingoo Han jg1@samsung.com wrote:
 The usage of strict_strtoul() is not preferred, because
 strict_strtoul() is obsolete. Thus, kstrtoul() should be
 used.

 Signed-off-by: Jingoo Han jg1@samsung.com

Reviewed-by: Andy Shevchenko andriy.shevche...@linux.intel.com

 ---
 Changes since v1:
 - Used return code from kstrtoul().

  drivers/scsi/pmcraid.c|6 --
  drivers/scsi/scsi_sysfs.c |6 --
  2 files changed, 8 insertions(+), 4 deletions(-)

 diff --git a/drivers/scsi/pmcraid.c b/drivers/scsi/pmcraid.c
 index 8e1b737..39b42a4 100644
 --- a/drivers/scsi/pmcraid.c
 +++ b/drivers/scsi/pmcraid.c
 @@ -4203,9 +4203,11 @@ static ssize_t pmcraid_store_log_level(
 struct Scsi_Host *shost;
 struct pmcraid_instance *pinstance;
 unsigned long val;
 +   int ret;

 -   if (strict_strtoul(buf, 10, val))
 -   return -EINVAL;
 +   ret = kstrtoul(buf, 10, val);
 +   if (ret)
 +   return ret;
 /* log-level should be from 0 to 2 */
 if (val  2)
 return -EINVAL;
 diff --git a/drivers/scsi/scsi_sysfs.c b/drivers/scsi/scsi_sysfs.c
 index 931a7d9..4a8b675 100644
 --- a/drivers/scsi/scsi_sysfs.c
 +++ b/drivers/scsi/scsi_sysfs.c
 @@ -789,9 +789,11 @@ sdev_store_queue_ramp_up_period(struct device *dev,
  {
 struct scsi_device *sdev = to_scsi_device(dev);
 unsigned long period;
 +   int ret;

 -   if (strict_strtoul(buf, 10, period))
 -   return -EINVAL;
 +   ret = kstrtoul(buf, 10, period);
 +   if (ret)
 +   return ret;

 sdev-queue_ramp_up_period = msecs_to_jiffies(period);
 return period;
 --
 1.7.10.4





--
With Best Regards,
Andy Shevchenko
--
To unsubscribe from this list: send the line unsubscribe linux-scsi in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH] scsi: replace strict_strtoul() with kstrtoul()

2013-06-02 Thread Andy Shevchenko
On Sat, Jun 1, 2013 at 10:29 AM, Jingoo Han jg1@samsung.com wrote:
 The usage of strict_strtoul() is not preferred, because
 strict_strtoul() is obsolete. Thus, kstrtoul() should be
 used.

 --- a/drivers/scsi/pmcraid.c
 +++ b/drivers/scsi/pmcraid.c
 @@ -4204,7 +4204,7 @@ static ssize_t pmcraid_store_log_level(
 struct pmcraid_instance *pinstance;
 unsigned long val;

 -   if (strict_strtoul(buf, 10, val))
 +   if (kstrtoul(buf, 10, val))
 return -EINVAL;
 /* log-level should be from 0 to 2 */
 if (val  2)

int ret;

ret = kstrtoul(...);
if (ret)
 return ret;

 diff --git a/drivers/scsi/scsi_sysfs.c b/drivers/scsi/scsi_sysfs.c
 index 931a7d9..bf36b45 100644
 --- a/drivers/scsi/scsi_sysfs.c
 +++ b/drivers/scsi/scsi_sysfs.c
 @@ -790,7 +790,7 @@ sdev_store_queue_ramp_up_period(struct device *dev,
 struct scsi_device *sdev = to_scsi_device(dev);
 unsigned long period;

 -   if (strict_strtoul(buf, 10, period))
 +   if (kstrtoul(buf, 10, period))
 return -EINVAL;

Ditto.

--
With Best Regards,
Andy Shevchenko
--
To unsubscribe from this list: send the line unsubscribe linux-scsi in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH 2/2] scsi: qla2xxx: print MAC via %pMR

2013-05-28 Thread Andy Shevchenko
On Thu, 2012-07-26 at 08:23 -0400, Chad Dupuis wrote: 
 
 On Thu, 12 Jul 2012, Andy Shevchenko wrote:
 
  Signed-off-by: Andy Shevchenko andriy.shevche...@linux.intel.com
  ---
  drivers/scsi/qla2xxx/qla_attr.c |5 +
  1 file changed, 1 insertion(+), 4 deletions(-)
 
  diff --git a/drivers/scsi/qla2xxx/qla_attr.c 
  b/drivers/scsi/qla2xxx/qla_attr.c
  index 5ab9530..095ba85 100644
  --- a/drivers/scsi/qla2xxx/qla_attr.c
  +++ b/drivers/scsi/qla2xxx/qla_attr.c
  @@ -1193,10 +1193,7 @@ qla2x00_vn_port_mac_address_show(struct device *dev,
if (!IS_CNA_CAPABLE(vha-hw))
return snprintf(buf, PAGE_SIZE, \n);
 
  - return snprintf(buf, PAGE_SIZE, %02x:%02x:%02x:%02x:%02x:%02x\n,
  - vha-fcoe_vn_port_mac[5], vha-fcoe_vn_port_mac[4],
  - vha-fcoe_vn_port_mac[3], vha-fcoe_vn_port_mac[2],
  - vha-fcoe_vn_port_mac[1], vha-fcoe_vn_port_mac[0]);
  + return snprintf(buf, PAGE_SIZE, %pMR\n, vha-fcoe_vn_port_mac);
  }
 
  static ssize_t
 
 
 Acked-by: Chad Dupuis chad.dup...@qlogic.com


James, do you have any comments on this patch and patch 1/2?

-- 
Andy Shevchenko andriy.shevche...@linux.intel.com
Intel Finland Oy
--
To unsubscribe from this list: send the line unsubscribe linux-scsi in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH] fusion: print lan address via %pMR

2013-05-28 Thread Andy Shevchenko

On Thu, 2012-07-12 at 10:55 +0300, Andy Shevchenko wrote: 
 Signed-off-by: Andy Shevchenko andriy.shevche...@linux.intel.com
 ---
  drivers/message/fusion/mptbase.c |   14 --
  1 file changed, 4 insertions(+), 10 deletions(-)
 
 diff --git a/drivers/message/fusion/mptbase.c 
 b/drivers/message/fusion/mptbase.c
 index d99db56..d202f25 100644
 --- a/drivers/message/fusion/mptbase.c
 +++ b/drivers/message/fusion/mptbase.c
 @@ -2562,10 +2562,7 @@ mpt_do_ioc_recovery(MPT_ADAPTER *ioc, u32 reason, int 
 sleepFlag)
   (void) GetLanConfigPages(ioc);
   a = 
 (u8*)ioc-lan_cnfg_page1.HardwareAddressLow;
   dprintk(ioc, printk(MYIOC_s_DEBUG_FMT
 - LanAddr = %02X:%02X:%02X
 - :%02X:%02X:%02X\n,
 - ioc-name, a[5], a[4],
 - a[3], a[2], a[1], a[0]));
 + LanAddr = %pMR\n, ioc-name, a));
   }
   break;
  
 @@ -6785,8 +6782,7 @@ static int mpt_iocinfo_proc_show(struct seq_file *m, 
 void *v)
   if (ioc-bus_type == FC) {
   if (ioc-pfacts[p].ProtocolFlags  
 MPI_PORTFACTS_PROTOCOL_LAN) {
   u8 *a = 
 (u8*)ioc-lan_cnfg_page1.HardwareAddressLow;
 - seq_printf(m, LanAddr = 
 %02X:%02X:%02X:%02X:%02X:%02X\n,
 - a[5], a[4], a[3], a[2], a[1], 
 a[0]);
 + seq_printf(m, LanAddr = %pMR\n, a);
   }
   seq_printf(m, WWN = %08X%08X:%08X%08X\n,
   ioc-fc_port_page0[p].WWNN.High,
 @@ -6863,8 +6859,7 @@ mpt_print_ioc_summary(MPT_ADAPTER *ioc, char *buffer, 
 int *size, int len, int sh
  
   if (showlan  (ioc-pfacts[0].ProtocolFlags  
 MPI_PORTFACTS_PROTOCOL_LAN)) {
   u8 *a = (u8*)ioc-lan_cnfg_page1.HardwareAddressLow;
 - y += sprintf(buffer+len+y, , 
 LanAddr=%02X:%02X:%02X:%02X:%02X:%02X,
 - a[5], a[4], a[3], a[2], a[1], a[0]);
 + y += sprintf(buffer+len+y, , LanAddr=%pMR, a);
   }
  
   y += sprintf(buffer+len+y, , IRQ=%d, ioc-pci_irq);
 @@ -6897,8 +6892,7 @@ static void seq_mpt_print_ioc_summary(MPT_ADAPTER *ioc, 
 struct seq_file *m, int
  
   if (showlan  (ioc-pfacts[0].ProtocolFlags  
 MPI_PORTFACTS_PROTOCOL_LAN)) {
   u8 *a = (u8*)ioc-lan_cnfg_page1.HardwareAddressLow;
 - seq_printf(m, , LanAddr=%02X:%02X:%02X:%02X:%02X:%02X,
 - a[5], a[4], a[3], a[2], a[1], a[0]);
 + seq_printf(m, , LanAddr=%pMR, a);
   }
  
   seq_printf(m, , IRQ=%d, ioc-pci_irq);

James, do you have any comments on this one?

-- 
Andy Shevchenko andriy.shevche...@linux.intel.com
Intel Finland Oy
--
To unsubscribe from this list: send the line unsubscribe linux-scsi in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH 2/2] scsi: qla2xxx: print MAC via %pMR

2012-07-12 Thread Andy Shevchenko
Signed-off-by: Andy Shevchenko andriy.shevche...@linux.intel.com
---
 drivers/scsi/qla2xxx/qla_attr.c |5 +
 1 file changed, 1 insertion(+), 4 deletions(-)

diff --git a/drivers/scsi/qla2xxx/qla_attr.c b/drivers/scsi/qla2xxx/qla_attr.c
index 5ab9530..095ba85 100644
--- a/drivers/scsi/qla2xxx/qla_attr.c
+++ b/drivers/scsi/qla2xxx/qla_attr.c
@@ -1193,10 +1193,7 @@ qla2x00_vn_port_mac_address_show(struct device *dev,
if (!IS_CNA_CAPABLE(vha-hw))
return snprintf(buf, PAGE_SIZE, \n);
 
-   return snprintf(buf, PAGE_SIZE, %02x:%02x:%02x:%02x:%02x:%02x\n,
-   vha-fcoe_vn_port_mac[5], vha-fcoe_vn_port_mac[4],
-   vha-fcoe_vn_port_mac[3], vha-fcoe_vn_port_mac[2],
-   vha-fcoe_vn_port_mac[1], vha-fcoe_vn_port_mac[0]);
+   return snprintf(buf, PAGE_SIZE, %pMR\n, vha-fcoe_vn_port_mac);
 }
 
 static ssize_t
-- 
1.7.10.4

--
To unsubscribe from this list: send the line unsubscribe linux-scsi in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH 1/2] scsi: use kernel's '%pM' format option to print MAC

2012-07-12 Thread Andy Shevchenko
Signed-off-by: Andy Shevchenko andriy.shevche...@linux.intel.com
Cc: Tom Tucker t...@opengridcomputing.com
Cc: Steve Wise sw...@opengridcomputing.com
Cc: linux-r...@vger.kernel.org
---
 drivers/scsi/fnic/vnic_dev.c  |   10 ++
 drivers/scsi/qla4xxx/ql4_nx.c |8 ++--
 2 files changed, 4 insertions(+), 14 deletions(-)

diff --git a/drivers/scsi/fnic/vnic_dev.c b/drivers/scsi/fnic/vnic_dev.c
index b576be7..0cb8ad0 100644
--- a/drivers/scsi/fnic/vnic_dev.c
+++ b/drivers/scsi/fnic/vnic_dev.c
@@ -499,10 +499,7 @@ void vnic_dev_add_addr(struct vnic_dev *vdev, u8 *addr)
 
err = vnic_dev_cmd(vdev, CMD_ADDR_ADD, a0, a1, wait);
if (err)
-   printk(KERN_ERR
-   Can't add addr [%02x:%02x:%02x:%02x:%02x:%02x], %d\n,
-   addr[0], addr[1], addr[2], addr[3], addr[4], addr[5],
-   err);
+   printk(KERN_ERR Can't add addr [%pM], %d\n, addr, err);
 }
 
 void vnic_dev_del_addr(struct vnic_dev *vdev, u8 *addr)
@@ -517,10 +514,7 @@ void vnic_dev_del_addr(struct vnic_dev *vdev, u8 *addr)
 
err = vnic_dev_cmd(vdev, CMD_ADDR_DEL, a0, a1, wait);
if (err)
-   printk(KERN_ERR
-   Can't del addr [%02x:%02x:%02x:%02x:%02x:%02x], %d\n,
-   addr[0], addr[1], addr[2], addr[3], addr[4], addr[5],
-   err);
+   printk(KERN_ERR Can't del addr [%pM], %d\n, addr, err);
 }
 
 int vnic_dev_notify_set(struct vnic_dev *vdev, u16 intr)
diff --git a/drivers/scsi/qla4xxx/ql4_nx.c b/drivers/scsi/qla4xxx/ql4_nx.c
index 228b670..c163767 100644
--- a/drivers/scsi/qla4xxx/ql4_nx.c
+++ b/drivers/scsi/qla4xxx/ql4_nx.c
@@ -2964,12 +2964,8 @@ int qla4_8xxx_get_sys_info(struct scsi_qla_host *ha)
ha-phy_port_num = sys_info-port_num;
ha-iscsi_pci_func_cnt = sys_info-iscsi_pci_func_cnt;
 
-   DEBUG2(printk(scsi%ld: %s: 
-   mac %02x:%02x:%02x:%02x:%02x:%02x 
-   serial %s\n, ha-host_no, __func__,
-   ha-my_mac[0], ha-my_mac[1], ha-my_mac[2],
-   ha-my_mac[3], ha-my_mac[4], ha-my_mac[5],
-   ha-serial_number));
+   DEBUG2(printk(scsi%ld: %s: mac %pM serial %s\n, ha-host_no, __func__,
+   ha-my_mac, ha-serial_number));
 
status = QLA_SUCCESS;
 
-- 
1.7.10.4

--
To unsubscribe from this list: send the line unsubscribe linux-scsi in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH] fusion: print lan address via %pMR

2012-07-12 Thread Andy Shevchenko
Signed-off-by: Andy Shevchenko andriy.shevche...@linux.intel.com
---
 drivers/message/fusion/mptbase.c |   14 --
 1 file changed, 4 insertions(+), 10 deletions(-)

diff --git a/drivers/message/fusion/mptbase.c b/drivers/message/fusion/mptbase.c
index d99db56..d202f25 100644
--- a/drivers/message/fusion/mptbase.c
+++ b/drivers/message/fusion/mptbase.c
@@ -2562,10 +2562,7 @@ mpt_do_ioc_recovery(MPT_ADAPTER *ioc, u32 reason, int 
sleepFlag)
(void) GetLanConfigPages(ioc);
a = 
(u8*)ioc-lan_cnfg_page1.HardwareAddressLow;
dprintk(ioc, printk(MYIOC_s_DEBUG_FMT
-   LanAddr = %02X:%02X:%02X
-   :%02X:%02X:%02X\n,
-   ioc-name, a[5], a[4],
-   a[3], a[2], a[1], a[0]));
+   LanAddr = %pMR\n, ioc-name, a));
}
break;
 
@@ -6785,8 +6782,7 @@ static int mpt_iocinfo_proc_show(struct seq_file *m, void 
*v)
if (ioc-bus_type == FC) {
if (ioc-pfacts[p].ProtocolFlags  
MPI_PORTFACTS_PROTOCOL_LAN) {
u8 *a = 
(u8*)ioc-lan_cnfg_page1.HardwareAddressLow;
-   seq_printf(m, LanAddr = 
%02X:%02X:%02X:%02X:%02X:%02X\n,
-   a[5], a[4], a[3], a[2], a[1], 
a[0]);
+   seq_printf(m, LanAddr = %pMR\n, a);
}
seq_printf(m, WWN = %08X%08X:%08X%08X\n,
ioc-fc_port_page0[p].WWNN.High,
@@ -6863,8 +6859,7 @@ mpt_print_ioc_summary(MPT_ADAPTER *ioc, char *buffer, int 
*size, int len, int sh
 
if (showlan  (ioc-pfacts[0].ProtocolFlags  
MPI_PORTFACTS_PROTOCOL_LAN)) {
u8 *a = (u8*)ioc-lan_cnfg_page1.HardwareAddressLow;
-   y += sprintf(buffer+len+y, , 
LanAddr=%02X:%02X:%02X:%02X:%02X:%02X,
-   a[5], a[4], a[3], a[2], a[1], a[0]);
+   y += sprintf(buffer+len+y, , LanAddr=%pMR, a);
}
 
y += sprintf(buffer+len+y, , IRQ=%d, ioc-pci_irq);
@@ -6897,8 +6892,7 @@ static void seq_mpt_print_ioc_summary(MPT_ADAPTER *ioc, 
struct seq_file *m, int
 
if (showlan  (ioc-pfacts[0].ProtocolFlags  
MPI_PORTFACTS_PROTOCOL_LAN)) {
u8 *a = (u8*)ioc-lan_cnfg_page1.HardwareAddressLow;
-   seq_printf(m, , LanAddr=%02X:%02X:%02X:%02X:%02X:%02X,
-   a[5], a[4], a[3], a[2], a[1], a[0]);
+   seq_printf(m, , LanAddr=%pMR, a);
}
 
seq_printf(m, , IRQ=%d, ioc-pci_irq);
-- 
1.7.10.4

--
To unsubscribe from this list: send the line unsubscribe linux-scsi in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html