Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
L
linux
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Kirill Smelkov
linux
Commits
199d68d4
Commit
199d68d4
authored
Aug 30, 2014
by
Greg Kroah-Hartman
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
greybus: start moving the function types into the greybus core
parent
caaa8a83
Changes
7
Show whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
97 additions
and
47 deletions
+97
-47
drivers/staging/greybus/Makefile
drivers/staging/greybus/Makefile
+1
-2
drivers/staging/greybus/core.c
drivers/staging/greybus/core.c
+24
-0
drivers/staging/greybus/gpio-gb.c
drivers/staging/greybus/gpio-gb.c
+6
-6
drivers/staging/greybus/greybus.h
drivers/staging/greybus/greybus.h
+29
-0
drivers/staging/greybus/i2c-gb.c
drivers/staging/greybus/i2c-gb.c
+25
-22
drivers/staging/greybus/sdio-gb.c
drivers/staging/greybus/sdio-gb.c
+4
-4
drivers/staging/greybus/uart-gb.c
drivers/staging/greybus/uart-gb.c
+8
-13
No files found.
drivers/staging/greybus/Makefile
View file @
199d68d4
greybus-y
:=
core.o gbuf.o
greybus-y
:=
core.o gbuf.o
i2c-gb.o
obj-m
+=
greybus.o
obj-m
+=
i2c-gb.o
obj-m
+=
sdio-gb.o
obj-m
+=
gpio-gb.o
obj-m
+=
uart-gb.o
...
...
drivers/staging/greybus/core.c
View file @
199d68d4
...
...
@@ -149,5 +149,29 @@ void greybus_deregister(struct greybus_driver *driver)
}
EXPORT_SYMBOL_GPL
(
greybus_deregister
);
static
int
new_device
(
struct
greybus_device
*
gdev
,
const
struct
greybus_device_id
*
id
)
{
int
retval
;
/* Allocate all of the different "sub device types" for this device */
retval
=
gb_i2c_probe
(
gdev
,
id
);
return
0
;
}
int
__init
gb_init
(
void
)
{
return
0
;
}
void
__exit
gb_exit
(
void
)
{
}
module_init
(
gb_init
);
module_exit
(
gb_exit
);
MODULE_LICENSE
(
"GPL"
);
MODULE_AUTHOR
(
"Greg Kroah-Hartman <gregkh@linuxfoundation.org>"
);
drivers/staging/greybus/gpio-gb.c
View file @
199d68d4
...
...
@@ -13,7 +13,7 @@
#include <linux/gpio/driver.h>
#include "greybus.h"
struct
gb_gpio
{
struct
gb_gpio
_device
{
struct
gpio_chip
chip
;
struct
greybus_device
*
gdev
;
struct
gpio_chip
*
gpio
;
...
...
@@ -27,7 +27,7 @@ static const struct greybus_device_id id_table[] = {
static
int
direction_input
(
struct
gpio_chip
*
gpio
,
unsigned
nr
)
{
// struct gb_gpio *gb_gpio = container_of(gpio, struct gb_gpio
, chip);
//struct gb_gpio_device *gb_gpio_dev = container_of(gpio, struct gb_gpio_device
, chip);
// FIXME - do something there
return
0
;
...
...
@@ -53,7 +53,7 @@ static void gpio_set(struct gpio_chip *gpio, unsigned nr, int val)
static
int
gpio_gb_probe
(
struct
greybus_device
*
gdev
,
const
struct
greybus_device_id
*
id
)
{
struct
gb_gpio
*
gb_gpio
;
struct
gb_gpio
_device
*
gb_gpio
;
struct
gpio_chip
*
gpio
;
struct
device
*
dev
=
&
gdev
->
dev
;
int
retval
;
...
...
@@ -89,11 +89,11 @@ static int gpio_gb_probe(struct greybus_device *gdev, const struct greybus_devic
static
void
gpio_gb_disconnect
(
struct
greybus_device
*
gdev
)
{
struct
gb_gpio
*
gb_gpio
;
struct
gb_gpio
_device
*
gb_gpio_dev
;
gb_gpio
=
greybus_get_drvdata
(
gdev
);
gb_gpio
_dev
=
greybus_get_drvdata
(
gdev
);
gpiochip_remove
(
&
gb_gpio
->
chip
);
gpiochip_remove
(
&
gb_gpio
_dev
->
chip
);
}
static
struct
greybus_driver
gpio_gb_driver
=
{
...
...
drivers/staging/greybus/greybus.h
View file @
199d68d4
...
...
@@ -72,15 +72,44 @@ struct gbuf {
*/
#define GBUF_FREE_BUFFER BIT(0)
/* Free the transfer buffer with the gbuf */
/* For SP1 hardware, we are going to "hardcode" each device to have all logical
* blocks in order to be able to address them as one unified "unit". Then
* higher up layers will then be able to talk to them as one logical block and
* properly know how they are hooked together (i.e. which i2c port is on the
* same module as the gpio pins, etc.)
*
* So, put the "private" data structures here in greybus.h and link to them off
* of the "main" greybus_device structure.
*/
struct
gb_i2c_device
;
struct
gb_gpio_device
;
struct
gb_sdio_host
;
struct
gb_tty
;
struct
gb_usb_device
;
struct
greybus_device
{
struct
device
dev
;
struct
greybus_descriptor
descriptor
;
int
num_cport
;
struct
cport
cport
[
0
];
struct
gb_i2c_device
*
gb_i2c_dev
;
struct
gb_gpio_device
*
gb_gpio_dev
;
struct
gb_sdio_host
*
gb_sdio_host
;
struct
gb_tty
*
gb_tty
;
struct
gb_usb_device
*
gb_usb_dev
;
};
#define to_greybus_device(d) container_of(d, struct greybus_device, dev)
/*
* Because we are allocating a data structure per "type" in the greybus device,
* we have static functions for this, not "dynamic" drivers like we really
* should in the end.
*/
int
gb_i2c_probe
(
struct
greybus_device
*
gdev
,
const
struct
greybus_device_id
*
id
);
void
gb_i2c_disconnect
(
struct
greybus_device
*
gdev
);
struct
gbuf
*
greybus_alloc_gbuf
(
struct
greybus_device
*
gdev
,
struct
cport
*
cport
,
...
...
drivers/staging/greybus/i2c-gb.c
View file @
199d68d4
...
...
@@ -12,7 +12,7 @@
#include <linux/i2c.h>
#include "greybus.h"
struct
i2c_gb_data
{
struct
gb_i2c_device
{
struct
i2c_adapter
*
adapter
;
struct
greybus_device
*
gdev
;
};
...
...
@@ -32,11 +32,11 @@ static s32 i2c_gb_access(struct i2c_adapter *adap, u16 addr,
unsigned
short
flags
,
char
read_write
,
u8
command
,
int
size
,
union
i2c_smbus_data
*
data
)
{
struct
i2c_gb_data
*
i2c_gb_data
;
struct
gb_i2c_device
*
i2c_gb_dev
;
struct
greybus_device
*
gdev
;
i2c_gb_d
ata
=
i2c_get_adapdata
(
adap
);
gdev
=
i2c_gb_d
ata
->
gdev
;
i2c_gb_d
ev
=
i2c_get_adapdata
(
adap
);
gdev
=
i2c_gb_d
ev
->
gdev
;
// FIXME - do the actual work of sending a i2c message here...
switch
(
size
)
{
...
...
@@ -75,22 +75,23 @@ static const struct i2c_algorithm smbus_algorithm = {
.
functionality
=
i2c_gb_func
,
};
static
int
i2c_gb_probe
(
struct
greybus_device
*
gdev
,
const
struct
greybus_device_id
*
id
)
int
gb_i2c_probe
(
struct
greybus_device
*
gdev
,
const
struct
greybus_device_id
*
id
)
{
struct
i2c_gb_data
*
i2c_gb_data
;
struct
gb_i2c_device
*
i2c_gb_dev
;
struct
i2c_adapter
*
adapter
;
int
retval
;
i2c_gb_d
ata
=
kzalloc
(
sizeof
(
*
i2c_gb_data
),
GFP_KERNEL
);
if
(
!
i2c_gb_d
ata
)
i2c_gb_d
ev
=
kzalloc
(
sizeof
(
*
i2c_gb_dev
),
GFP_KERNEL
);
if
(
!
i2c_gb_d
ev
)
return
-
ENOMEM
;
adapter
=
kzalloc
(
sizeof
(
*
adapter
),
GFP_KERNEL
);
if
(
!
adapter
)
{
kfree
(
i2c_gb_d
ata
);
kfree
(
i2c_gb_d
ev
);
return
-
ENOMEM
;
}
i2c_set_adapdata
(
adapter
,
i2c_gb_d
ata
);
i2c_set_adapdata
(
adapter
,
i2c_gb_d
ev
);
adapter
->
owner
=
THIS_MODULE
;
adapter
->
class
=
I2C_CLASS_HWMON
|
I2C_CLASS_SPD
;
adapter
->
algo
=
&
smbus_algorithm
;
...
...
@@ -103,33 +104,35 @@ static int i2c_gb_probe(struct greybus_device *gdev, const struct greybus_device
goto
error
;
}
i2c_gb_d
ata
->
gdev
=
gdev
;
i2c_gb_d
ata
->
adapter
=
adapter
;
i2c_gb_d
ev
->
gdev
=
gdev
;
i2c_gb_d
ev
->
adapter
=
adapter
;
greybus_set_drvdata
(
gdev
,
i2c_gb_d
ata
);
greybus_set_drvdata
(
gdev
,
i2c_gb_d
ev
);
return
0
;
error:
kfree
(
adapter
);
kfree
(
i2c_gb_d
ata
);
kfree
(
i2c_gb_d
ev
);
return
retval
;
}
static
void
i2c_gb
_disconnect
(
struct
greybus_device
*
gdev
)
void
gb_i2c
_disconnect
(
struct
greybus_device
*
gdev
)
{
struct
i2c_gb_data
*
i2c_gb_data
;
struct
gb_i2c_device
*
i2c_gb_dev
;
i2c_gb_d
ata
=
greybus_get_drvdata
(
gdev
);
i2c_del_adapter
(
i2c_gb_d
ata
->
adapter
);
kfree
(
i2c_gb_d
ata
->
adapter
);
kfree
(
i2c_gb_d
ata
);
i2c_gb_d
ev
=
greybus_get_drvdata
(
gdev
);
i2c_del_adapter
(
i2c_gb_d
ev
->
adapter
);
kfree
(
i2c_gb_d
ev
->
adapter
);
kfree
(
i2c_gb_d
ev
);
}
#if 0
static struct greybus_driver i2c_gb_driver = {
.
probe
=
i2c_gb
_probe
,
.
disconnect
=
i2c_gb
_disconnect
,
.probe =
gb_i2c
_probe,
.disconnect =
gb_i2c
_disconnect,
.id_table = id_table,
};
module_greybus_driver(i2c_gb_driver);
MODULE_LICENSE("GPL");
MODULE_AUTHOR("Greg Kroah-Hartman <gregkh@linuxfoundation.org>");
#endif
drivers/staging/greybus/sdio-gb.c
View file @
199d68d4
...
...
@@ -12,7 +12,7 @@
#include <linux/mmc/host.h>
#include "greybus.h"
struct
sd_gb
_host
{
struct
gb_sdio
_host
{
struct
mmc_host
*
mmc
;
struct
mmc_request
*
mrq
;
// FIXME - some lock?
...
...
@@ -48,9 +48,9 @@ static const struct mmc_host_ops gb_sd_ops = {
static
int
sd_gb_probe
(
struct
greybus_device
*
gdev
,
const
struct
greybus_device_id
*
id
)
{
struct
mmc_host
*
mmc
;
struct
sd_gb
_host
*
host
;
struct
gb_sdio
_host
*
host
;
mmc
=
mmc_alloc_host
(
sizeof
(
struct
sd_gb
_host
),
&
gdev
->
dev
);
mmc
=
mmc_alloc_host
(
sizeof
(
struct
gb_sdio
_host
),
&
gdev
->
dev
);
if
(
!
mmc
)
return
-
ENOMEM
;
...
...
@@ -67,7 +67,7 @@ static int sd_gb_probe(struct greybus_device *gdev, const struct greybus_device_
static
void
sd_gb_disconnect
(
struct
greybus_device
*
gdev
)
{
struct
mmc_host
*
mmc
;
struct
sd_gb
_host
*
host
;
struct
gb_sdio
_host
*
host
;
host
=
greybus_get_drvdata
(
gdev
);
mmc
=
host
->
mmc
;
...
...
drivers/staging/greybus/uart-gb.c
View file @
199d68d4
...
...
@@ -344,27 +344,22 @@ static int gb_tty_ioctl(struct tty_struct *tty, unsigned int cmd,
unsigned
long
arg
)
{
struct
gb_tty
*
gb_tty
=
tty
->
driver_data
;
int
retval
=
-
ENOIOCTLCMD
;
switch
(
cmd
)
{
case
TIOCGSERIAL
:
ret
val
=
get_serial_info
(
gb_tty
,
ret
urn
get_serial_info
(
gb_tty
,
(
struct
serial_struct
__user
*
)
arg
);
break
;
case
TIOCSSERIAL
:
ret
val
=
set_serial_info
(
gb_tty
,
ret
urn
set_serial_info
(
gb_tty
,
(
struct
serial_struct
__user
*
)
arg
);
break
;
case
TIOCMIWAIT
:
retval
=
wait_serial_change
(
gb_tty
,
arg
);
break
;
return
wait_serial_change
(
gb_tty
,
arg
);
case
TIOCGICOUNT
:
ret
val
=
get_serial_usage
(
gb_tty
,
ret
urn
get_serial_usage
(
gb_tty
,
(
struct
serial_icounter_struct
__user
*
)
arg
);
break
;
}
return
retval
;
return
-
ENOIOCTLCMD
;
}
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment