All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH, resend] pch_phub: re-use native MAC address parser
@ 2013-05-28 15:54 Andy Shevchenko
  2013-06-04 14:03 ` Arnd Bergmann
  0 siblings, 1 reply; 6+ messages in thread
From: Andy Shevchenko @ 2013-05-28 15:54 UTC (permalink / raw)
  To: Arnd Bergmann, Greg Kroah-Hartman, linux-kernel; +Cc: Andy Shevchenko

We have mac_pton() helper to parse MAC addresses.

Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Acked-by: Arnd Bergmann <arnd@arndb.de>
---
 drivers/misc/pch_phub.c | 8 ++------
 1 file changed, 2 insertions(+), 6 deletions(-)

diff --git a/drivers/misc/pch_phub.c b/drivers/misc/pch_phub.c
index 931e635..8b4d4fb 100644
--- a/drivers/misc/pch_phub.c
+++ b/drivers/misc/pch_phub.c
@@ -633,17 +633,13 @@ static ssize_t show_pch_mac(struct device *dev, struct device_attribute *attr,
 static ssize_t store_pch_mac(struct device *dev, struct device_attribute *attr,
 			     const char *buf, size_t count)
 {
-	u8 mac[6];
+	u8 mac[ETH_ALEN];
 	ssize_t rom_size;
 	struct pch_phub_reg *chip = dev_get_drvdata(dev);
 
-	if (count != 18)
+	if (!mac_pton(buf, mac))
 		return -EINVAL;
 
-	sscanf(buf, "%02x:%02x:%02x:%02x:%02x:%02x",
-		(u32 *)&mac[0], (u32 *)&mac[1], (u32 *)&mac[2], (u32 *)&mac[3],
-		(u32 *)&mac[4], (u32 *)&mac[5]);
-
 	chip->pch_phub_extrom_base_address = pci_map_rom(chip->pdev, &rom_size);
 	if (!chip->pch_phub_extrom_base_address)
 		return -ENOMEM;
-- 
1.8.2.rc0.22.gb3600c3


^ permalink raw reply related	[flat|nested] 6+ messages in thread

* Re: [PATCH, resend] pch_phub: re-use native MAC address parser
  2013-05-28 15:54 [PATCH, resend] pch_phub: re-use native MAC address parser Andy Shevchenko
@ 2013-06-04 14:03 ` Arnd Bergmann
  2013-06-04 14:21   ` Andy Shevchenko
  0 siblings, 1 reply; 6+ messages in thread
From: Arnd Bergmann @ 2013-06-04 14:03 UTC (permalink / raw)
  To: Andy Shevchenko; +Cc: Greg Kroah-Hartman, linux-kernel

On Tuesday 28 May 2013, Andy Shevchenko wrote:
> We have mac_pton() helper to parse MAC addresses.
> 
> Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
> Acked-by: Arnd Bergmann <arnd@arndb.de>

Hmm, the patch has appeared in linux-next now, and I'm now getting
randconfig build errors when CONFIG_NET is disabled, since 
mac_pton is undefined then. The easiest solution would be to
make the entire driver "depend on NET".

	Arnd

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCH, resend] pch_phub: re-use native MAC address parser
  2013-06-04 14:03 ` Arnd Bergmann
@ 2013-06-04 14:21   ` Andy Shevchenko
  2013-06-04 14:38     ` Arnd Bergmann
  0 siblings, 1 reply; 6+ messages in thread
From: Andy Shevchenko @ 2013-06-04 14:21 UTC (permalink / raw)
  To: Arnd Bergmann; +Cc: Andy Shevchenko, Greg Kroah-Hartman, linux-kernel

On Tue, Jun 4, 2013 at 5:03 PM, Arnd Bergmann <arnd@arndb.de> wrote:
> On Tuesday 28 May 2013, Andy Shevchenko wrote:
>> We have mac_pton() helper to parse MAC addresses.
>>
>> Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
>> Acked-by: Arnd Bergmann <arnd@arndb.de>
>
> Hmm, the patch has appeared in linux-next now, and I'm now getting
> randconfig build errors when CONFIG_NET is disabled, since
> mac_pton is undefined then.

Thanks for catching this.

> The easiest solution would be to
> make the entire driver "depend on NET".

I don't feel that is good idea. Driver is an abstraction to the ROM,
it doesn't mean you can't read ROM without network framework.
It seems proper solution is to move mac_pton() outside of CONFIG_NET,
though I don't know how to do this easily.

--
With Best Regards,
Andy Shevchenko

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCH, resend] pch_phub: re-use native MAC address parser
  2013-06-04 14:21   ` Andy Shevchenko
@ 2013-06-04 14:38     ` Arnd Bergmann
  2013-06-04 14:57       ` Andy Shevchenko
  0 siblings, 1 reply; 6+ messages in thread
From: Arnd Bergmann @ 2013-06-04 14:38 UTC (permalink / raw)
  To: Andy Shevchenko; +Cc: Andy Shevchenko, Greg Kroah-Hartman, linux-kernel

On Tuesday 04 June 2013 17:21:16 Andy Shevchenko wrote:

> > The easiest solution would be to
> > make the entire driver "depend on NET".
> 
> I don't feel that is good idea. Driver is an abstraction to the ROM,
> it doesn't mean you can't read ROM without network framework.

Right, makes sense.

> It seems proper solution is to move mac_pton() outside of CONFIG_NET,
> though I don't know how to do this easily.

If we want to use it outside of CONFIG_NET, it cannot be part of net/core/*.c.
Maybe we can move the function to lib/mac_pton.c instead and create a
Kconfig symbol that gets selected by CONFIG_NET and by any driver lib
PCH_PHUB that needs it.

	Arnd

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCH, resend] pch_phub: re-use native MAC address parser
  2013-06-04 14:38     ` Arnd Bergmann
@ 2013-06-04 14:57       ` Andy Shevchenko
  2013-06-04 15:12         ` Arnd Bergmann
  0 siblings, 1 reply; 6+ messages in thread
From: Andy Shevchenko @ 2013-06-04 14:57 UTC (permalink / raw)
  To: Arnd Bergmann; +Cc: Andy Shevchenko, Greg Kroah-Hartman, linux-kernel

On Tue, Jun 4, 2013 at 5:38 PM, Arnd Bergmann <arnd@arndb.de> wrote:
> On Tuesday 04 June 2013 17:21:16 Andy Shevchenko wrote:
>
>> > The easiest solution would be to
>> > make the entire driver "depend on NET".
>>
>> I don't feel that is good idea. Driver is an abstraction to the ROM,
>> it doesn't mean you can't read ROM without network framework.
>
> Right, makes sense.
>
>> It seems proper solution is to move mac_pton() outside of CONFIG_NET,
>> though I don't know how to do this easily.
>
> If we want to use it outside of CONFIG_NET, it cannot be part of net/core/*.c.
> Maybe we can move the function to lib/mac_pton.c instead and create a
> Kconfig symbol that gets selected by CONFIG_NET and by any driver lib
> PCH_PHUB that needs it.

Sounds like a solution. Would you like me to implement this?


--
With Best Regards,
Andy Shevchenko

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCH, resend] pch_phub: re-use native MAC address parser
  2013-06-04 14:57       ` Andy Shevchenko
@ 2013-06-04 15:12         ` Arnd Bergmann
  0 siblings, 0 replies; 6+ messages in thread
From: Arnd Bergmann @ 2013-06-04 15:12 UTC (permalink / raw)
  To: Andy Shevchenko; +Cc: Andy Shevchenko, Greg Kroah-Hartman, linux-kernel

On Tuesday 04 June 2013 17:57:38 Andy Shevchenko wrote:
> On Tue, Jun 4, 2013 at 5:38 PM, Arnd Bergmann <arnd@arndb.de> wrote:
> > On Tuesday 04 June 2013 17:21:16 Andy Shevchenko wrote:

> >> It seems proper solution is to move mac_pton() outside of CONFIG_NET,
> >> though I don't know how to do this easily.
> >
> > If we want to use it outside of CONFIG_NET, it cannot be part of net/core/*.c.
> > Maybe we can move the function to lib/mac_pton.c instead and create a
> > Kconfig symbol that gets selected by CONFIG_NET and by any driver lib
> > PCH_PHUB that needs it.
> 
> Sounds like a solution. Would you like me to implement this?

Yes, that would be good.

Thanks,

	Arnd

^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2013-06-04 15:13 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2013-05-28 15:54 [PATCH, resend] pch_phub: re-use native MAC address parser Andy Shevchenko
2013-06-04 14:03 ` Arnd Bergmann
2013-06-04 14:21   ` Andy Shevchenko
2013-06-04 14:38     ` Arnd Bergmann
2013-06-04 14:57       ` Andy Shevchenko
2013-06-04 15:12         ` Arnd Bergmann

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.