~ubuntu-branches/debian/sid/powerpc-ibm-utils/sid

« back to all changes in this revision

Viewing changes to src/drmgr/drslot_chrp_cpu.c

  • Committer: Package Import Robot
  • Author(s): Adam Conrad
  • Date: 2015-04-13 11:14:55 UTC
  • mfrom: (1.1.8)
  • Revision ID: package-import@ubuntu.com-20150413111455-a72phdrwz4ds6jpq
Tags: 1.2.25-1
* New upstream release, with LE and hotplug fixes (LP: #1441856)
* Drop our ppc64_cpu manpage, upstream has written a better one.

Show diffs side-by-side

added added

removed removed

Lines of Context:
44
44
get_cpu_by_name(struct dr_info *drinfo, const char *name)
45
45
{
46
46
        struct dr_node *cpu;
47
 
        uint32_t drc_index;
48
 
 
49
 
        for (cpu = drinfo->all_cpus; cpu; cpu = cpu->next) {
50
 
                if (strcmp(cpu->drc_name, name) == 0)
51
 
                        break;
52
 
 
53
 
                /* See if the drc index was specified */
54
 
                drc_index = strtoul(name, NULL, 0);
55
 
                if (cpu->drc_index == drc_index)
56
 
                        break;
 
47
 
 
48
        for (cpu = drinfo->all_cpus; cpu; cpu = cpu->next) {
 
49
                if (strcmp(cpu->drc_name, name) == 0) {
 
50
                        break;
 
51
                }
 
52
        }
 
53
 
 
54
        return cpu;
 
55
}
 
56
 
 
57
static struct dr_node *
 
58
get_cpu_by_index(struct dr_info *drinfo, uint32_t index)
 
59
{
 
60
        struct dr_node *cpu;
 
61
 
 
62
        for (cpu = drinfo->all_cpus; cpu; cpu = cpu->next) {
 
63
                if (cpu->drc_index == index) {
 
64
                        break;
 
65
                }
57
66
        }
58
67
 
59
68
        return cpu;
105
114
                            opts->usr_drc_name);
106
115
 
107
116
                return cpu;
 
117
        } else if (opts->usr_drc_index) {
 
118
                cpu = get_cpu_by_index(dr_info, opts->usr_drc_index);
 
119
                if (!cpu)
 
120
                        say(ERROR, "Could not locate cpu %x\n",
 
121
                            opts->usr_drc_index);
 
122
 
 
123
                return cpu;
108
124
        }
109
125
 
110
126
        switch (opts->action) {
261
277
smt_threads_func(struct options *opts, struct dr_info *dr_info)
262
278
{
263
279
        int rc;
 
280
        struct dr_node *cpu;
264
281
 
265
282
        if (opts->quantity != 1) {
266
283
                say(ERROR, "Quantity option '-q' may not be specified with "
274
291
        }
275
292
 
276
293
        if (opts->usr_drc_name) {
277
 
                struct dr_node *cpu;
278
 
 
279
294
                cpu = get_cpu_by_name(dr_info, opts->usr_drc_name);
280
295
                if (cpu == NULL) {
281
296
                        say(ERROR, "Could not find cpu %s\n",
288
303
                else if (opts->action == REMOVE)
289
304
                        rc = cpu_disable_smt(cpu);
290
305
 
 
306
        } else if (opts->usr_drc_index) {
 
307
                cpu = get_cpu_by_index(dr_info, opts->usr_drc_index);
 
308
                if (cpu == NULL) {
 
309
                        say(ERROR, "Could not find cpu %x\n",
 
310
                            opts->usr_drc_index);
 
311
                        return -1;
 
312
                }
 
313
 
 
314
                if (opts->action == ADD)
 
315
                        rc = cpu_enable_smt(cpu, dr_info);
 
316
                else if (opts->action == REMOVE)
 
317
                        rc = cpu_disable_smt(cpu);
 
318
 
291
319
        } else { /* no drc name given, action is system-wide */
292
320
                if (opts->action == ADD)
293
321
                        rc = system_enable_smt(dr_info);
302
330
valid_cpu_options(struct options *opts)
303
331
{
304
332
        /* default to a quantity of 1 */
305
 
        if ((opts->quantity == 0) && (opts->usr_drc_name == NULL))
 
333
        if ((opts->quantity == 0))
306
334
                opts->quantity = 1;
307
335
 
308
336
        if ((opts->action != ADD) && (opts->action != REMOVE)) {