Skip to content

Commit 91f8d01

Browse files
oakadPierre Ossman
authored andcommitted
tifm: layout fixes, small changes to comments and printfs
Cosmetic changes to the code. Signed-off-by: Alex Dubov <oakad@yahoo.com> Signed-off-by: Pierre Ossman <drzeus@drzeus.cx>
1 parent 13cdf48 commit 91f8d01

4 files changed

Lines changed: 80 additions & 72 deletions

File tree

‎drivers/misc/tifm_7xx1.c‎

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,6 @@
1010
*/
1111

1212
#include <linux/tifm.h>
13-
#include <linux/dma-mapping.h>
14-
#include <linux/freezer.h>
1513

1614
#define DRIVER_NAME "tifm_7xx1"
1715
#define DRIVER_VERSION "0.8"
@@ -41,8 +39,7 @@ static irqreturn_t tifm_7xx1_isr(int irq, void *dev_id)
4139
{
4240
struct tifm_adapter *fm = dev_id;
4341
struct tifm_dev *sock;
44-
unsigned int irq_status;
45-
unsigned int cnt;
42+
unsigned int irq_status, cnt;
4643

4744
spin_lock(&fm->lock);
4845
irq_status = readl(fm->addr + FM_INTERRUPT_STATUS);
@@ -134,11 +131,10 @@ static void tifm_7xx1_switch_media(struct work_struct *work)
134131
{
135132
struct tifm_adapter *fm = container_of(work, struct tifm_adapter,
136133
media_switcher);
134+
struct tifm_dev *sock;
137135
unsigned long flags;
138136
unsigned char media_id;
139-
int cnt;
140-
struct tifm_dev *sock;
141-
unsigned int socket_change_set;
137+
unsigned int socket_change_set, cnt;
142138

143139
spin_lock_irqsave(&fm->lock, flags);
144140
socket_change_set = fm->socket_change_set;

‎drivers/misc/tifm_core.c‎

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -115,23 +115,23 @@ static int tifm_device_remove(struct device *dev)
115115

116116
static int tifm_device_suspend(struct device *dev, pm_message_t state)
117117
{
118-
struct tifm_dev *fm_dev = container_of(dev, struct tifm_dev, dev);
118+
struct tifm_dev *sock = container_of(dev, struct tifm_dev, dev);
119119
struct tifm_driver *drv = container_of(dev->driver, struct tifm_driver,
120120
driver);
121121

122122
if (dev->driver && drv->suspend)
123-
return drv->suspend(fm_dev, state);
123+
return drv->suspend(sock, state);
124124
return 0;
125125
}
126126

127127
static int tifm_device_resume(struct device *dev)
128128
{
129-
struct tifm_dev *fm_dev = container_of(dev, struct tifm_dev, dev);
129+
struct tifm_dev *sock = container_of(dev, struct tifm_dev, dev);
130130
struct tifm_driver *drv = container_of(dev->driver, struct tifm_driver,
131131
driver);
132132

133133
if (dev->driver && drv->resume)
134-
return drv->resume(fm_dev);
134+
return drv->resume(sock);
135135
return 0;
136136
}
137137

@@ -155,14 +155,14 @@ static struct device_attribute tifm_dev_attrs[] = {
155155
};
156156

157157
static struct bus_type tifm_bus_type = {
158-
.name = "tifm",
159-
.dev_attrs = tifm_dev_attrs,
160-
.match = tifm_bus_match,
161-
.uevent = tifm_uevent,
162-
.probe = tifm_device_probe,
163-
.remove = tifm_device_remove,
164-
.suspend = tifm_device_suspend,
165-
.resume = tifm_device_resume
158+
.name = "tifm",
159+
.dev_attrs = tifm_dev_attrs,
160+
.match = tifm_bus_match,
161+
.uevent = tifm_uevent,
162+
.probe = tifm_device_probe,
163+
.remove = tifm_device_remove,
164+
.suspend = tifm_device_suspend,
165+
.resume = tifm_device_resume
166166
};
167167

168168
static void tifm_free(struct class_device *cdev)

‎drivers/mmc/tifm_sd.c‎

Lines changed: 30 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,8 @@
77
* it under the terms of the GNU General Public License version 2 as
88
* published by the Free Software Foundation.
99
*
10+
* Special thanks to Brad Campbell for extensive testing of this driver.
11+
*
1012
*/
1113

1214

@@ -39,6 +41,7 @@ module_param(fixed_timeout, bool, 0644);
3941

4042
#define TIFM_MMCSD_ERRMASK 0x01e0 /* set bits: CCRC, CTO, DCRC, DTO */
4143
#define TIFM_MMCSD_EOC 0x0001 /* end of command phase */
44+
#define TIFM_MMCSD_CD 0x0002 /* card detect */
4245
#define TIFM_MMCSD_CB 0x0004 /* card enter busy state */
4346
#define TIFM_MMCSD_BRS 0x0008 /* block received/sent */
4447
#define TIFM_MMCSD_EOFB 0x0010 /* card exit busy state */
@@ -48,6 +51,8 @@ module_param(fixed_timeout, bool, 0644);
4851
#define TIFM_MMCSD_CCRC 0x0100 /* command crc error */
4952
#define TIFM_MMCSD_AF 0x0400 /* fifo almost full */
5053
#define TIFM_MMCSD_AE 0x0800 /* fifo almost empty */
54+
#define TIFM_MMCSD_OCRB 0x1000 /* OCR busy */
55+
#define TIFM_MMCSD_CIRQ 0x2000 /* card irq (cmd40/sdio) */
5156
#define TIFM_MMCSD_CERR 0x4000 /* card status error */
5257

5358
#define TIFM_MMCSD_ODTO 0x0040 /* open drain / extended timeout */
@@ -83,16 +88,16 @@ enum {
8388
};
8489

8590
struct tifm_sd {
86-
struct tifm_dev *dev;
91+
struct tifm_dev *dev;
8792

88-
unsigned short eject:1,
89-
open_drain:1,
90-
no_dma:1;
91-
unsigned short cmd_flags;
93+
unsigned short eject:1,
94+
open_drain:1,
95+
no_dma:1;
96+
unsigned short cmd_flags;
9297

93-
unsigned int clk_freq;
94-
unsigned int clk_div;
95-
unsigned long timeout_jiffies;
98+
unsigned int clk_freq;
99+
unsigned int clk_div;
100+
unsigned long timeout_jiffies;
96101

97102
struct tasklet_struct finish_tasklet;
98103
struct timer_list timer;
@@ -627,7 +632,8 @@ static void tifm_sd_request(struct mmc_host *mmc, struct mmc_request *mrq)
627632
}
628633

629634
if (host->req) {
630-
printk(KERN_ERR DRIVER_NAME ": unfinished request detected\n");
635+
printk(KERN_ERR "%s : unfinished request detected\n",
636+
sock->dev.bus_id);
631637
spin_unlock_irqrestore(&sock->lock, flags);
632638
goto err_out;
633639
}
@@ -737,7 +743,8 @@ static void tifm_sd_end_cmd(unsigned long data)
737743
host->req = NULL;
738744

739745
if (!mrq) {
740-
printk(KERN_ERR DRIVER_NAME ": no request to complete?\n");
746+
printk(KERN_ERR " %s : no request to complete?\n",
747+
sock->dev.bus_id);
741748
spin_unlock_irqrestore(&sock->lock, flags);
742749
return;
743750
}
@@ -775,8 +782,10 @@ static void tifm_sd_abort(unsigned long data)
775782
{
776783
struct tifm_sd *host = (struct tifm_sd*)data;
777784

778-
printk(KERN_ERR DRIVER_NAME
779-
": card failed to respond for a long period of time\n");
785+
printk(KERN_ERR
786+
"%s : card failed to respond for a long period of time "
787+
"(%x, %x)\n",
788+
host->dev->dev.bus_id, host->req->cmd->opcode, host->cmd_flags);
780789

781790
tifm_eject(host->dev);
782791
}
@@ -790,8 +799,11 @@ static void tifm_sd_ios(struct mmc_host *mmc, struct mmc_ios *ios)
790799

791800
spin_lock_irqsave(&sock->lock, flags);
792801

793-
dev_dbg(&sock->dev, "Setting bus width %d, power %d\n", ios->bus_width,
794-
ios->power_mode);
802+
dev_dbg(&sock->dev, "ios: clock = %u, vdd = %x, bus_mode = %x, "
803+
"chip_select = %x, power_mode = %x, bus_width = %x\n",
804+
ios->clock, ios->vdd, ios->bus_mode, ios->chip_select,
805+
ios->power_mode, ios->bus_width);
806+
795807
if (ios->bus_width == MMC_BUS_WIDTH_4) {
796808
writel(TIFM_MMCSD_4BBUS | readl(sock->addr + SOCK_MMCSD_CONFIG),
797809
sock->addr + SOCK_MMCSD_CONFIG);
@@ -937,7 +949,8 @@ static int tifm_sd_probe(struct tifm_dev *sock)
937949

938950
if (!(TIFM_SOCK_STATE_OCCUPIED
939951
& readl(sock->addr + SOCK_PRESENT_STATE))) {
940-
printk(KERN_WARNING DRIVER_NAME ": card gone, unexpectedly\n");
952+
printk(KERN_WARNING "%s : card gone, unexpectedly\n",
953+
sock->dev.bus_id);
941954
return rc;
942955
}
943956

@@ -974,11 +987,9 @@ static int tifm_sd_probe(struct tifm_dev *sock)
974987

975988
if (!rc)
976989
rc = mmc_add_host(mmc);
977-
if (rc)
978-
goto out_free_mmc;
990+
if (!rc)
991+
return 0;
979992

980-
return 0;
981-
out_free_mmc:
982993
mmc_free_host(mmc);
983994
return rc;
984995
}

‎include/linux/tifm.h‎

Lines changed: 35 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -14,16 +14,16 @@
1414

1515
#include <linux/spinlock.h>
1616
#include <linux/interrupt.h>
17-
#include <linux/wait.h>
1817
#include <linux/delay.h>
1918
#include <linux/pci.h>
20-
#include <linux/kthread.h>
19+
#include <linux/workqueue.h>
2120

2221
/* Host registers (relative to pci base address): */
2322
enum {
2423
FM_SET_INTERRUPT_ENABLE = 0x008,
2524
FM_CLEAR_INTERRUPT_ENABLE = 0x00c,
26-
FM_INTERRUPT_STATUS = 0x014 };
25+
FM_INTERRUPT_STATUS = 0x014
26+
};
2727

2828
/* Socket registers (relative to socket base address): */
2929
enum {
@@ -58,22 +58,23 @@ enum {
5858
SOCK_MS_DATA = 0x188,
5959
SOCK_MS_STATUS = 0x18c,
6060
SOCK_MS_SYSTEM = 0x190,
61-
SOCK_FIFO_ACCESS = 0x200 };
61+
SOCK_FIFO_ACCESS = 0x200
62+
};
6263

6364
#define TIFM_CTRL_LED 0x00000040
6465
#define TIFM_CTRL_FAST_CLK 0x00000100
6566

6667
#define TIFM_SOCK_STATE_OCCUPIED 0x00000008
6768
#define TIFM_SOCK_STATE_POWERED 0x00000080
6869

69-
#define TIFM_FIFO_ENABLE 0x00000001 /* Meaning of this constant is unverified */
70-
#define TIFM_FIFO_READY 0x00000001 /* Meaning of this constant is unverified */
70+
#define TIFM_FIFO_ENABLE 0x00000001
71+
#define TIFM_FIFO_READY 0x00000001
7172
#define TIFM_FIFO_INT_SETALL 0x0000ffff
72-
#define TIFM_FIFO_INTMASK 0x00000005 /* Meaning of this constant is unverified */
73+
#define TIFM_FIFO_INTMASK 0x00000005
7374

74-
#define TIFM_DMA_RESET 0x00000002 /* Meaning of this constant is unverified */
75-
#define TIFM_DMA_TX 0x00008000 /* Meaning of this constant is unverified */
76-
#define TIFM_DMA_EN 0x00000001 /* Meaning of this constant is unverified */
75+
#define TIFM_DMA_RESET 0x00000002
76+
#define TIFM_DMA_TX 0x00008000
77+
#define TIFM_DMA_EN 0x00000001
7778
#define TIFM_DMA_TSIZE 0x0000007f
7879

7980
#define TIFM_TYPE_XD 1
@@ -86,44 +87,44 @@ struct tifm_device_id {
8687

8788
struct tifm_driver;
8889
struct tifm_dev {
89-
char __iomem *addr;
90-
spinlock_t lock;
91-
unsigned char type;
92-
unsigned int socket_id;
90+
char __iomem *addr;
91+
spinlock_t lock;
92+
unsigned char type;
93+
unsigned int socket_id;
9394

9495
void (*card_event)(struct tifm_dev *sock);
9596
void (*data_event)(struct tifm_dev *sock);
9697

97-
struct device dev;
98+
struct device dev;
9899
};
99100

100101
struct tifm_driver {
101102
struct tifm_device_id *id_table;
102-
int (*probe)(struct tifm_dev *dev);
103-
void (*remove)(struct tifm_dev *dev);
104-
int (*suspend)(struct tifm_dev *dev,
105-
pm_message_t state);
106-
int (*resume)(struct tifm_dev *dev);
103+
int (*probe)(struct tifm_dev *dev);
104+
void (*remove)(struct tifm_dev *dev);
105+
int (*suspend)(struct tifm_dev *dev,
106+
pm_message_t state);
107+
int (*resume)(struct tifm_dev *dev);
107108

108-
struct device_driver driver;
109+
struct device_driver driver;
109110
};
110111

111112
struct tifm_adapter {
112-
char __iomem *addr;
113-
spinlock_t lock;
114-
unsigned int irq_status;
115-
unsigned int socket_change_set;
116-
unsigned int id;
117-
unsigned int num_sockets;
118-
struct completion *finish_me;
113+
char __iomem *addr;
114+
spinlock_t lock;
115+
unsigned int irq_status;
116+
unsigned int socket_change_set;
117+
unsigned int id;
118+
unsigned int num_sockets;
119+
struct completion *finish_me;
119120

120-
struct work_struct media_switcher;
121-
struct class_device cdev;
121+
struct work_struct media_switcher;
122+
struct class_device cdev;
122123

123-
void (*eject)(struct tifm_adapter *fm,
124-
struct tifm_dev *sock);
124+
void (*eject)(struct tifm_adapter *fm,
125+
struct tifm_dev *sock);
125126

126-
struct tifm_dev *sockets[0];
127+
struct tifm_dev *sockets[0];
127128
};
128129

129130
struct tifm_adapter *tifm_alloc_adapter(unsigned int num_sockets,
@@ -147,7 +148,7 @@ void tifm_queue_work(struct work_struct *work);
147148

148149
static inline void *tifm_get_drvdata(struct tifm_dev *dev)
149150
{
150-
return dev_get_drvdata(&dev->dev);
151+
return dev_get_drvdata(&dev->dev);
151152
}
152153

153154
static inline void tifm_set_drvdata(struct tifm_dev *dev, void *data)

0 commit comments

Comments
 (0)