lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <e2048f92-c9fe-08a2-6ae4-909555988b23@denx.de>
Date:   Fri, 21 Dec 2018 03:03:08 +0100
From:   Marek Vasut <marex@...x.de>
To:     Tristram.Ha@...rochip.com
Cc:     vivien.didelot@...oirfairelinux.com, UNGLinuxDriver@...rochip.com,
        netdev@...r.kernel.org, sergio.paracuellos@...il.com,
        andrew@...n.ch, dan.carpenter@...cle.com, pavel@....cz,
        f.fainelli@...il.com
Subject: Re: [PATCH v1 net-next] net: dsa: microchip: add KSZ9477 I2C driver

On 12/21/2018 01:48 AM, Tristram.Ha@...rochip.com wrote:
>>>> Well, I just did 'git grep regmap_i2c drivers' and 'git grep regmap_spi
>>>> drivers/' and found eg.
>>>> drivers/iio/pressure/zpa2326_i2c.c
>>>> drivers/iio/pressure/zpa2326_spi.c
>>>>
>>>> There's plenty of drivers using regmap in drivers/ to demonstrate how to
>>>> use it. And there's always include/linux/regmap.h .
>>>>
>>>> In this specific (DSA) case, register either regmap_spi or regmap_i2c in
>>>> the ksz_switch_register(), pop the regmap pointer into ksz_device and
>>>> then use it in ksz_read*()/ksz_write*(). You can then, in a subsequent
>>>> patch, massage the regmap accesses directly into the code instead and
>>>> drop the ksz_read*()/ksz_write*() functions altogether, since those
>>>> would be just regmap function wrappers.
>>>>
>>>> And if you're still lost, I can start on the conversion myself.
>>>
>>> Actually, wait a few hours, I'll try to prepare a regmap patchset.
>>
>> Try this [1], it should be a start. The last two patches might need some
>> adjustments, so please test and let me know how that works (or better
>> yet, provide fixes). Adding i2c regmap should then be trivial :)
>>
>> [1] https://patchwork.ozlabs.org/cover/1016432/
> 
> I did look at the code in regmap_i2c.c and regmap_spi.c.
> 
> So the assumption is there is a regmap_read function that automatically
> maps to regmap_i2c_read or regmap_spi_read depending on the device.

Yes, I just sent a V2 patchset tested on KSZ8795 . It removes over 200
LoC from the KSZ driver. Please test it on KSZ9477 and let me know if it
broke anything -- and ideally, send patch :)

> But the SPI access does not use the register directly.  It has to convert it
> into a special format recognized by the chip.  The size used by SPI is 4, while
> I2C access uses the standard way and the size is 2.

Regmap can handle that too, see the V2 :-)

-- 
Best regards,
Marek Vasut

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ