All of lore.kernel.org
 help / color / mirror / Atom feed
From: anarsoul@gmail.com (Vasily Khoruzhick)
To: linux-arm-kernel@lists.infradead.org
Subject: [PATCH v2 1/5] ARM: PXA: Add z2-usb-switch driver
Date: Mon, 29 Oct 2012 01:27:42 +0300	[thread overview]
Message-ID: <CA+E=qVdEPcBobVDODcyjZkbhZD6KXmGR7Fo5T40GRSPWNhujsQ@mail.gmail.com> (raw)
In-Reply-To: <201210282257.48770.marex@denx.de>

On Mon, Oct 29, 2012 at 12:57 AM, Marek Vasut <marex@denx.de> wrote:
> Dear Vasily Khoruzhick,

Dear Marek Vasut,

>> This driver controls mode of USB port #2 pins - device or host.
>
> Please supply proper commit message. This short message describes nothing.

OK, "This driver allows user to choose USB port #2 mode between device
and host" - that would be OK?

> [...]
>
>> @@ -0,0 +1,100 @@
>> +/*
>> + * USB mode switcher for Z2
>> + *
>> + * Copyright (c) 2011 Vasily Khoruzhick
>
> 2012

Actually, it was implemented early in 2011, so 2011-2012

>> + * This program is free software; you can redistribute it and/or modify
>> + * it under the terms of the GNU General Public License version 2 as
>> + * published by the Free Software Foundation.
>> + *
>> + */
>> +
>> +#include <linux/kernel.h>
>> +#include <linux/module.h>
>> +#include <linux/platform_device.h>
>> +#include <linux/delay.h>
>> +
>> +#include <mach/pxa27x.h>
>> +#include <mach/pxa27x-udc.h>
>> +
>> +#include <asm/io.h>
>> +
>> +#define MIN(a, b) ((a) < (b) ? (a) : (b))
>
> min() is already defined in kernel.h

OK

>> +static ssize_t usb_mode_show(struct device *dev, struct device_attribute
>> *attr, +      char *buf)
>> +{
>> +     if (UP2OCR & UP2OCR_HXS)
>> +             return sprintf(buf, "host\n");
>> +     else
>> +             return sprintf(buf, "device\n");
>> +}
>> +
>> +static ssize_t usb_mode_set(struct device *dev, struct device_attribute
>> *attr, +      const char *buf, size_t count)
>> +{
>> +     if (strncmp(buf, "host", MIN(count, 4)) == 0) {
>> +             UP2OCR = UP2OCR_HXS | UP2OCR_HXOE | UP2OCR_DPPDE | UP2OCR_DMPDE;
>> +             return count;
>> +     } else if (strncmp(buf, "device", MIN(count, 6)) == 0) {
>> +             UP2OCR = UP2OCR_HXOE | UP2OCR_DPPUE;
>> +             return count;
>> +     }
>> +     return -EINVAL;
>> +}
>> +
>> +static DEVICE_ATTR(usb_mode, 0644, usb_mode_show, usb_mode_set);
>
> I wonder if we have no better means to control enforcement of mode.

Why? sysfs fits nicely.

>> +static const struct attribute *attrs[] = {
>> +     &dev_attr_usb_mode.attr,
>> +     NULL,
>> +};
>> +
>> +static const struct attribute_group attr_group = {
>> +     .attrs  = (struct attribute **)attrs,
>> +};
>
> Isn't there some macro to do this assignment?

Will check

>> +static int z2_usb_switch_probe(struct platform_device *dev)
>
> Missing __devinit

OK

>> +{
>> +     int res;
>> +
>> +     res = sysfs_create_group(&dev->dev.kobj, &attr_group);
>> +     if (res)
>> +             return res;
>> +
>> +     UP2OCR = UP2OCR_HXOE | UP2OCR_DPPUE;
>> +
>> +     return 0;
>> +}
>> +
>> +static int __devexit z2_usb_switch_remove(struct platform_device *dev)
>> +{
>> +     UP2OCR = UP2OCR_HXOE;
>> +     sysfs_remove_group(&dev->dev.kobj, &attr_group);
>> +
>> +     return 0;
>> +}
>> +
>> +static struct platform_driver z2_usb_switch_driver = {
>> +     .probe = z2_usb_switch_probe,
>> +     .remove = __devexit_p(z2_usb_switch_remove),
>> +
>> +     .driver = {
>> +             .name = "z2-usb-switch",
>> +             .owner = THIS_MODULE,
>> +     },
>> +};
>> +
>> +
>> +static int __init z2_usb_switch_init(void)
>> +{
>> +     return platform_driver_register(&z2_usb_switch_driver);
>> +}
>> +
>> +static void __exit z2_usb_switch_exit(void)
>> +{
>> +     platform_driver_unregister(&z2_usb_switch_driver);
>> +}
>> +
>> +module_init(z2_usb_switch_init);
>> +module_exit(z2_usb_switch_exit);
>
> module_platform_driver()

OK

> Best regards,
> Marek Vasut

Thanks for review!

Regards
Vasily

  reply	other threads:[~2012-10-28 22:27 UTC|newest]

Thread overview: 43+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-10-28 15:35 [PATCH 1/5] ARM: PXA: Add z2-usb-switch driver Vasily Khoruzhick
2012-10-28 15:35 ` [PATCH 2/5] ARM: PXA: Zipit Z2: Add USB host and device support Vasily Khoruzhick
2012-10-28 21:59   ` Marek Vasut
2012-10-28 22:38     ` Vasily Khoruzhick
2012-10-28 22:43       ` Marek Vasut
2012-10-28 22:58       ` Daniel Mack
2012-10-29  9:33         ` Vasily Khoruzhick
2012-10-29  9:42           ` Daniel Mack
2012-10-29 10:07             ` Vasily Khoruzhick
2012-10-29 10:22               ` Marek Vasut
2012-10-29 10:26                 ` Vasily Khoruzhick
2012-10-29 10:44               ` Daniel Mack
2012-10-29 10:52                 ` Vasily Khoruzhick
2012-10-29 11:00                   ` Daniel Mack
2012-10-29 11:12                     ` Vasily Khoruzhick
2012-10-29 11:14                       ` Daniel Mack
2012-10-30 20:01                         ` Vasily Khoruzhick
2012-10-30 20:05                           ` Daniel Mack
2012-10-30 21:20                             ` Vasily Khoruzhick
2012-10-31 14:00                             ` Haojian Zhuang
2012-10-31 15:31                             ` Haojian Zhuang
2012-11-02 20:52                               ` Vasily Khoruzhick
2012-11-02 21:29                               ` Vasily Khoruzhick
2012-11-05 17:31                                 ` Vasily Khoruzhick
2012-12-04  8:30                                   ` Haojian Zhuang
2012-10-29 10:48               ` Daniel Mack
2012-10-28 15:35 ` [PATCH 3/5] ARM: PXA: Zipit Z2: Fix oops in z2_power_off Vasily Khoruzhick
2012-10-28 15:35 ` [PATCH 4/5] ARM: PXA: Zipit Z2: Change active_state of power button Vasily Khoruzhick
2012-10-28 22:01   ` Marek Vasut
2012-10-28 22:31     ` mark at engine12.com
2012-10-28 15:35 ` [PATCH 5/5] ARM: PXA: Zipit Z2: Fix backlight PWM device number Vasily Khoruzhick
2012-10-28 22:01   ` Marek Vasut
2012-10-28 22:23     ` Vasily Khoruzhick
2012-10-28 22:39       ` Marek Vasut
2012-10-28 15:39 ` [PATCH 1/5] ARM: PXA: Add z2-usb-switch driver Vasily Khoruzhick
2012-10-28 15:42   ` [PATCH v2 " Vasily Khoruzhick
2012-10-28 17:03     ` Marko Katić
2012-10-28 18:12       ` Vasily Khoruzhick
2012-10-28 21:57     ` Marek Vasut
2012-10-28 22:27       ` Vasily Khoruzhick [this message]
2012-10-28 22:38         ` Marek Vasut
2012-10-28 22:45           ` Vasily Khoruzhick
2012-10-28 22:48             ` Marek Vasut

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to='CA+E=qVdEPcBobVDODcyjZkbhZD6KXmGR7Fo5T40GRSPWNhujsQ@mail.gmail.com' \
    --to=anarsoul@gmail.com \
    --cc=linux-arm-kernel@lists.infradead.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is 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.