stdio: Tidy up the coding style
Bring the coding style in this file up to the current level. Signed-off-by: Simon Glass <sjg@chromium.org>
This commit is contained in:
@@ -191,16 +191,15 @@ struct stdio_dev *stdio_get_by_name(const char *name)
|
|||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
struct stdio_dev* stdio_clone(struct stdio_dev *dev)
|
struct stdio_dev *stdio_clone(struct stdio_dev *dev)
|
||||||
{
|
{
|
||||||
struct stdio_dev *_dev;
|
struct stdio_dev *_dev;
|
||||||
|
|
||||||
if(!dev)
|
if (!dev)
|
||||||
return NULL;
|
return NULL;
|
||||||
|
|
||||||
_dev = calloc(1, sizeof(struct stdio_dev));
|
_dev = calloc(1, sizeof(struct stdio_dev));
|
||||||
|
if (!_dev)
|
||||||
if(!_dev)
|
|
||||||
return NULL;
|
return NULL;
|
||||||
|
|
||||||
memcpy(_dev, dev, sizeof(struct stdio_dev));
|
memcpy(_dev, dev, sizeof(struct stdio_dev));
|
||||||
@@ -213,7 +212,7 @@ int stdio_register_dev(struct stdio_dev *dev, struct stdio_dev **devp)
|
|||||||
struct stdio_dev *_dev;
|
struct stdio_dev *_dev;
|
||||||
|
|
||||||
_dev = stdio_clone(dev);
|
_dev = stdio_clone(dev);
|
||||||
if(!_dev)
|
if (!_dev)
|
||||||
return -ENODEV;
|
return -ENODEV;
|
||||||
list_add_tail(&_dev->list, &devs.list);
|
list_add_tail(&_dev->list, &devs.list);
|
||||||
if (devp)
|
if (devp)
|
||||||
@@ -227,41 +226,38 @@ int stdio_register(struct stdio_dev *dev)
|
|||||||
return stdio_register_dev(dev, NULL);
|
return stdio_register_dev(dev, NULL);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* deregister the device "devname".
|
|
||||||
* returns 0 if success, -1 if device is assigned and 1 if devname not found
|
|
||||||
*/
|
|
||||||
int stdio_deregister_dev(struct stdio_dev *dev, int force)
|
int stdio_deregister_dev(struct stdio_dev *dev, int force)
|
||||||
{
|
{
|
||||||
int l;
|
|
||||||
struct list_head *pos;
|
struct list_head *pos;
|
||||||
char temp_names[3][16];
|
char temp_names[3][16];
|
||||||
|
int i;
|
||||||
|
|
||||||
/* get stdio devices (ListRemoveItem changes the dev list) */
|
/* get stdio devices (ListRemoveItem changes the dev list) */
|
||||||
for (l=0 ; l< MAX_FILES; l++) {
|
for (i = 0 ; i < MAX_FILES; i++) {
|
||||||
if (stdio_devices[l] == dev) {
|
if (stdio_devices[i] == dev) {
|
||||||
if (force) {
|
if (force) {
|
||||||
strcpy(temp_names[l], "nulldev");
|
strcpy(temp_names[i], "nulldev");
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
/* Device is assigned -> report error */
|
/* Device is assigned -> report error */
|
||||||
return -1;
|
return -EBUSY;
|
||||||
}
|
}
|
||||||
memcpy (&temp_names[l][0],
|
memcpy(&temp_names[i][0], stdio_devices[i]->name,
|
||||||
stdio_devices[l]->name,
|
sizeof(temp_names[i]));
|
||||||
sizeof(temp_names[l]));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
list_del(&dev->list);
|
list_del(&dev->list);
|
||||||
free(dev);
|
free(dev);
|
||||||
|
|
||||||
/* reassign Device list */
|
/* reassign device list */
|
||||||
list_for_each(pos, &devs.list) {
|
list_for_each(pos, &devs.list) {
|
||||||
dev = list_entry(pos, struct stdio_dev, list);
|
dev = list_entry(pos, struct stdio_dev, list);
|
||||||
for (l=0 ; l< MAX_FILES; l++) {
|
for (i = 0 ; i < MAX_FILES; i++) {
|
||||||
if(strcmp(dev->name, temp_names[l]) == 0)
|
if (strcmp(dev->name, temp_names[i]) == 0)
|
||||||
stdio_devices[l] = dev;
|
stdio_devices[i] = dev;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -270,7 +266,6 @@ int stdio_deregister(const char *devname, int force)
|
|||||||
struct stdio_dev *dev;
|
struct stdio_dev *dev;
|
||||||
|
|
||||||
dev = stdio_get_by_name(devname);
|
dev = stdio_get_by_name(devname);
|
||||||
|
|
||||||
if (!dev) /* device not found */
|
if (!dev) /* device not found */
|
||||||
return -ENODEV;
|
return -ENODEV;
|
||||||
|
|
||||||
|
@@ -84,6 +84,15 @@ int stdio_init(void);
|
|||||||
|
|
||||||
void stdio_print_current_devices(void);
|
void stdio_print_current_devices(void);
|
||||||
int stdio_deregister(const char *devname, int force);
|
int stdio_deregister(const char *devname, int force);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* stdio_deregister_dev() - deregister the device "devname".
|
||||||
|
*
|
||||||
|
* @dev: Stdio device to deregister
|
||||||
|
* @force: true to force deregistration even if in use
|
||||||
|
*
|
||||||
|
* returns 0 on success, -EBUSY if device is assigned
|
||||||
|
*/
|
||||||
int stdio_deregister_dev(struct stdio_dev *dev, int force);
|
int stdio_deregister_dev(struct stdio_dev *dev, int force);
|
||||||
struct list_head *stdio_get_list(void);
|
struct list_head *stdio_get_list(void);
|
||||||
struct stdio_dev *stdio_get_by_name(const char *name);
|
struct stdio_dev *stdio_get_by_name(const char *name);
|
||||||
|
Reference in New Issue
Block a user